Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 5cd418a

Browse files
committed
Add more ontology annotations
1 parent 9711117 commit 5cd418a

10 files changed

Lines changed: 320 additions & 1 deletion

src/main/java/de/linkvt/bachelor/config/OntologyIriExtractor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package de.linkvt.bachelor.config;
22

3+
import de.linkvt.bachelor.web.GeneratorController;
4+
5+
import org.apache.commons.lang3.StringUtils;
36
import org.springframework.stereotype.Component;
47

58
/**
@@ -8,6 +11,12 @@
811
@Component
912
public class OntologyIriExtractor {
1013

14+
public String extractGeneratorIri(String url) {
15+
String urlWithoutIdAndFilename = trimFilenameAndId(url);
16+
17+
return trimOntologyPath(urlWithoutIdAndFilename);
18+
}
19+
1120
public String extractOntologyIri(String url, Long generationId) {
1221
String urlWithoutFilename = trimFilenameAndId(url);
1322

@@ -17,4 +26,9 @@ public String extractOntologyIri(String url, Long generationId) {
1726
private String trimFilenameAndId(String url) {
1827
return url.replaceAll("(\\d+/)?[^/]*$", "");
1928
}
29+
30+
private String trimOntologyPath(String url) {
31+
return StringUtils.stripEnd(url, GeneratorController.ONTOLOGY_PATH);
32+
}
33+
2034
}

src/main/java/de/linkvt/bachelor/features/annotations/ontology/OntologyConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package de.linkvt.bachelor.features.annotations.ontology;
22

3+
import org.semanticweb.owlapi.model.IRI;
34
import org.springframework.stereotype.Component;
45

56
import java.text.SimpleDateFormat;
@@ -8,6 +9,9 @@
89
@Component
910
public class OntologyConstants {
1011

12+
public static final IRI ONTOVIBE_CORE_IRI = IRI.create("http://ontovibe.visualdataweb.org/");
13+
public static final IRI ONTOVIBE_MINIMAL_IRI = IRI.create("http://ontovibe.visualdataweb.org/minimal/");
14+
1115
public String getContributor() {
1216
return "Vincent Link";
1317
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.owl;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.features.annotations.ontology.OntologyConstants;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.stereotype.Component;
12+
13+
@Component
14+
public class OwlBackwardCompatibleWithFeature extends Feature {
15+
16+
private static final String OWL_BACKWARD_COMPATIBLE_WITH = "owl:backwardCompatibleWith";
17+
18+
@Override
19+
public void addToOntology() {
20+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_BACKWARD_COMPATIBLE_WITH, pm);
21+
IRI value = OntologyConstants.ONTOVIBE_MINIMAL_IRI;
22+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);
23+
24+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
25+
}
26+
27+
@Override
28+
public String getName() {
29+
return OWL_BACKWARD_COMPATIBLE_WITH;
30+
}
31+
32+
@Override
33+
public String getToken() {
34+
return "owlbackwardcompatiblewith";
35+
}
36+
37+
@Override
38+
public FeatureCategory getCategory() {
39+
return FeatureCategory.ANNOTATIONS;
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.owl;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.features.annotations.ontology.OntologyConstants;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.stereotype.Component;
12+
13+
@Component
14+
public class OwlImportsFeature extends Feature {
15+
16+
private static final String OWL_IMPORTS = "owl:imports";
17+
18+
@Override
19+
public void addToOntology() {
20+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_IMPORTS, pm);
21+
IRI value = OntologyConstants.ONTOVIBE_MINIMAL_IRI;
22+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);
23+
24+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
25+
}
26+
27+
@Override
28+
public String getName() {
29+
return OWL_IMPORTS;
30+
}
31+
32+
@Override
33+
public String getToken() {
34+
return "owlimports";
35+
}
36+
37+
@Override
38+
public FeatureCategory getCategory() {
39+
return FeatureCategory.ANNOTATIONS;
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.owl;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.features.annotations.ontology.OntologyConstants;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.stereotype.Component;
12+
13+
@Component
14+
public class OwlIncompatibleWithFeature extends Feature {
15+
16+
private static final String OWL_INCOMPATIBLE_WITH = "owl:incompatibleWith";
17+
18+
@Override
19+
public void addToOntology() {
20+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_INCOMPATIBLE_WITH, pm);
21+
IRI value = OntologyConstants.ONTOVIBE_CORE_IRI;
22+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);
23+
24+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
25+
}
26+
27+
@Override
28+
public String getName() {
29+
return OWL_INCOMPATIBLE_WITH;
30+
}
31+
32+
@Override
33+
public String getToken() {
34+
return "owlincompatiblewith";
35+
}
36+
37+
@Override
38+
public FeatureCategory getCategory() {
39+
return FeatureCategory.ANNOTATIONS;
40+
}
41+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.owl;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.features.annotations.ontology.OntologyConstants;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.stereotype.Component;
12+
13+
@Component
14+
public class OwlPriorVersionFeature extends Feature {
15+
16+
private static final String OWL_PRIOR_VERSION = "owl:priorVersion";
17+
18+
@Override
19+
public void addToOntology() {
20+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_PRIOR_VERSION, pm);
21+
IRI value = OntologyConstants.ONTOVIBE_CORE_IRI;
22+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);
23+
24+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
25+
}
26+
27+
@Override
28+
public String getName() {
29+
return OWL_PRIOR_VERSION;
30+
}
31+
32+
@Override
33+
public String getToken() {
34+
return "owlpriorversion";
35+
}
36+
37+
@Override
38+
public FeatureCategory getCategory() {
39+
return FeatureCategory.ANNOTATIONS;
40+
}
41+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.owl;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
6+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
7+
import org.semanticweb.owlapi.model.IRI;
8+
import org.semanticweb.owlapi.model.OWLAnnotation;
9+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
10+
import org.springframework.stereotype.Component;
11+
12+
import java.util.Optional;
13+
14+
@Component
15+
public class OwlVersionIriFeature extends Feature {
16+
17+
private static final String OWL_VERSION_IRI = "owl:versionIri";
18+
19+
@Override
20+
public void addToOntology() {
21+
Optional<IRI> iri = ontology.getOntologyID().getDefaultDocumentIRI();
22+
assert iri.isPresent();
23+
24+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWL_VERSION_IRI, pm);
25+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, iri.get());
26+
27+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return OWL_VERSION_IRI;
33+
}
34+
35+
@Override
36+
public String getToken() {
37+
return "owlversioniri";
38+
}
39+
40+
@Override
41+
public FeatureCategory getCategory() {
42+
return FeatureCategory.ANNOTATIONS;
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.rdfs;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.web.RequestInformation;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.stereotype.Component;
13+
14+
@Component
15+
public class RdfsIsDefinedByFeature extends Feature {
16+
17+
private static final String RDFS_IS_DEFINED_BY = "rdfs:isDefinedBy";
18+
19+
@Autowired
20+
private RequestInformation requestInformation;
21+
22+
@Override
23+
public void addToOntology() {
24+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(RDFS_IS_DEFINED_BY, pm);
25+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, IRI.create(requestInformation.getGeneratorIri()));
26+
27+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return RDFS_IS_DEFINED_BY;
33+
}
34+
35+
@Override
36+
public String getToken() {
37+
return "rdfsisdefinedby";
38+
}
39+
40+
@Override
41+
public FeatureCategory getCategory() {
42+
return FeatureCategory.ANNOTATIONS;
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package de.linkvt.bachelor.features.annotations.ontology.rdfs;
2+
3+
import de.linkvt.bachelor.features.Feature;
4+
import de.linkvt.bachelor.features.FeatureCategory;
5+
import de.linkvt.bachelor.web.RequestInformation;
6+
7+
import org.semanticweb.owlapi.model.AddOntologyAnnotation;
8+
import org.semanticweb.owlapi.model.IRI;
9+
import org.semanticweb.owlapi.model.OWLAnnotation;
10+
import org.semanticweb.owlapi.model.OWLAnnotationProperty;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.stereotype.Component;
13+
14+
@Component
15+
public class RdfsSeeAlsoFeature extends Feature {
16+
17+
private static final String RDFS_SEE_ALSO = "rdfs:seeAlso";
18+
19+
@Autowired
20+
private RequestInformation requestInformation;
21+
22+
@Override
23+
public void addToOntology() {
24+
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(RDFS_SEE_ALSO, pm);
25+
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, IRI.create(requestInformation.getGeneratorIri()));
26+
27+
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
28+
}
29+
30+
@Override
31+
public String getName() {
32+
return RDFS_SEE_ALSO;
33+
}
34+
35+
@Override
36+
public String getToken() {
37+
return "rdfsseealso";
38+
}
39+
40+
@Override
41+
public FeatureCategory getCategory() {
42+
return FeatureCategory.ANNOTATIONS;
43+
}
44+
}

src/main/java/de/linkvt/bachelor/web/RequestInformation.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55

66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.context.annotation.Scope;
8+
import org.springframework.context.annotation.ScopedProxyMode;
89
import org.springframework.stereotype.Component;
910
import org.springframework.web.context.WebApplicationContext;
1011

1112
import javax.servlet.http.HttpServletRequest;
1213

1314

1415
@Component
15-
@Scope(WebApplicationContext.SCOPE_REQUEST)
16+
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
1617
public class RequestInformation {
1718

1819
private HttpServletRequest request;
@@ -43,4 +44,8 @@ public OntologyGenerator getGenerator() {
4344
public String getOntologyIri() {
4445
return ontologyIriExtractor.extractOntologyIri(request.getRequestURL().toString(), generationId);
4546
}
47+
48+
public String getGeneratorIri() {
49+
return ontologyIriExtractor.extractGeneratorIri(request.getRequestURL().toString());
50+
}
4651
}

0 commit comments

Comments
 (0)