use of org.apache.jena.ontology.OntModel in project Vitro by vivo-project.
the class ApplicationDaoJena method getExternallyLinkedNamespaces.
private synchronized List<String> getExternallyLinkedNamespaces(boolean clearCache) {
if (clearCache || externallyLinkedNamespaces == null) {
externallyLinkedNamespaces = new ArrayList<String>();
OntModel ontModel = getOntModelSelector().getDisplayModel();
NodeIterator nodes = ontModel.listObjectsOfProperty(LINKED_NAMESPACE_PROP);
while (nodes.hasNext()) {
RDFNode node = nodes.next();
if (node.isLiteral()) {
String namespace = ((Literal) node).getLexicalForm();
// It also accords with the way the default namespace is defined.
if (!namespace.endsWith("/")) {
namespace += "/";
}
externallyLinkedNamespaces.add(namespace);
}
}
}
return externallyLinkedNamespaces;
}
use of org.apache.jena.ontology.OntModel in project Vitro by vivo-project.
the class ApplicationDaoJena method updateApplicationBean.
public void updateApplicationBean(ApplicationBean application) {
// TODO migrate to "application" in the resource URI
OntModel ontModel = getOntModelSelector().getApplicationMetadataModel();
Individual appInd = ontModel.getIndividual(getApplicationResourceURI());
if (appInd == null) {
appInd = ontModel.createIndividual(getApplicationResourceURI(), PORTAL);
}
ontModel.enterCriticalSection(Lock.WRITE);
try {
appInd.setLabel(application.getApplicationName(), null);
updatePropertyStringValue(appInd, APPLICATION_ABOUTTEXT, application.getAboutText(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_ACKNOWLEGETEXT, application.getAcknowledgeText(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_CONTACTMAIL, application.getContactMail(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_CORRECTIONMAIL, application.getCorrectionMail(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_COPYRIGHTANCHOR, application.getCopyrightAnchor(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_COPYRIGHTURL, application.getCopyrightURL(), ontModel);
updatePropertyStringValue(appInd, APPLICATION_THEMEDIR, application.getThemeDir(), ontModel);
} catch (Exception e) {
log.error(e, e);
} finally {
ontModel.leaveCriticalSection();
}
}
use of org.apache.jena.ontology.OntModel in project Vitro by vivo-project.
the class IndividualRdfAssemblerTest method modelDifference.
private List<Statement> modelDifference(OntModel first, OntModel second) {
OntModel temp = ModelFactory.createOntologyModel(OWL_MEM);
temp.add(first);
temp.remove(statementList(second));
return statementList(temp);
}
use of org.apache.jena.ontology.OntModel in project Vitro by vivo-project.
the class IndividualRdfAssemblerTest method runGetRdf.
private OntModel runGetRdf() {
try {
Method m = IndividualRdfAssembler.class.getDeclaredMethod("getRdf");
m.setAccessible(true);
return (OntModel) m.invoke(ira);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of org.apache.jena.ontology.OntModel in project Vitro by vivo-project.
the class PrimitiveRdfEditTest method testProcessChanges.
@Test
public void testProcessChanges() throws Exception {
OntModel writeModel = ModelFactory.createOntologyModel();
int totalStmts = 3;
PrimitiveRdfEdit pre = new PrimitiveRdfEdit();
String[] params = { testN3a, testN3b };
Set<Model> models = pre.parseRdfParam(params, "N3");
Assert.assertNotNull(models);
Assert.assertTrue(models.size() == 2);
Assert.assertNotNull(writeModel);
long size = writeModel.size();
pre.processChanges("uri:fakeEditorUri", writeModel, pre.mergeModels(models), ModelFactory.createDefaultModel());
Assert.assertEquals(size + totalStmts, writeModel.size());
String[] params3 = { testN3b };
Set<Model> retracts = pre.parseRdfParam(params3, "N3");
pre.processChanges("uri:fakeEditorUri", writeModel, ModelFactory.createDefaultModel(), pre.mergeModels(retracts));
Assert.assertEquals(size + totalStmts - 1, writeModel.size());
}
Aggregations