|
a/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/ExtendedOWL.java |
|
b/src/main/java/net/timbusproject/extractors/modules/tavernaextractor/ExtendedOWL.java |
|
... |
|
... |
98 |
IRI.create(IRI_PREMIS.toString() + "#", "File"));
|
98 |
IRI.create(IRI_PREMIS.toString() + "#", "File"));
|
99 |
|
99 |
|
100 |
/**
|
100 |
/**
|
101 |
* PRONOM PUID
|
101 |
* PRONOM PUID
|
102 |
*/
|
102 |
*/
|
103 |
public static final String PRONOM_REGISTRY_URI = "http://www.loc.gov/premis/rdf/v1#hasFormatRegistryKey";
|
103 |
public static final String PRONOM_REGISTRY_KEY_URI = "http://www.loc.gov/premis/rdf/v1#hasFormatRegistryKey";
|
104 |
public static final IRI PRONOM_REGISTRY_IRI = IRI.create(PRONOM_REGISTRY_URI);
|
104 |
public static final IRI PRONOM_REGISTRY_KEY_IRI = IRI.create(PRONOM_REGISTRY_KEY_URI);
|
|
|
105 |
public static final String PRONOM_REGISTRY_NAME_URI = "http://www.loc.gov/premis/rdf/v1#hasFormatRegistryName";
|
|
|
106 |
public static final IRI PRONOM_REGISTRY_NAME_IRI = IRI.create(PRONOM_REGISTRY_NAME_URI);
|
105 |
|
107 |
|
106 |
public ExtendedOWL() {
|
108 |
public ExtendedOWL() {
|
107 |
logger.setLevel(Level.DEBUG);
|
109 |
logger.setLevel(Level.DEBUG);
|
108 |
}
|
110 |
}
|
109 |
|
111 |
|
|
... |
|
... |
148 |
// (2) Read entries from DROID CSV report file
|
150 |
// (2) Read entries from DROID CSV report file
|
149 |
provenanceAccessClient = new ProvenanceAccessClient();
|
151 |
provenanceAccessClient = new ProvenanceAccessClient();
|
150 |
provenanceEntries = provenanceAccessClient.filterEntries(provenanceAccessClient.readCSV(droidCSVReport));
|
152 |
provenanceEntries = provenanceAccessClient.filterEntries(provenanceAccessClient.readCSV(droidCSVReport));
|
151 |
|
153 |
|
152 |
if (provenanceEntries.isEmpty()) {
|
154 |
if (provenanceEntries.isEmpty()) {
|
153 |
logger.error("ERROR: Stop processing due to an empty provenance entry list.");
|
155 |
logger.info("Nothing to apply due to an empty provenance entry set.");
|
154 |
return;
|
156 |
return;
|
155 |
}
|
157 |
}
|
156 |
|
158 |
|
157 |
if (ontology != null) {
|
159 |
if (ontology != null) {
|
158 |
|
160 |
|
|
... |
|
... |
174 |
// iterate over all entries found in the DROID CSV report
|
176 |
// iterate over all entries found in the DROID CSV report
|
175 |
for (CSVEntry entry : provenanceEntries) {
|
177 |
for (CSVEntry entry : provenanceEntries) {
|
176 |
|
178 |
|
177 |
logger.debug(entry.toString());
|
179 |
logger.debug(entry.toString());
|
178 |
for (OWLNamedIndividual ind : individuals) {
|
180 |
for (OWLNamedIndividual ind : individuals) {
|
179 |
if (hasAnnotationValue(ind, ontology, entry.getNAME()) && entry.getPUID() != null
|
181 |
if (hasAnnotationValue(ind, ontology, entry.getNameForExtensionUsage()) && entry.getPUID() != null
|
180 |
&& !entry.getPUID().isEmpty()) {
|
182 |
&& !entry.getPUID().isEmpty()) {
|
181 |
|
183 |
|
182 |
logger.info("Found individual (" + ind.getIRI() + ") which has to be extended with PUID ("
|
184 |
logger.info("Found individual (" + ind.getIRI() + ") which has to be extended with PUID ("
|
183 |
+ entry.getPUID() + ")");
|
185 |
+ entry.getPUID() + ")");
|
184 |
updateOWL(ind, entry);
|
186 |
updateOWL(ind, entry);
|
|
... |
|
... |
193 |
}
|
195 |
}
|
194 |
|
196 |
|
195 |
// add a new individual to existing ontology
|
197 |
// add a new individual to existing ontology
|
196 |
private void updateOWL(OWLNamedIndividual ind, CSVEntry entry) {
|
198 |
private void updateOWL(OWLNamedIndividual ind, CSVEntry entry) {
|
197 |
|
199 |
|
198 |
Queue<AddAxiom> changes = new LinkedList<AddAxiom>();
|
200 |
Queue<AddAxiom> changes = new LinkedList<>();
|
199 |
|
201 |
|
200 |
// Add File assertion
|
202 |
// Add File assertion
|
201 |
OWLClassAssertionAxiom swoClassAxiom_File = owlDataFactory.getOWLClassAssertionAxiom(PREMIS_FILE_CLASS, ind);
|
203 |
OWLClassAssertionAxiom swoClassAxiom_File = owlDataFactory.getOWLClassAssertionAxiom(PREMIS_FILE_CLASS, ind);
|
202 |
changes.add(new AddAxiom(ontology, swoClassAxiom_File));
|
204 |
changes.add(new AddAxiom(ontology, swoClassAxiom_File));
|
203 |
|
205 |
|
204 |
// Create new ObjectCharacteristics
|
206 |
// Create new ObjectCharacteristics
|
205 |
OWLNamedIndividual swoIndividual_ObjectCharacteristics = owlDataFactory.getOWLNamedIndividual(IRI.create("#",
|
207 |
OWLNamedIndividual swoIndividual_ObjectCharacteristics = owlDataFactory.getOWLNamedIndividual(IRI.create("#",
|
206 |
replaceWhitespace(entry.getNAME()) + "Characteristics"));
|
208 |
replaceWhitespace(entry.getNameForExtensionUsage()) + "Characteristics"));
|
207 |
OWLClassAssertionAxiom swoClassAxiom_ObjectCharacteristics = owlDataFactory.getOWLClassAssertionAxiom(
|
209 |
OWLClassAssertionAxiom swoClassAxiom_ObjectCharacteristics = owlDataFactory.getOWLClassAssertionAxiom(
|
208 |
PREMIS_OBJECTCHAR_CLASS, swoIndividual_ObjectCharacteristics);
|
210 |
PREMIS_OBJECTCHAR_CLASS, swoIndividual_ObjectCharacteristics);
|
209 |
changes.add(new AddAxiom(ontology, swoClassAxiom_ObjectCharacteristics));
|
211 |
changes.add(new AddAxiom(ontology, swoClassAxiom_ObjectCharacteristics));
|
210 |
|
212 |
|
211 |
changes.add(linkIndividuals(PREMIS_LINKING_HASOBJECTCHARACTERISTICS, ind, swoIndividual_ObjectCharacteristics));
|
213 |
changes.add(linkIndividuals(PREMIS_LINKING_HASOBJECTCHARACTERISTICS, ind, swoIndividual_ObjectCharacteristics));
|
|
... |
|
... |
219 |
|
221 |
|
220 |
changes.add(linkIndividuals(PREMIS_LINKING_HASFORMAT, swoIndividual_ObjectCharacteristics, swoIndividual_Format));
|
222 |
changes.add(linkIndividuals(PREMIS_LINKING_HASFORMAT, swoIndividual_ObjectCharacteristics, swoIndividual_Format));
|
221 |
|
223 |
|
222 |
// Create new FormatRegistry
|
224 |
// Create new FormatRegistry
|
223 |
OWLNamedIndividual swoIndividual_FormatRegistry = owlDataFactory.getOWLNamedIndividual(IRI.create("#",
|
225 |
OWLNamedIndividual swoIndividual_FormatRegistry = owlDataFactory.getOWLNamedIndividual(IRI.create("#",
|
224 |
"PronomRegistry[" + entry.getNAME() + "]"));
|
226 |
"PronomRegistry[" + entry.getNameForExtensionUsage() + "]"));
|
225 |
OWLClassAssertionAxiom swoClassAxiom_FormatRegistry = owlDataFactory.getOWLClassAssertionAxiom(
|
227 |
OWLClassAssertionAxiom swoClassAxiom_FormatRegistry = owlDataFactory.getOWLClassAssertionAxiom(
|
226 |
PREMIS_FROMATREGISTRY_CLASS, swoIndividual_FormatRegistry);
|
228 |
PREMIS_FROMATREGISTRY_CLASS, swoIndividual_FormatRegistry);
|
227 |
changes.add(new AddAxiom(ontology, swoClassAxiom_FormatRegistry));
|
229 |
changes.add(new AddAxiom(ontology, swoClassAxiom_FormatRegistry));
|
228 |
|
230 |
|
229 |
changes.add(linkIndividuals(PREMIS_LINKING_HASFORMATREGISTRY, swoIndividual_Format,
|
231 |
changes.add(linkIndividuals(PREMIS_LINKING_HASFORMATREGISTRY, swoIndividual_Format,
|
230 |
swoIndividual_FormatRegistry));
|
232 |
swoIndividual_FormatRegistry));
|
231 |
|
233 |
|
232 |
// Create new FormatRegistry Data Property Assertion
|
234 |
// Create new FormatRegistry Data Property Assertion
|
233 |
OWLDataProperty owlp = owlDataFactory.getOWLDataProperty(PRONOM_REGISTRY_IRI);
|
235 |
OWLDataProperty owlp = owlDataFactory.getOWLDataProperty(PRONOM_REGISTRY_KEY_IRI);
|
234 |
OWLLiteral owlLiteral = owlDataFactory.getOWLLiteral("info:pronom/" + entry.getPUID(),
|
236 |
OWLLiteral owlLiteral = owlDataFactory.getOWLLiteral("info:pronom/" + entry.getPUID(),
|
235 |
OWL2Datatype.RDFS_LITERAL);
|
237 |
OWL2Datatype.RDFS_LITERAL);
|
236 |
OWLDataPropertyAssertionAxiom addProp = owlDataFactory.getOWLDataPropertyAssertionAxiom(owlp,
|
238 |
OWLDataPropertyAssertionAxiom addProp = owlDataFactory.getOWLDataPropertyAssertionAxiom(owlp,
|
237 |
swoIndividual_FormatRegistry, owlLiteral);
|
239 |
swoIndividual_FormatRegistry, owlLiteral);
|
238 |
changes.add(new AddAxiom(ontology, addProp));
|
240 |
changes.add(new AddAxiom(ontology, addProp));
|
|
|
241 |
|
|
|
242 |
OWLDataProperty owlp2 = owlDataFactory.getOWLDataProperty(PRONOM_REGISTRY_NAME_IRI);
|
|
|
243 |
OWLLiteral owlLiteral2 = owlDataFactory.getOWLLiteral("http://www.nationalarchives.gov.uk/PRONOM/",
|
|
|
244 |
OWL2Datatype.RDFS_LITERAL);
|
|
|
245 |
OWLDataPropertyAssertionAxiom addProp2 = owlDataFactory.getOWLDataPropertyAssertionAxiom(owlp2,
|
|
|
246 |
swoIndividual_FormatRegistry, owlLiteral2);
|
|
|
247 |
changes.add(new AddAxiom(ontology, addProp2));
|
239 |
|
248 |
|
240 |
// apply all changes to the Model
|
249 |
// apply all changes to the Model
|
241 |
for (AddAxiom addAxiom : changes) {
|
250 |
for (AddAxiom addAxiom : changes) {
|
242 |
owlManager.applyChange(addAxiom);
|
251 |
owlManager.applyChange(addAxiom);
|
243 |
}
|
252 |
}
|