Skip to content

Commit

Permalink
Merge pull request #434 from monarch-initiative/release_v2.0.1
Browse files Browse the repository at this point in the history
Release v2.0.1
  • Loading branch information
ielis authored Jun 7, 2023
2 parents ff97924 + 7decd0f commit de528b5
Show file tree
Hide file tree
Showing 16 changed files with 192 additions and 43 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
Changelog
=========

------
latest
------

------
v2.0.1
------

Minor changes
#############

- Use Jackson annotations to configure serialization of `TermId` and `Identified`
- update dependencies

------
v2.0.0
------
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ associate phenotype annotation files.

- **Language/Platform:** Java >=11
- **License:** BSD 3-Clause Clear
- **Version:** 2.0.0
- **Version:** 2.0.1
- **Authors:**
- Sebastian Bauer
- Peter N. Robinson
Expand All @@ -39,7 +39,7 @@ We recommend indicating the phenol version in the `properties` section of the po
```
<properties>
(...)
<phenol.version>2.0.0</phenol.version>
<phenol.version>2.0.1</phenol.version>
</properties>
```

Expand Down
7 changes: 6 additions & 1 deletion phenol-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.monarchinitiative.phenol</groupId>
<artifactId>phenol</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>phenol-analysis</artifactId>
Expand All @@ -25,6 +25,11 @@
<version>${commons-codec.version}</version>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion phenol-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.monarchinitiative.phenol</groupId>
<artifactId>phenol</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>phenol-annotations</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion phenol-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.monarchinitiative.phenol</groupId>
<artifactId>phenol</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>phenol-cli</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion phenol-cli/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
requires org.monarchinitiative.phenol.io;
requires org.monarchinitiative.phenol.analysis;

requires commons.csv;
requires org.apache.commons.csv;
requires info.picocli;
requires org.slf4j;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@CommandLine.Command(name = "phenol demo",
mixinStandardHelpOptions = true,
version = "2.0.0",
version = "2.0.1",
description = "phenol demo programs")
public class Main implements Callable<Integer> {
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
Expand Down
7 changes: 6 additions & 1 deletion phenol-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.monarchinitiative.phenol</groupId>
<artifactId>phenol</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>phenol-core</artifactId>
Expand All @@ -18,6 +18,11 @@
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions phenol-core/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
exports org.monarchinitiative.phenol.utils;

requires transitive org.jgrapht.core; // due to DefaultDirectedGraph being exposed in MinimalOntology
requires com.fasterxml.jackson.databind; // for annotating model classes
requires org.slf4j;

// To enable custom `TermId` serialization
opens org.monarchinitiative.phenol.ontology.serialize;
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package org.monarchinitiative.phenol.ontology.data;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
* The interface implemented by entities that have an identifier.
*/
public interface Identified {

@JsonGetter
TermId id();

/**
* @deprecated the getter will be removed in <code>v3.0.0</code>, use {@link #id()} instead.
*/
@Deprecated(forRemoval = true, since = "2.0.0-RC2")
@JsonIgnore
default TermId getId() {
return id();
}
Expand Down
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;
Expand All @@ -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. */
Expand Down
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());
}
}
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;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.hamcrest.Matchers.lessThan;
import static org.junit.jupiter.api.Assertions.*;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.monarchinitiative.phenol.base.PhenolRuntimeException;

Expand Down Expand Up @@ -60,6 +61,16 @@ public void testQueryFunctions() {
assertEquals("HP:0000001", termId.getValue());
}

/**
* Check that the `TermId` is serialized into a simple quoted string and NOT into a JSON object.
*/
@Test
public void testSerializeToJson() throws Exception {
ObjectMapper mapper = new ObjectMapper();
assertEquals("\"HP:0000001\"", mapper.writeValueAsString(termId));
assertEquals("\"HP:0000002\"", mapper.writeValueAsString(termId2));
}

@Test
public void testToString() {
assertEquals("HP:0000001", termId.toString());
Expand Down
19 changes: 6 additions & 13 deletions phenol-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>org.monarchinitiative.phenol</groupId>
<artifactId>phenol</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</parent>

<artifactId>phenol-io</artifactId>
Expand All @@ -23,18 +23,11 @@
<groupId>org.geneontology.obographs</groupId>
<artifactId>obographs-core</artifactId>
</dependency>
<!-- We can drop the dependency after obographs-core updates the vulnerable snakeyaml 1.33 to >=2.0. -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--add-reads com.fasterxml.jackson.datatype.guava=ALL-UNNAMED </argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
Loading

0 comments on commit de528b5

Please sign in to comment.