當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.add方法代碼示例

本文整理匯總了Java中org.apache.jena.rdf.model.Model.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Model.add方法的具體用法?Java Model.add怎麽用?Java Model.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.jena.rdf.model.Model的用法示例。


在下文中一共展示了Model.add方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testLocalDiff

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
@Test
public void testLocalDiff() throws Exception {
  Model firstModel = ModelFactory.createDefaultModel();
  firstModel.read("Playpen2.ttl", "TTL");

  Model secondModel = ModelFactory.createDefaultModel();
  secondModel.add(firstModel);
  Resource res1 = secondModel.createResource(resIri1);
  res1.addProperty(RDF.type, SKOS.Concept);

  client.setCurrentModel(firstModel);
  client.setPendingModel(secondModel);
  assertEquals(firstModel, client.getCurrentModel());
  assertEquals(secondModel, client.getPendingModel());

  RDFDifference diff = client.getBatchDiff();

  assertTrue(diff.getInLeftOnly().size() == 0);
  assertTrue(diff.getInRightOnly().size() == 1);

  assertFalse(diff.getInLeftOnly().containsResource(res1));
  assertFalse(diff.getInLeftOnly().contains(res1, RDF.type, SKOS.Concept));

  assertTrue(diff.getInRightOnly().containsResource(res1));
  assertTrue(diff.getInRightOnly().contains(res1, RDF.type, SKOS.Concept));
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:27,代碼來源:OEBatchClientTests.java

示例2: getJenaModel

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
private Model getJenaModel(@NonNull org.eclipse.rdf4j.model.Model model) {
  Model jenaModel = ModelFactory.createDefaultModel();
  java.util.Iterator<org.eclipse.rdf4j.model.Statement> iterator = model.iterator();

  while (iterator.hasNext()) {
    org.eclipse.rdf4j.model.Statement rdf4jStatement = iterator.next();

    // create resource / subject
    Resource resource = rdf4jResourceToJenaResource(jenaModel, rdf4jStatement.getSubject());
    // create property / predicate
    Property property =
        rdf4jPropertyToJenaProperty(jenaModel, (SimpleIRI) rdf4jStatement.getPredicate());
    // create rdfnode / object
    RDFNode node = rdf4jValueToJenaRdfNode(jenaModel, rdf4jStatement.getObject());

    Statement statement = ResourceFactory.createStatement(resource, property, node);
    jenaModel.add(statement);
  }
  return jenaModel;
}
 
開發者ID:dotwebstack,項目名稱:dotwebstack-framework,代碼行數:21,代碼來源:ShaclValidator.java

示例3: loadModelToTdb

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
/**
 * Return an new TDB-backed Jena model with the specified model added.
 *
 * @param inModel
 * @param modelId
 * @param tDbDirectoryPath
 * @return
 */
public static Model loadModelToTdb(Model inModel, String modelId, String tDbDirectoryPath) {

  if (logger.isDebugEnabled()) {
    logger.debug("Model  : <object>");
    logger.debug("Model ID: {}", modelId);
    logger.debug("TDB  DIR: {}", tDbDirectoryPath);
  }

  Dataset dataset = TDBFactory.createDataset(tDbDirectoryPath);
  Model model = dataset.getNamedModel(modelId);
  model.add(inModel);
  return model;
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:22,代碼來源:ModelLoader.java

示例4: hydrateAndModifySecondModel

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
public Model hydrateAndModifySecondModel() {
  Model model2 = ModelFactory.createDefaultModel();
  model2.add(model);

  StmtIterator it = model2.listStatements(newConceptRes, null, (RDFNode) null);
  List<Statement> toDelete = Lists.newArrayList();
  while (it.hasNext()) {
    Statement stmt = it.nextStatement();
    toDelete.add(stmt);
  }
  model2.remove(toDelete);

  Resource foobarFooRes = model2.createResource("http://example/com/Playpen2#foobarFoo");
  foobarFooRes.addProperty(RDF.type, SKOS.Concept);

  foobarFooRes.addLiteral(prop1, false);
  foobarFooRes.addLiteral(prop2, 1);
  Calendar c = Calendar.getInstance();
  c.set(Calendar.YEAR, 2016);
  c.set(Calendar.DAY_OF_MONTH, 3);
  c.set(Calendar.MONTH, 10);
  foobarFooRes.addLiteral(prop3, model.createTypedLiteral(dtfmt.format(c.getTime()), XSDDatatype.XSDdate));
  foobarFooRes.addProperty(prop4, "2017-01-01", XSDDatatype.XSDdate);
  foobarFooRes.addProperty(prop5, "http://www.google.com", XSDDatatype.XSDanyURI);

  model2.addLiteral(foobarFooRes, prop6, model.createLiteral("2017-02-22", "en"));

  return model2;
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:30,代碼來源:DiffToSparqlInsertUpdateBuilderTests.java

示例5: loadModelToMem

import org.apache.jena.rdf.model.Model; //導入方法依賴的package包/類
/**
 * Creates a new model, adds the specified model to it, and returns the new model.
 * @param inModel
 * @return
 */
public static Model loadModelToMem(Model inModel) {
  Model newModel = ModelFactory.createDefaultModel();
  newModel.add(inModel);
  return newModel;
}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:11,代碼來源:ModelLoader.java


注:本文中的org.apache.jena.rdf.model.Model.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。