本文整理汇总了Java中org.apache.jena.ontology.Individual类的典型用法代码示例。如果您正苦于以下问题:Java Individual类的具体用法?Java Individual怎么用?Java Individual使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Individual类属于org.apache.jena.ontology包,在下文中一共展示了Individual类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderHierarchy
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
protected static void renderHierarchy(PrintStream out, OntClass cls, List<Object> occurs, int depth) {
renderClassDescription(out, cls, depth);
out.println();
// recurse to the next level down
if (cls.canAs(OntClass.class) && !occurs.contains(cls)) {
for (Iterator<?> i = cls.listSubClasses(true); i.hasNext(); ) {
OntClass sub = (OntClass) i.next();
// we push this expression on the occurs list before we recurse
occurs.add(cls);
renderHierarchy(out, sub, occurs, depth + 1);
occurs.remove(cls);
}
for (Iterator<?> i = cls.listInstances(); i.hasNext(); ) {
Individual individual = (Individual) i.next();
renderURI(out, individual.getModel(), individual.getURI());
out.print(" [");
for (Iterator<?> j = individual.listLabels(null); j.hasNext(); ) {
out.print(((Literal) j.next()).getString() + ", ");
}
out.print("] ");
out.println();
}
}
}
示例2: inferClasses
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
@Override
public Set<URI> inferClasses(final URI uri, final WebResource resource, final Ontology ontology) {
final OntModel model = resolveImports(ont(ontology));
model.add(parse(resource));
final Individual individual = model.getIndividual(uri.toString());
if (individual != null) {
return individual
.listRDFTypes(false)
.filterKeep(Resource::isURIResource)
.mapWith(Resource::getURI)
.mapWith(URI::create)
.toSet();
} else {
LOG.info("<{}> does not make any statements about itself, " +
"so we can't infer anything about it nor bind extensions to it", uri);
return Collections.emptySet();
}
}
示例3: map
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
@Override
public void map(List<DIF> pojoList, Properties props) {
// create the base model
OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
ontModel.setNsPrefix("dif_v9.8.2", MUDROD_GCMD_DIF_9_8_2);
ontModel.setNsPrefix("geo", "http://www.opengis.net/ont/geosparql#");
ontModel.read(SWEET_REPR_DATA_PRODUCT, null, "TURTLE");
// get the https://sweetontology.net/reprDataProduct/Dataset class reference
Resource dataset = ontModel.getResource(SWEET_REPR_DATA_PRODUCT_NS + "Dataset");
// create the https://sweetontology.net/reprDataProduct/PODAACDataset class
// reference
OntClass podaacDataset = ontModel.createClass(PODAAC_DATASET + "PODAACDataset");
// make PODAACDataset a subclass of Dataset
podaacDataset.addSuperClass(dataset);
// create an individual for each DIF POJO
for (DIF dif : pojoList) {
Individual gcmdDif = podaacDataset.createIndividual(PODAAC_DATASET + dif.getEntryID());
buildIndividual(ontModel, dif, gcmdDif);
}
writeOntologyModel(ontModel, props);
}
示例4: addStackTrace
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
protected void addStackTrace(Individual error, ErrorDocument errorDoc)
throws IOException {
StringBuilder sb = new StringBuilder();
addStackTrace(sb, errorDoc);
if (sb.length() > 0) {
error.addLiteral(provModel.stackTrace, sb.toString());
}
for (T2Reference errRef : errorDoc.getErrorReferences()) {
URI errorURI = URI.create(uriGenerator.makeT2ReferenceURI(errRef
.toUri().toASCIIString()));
Individual nestedErr = provModel.createError(errorURI);
provModel.setWasDerivedFrom(error, nestedErr);
describeEntity(errRef);
}
}
示例5: getContentAsModel
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public OntModel getContentAsModel() {
OntModel result = createOntologyModel();
try {
populateModelFromString(result, getContentAsString());
// Check it is not still called changeme
List<Individual> individuals = result.listIndividuals(clazz)
.toList();
if (individuals.isEmpty()) {
errors.setText("No valid individuals");
return null;
}
for (Individual i : individuals)
if (i.getURI().endsWith("changeme")) {
errors.setText("Name has not been changed");
return null;
}
errors.setText("No errors found");
return result;
} catch (Throwable ex) { // syntax error?
errors.setText(ex.getMessage());
return null;
}
}
示例6: addKeyPair
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public void addKeyPair(Individual dictionary, long position,
Individual listItem) {
dictionary.addProperty(hadMember, listItem);
Individual keyPair = model.createIndividual(KeyEntityPair);
keyPair.addProperty(pairEntity, listItem);
keyPair.addLiteral(pairKey, position);
dictionary.addProperty(hadDictionaryMember, keyPair);
}
示例7: setEndedAtTime
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setEndedAtTime(Individual endedActivity, Calendar time) {
if (time == null) {
logger.warn("Unknown end time");
return null;
}
return setEndedAtTime(endedActivity, model.createTypedLiteral(time));
}
示例8: setStartedAtTime
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setStartedAtTime(Individual startedActivity, Calendar time) {
if (time == null) {
logger.warn("Unknown start time");
return null;
}
return setStartedAtTime(startedActivity, model.createTypedLiteral(time));
}
示例9: setUsed
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setUsed(Individual activity, Individual usedEntity) {
activity.addProperty(used, usedEntity);
Individual usage = model.createIndividual(Usage);
activity.addProperty(qualifiedUsage, usage);
usage.addProperty(entity, usedEntity);
return usage;
}
示例10: setWasAssociatedWith
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setWasAssociatedWith(Individual activity,
Individual associatedAgent, Individual plan) {
activity.setPropertyValue(wasAssociatedWith, associatedAgent);
Individual association = model.createIndividual(Association);
activity.setPropertyValue(qualifiedAssociation, association);
association.setPropertyValue(agent, associatedAgent);
if (plan != null) {
association.setPropertyValue(hadPlan, plan);
}
return association;
}
示例11: setWasGeneratedBy
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setWasGeneratedBy(Individual generated,
Individual generatingActivity) {
generated.setPropertyValue(wasGeneratedBy, generatingActivity);
Individual generation = model.createIndividual(Generation);
generated.setPropertyValue(qualifiedGeneration, generation);
generation.setPropertyValue(activity, generatingActivity);
return generation;
}
示例12: setWasInformedBy
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
public Individual setWasInformedBy(Individual informed, Individual informer) {
informed.setPropertyValue(wasInformedBy, informer);
Individual communication = model.createIndividual(Communication);
informed.setPropertyValue(qualifiedCommunication, communication);
communication.setPropertyValue(activity, informer);
return communication;
}
示例13: dummy
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
@Test
public void dummy() throws Exception {
ProvModel provModel = new WfprovModel();
Individual bundle = provModel.createBundle(uuid());
assertEquals("Bundle", bundle.getOntClass().getLocalName());
}
示例14: createEntity
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
@Test
public void createEntity() throws Exception {
Individual ent = provModel.createEntity(URI
.create("http://example.com/fred#test"));
provModel.createEntity(URI.create("http://example.com/test"));
OntModel model = provModel.model;
model.write(System.out, "TURTLE", "http://example.com/fred");
model.write(System.out, "RDF/XML", "http://example.com/fred");
WriterGraphRIOT writer = RDFDataMgr.createGraphWriter(RDFFormat.TURTLE_BLOCKS);
writer.write(System.out, model.getBaseModel().getGraph(), RiotLib.prefixMap(model.getGraph()), "http://example.com/fred", new Context());
}
示例15: describeEntity
import org.apache.jena.ontology.Individual; //导入依赖的package包/类
protected Individual describeEntity(T2Reference t2Ref) throws IOException {
URI dataURI = URI.create(uriGenerator.makeT2ReferenceURI(t2Ref.toUri()
.toASCIIString()));
Individual artifact = describedEntities.get(dataURI);
if (artifact != null) {
return artifact;
}
artifact = provModel.createArtifact(dataURI);
describedEntities.put(dataURI, artifact);
if (t2Ref.getReferenceType() == T2ReferenceType.ErrorDocument) {
Individual error = provModel.createError(dataURI);
ErrorDocument errorDoc = saver.getReferenceService()
.getErrorDocumentService().getError(t2Ref);
addMessageIfNonEmpty(error, errorDoc.getMessage());
// getExceptionMEssage added by addStackTrace
addStackTrace(error, errorDoc);
} else if (t2Ref.getReferenceType() == T2ReferenceType.IdentifiedList) {
IdentifiedList<T2Reference> list = saver.getReferenceService()
.getListService().getList(t2Ref);
Individual dictionary = provModel.createDictionary(dataURI);
int pos = 0;
for (T2Reference ref : list) {
URI itemURI = URI.create(uriGenerator.makeT2ReferenceURI(ref
.toUri().toASCIIString()));
Individual listItem = provModel.createArtifact(itemURI);
provModel.addKeyPair(dictionary, pos++, listItem);
describeEntity(ref);
}
if (list.isEmpty()) {
artifact.addRDFType(provModel.EmptyCollection);
artifact.addRDFType(provModel.EmptyDictionary);
}
}
return artifact;
}