-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #434 from monarch-initiative/release_v2.0.1
Release v2.0.1
- Loading branch information
Showing
16 changed files
with
192 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
phenol-core/src/main/java/org/monarchinitiative/phenol/ontology/data/Identified.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
package org.monarchinitiative.phenol.ontology.data; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import org.monarchinitiative.phenol.base.PhenolRuntimeException; | ||
import org.monarchinitiative.phenol.ontology.serialize.TermIdSerializer; | ||
|
||
import java.io.Serializable; | ||
import java.util.Objects; | ||
|
@@ -11,6 +13,7 @@ | |
* @author <a href="mailto:[email protected]">Manuel Holtgrewe</a> | ||
* @author <a href="mailto:[email protected]">Peter Robinson</a> | ||
*/ | ||
@JsonSerialize(using = TermIdSerializer.class) | ||
public final class TermId implements Comparable<TermId>, Serializable { | ||
|
||
/** Serial UId for serialization. */ | ||
|
27 changes: 27 additions & 0 deletions
27
...-core/src/main/java/org/monarchinitiative/phenol/ontology/serialize/TermIdSerializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.monarchinitiative.phenol.ontology.serialize; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.ser.std.StdSerializer; | ||
import org.monarchinitiative.phenol.ontology.data.TermId; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Serialize the {@link TermId}'s {@code value} as a {@link String}. | ||
*/ | ||
public class TermIdSerializer extends StdSerializer<TermId> { | ||
|
||
public TermIdSerializer() { | ||
super(TermId.class); | ||
} | ||
|
||
public TermIdSerializer(StdSerializer<?> src) { | ||
super(src); | ||
} | ||
|
||
@Override | ||
public void serialize(TermId id, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { | ||
jsonGenerator.writeString(id.getValue()); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
phenol-core/src/test/java/org/monarchinitiative/phenol/ontology/data/IdentifiedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package org.monarchinitiative.phenol.ontology.data; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.equalTo; | ||
|
||
public class IdentifiedTest { | ||
|
||
/** | ||
* | ||
* Two-pronged test. First, test that {@link Identified#id()} is serialized as an "id" string field. | ||
* Second, test that a list of {@link TermId}s is serialized as a list of string values (NOT JSON objects). | ||
*/ | ||
@Test | ||
public void testSerialization() throws JsonProcessingException { | ||
ObjectMapper mapper = new ObjectMapper(); | ||
|
||
Identified id = new SimpleIdentified( | ||
TermId.of("BLA:1234567"), | ||
List.of(TermId.of("BLA:999"), TermId.of("BLA:888")), | ||
"Jimmy", | ||
15, | ||
true); | ||
|
||
|
||
String actual = mapper.writeValueAsString(id); | ||
assertThat(actual, equalTo("{\"id\":\"BLA:1234567\",\"altTermIds\":[\"BLA:999\",\"BLA:888\"],\"name\":\"Jimmy\",\"age\":15,\"alive\":true}")); | ||
} | ||
|
||
public static class SimpleIdentified implements Identified { | ||
|
||
private final TermId id; | ||
private final List<TermId> altTermIds; | ||
private final String name; | ||
private final int age; | ||
private final boolean alive; | ||
|
||
private SimpleIdentified(TermId id, List<TermId> altTermIds, String name, int age, boolean alive) { | ||
this.id = id; | ||
this.altTermIds = altTermIds; | ||
this.name = name; | ||
this.age = age; | ||
this.alive = alive; | ||
} | ||
|
||
|
||
@Override | ||
public TermId id() { | ||
return id; | ||
} | ||
|
||
public List<TermId> getAltTermIds() { | ||
return altTermIds; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public int getAge() { | ||
return age; | ||
} | ||
|
||
public boolean isAlive() { | ||
return alive; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.