private String createContainer(String url, String slug, SolidUtilities utilities) throws Exception { Model containerModel = ModelFactory.createDefaultModel(); Resource containerResource = containerModel.createResource(""); containerResource.addProperty(DCTerms.title, slug); return utilities.postContent(url, slug, BASIC_CONTAINER_TYPE, containerModel); }
private String createPersonDirectory(String url, SolidUtilities utilities) throws IOException { Model personDirectoryModel = ModelFactory.createDefaultModel(); personDirectoryModel.createResource(""); return utilities.postContent( url, "Person", BASIC_CONTAINER_TYPE, personDirectoryModel); }
private String createIndex(String url, String slug, SolidUtilities utilities) throws Exception { Model model = ModelFactory.createDefaultModel(); Resource containerResource = model.createResource("#this"); containerResource.addProperty(RDF.type, model.getResource(VCARD4.NS + "AddressBook")); containerResource.addProperty( model.createProperty(VCARD4.NS + "nameEmailIndex"), model.createResource("people.ttl")); containerResource.addProperty( model.createProperty(VCARD4.NS + "groupIndex"), model.createResource("groups.ttl")); containerResource.addProperty(DC_11.title, slug); return utilities.postContent( url, "index", BASIC_RESOURCE_TYPE, model); }
public void testCreateListFromIterator() { List<RDFNode> expected = new ArrayList<>(); expected.add(model.createResource()); expected.add(model.createResource()); expected.add(model.createResource()); RDFList list = model.createList(expected.iterator()); Assert.assertEquals(expected, list.asJavaList()); }
public void testAddByIterator() { ModelHelper.modelAdd(model, "a P b; c P d; x Q 1; y Q 2"); model2.add(model.listStatements()); Assert.assertEquals(model.size(), model2.size()); assertSameStatements(model, model2); model.add(model.createResource(), RDF.value, model.createResource()); model.add(model.createResource(), RDF.value, model.createResource()); model.add(model.createResource(), RDF.value, model.createResource()); final StmtIterator s = model.listStatements(); model2.remove(s.nextStatement()).remove(s); Assert.assertEquals(0, model2.size()); }
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") ; }
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; }
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() ); }
@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
/** * "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); }
@Test public void optionalDotInBase() { Model model = ModelFactory.createDefaultModel() ; StringReader reader = new StringReader("@base <http://example/> <x> <p> <o> .") ; RDFDataMgr.read(model, reader, null, RDFLanguages.TURTLE) ; assertEquals(1, model.size()) ; Resource r = model.createResource("http://example/x") ; Property p = model.createProperty("http://example/p") ; assertTrue(model.contains(r,p)) ; }
/** * Register a Reasoner - simple case with no RDF description. * @param factory an factory that can be used to create instances of the reasoner * @param reasonerUri the URI used to label the reasoner, expressed as a * simple string */ public void register(String reasonerUri, ReasonerFactory factory) { reasonerFactories.put(reasonerUri, factory); allDescriptions.createResource(reasonerUri) .addProperty(RDF.type, ReasonerVocabulary.ReasonerClass); }
@Override public void setUp() { super.setUp(); S = model.createResource("http://nowhere.man/subject"); P = model.createProperty("http://nowhere.man/predicate"); }
public void testCreateNamedResource() { final String uri = "http://aldabaran.hpl.hp.com/foo"; Assert.assertEquals(uri, model.createResource(uri).getURI()); }
@VisibleForTesting final static Model getPersonModel(VCard vcard) { Model personModel = ModelFactory.createDefaultModel(); Resource r = personModel.createResource("#this"); r.addProperty(RDF.type, VCARD4.Individual); r.addProperty(VCARD4.fn, vcard.getFormattedName().getValue()); Resource strucName = personModel.createResource(); if (!Strings.isNullOrEmpty(structuredName.getFamily())) { strucName.addProperty(VCARD4.family_name, structuredName.getFamily()); r.addProperty(VCARD4.hasEmail, mailTo); } else { Resource emailResource = personModel.createResource(); emailResource.addProperty(VCARD4.value, mailTo); for (EmailType type : email.getTypes()) { r.addProperty(VCARD4.hasTelephone, telephone.getText()); } else { Resource telephoneResource = personModel.createResource(); telephoneResource.addProperty(VCARD4.value, telephone.getText()); for (TelephoneType type : telephone.getTypes()) {
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 Model simpleModel(String ns) { Model m = ModelFactory.createDefaultModel(); Resource s = m.createResource(ns + "s"); Property p = m.createProperty(ns + "p"); Resource o = m.createResource(ns + "o"); m.add(s,p,o); return m; }
private String createPeopleFile( String baseUrl, String containerUrl, Map<String, VCard> importedPeople, SolidUtilities utilities) throws Exception { Model peopleModel = ModelFactory.createDefaultModel(); Resource indexResource = peopleModel.createResource("index.ttl#this"); for (String insertedId : importedPeople.keySet()) { VCard insertedPerson = importedPeople.get(insertedId); String relativePath = insertedId.replace(containerUrl, ""); Resource personResource = peopleModel.createResource(relativePath + "#this"); if (insertedPerson.getFormattedName() != null) { personResource.addProperty(VCARD4.fn, insertedPerson.getFormattedName().getValue()); } personResource.addProperty( peopleModel.createProperty(VCARD4.NS, "inAddressBook"), indexResource); } return utilities.postContent( baseUrl + containerUrl, "people", BASIC_RESOURCE_TYPE, peopleModel); }
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() ); }
@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