Skip to content

Commit

Permalink
relation pagination by type
Browse files Browse the repository at this point in the history
  • Loading branch information
hkir-dev committed Aug 31, 2024
1 parent 5356dc9 commit fa4e24d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/main/java/ebi/spot/neo4j2owl/N2OProcedure.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public Stream<N2OReturnValue> exportOWLNodes(@Name("skip") Long skip, @Name("lim

@SuppressWarnings("unused")
@Procedure(mode = Mode.WRITE)
public Stream<N2OReturnValue> exportOWLEdges(@Name("skip") Long skip, @Name("limit") Long limit) {
public Stream<N2OReturnValue> exportOWLEdges(@Name("relationType") String relationType) {
logger.resetTimer();
N2OExportService exportService = new N2OExportService(db);
N2OReturnValue result = exportService.owl2ExportEdges(skip, limit);
N2OReturnValue result = exportService.owl2ExportEdges(relationType);
return Stream.of(result);
}

Expand Down
31 changes: 22 additions & 9 deletions src/main/java/ebi/spot/neo4j2owl/exporter/N2OExportService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ public class N2OExportService {
// static IRIManager iriManager = new IRIManager();
private N2OExportManager n2OEntityManager;
private Set<String> qsls_with_no_matching_properties;


private final static String SUBCLASS_OF = "subclassOf";
private final static String INSTANCE_OF = "instanceOf";
private final static String ANNOTATION_PROPERTY = "annotationProperty";
private final static String OBJECT_PROPERTY = "objectProperty";

public N2OExportService(GraphDatabaseService db) {
this.db = db;
}
Expand Down Expand Up @@ -115,7 +120,7 @@ public N2OReturnValue owl2ExportNodes(Long skip, Long limit) {
return returnValue;
}

public N2OReturnValue owl2ExportEdges(Long skip, Long limit) {
public N2OReturnValue owl2ExportEdges(String relationType) {
n2OEntityManager = new N2OExportManager();
qsls_with_no_matching_properties = new HashSet<>();
logger.resetTimer();
Expand All @@ -125,14 +130,22 @@ public N2OReturnValue owl2ExportEdges(Long skip, Long limit) {
OWLOntologyManager man = OWLManager.createOWLOntologyManager();

OWLOntology o = man.createOntology();
findEntities(skip, limit);
addRelation(o, N2OStatic.RELTYPE_SUBCLASSOF);
addRelation(o, N2OStatic.RELTYPE_INSTANCEOF);
for (String rel_qsl : getRelations(OWLAnnotationProperty.class)) {
addRelation(o, rel_qsl);
findEntities(0L, Long.MAX_VALUE);
if (relationType == null || relationType.isEmpty() || relationType.equals(SUBCLASS_OF)) {
addRelation(o, N2OStatic.RELTYPE_SUBCLASSOF);
}
for (String rel_qsl : getRelations(OWLObjectProperty.class)) {
addRelation(o, rel_qsl);
if (relationType == null || relationType.isEmpty() || relationType.equals(INSTANCE_OF)) {
addRelation(o, N2OStatic.RELTYPE_INSTANCEOF);
}
if (relationType == null || relationType.isEmpty() || relationType.equals(ANNOTATION_PROPERTY)) {
for (String rel_qsl : getRelations(OWLAnnotationProperty.class)) {
addRelation(o, rel_qsl);
}
}
if (relationType == null || relationType.isEmpty() || relationType.equals(OBJECT_PROPERTY)) {
for (String rel_qsl : getRelations(OWLObjectProperty.class)) {
addRelation(o, rel_qsl);
}
}
ByteArrayOutputStream os = new ByteArrayOutputStream(); // new FileOutputStream(new File(fileName))
man.saveOntology(o, new RDFXMLDocumentFormat(), os);
Expand Down

0 comments on commit fa4e24d

Please sign in to comment.