当前位置: 首页>>代码示例>>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;未经允许,请勿转载。