org.apache.jena.rdf.model.Model.createResource()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(9.2k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中org.apache.jena.rdf.model.Model.createResource()方法的一些代码示例,展示了Model.createResource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Model.createResource()方法的具体详情如下:
包路径:org.apache.jena.rdf.model.Model
类名称:Model
方法名:createResource

Model.createResource介绍

[英]Create a new anonymous resource whose model is this model. This bnode will have a new AnonId distinct from any allocated by any other call of this method.

Subsequent operations on the returned resource may modify this model.
[中]创建一个新的匿名资源,其模型是此模型。此bnode将有一个新的AnonId,与此方法的任何其他调用分配的任何AnonId不同。
对返回资源的后续操作可能会修改此模型。

代码示例

代码示例来源:origin: google/data-transfer-project

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);
}

代码示例来源:origin: google/data-transfer-project

private String createPersonDirectory(String url, SolidUtilities utilities) throws IOException {
 Model personDirectoryModel = ModelFactory.createDefaultModel();
 personDirectoryModel.createResource("");
 return utilities.postContent(
   url,
   "Person",
   BASIC_CONTAINER_TYPE,
   personDirectoryModel);
}

代码示例来源:origin: google/data-transfer-project

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);
}

代码示例来源:origin: apache/jena

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());
}

代码示例来源:origin: apache/jena

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());
}

代码示例来源:origin: apache/jena

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") ;
}

代码示例来源:origin: vivo-project/Vitro

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;
}

代码示例来源:origin: apache/jena

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() );
}

代码示例来源:origin: apache/jena

@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

代码示例来源:origin: apache/jena

/**
 * "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);
}

代码示例来源:origin: apache/jena

@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)) ;
}

代码示例来源:origin: apache/jena

/**
 * 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);
}

代码示例来源:origin: apache/jena

@Override
public void setUp()
{
  super.setUp();
  S = model.createResource("http://nowhere.man/subject");
  P = model.createProperty("http://nowhere.man/predicate");
}

代码示例来源:origin: apache/jena

public void testCreateNamedResource()
{
  final String uri = "http://aldabaran.hpl.hp.com/foo";
  Assert.assertEquals(uri, model.createResource(uri).getURI());
}

代码示例来源:origin: google/data-transfer-project

@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()) {

代码示例来源:origin: apache/jena

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") ;
}

代码示例来源:origin: apache/jena

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;
}

代码示例来源:origin: google/data-transfer-project

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);
}

代码示例来源:origin: org.apache.jena/jena-core

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() );
}

代码示例来源:origin: org.apache.jena/jena-core

@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

相关文章

Model类方法