Skip to content

Commit

Permalink
Merge pull request #20 from JULIELab/neo4j4.0
Browse files Browse the repository at this point in the history
Neo4j4.0
  • Loading branch information
khituras authored Oct 19, 2020
2 parents 3797b08 + 467834a commit a6fd131
Show file tree
Hide file tree
Showing 66 changed files with 8,020 additions and 6,887 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ name: Java CI with Maven

on:
push:
branches: [ master, neo4j3.5 ]
branches: [ master, neo4j3.5, neo4j4.0 ]
pull_request:
branches: [ master ]

Expand All @@ -16,9 +16,9 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Build with Maven
run: mvn -B package --file pom.xml
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# julielab-neo4j-server-plugins
# julielab-neo4j-server-plugins

![Java CI with Maven](https://github.com/JULIELab/julielab-neo4j-server-plugins/workflows/Java%20CI%20with%20Maven/badge.svg?branch=neo4j4.0) [![Codacy Badge](https://app.codacy.com/project/badge/Grade/f26cced4cb664a6ab53e3b5cd1cc4648)](https://www.codacy.com/manual/khituras/julielab-neo4j-server-plugins?utm_source=github.com&utm_medium=referral&utm_content=JULIELab/julielab-neo4j-server-plugins&utm_campaign=Badge_Grade)
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)
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>2.1.0</version>
<version>3.0.0</version>
</parent>
<artifactId>julielab-neo4j-plugins-concepts-representation</artifactId>
<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class ConceptCoordinates implements Cloneable {
public ConceptCoordinates() {
}



public ConceptCoordinates(String sourceId, String source, String originalId, String originalSource,
boolean uniqueSourceId) {
super();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.julielab.neo4j.plugins.datarepresentation;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import de.julielab.neo4j.plugins.datarepresentation.constants.ConceptConstants;

Expand Down Expand Up @@ -37,6 +38,13 @@ public class ImportConcept {
@JsonProperty(ConceptConstants.AGGREGATE_INCLUDE_IN_HIERARCHY)
public boolean aggregateIncludeInHierarchy;

/**
* This map may contain specific properties required during concept creation. It is not meant to be imported
* into the database.
*/
@JsonIgnore
public Map<String, Object> auxProperties;

public ImportConcept(String preferredName, ConceptCoordinates coordinates) {
prefName = preferredName;
this.coordinates = coordinates;
Expand Down Expand Up @@ -131,6 +139,18 @@ public ImportConcept(ConceptCoordinates conceptCoordinates) {
public ImportConcept() {
}

public void putAuxProperty(String key, Object value) {
if (auxProperties == null)
auxProperties = new HashMap<>();
auxProperties.put(key, value);
}

public Object getAuxProperty(String key) {
if (auxProperties == null)
return null;
return auxProperties.get(key);
}

public void addRelationship(ImportConceptRelationship relationship) {
if (relationships.isEmpty())
relationships = new ArrayList<>();
Expand All @@ -141,8 +161,7 @@ public void addGeneralLabel(String... labels) {
if (generalLabels.isEmpty())
generalLabels = new ArrayList<>();
try {
for (int i = 0; i < labels.length; i++) {
String label = labels[i];
for (String label : labels) {
generalLabels.add(label);
}
} catch (java.lang.UnsupportedOperationException e) {
Expand All @@ -167,16 +186,10 @@ public void removeGeneralLabel(String... labels) {
if (generalLabels.isEmpty())
return;
Set<String> removeLabels = new HashSet<>(labels.length);
for (int i = 0; i < labels.length; i++) {
String label = labels[i];
for (String label : labels) {
removeLabels.add(label);
}
Iterator<String> existingLabels = generalLabels.iterator();
while (existingLabels.hasNext()) {
String existingLabel = existingLabels.next();
if (removeLabels.contains(existingLabel))
existingLabels.remove();
}
generalLabels.removeIf(removeLabels::contains);

}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,93 +1,131 @@
package de.julielab.neo4j.plugins.datarepresentation;

import java.util.Collections;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;

import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

// The order is important for streaming. The list of concepts should come at the end so we don't need to have the
// complete data available to begin importing them
@JsonPropertyOrder({ImportConcepts.NAME_FACET, ImportConcepts.NAME_IMPORT_OPTIONS, ImportConcepts.NAME_NUM_CONCEPTS, ImportConcepts.NAME_CONCEPTS})
public class ImportConcepts {
private List<ImportConcept> concepts;

private ImportFacet facet;

private ImportOptions importOptions;

public ImportConcepts(){}

public ImportConcepts(ImportFacet facet) {
this.facet = facet;
}

public ImportConcepts(Stream<ImportConcept> termList, ImportFacet facet) {
this(termList != null ? termList.collect(Collectors.toList()) : Collections.emptyList(), facet);
}

public ImportConcepts(Stream<ImportConcept> termList, ImportFacet importFacet, ImportOptions importOptions) {
this(termList, importFacet);
this.importOptions = importOptions;
}


/**
* Constructor for an already existing list of concepts. The list will directly
* be used for {@link #getConcepts()} and {@link #getConcepts()};
*
* @param concepts
* The list of concepts.
* @param importFacet
* The facet to add the concepts to.
*/
public ImportConcepts(List<ImportConcept> concepts, ImportFacet importFacet) {
this.concepts = concepts;
this.facet = importFacet;
}

/**
* Constructor for an already existing list of concepts. The list will directly
* be used for {@link #getConcepts()} and {@link #getConcepts()};
*
* @param concepts
* The list of concepts.
* @param importFacet
* The facet to add the concepts to.
* @param importOptions
* Options regarding the database import of the given concepts.
*/
public ImportConcepts(List<ImportConcept> concepts, ImportFacet importFacet, ImportOptions importOptions) {
this((Stream<ImportConcept>) null, importFacet, importOptions);
}

/**
* Returns the concepts as a stream. This may be the single, original stream
* given to the constructor, or a stream derived from a underlying list in case
* a list of concepts was passed to a constructor or
* {@link #getConcepts()} was called at least once.
*
* @return The concepts as a stream.
*/
public List<ImportConcept> getConcepts() {
return concepts;
}



public ImportFacet getFacet() {
return facet;
}

public ImportOptions getImportOptions() {
return importOptions;
}

public void setConcepts(List<ImportConcept> concepts) {
this.concepts = concepts;
}

public void setFacet(ImportFacet facet) {
this.facet = facet;
}

public void setImportOptions(ImportOptions importOptions) {
this.importOptions = importOptions;
}
public static final String NAME_FACET = "facet";
public static final String NAME_IMPORT_OPTIONS = "importOptions";
public static final String NAME_CONCEPTS = "concepts";
public static final String NAME_NUM_CONCEPTS = "name_num_concepts";

@JsonProperty(NAME_CONCEPTS)
private Stream<ImportConcept> concepts;
@JsonProperty(NAME_FACET)
private ImportFacet facet;
@JsonProperty(NAME_IMPORT_OPTIONS)
private ImportOptions importOptions;
@JsonProperty(NAME_NUM_CONCEPTS)
private long numConcepts = -1;
@JsonIgnore
private List<ImportConcept> conceptsList;

public ImportConcepts() {
}

public ImportConcepts(ImportFacet facet) {
this.facet = facet;
}

public ImportConcepts(Stream<ImportConcept> conceptStream, ImportFacet facet) {
this.concepts = conceptStream;
this.facet = facet;
}

public ImportConcepts(Stream<ImportConcept> termList, ImportFacet importFacet, ImportOptions importOptions) {
this(termList, importFacet);
this.importOptions = importOptions;
}

/**
* Constructor for an already existing list of concepts. The list will directly
* be used for {@link #getConceptsAsList()} and {@link #getConceptsAsList()};
*
* @param concepts The list of concepts.
* @param importFacet The facet to add the concepts to.
*/
public ImportConcepts(List<ImportConcept> concepts, ImportFacet importFacet) {
this(concepts.stream(), importFacet);
this.conceptsList = concepts;
}

/**
* Constructor for an already existing list of concepts. The list will directly
* be used for {@link #getConceptsAsList()} and {@link #getConceptsAsList()};
*
* @param concepts The list of concepts.
* @param importFacet The facet to add the concepts to.
* @param importOptions Options regarding the database import of the given concepts.
*/
public ImportConcepts(List<ImportConcept> concepts, ImportFacet importFacet, ImportOptions importOptions) {
this(concepts.stream(), importFacet, importOptions);
this.conceptsList = concepts;
}

public Stream<ImportConcept> getConcepts() {
return concepts;
}

public void setConcepts(List<ImportConcept> concepts) {
this.concepts = concepts.stream();
}

public void setConcepts(Stream<ImportConcept> concepts) {
this.concepts = concepts;
}

/**
* Optional specification of the number of elements returned by the concept stream. If this returns -1, the total
* number of concepts is unknown.
*
* @return The total number of concepts.
*/
public long getNumConcepts() {
return numConcepts;
}

public void setNumConcepts(long numConcepts) {
this.numConcepts = numConcepts;
}

/**
* Returns the concepts as a stream. This may be the single, original stream
* given to the constructor, or a stream derived from a underlying list in case
* a list of concepts was passed to a constructor or
* {@link #getConceptsAsList()} was called at least once.
*
* @return The concepts as a stream.
*/
@JsonIgnore
public List<ImportConcept> getConceptsAsList() {
if (conceptsList == null) {
conceptsList = concepts.collect(Collectors.toList());
concepts = conceptsList.stream();
}
return conceptsList;
}

public ImportFacet getFacet() {
return facet;
}

public void setFacet(ImportFacet facet) {
this.facet = facet;
}

public ImportOptions getImportOptions() {
return importOptions;
}

public void setImportOptions(ImportOptions importOptions) {
this.importOptions = importOptions;
}
}
Loading

0 comments on commit a6fd131

Please sign in to comment.