Skip to content

Commit

Permalink
Resolves #33.
Browse files Browse the repository at this point in the history
  • Loading branch information
khituras committed Jan 23, 2023
1 parent 7ada311 commit 508f4a4
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion julielab-neo4j-plugins-concepts-representation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.julielab</groupId>
<artifactId>julielab-neo4j-server-plugins</artifactId>
<version>3.2.0</version>
<version>3.2.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>julielab-neo4j-plugins-concepts-representation</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class ImportOptions {
* will be changed.
*/
public boolean merge;
/**
* Normally, the preferred name is only set once. In case of correction or necessary update, this option
* allows to set the preferred name on already existing nodes. Only non-blank names are accepted.
*/
public boolean overridePreferredName;

public ImportOptions() {
doNotCreateHollowParents = false;
Expand Down
2 changes: 1 addition & 1 deletion julielab-neo4j-plugins-concepts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>de.julielab</groupId>
<artifactId>julielab-neo4j-server-plugins</artifactId>
<version>3.2.0</version>
<version>3.2.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>julielab-neo4j-plugins-concepts</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,10 @@ else if (concept == null)
concept.setProperty(PROP_ORG_ID, coordinates.originalId);
concept.setProperty(PROP_ORG_SRC, coordinates.originalSource);
}
setNonNullNodeProperty(concept, PROP_PREF_NAME, jsonConcept.prefName);
if (!importOptions.overridePreferredName)
setNonNullNodeProperty(concept, PROP_PREF_NAME, jsonConcept.prefName);
else if (!jsonConcept.prefName.isBlank())
concept.setProperty(PROP_PREF_NAME, jsonConcept.prefName);
mergeArrayProperty(concept, PROP_DESCRIPTIONS, () -> jsonConcept.descriptions.toArray(new String[0]));
mergeArrayProperty(concept, PROP_WRITING_VARIANTS, () -> jsonConcept.writingVariants.toArray(new String[0]));
mergeArrayProperty(concept, PROP_COPY_PROPERTIES, () -> jsonConcept.copyProperties.toArray(new String[0]));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1957,4 +1957,28 @@ public void testGetAllFacetRoots() {
}
}

@Test
public void testOverridePreferredName() {
final ImportConcepts testConcepts = getTestConcepts(1);
final ConceptManager cm = new ConceptManager(graphDBMS, log);
cm.insertConcepts(testConcepts);

// Make sure a node exists with the default name now
try (Transaction tx = graphDb.beginTx()) {
final Node concept = tx.findNode(CONCEPT, PROP_ID, NodeIDPrefixConstants.TERM + 0);
assertEquals("prefname0", concept.getProperty(PROP_PREF_NAME));
}

// Now change the name, insert again and check that the name was actually changed
final ImportConcepts changedTestConcepts = getTestConcepts(1);
changedTestConcepts.setImportOptions(new ImportOptions());
changedTestConcepts.getImportOptions().overridePreferredName = true;
changedTestConcepts.getConceptsAsList().get(0).prefName = "changedName";
cm.insertConcepts(changedTestConcepts);
try (Transaction tx = graphDb.beginTx()) {
final Node concept = tx.findNode(CONCEPT, PROP_ID, NodeIDPrefixConstants.TERM + 0);
assertEquals("changedName", concept.getProperty(PROP_PREF_NAME));
}
}

}
2 changes: 1 addition & 1 deletion julielab-neo4j-plugins-utilities/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>de.julielab</groupId>
<artifactId>julielab-neo4j-server-plugins</artifactId>
<version>3.2.0</version>
<version>3.2.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>julielab-neo4j-plugins-utilities</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<version>2.5.0</version>
</parent>
<artifactId>julielab-neo4j-server-plugins</artifactId>
<version>3.2.0</version>
<version>3.2.1-SNAPSHOT</version>
<name>JULIE Lab Neo4j Server Plugins</name>
<build>
<pluginManagement>
Expand Down

0 comments on commit 508f4a4

Please sign in to comment.