Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>build</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ehri-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<artifactId>ehri-cli</artifactId>
<name>Command Line Tools</name>
Expand Down
2 changes: 1 addition & 1 deletion ehri-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<artifactId>ehri-core</artifactId>
<packaging>jar</packaging>
Expand Down
20 changes: 20 additions & 0 deletions ehri-core/src/main/java/eu/ehri/project/models/base/Versioned.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,28 @@
import com.tinkerpop.frames.modules.javahandler.JavaHandler;
import com.tinkerpop.frames.modules.javahandler.JavaHandlerContext;
import eu.ehri.project.definitions.Ontology;
import eu.ehri.project.models.annotations.Meta;
import eu.ehri.project.models.events.Version;
import eu.ehri.project.models.utils.JavaHandlerUtils;

import static eu.ehri.project.models.utils.JavaHandlerUtils.hasEdge;

/**
* An entity that may have prior versions.
*/
public interface Versioned extends Accessible {
String IS_VERSIONED = "isVersioned";


/**
* Determine if this item has a prior version.
*
* @return true, if a prior version exists.
*/
@Meta(IS_VERSIONED)
@JavaHandler
boolean isVersioned();

/**
* Get the most recent version for this item, if one exists.
*
Expand All @@ -54,5 +69,10 @@ public Iterable<Version> getAllPriorVersions() {
return frameVertices(gremlin().as("n").out(Ontology.ENTITY_HAS_PRIOR_VERSION)
.loop("n", JavaHandlerUtils.noopLoopFunc, JavaHandlerUtils.noopLoopFunc));
}

@Override
public boolean isVersioned() {
return hasEdge(it(), Direction.OUT, Ontology.ENTITY_HAS_PRIOR_VERSION);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public void testVersioning() throws Exception {
EventTypes.creation).commit();
assertEquals(1, Iterables.size(first.getSubjects()));

assertFalse(user.isVersioned());

// Change the user twice in succession, with the data from userBundle2
// and userBundle3
SystemEvent second = actionManager.newEventContext(user,
Expand All @@ -73,6 +75,9 @@ public void testVersioning() throws Exception {
Mutation<UserProfile> update2 = bundleManager.update(userBundle3, UserProfile.class);
assertEquals(MutationState.UPDATED, update2.getState());

// Ensure isVersioned works
assertTrue(user.isVersioned());

// Now compare the values in the versions
Version firstVersion = second.getPriorVersions().iterator().next();
assertEquals(second, firstVersion.getTriggeringEvent());
Expand Down
2 changes: 1 addition & 1 deletion ehri-cypher/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>ehri-data</artifactId>
<groupId>eu.ehri-project</groupId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ehri-definitions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
<relativePath>..</relativePath>
</parent>
<artifactId>ehri-definitions</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion ehri-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<artifactId>ehri-io</artifactId>

Expand Down
2 changes: 1 addition & 1 deletion ehri-ws-graphql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>ehri-data</artifactId>
<groupId>eu.ehri-project</groupId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ehri-ws-oaipmh/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<artifactId>ehri-data</artifactId>
<groupId>eu.ehri-project</groupId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
2 changes: 1 addition & 1 deletion ehri-ws/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
</parent>
<artifactId>ehri-ws</artifactId>
<name>Web Service</name>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>eu.ehri-project</groupId>
<artifactId>ehri-data</artifactId>
<version>0.15.4</version>
<version>0.15.5</version>
<packaging>pom</packaging>

<name>EHRI Backend</name>
Expand Down
Loading