/** Package access to allow for unit testing. */ Model mergeModels(Set<Model> additions) { Model a = org.apache.jena.rdf.model.ModelFactory.createDefaultModel(); for (Model m : additions) { a.add(m); } return a; }
Model constructModel(Resource individual, Property property) { Model model = ModelFactory.createDefaultModel(); for (String uri : typeUris) { model.add(individual, property, model.createResource(uri)); } return model; }
Model constructModel(Resource individual, String property) { Model model = ModelFactory.createDefaultModel(); for (String uri : typeUris) { model.add(individual, model.createProperty(property), model.createResource(uri)); } return model; }
private static void load3(Model model) { Resource r3 = model.createResource(base1+"r3") ; Property p1 = model.createProperty(baseNS+"p2") ; model.add(r3, p1, "x1") ; model.add(r3, p1, "x2") ; }
private void addAdditionalData(final Model targetModel, Model fromModel, final Resource targetResource) { if (fromModel != null && fromModel.size() > 0) { Resource additionalData = fromModel.createResource(); //TODO: check if the statement below is now necessary //RdfUtils.replaceBaseResource(additionalDataModel, additionalData); targetModel.add(targetModel.createStatement(targetResource, WON.HAS_ADDITIONAL_DATA, additionalData)); targetModel.add(fromModel); } }
public void testConfigure2() { // create a simple policy Model m = ModelFactory.createDefaultModel(); Resource policy = m.createResource(); m.add( policy, RDF.type, OntDocManagerVocab.DocumentManagerPolicy ); m.addLiteral( policy, OntDocManagerVocab.cacheModels, false ); OntDocumentManager mgr = new OntDocumentManager( (String) null ); assertTrue( mgr.getCacheModels() ); mgr.configure( m ); assertFalse( "Docmgr configure() should have updated cache models flag", mgr.getCacheModels() ); }
private void doTestRDFSSimple(String level) { Model model = ModelFactory.createDefaultModel(); String NS = "http://jena.hpl.hp.com/example#"; Property prop = model.createProperty(NS + "prop"); model.add(prop, RDF.type, RDF.Property); Reasoner reasoner = RDFSRuleReasonerFactory.theInstance().create(null); reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, level); InfModel im = ModelFactory.createInfModel(reasoner, model); assertTrue( im.contains(prop, RDFS.subPropertyOf, prop) ); }
public void addObject(String subject, String predicate, String object) { Model model =getContextModel(); Resource s = getResource(model, subject.trim()); Property p = model.createProperty(predicate.trim()); Resource o = getResource(model, object.trim()); model.add(s, p, o); }
private Model buildModel(QuerySolution results, JsonNode currentNode , HGQLSchema schema) { Model model = ModelFactory.createDefaultModel(); FieldConfig propertyString = schema.getFields().get(currentNode.get("name").asText()); TypeConfig targetTypeString = schema.getTypes().get(currentNode.get("targetName").asText()); populateModel(results, currentNode, model, propertyString, targetTypeString); QueryFieldConfig queryField = schema.getQueryFields().get(currentNode.get("name").asText()); if (queryField != null) { String typeName = (currentNode.get("alias").isNull()) ? currentNode.get("name").asText() : currentNode.get("alias").asText(); Resource object = results.getResource(currentNode.get("nodeId").asText()); Resource subject = model.createResource(HGQL_QUERY_URI); Property predicate = model.createProperty("", HGQL_QUERY_NAMESPACE + typeName); model.add(subject, predicate, object); } return model; }
/** To each subclass X of <code>parents.item</code> add as superclass all the classes between X and that item and all the items in the rest of <code>parents</code>. */ private static void addSuperClasses( Model m, LinkedSeq parents ) { Model toAdd = ModelFactory.createDefaultModel(); addSuperClasses( m, parents, toAdd ); m.add( toAdd ); }
private static void load2(Model model) { Resource r2 = model.createResource(base1+"r2") ; Property p1 = model.createProperty(baseNS+"p1") ; model.add(r2, p1, "x1") ; model.add(r2, p1, "x2") ; }
/** * "dirty" reifications - those with conflicting quadlets - should fail. */ public void testDirtyReification() { final Resource R = model.createResource(TestReifiedStatements.aURI); model.add(R, RDF.type, RDF.Statement); model.add(R, RDF.subject, S); model.add(R, RDF.subject, P); testDoesNotReify("boo", R); }
@Override public Iterator< ? extends Resource> doList( OntModel schema ) { Model data = ModelFactory.createDefaultModel(); Resource c = schema.createResource( "http://example.com/foo#AClass" ); Resource i = data.createResource( "http://example.com/foo#anInd" ); schema.add( c, RDF.type, OWL.Class ); data.add( i, RDF.type, c ); OntModel composite = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, schema ); composite.addSubModel( data ); return composite.listIndividuals(); } @Override
public void testConfigure2() { // create a simple policy Model m = ModelFactory.createDefaultModel(); Resource policy = m.createResource(); m.add( policy, RDF.type, OntDocManagerVocab.DocumentManagerPolicy ); m.addLiteral( policy, OntDocManagerVocab.cacheModels, false ); OntDocumentManager mgr = new OntDocumentManager( (String) null ); assertTrue( mgr.getCacheModels() ); mgr.configure( m ); assertFalse( "Docmgr configure() should have updated cache models flag", mgr.getCacheModels() ); }
private void doTestRDFSSimple(String level) { Model model = ModelFactory.createDefaultModel(); String NS = "http://jena.hpl.hp.com/example#"; Property prop = model.createProperty(NS + "prop"); model.add(prop, RDF.type, RDF.Property); Reasoner reasoner = RDFSRuleReasonerFactory.theInstance().create(null); reasoner.setParameter(ReasonerVocabulary.PROPsetRDFSLevel, level); InfModel im = ModelFactory.createInfModel(reasoner, model); assertTrue( im.contains(prop, RDFS.subPropertyOf, prop) ); }
public static void renameProperty(Model model, Property p, String uri) { List<Statement> stmts = model.listStatements(null, p, (RDFNode)null).toList(); model.remove(stmts); for(Statement stmt : stmts) { Property newProperty = model.createProperty(uri); model.add(stmt.getSubject(), newProperty, stmt.getObject()); } }
private Model buildModel(QuerySolution results, JsonNode currentNode , HGQLSchema schema) { Model model = ModelFactory.createDefaultModel(); FieldConfig propertyString = schema.getFields().get(currentNode.get("name").asText()); TypeConfig targetTypeString = schema.getTypes().get(currentNode.get("targetName").asText()); populateModel(results, currentNode, model, propertyString, targetTypeString); QueryFieldConfig queryField = schema.getQueryFields().get(currentNode.get("name").asText()); if (queryField != null) { String typeName = (currentNode.get("alias").isNull()) ? currentNode.get("name").asText() : currentNode.get("alias").asText(); Resource object = results.getResource(currentNode.get("nodeId").asText()); Resource subject = model.createResource(HGQL_QUERY_URI); Property predicate = model.createProperty("", HGQL_QUERY_NAMESPACE + typeName); model.add(subject, predicate, object); } return model; }
/** To each subclass X of <code>parents.item</code> add as superclass all the classes between X and that item and all the items in the rest of <code>parents</code>. */ private static void addSuperClasses( Model m, LinkedSeq parents ) { Model toAdd = ModelFactory.createDefaultModel(); addSuperClasses( m, parents, toAdd ); m.add( toAdd ); }
private static void load3(Model model) { Resource r3 = model.createResource(base1+"r3") ; Property p1 = model.createProperty(baseNS+"p2") ; model.add(r3, p1, "x1") ; model.add(r3, p1, "x2") ; }
/** * "dirty" reifications - those with conflicting quadlets - should fail. */ public void testDirtyReification() { final Resource R = model.createResource(TestReifiedStatements.aURI); model.add(R, RDF.type, RDF.Statement); model.add(R, RDF.subject, S); model.add(R, RDF.subject, P); testDoesNotReify("boo", R); }