本文整理匯總了Java中org.apache.jena.rdf.model.Resource.addProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Resource.addProperty方法的具體用法?Java Resource.addProperty怎麽用?Java Resource.addProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.jena.rdf.model.Resource
的用法示例。
在下文中一共展示了Resource.addProperty方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createConcept
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public Concept createConcept(URI uri, Label prefLabel, URI[] classURIs, UUID uuid) throws ModelException {
Resource conceptURIResource = resourceFromURI(model, uri);
if (resourceInUse(conceptURIResource)) throw new ModelException("Attempting to create concept with URI - '%s'. This URI is already in use.", uri.toString());
if ((classURIs == null) || (classURIs.length == 0)) {
conceptURIResource.addProperty(RDF.type, SKOS.Concept);
} else {
for (URI classURI: classURIs) {
conceptURIResource.addProperty(RDF.type, resourceFromURI(model, classURI));
}
}
conceptURIResource.addLiteral(SEM.guid, (uuid == null ? Utils.generateGuid(uri.toString()) : uuid.toString()));
URI labelURI = getLabelURI(model, conceptURIResource, SKOS.prefLabel, prefLabel);
Resource labelURIResource = resourceFromURI(model, labelURI);
model.add(conceptURIResource, SKOSXL.prefLabel, labelURIResource);
model.add(labelURIResource, SKOSXL.literalForm, getAsLiteral(model, prefLabel));
model.add(labelURIResource, RDF.type, SKOSXL.Label);
return new Concept(model, conceptURIResource);
}
示例2: testLocalDiff
import org.apache.jena.rdf.model.Resource; //導入方法依賴的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));
}
示例3: rdfModelFor
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
protected Model rdfModelFor(Entry entry, boolean includeKey) {
Model model = ModelFactory.createDefaultModel();
Property entryNumberProperty = model.createProperty(SPEC_PREFIX + "entry-number-field");
Property entryTimestampProperty = model.createProperty(SPEC_PREFIX + "entry-timestamp-field");
Property itemProperty = model.createProperty(SPEC_PREFIX + "item-resource");
String entryNumber = Integer.toString(entry.getEntryNumber());
Resource resource = model.createResource(entryUri(entryNumber).toString())
.addProperty(entryNumberProperty, entryNumber)
.addProperty(entryTimestampProperty, entry.getTimestampAsISOFormat())
.addProperty(itemProperty, model.createResource(itemUri(entry.getItemHashes().get(0).encode()).toString()));
if (includeKey) {
Property keyProperty = model.createProperty(SPEC_PREFIX + "key-field");
resource.addProperty(keyProperty, entry.getKey());
}
model.setNsPrefix("register-metadata", SPEC_PREFIX);
return model;
}
示例4: expose
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private void expose(final ServiceExposureSpec spec) {
final URI uri = URI.create(resourceURI);
final Resource serviceInstance = doc.createResource(base + "#" + UUID.randomUUID().toString());
services.addProperty(doc.getProperty(ORE_AGGREGATES), serviceInstance);
serviceInstance.addProperty(doc.getProperty(RDF_TYPE), doc.getResource(CLASS_SERVICE_INSTANCE));
serviceInstance.addProperty(doc.getProperty(PROP_SERVICE_INSTANCE_EXPOSED_BY),
doc.getResource(proxyURI));
serviceInstance.addProperty(doc.getProperty(PROP_IS_SERVICE_INSTANCE_OF),
doc.getResource(spec.exposedService().toString()));
serviceInstance.addProperty(doc.getProperty(PROP_HAS_ENDPOINT),
doc.getResource(routing.endpointFor(spec, uri).toString()));
if (RESOURCE.equals(spec.scope())) {
serviceInstance.addProperty(doc.getProperty(PROP_IS_FUNCTION_OF),
doc.getProperty(proxyURI));
}
}
示例5: createMetadataTypeResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private Resource createMetadataTypeResource(URI uri, Label label, Resource range) throws ModelException {
Resource metadataTypeURIResource = resourceFromURI(model, uri);
if (resourceInUse(metadataTypeURIResource)) throw new ModelException("Attempting to create metadata type with URI - '%s'. This URI is already in use.", uri.toString());
metadataTypeURIResource.addProperty(RDF.type, OWL.ObjectProperty);
metadataTypeURIResource.addProperty(RDFS.label, getAsLiteral(model, label));
metadataTypeURIResource.addProperty(RDFS.domain, SKOS.Concept);
metadataTypeURIResource.addProperty(RDFS.range, range);
return metadataTypeURIResource;
}
示例6: createHasBroaderRelationshipType
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public HasBroaderRelationshipType createHasBroaderRelationshipType(URI uri, Label label, URI inverseURI, Label inverseLabel) throws ModelException {
Resource relationshipTypeResource = createConceptToConceptRelationshipTypeResource(uri, label, SKOS.broader);
Resource inverseRelationshipTypeResource = null;
if (inverseURI != null) {
inverseRelationshipTypeResource = createConceptToConceptRelationshipTypeResource(inverseURI, inverseLabel, SKOS.narrower);
relationshipTypeResource.addProperty(OWL.inverseOf, inverseRelationshipTypeResource);
inverseRelationshipTypeResource.addProperty(OWL.inverseOf, relationshipTypeResource);
}
return new HasBroaderRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
}
示例7: createHasNarrowerRelationshipType
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public HasNarrowerRelationshipType createHasNarrowerRelationshipType(URI uri, Label label, URI inverseURI, Label inverseLabel) throws ModelException {
Resource relationshipTypeResource = createConceptToConceptRelationshipTypeResource(uri, label, SKOS.narrower);
Resource inverseRelationshipTypeResource = null;
if (inverseURI != null) {
inverseRelationshipTypeResource = createConceptToConceptRelationshipTypeResource(inverseURI, inverseLabel, SKOS.narrower);
relationshipTypeResource.addProperty(OWL.inverseOf, inverseRelationshipTypeResource);
inverseRelationshipTypeResource.addProperty(OWL.inverseOf, relationshipTypeResource);
}
return new HasNarrowerRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
}
示例8: createAssociativeRelationshipType
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
public AssocativeRelationshipType createAssociativeRelationshipType(URI uri, Label label, URI inverseURI, Label inverseLabel) throws ModelException {
Resource relationshipTypeResource = createConceptToConceptRelationshipTypeResource(uri, label, SKOS.related);
Resource inverseRelationshipTypeResource = null;
if (inverseURI == null) {
relationshipTypeResource.addProperty(RDF.type, OWL.SymmetricProperty);
} else {
inverseRelationshipTypeResource = createConceptToConceptRelationshipTypeResource(inverseURI, inverseLabel, SKOS.related);
relationshipTypeResource.addProperty(OWL.inverseOf, inverseRelationshipTypeResource);
inverseRelationshipTypeResource.addProperty(OWL.inverseOf, relationshipTypeResource);
}
return new AssocativeRelationshipType(model, relationshipTypeResource, inverseRelationshipTypeResource);
}
示例9: createRelationshipTypeResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private Resource createRelationshipTypeResource(URI uri, Label label, Property parentProperty) throws ModelException {
Resource relationshipTypeURIResource = resourceFromURI(model, uri);
if (resourceInUse(relationshipTypeURIResource)) throw new ModelException("Attempting to create relationship type with URI - '%s'. This URI is already in use.", uri.toString());
relationshipTypeURIResource.addProperty(RDF.type, OWL.ObjectProperty);
relationshipTypeURIResource.addProperty(RDFS.label, getAsLiteral(model, label));
relationshipTypeURIResource.addProperty(RDFS.domain, SKOS.Concept);
relationshipTypeURIResource.addProperty(RDFS.subPropertyOf, parentProperty);
return relationshipTypeURIResource;
}
示例10: hydrateAndModifySecondModel
import org.apache.jena.rdf.model.Resource; //導入方法依賴的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
示例11: main
import org.apache.jena.rdf.model.Resource; //導入方法依賴的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();
}
}
示例12: addPropertiesToResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private void addPropertiesToResource(Resource to, Resource from) {
StmtIterator iterator = from.listProperties();
while (iterator.hasNext()) {
Statement statement = iterator.next();
to.addProperty(statement.getPredicate(), statement.getObject());
}
}
示例13: renderScalar
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private void renderScalar(FieldValue value, Resource resource) {
if (value.isLink()) {
URI resolvedUri = registerResolver.getLinkResolver().resolve((LinkValue) value);
resource.addProperty(fieldProperty, resource.getModel().createResource(resolvedUri.toString()));
} else {
resource.addProperty(fieldProperty, value.getValue());
}
}
示例14: createConceptToConceptRelationshipTypeResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private Resource createConceptToConceptRelationshipTypeResource(URI uri, Label label, Property parentProperty) throws ModelException {
Resource relationshipTypeURIResource = createRelationshipTypeResource(uri, label, parentProperty);
relationshipTypeURIResource.addProperty(RDFS.range, SKOS.Concept);
return relationshipTypeURIResource;
}
示例15: createConceptToLabelRelationshipTypeResource
import org.apache.jena.rdf.model.Resource; //導入方法依賴的package包/類
private Resource createConceptToLabelRelationshipTypeResource(URI uri, Label label, Property parentProperty) throws ModelException {
Resource relationshipTypeURIResource = createRelationshipTypeResource(uri, label, parentProperty);
relationshipTypeURIResource.addProperty(RDFS.range, SKOSXL.Label);
return relationshipTypeURIResource;
}