本文整理汇总了Java中org.apache.jena.rdf.model.Model.createResource方法的典型用法代码示例。如果您正苦于以下问题:Java Model.createResource方法的具体用法?Java Model.createResource怎么用?Java Model.createResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.createResource方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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));
}
示例2: testSimpleDiff
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
@Test
public void testSimpleDiff() throws Exception {
Model model2 = hydrateAndModifySecondModel();
String sparql = DiffToSparqlInsertUpdateBuilder.buildSparqlInsertUpdate(
RDFDifferenceBuilder.buildDifference(model, model2));
System.out.println(sparql);
assertTrue(sparql.startsWith("DELETE"));
Resource res2 = model2.createResource("http://example/com/Playpen2#foobarFoo");
StmtIterator it = model2.listStatements(res2, prop1, (RDFNode) null);
Statement stmt = it.nextStatement();
assertTrue(stmt.getObject().asLiteral().getBoolean() == false);
it = model2.listStatements(res2, prop2, (RDFNode) null);
stmt = it.nextStatement();
assertTrue(stmt.getObject().asLiteral().getLong() == 1);
it = model2.listStatements(res2, prop3, (RDFNode) null);
stmt = it.nextStatement();
XSDDateTime date = (XSDDateTime) stmt.getObject().asLiteral().getValue();
it = model2.listStatements(res2, prop4, (RDFNode) null);
stmt = it.nextStatement();
Literal lit = stmt.getObject().asLiteral();
String val = lit.getLexicalForm();
String dataType = lit.getDatatype().getURI();
assertTrue(val.equals("2017-01-01"));
assertTrue(dataType.equals(XSDDatatype.XSDdate.getURI()));
it = model2.listStatements(res2, prop5, (RDFNode) null);
stmt = it.nextStatement();
assertTrue(stmt.getObject().asLiteral().getString().equals("http://www.google.com"));
assertTrue(stmt.getObject().asLiteral().getDatatype().getURI().equals(XSDDatatype.XSDanyURI.getURI()));
}
开发者ID:Smartlogic-Semaphore-Limited,项目名称:Java-APIs,代码行数:37,代码来源:DiffToSparqlInsertUpdateBuilderTests.java
示例3: 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
示例4: main
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void main(String[] args) {
try {
OEModelEndpoint endpoint = new OEModelEndpoint();
endpoint.setBaseUrl("http://localhost:8080/swoe");
endpoint.setModelIRI("model:myExample");
try (OEBatchClient client = new OEBatchClient(endpoint)) {
client.loadCurrentModelFromOE();
Model m = client.getPendingModel();
Property semGuid = m.createProperty("http://www.smartlogic.com/2014/08/semaphore-core#guid");
Resource r = m.createResource("http://myexample.com/Scheme4");
r.addProperty(RDF.type, SKOS.ConceptScheme);
r.addProperty(RDFS.label, "Test Scheme 4 (Test)");
r.addProperty(semGuid, UUID.randomUUID().toString());
Resource c = m.createResource("http://myexample.com/MyTestConcept1");
c.addProperty(RDF.type, SKOS.Concept);
c.addProperty(semGuid, UUID.randomUUID().toString());
Resource cl = m.createResource("http://myexample.com/MyTestConcept1_prefLabel_en");
cl.addProperty(SKOSXL.literalForm, "My Test Concept 1");
cl.addProperty(RDF.type, SKOSXL.Label);
c.addProperty(SKOSXL.prefLabel, cl);
r.addProperty(SKOS.hasTopConcept, c);
client.commit();
} finally {
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例5: rdf4jResourceToJenaResource
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
private Resource rdf4jResourceToJenaResource(@NonNull Model jenaModel,
@NonNull org.eclipse.rdf4j.model.Resource resource) {
if (resource instanceof SimpleIRI) {
return jenaModel.createResource(resource.stringValue());
} else {
return jenaModel.createResource(new AnonId(resource.stringValue()));
}
}
示例6: resourceFromURI
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
protected static Resource resourceFromURI(Model model, URI uri) {
return model.createResource(uri.toString());
}