本文整理汇总了Java中com.hp.hpl.jena.ontology.OntResource类的典型用法代码示例。如果您正苦于以下问题:Java OntResource类的具体用法?Java OntResource怎么用?Java OntResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OntResource类属于com.hp.hpl.jena.ontology包,在下文中一共展示了OntResource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addSinglePropertyFromTypeRemembrance
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private void addSinglePropertyFromTypeRemembrance(Resource r, OntProperty p, String literalString, TypeVO typeremembrance,IFCVO ivo) throws IOException, IfcDataFormatException {
OntResource range = ontModel.getOntResource(getOntNS() + typeremembrance.getName());
if (range.isClass()) {
if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "ENUMERATION"))) {
// Check for ENUM
addEnumProperty(r, p, range, literalString,ivo);
} else if (range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "SELECT"))) {
// Check for SELECT
// if (logToFile)
// bw.write("*OK 24*: found subClass of SELECT Class, now doing nothing with it: " + p + " - " + range.getLocalName() + " - " + literalString + "\r\n");
createLiteralProperty(r, p, range, literalString,ivo);
} else if (range.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
// Check for LIST
throw IfcDataFormatException.valueOutOfRange("#"+ivo.getLineNum(),literalString,range.getLocalName());
} else {
createLiteralProperty(r, p, range, literalString,ivo);
}
} else {
LOGGER.log(Level.WARNING ,"found other kind of property: " + p + " - " + range.getLocalName() + "\r\n");
}
}
示例2: fillClassInstanceList
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private void fillClassInstanceList(LinkedList<Object> tmpList, OntResource typerange, OntProperty p, Resource r) throws IOException, IfcDataFormatException {
List<Resource> reslist = new ArrayList<Resource>();
List<IFCVO> entlist = new ArrayList<IFCVO>();
// createrequirednumberofresources
for (int i = 0; i < tmpList.size(); i++) {
if (IFCVO.class.isInstance(tmpList.get(i))) {
Resource r1 = getResource(getBaseURI() + createLocalName(typerange.getLocalName() + "_" + IDcounter), typerange);
reslist.add(r1);
IDcounter++;
entlist.add((IFCVO) tmpList.get(i));
if (i == 0) {
getRdfWriter().triple(new Triple(r.asNode(), p.asNode(), r1.asNode()));
}
}
}
// bindtheproperties
String listvaluepropURI = getOntNS() + typerange.getLocalName().substring(0, typerange.getLocalName().length() - 5);
OntResource listrange = ontModel.getOntResource(listvaluepropURI);
addClassInstanceListProperties(reslist, entlist, listrange);
}
示例3: getListContentType
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private OntResource getListContentType(OntClass range) throws IOException {
if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "STRING_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "STRING_List")))
return expressModel.getOntResource(getExpressns() + "STRING");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "REAL_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "REAL_List")))
return expressModel.getOntResource(getExpressns() + "REAL");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "INTEGER_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "INTEGER_List")))
return expressModel.getOntResource(getExpressns() + "INTEGER");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BINARY_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BINARY_List")))
return expressModel.getOntResource(getExpressns() + "BINARY");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BOOLEAN_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BOOLEAN_List")))
return expressModel.getOntResource(getExpressns() + "BOOLEAN");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "LOGICAL_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "LOGICAL_List")))
return expressModel.getOntResource(getExpressns() + "LOGICAL");
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "NUMBER_List") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "NUMBER_List")))
return expressModel.getOntResource(getExpressns() + "NUMBER");
else if (range.asClass().hasSuperClass(listModel.getOntClass(getListns() + "OWLList"))) {
String listvaluepropURI = getOntNS() + range.getLocalName().substring(0, range.getLocalName().length() - 5);
return ontModel.getOntResource(listvaluepropURI);
} else {
LOGGER.log(Level.WARNING,"did not find listcontenttype for : " + range.getLocalName() + "\r\n");
return null;
}
}
示例4: getXSDTypeFromRange
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private String getXSDTypeFromRange(OntResource range) {
if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "STRING") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "STRING")))
return "string";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "REAL") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "REAL")))
return "double";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "INTEGER") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "INTEGER")))
return "integer";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BINARY") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BINARY")))
return "hexBinary";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "BOOLEAN") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "BOOLEAN")))
return "boolean";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "LOGICAL") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "LOGICAL")))
return "logical";
else if (range.asClass().getURI().equalsIgnoreCase(getExpressns() + "NUMBER") || range.asClass().hasSuperClass(expressModel.getOntClass(getExpressns() + "NUMBER")))
return "double";
else
return null;
}
示例5: Linkset
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
public Linkset(Void voidInstance, Datasets datasets, OntResource linkset,
OntResource sparqlEndPoint, OntResource linkPredicate,
OntResource subjectsDataset, OntResource subjectsTarget,
OntResource subjectsClass, OntResource objectsDataset,
OntResource objectsTarget, OntResource objectsClass) {
super(voidInstance, linkset, sparqlEndPoint);
this.linkPredicate = linkPredicate;
this.subjectsDataset = datasets.getDataset(subjectsDataset);
this.subjectsTarget = subjectsTarget;
this.subjectsClass = subjectsClass;
this.objectsDataset = datasets.getDataset(objectsDataset);
this.objectsTarget = objectsTarget;
this.objectsClass = objectsClass;
loadVocabularies();
}
示例6: loadVocabularies
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
@Override
public void loadVocabularies() {
QuerySolutionMap binding = new QuerySolutionMap();
binding.add("linkset", this.dataset);
Query query = QueryFactory.create(linksetVocabularyQuery);
QueryExecution qexec = QueryExecutionFactory.create(query, voidInstance.getVoidModel(),
binding);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource vocabulary = soln.getResource("vocabulary").as(
OntResource.class);
vocabularies.add(vocabulary);
}
} catch (Exception e) {
Log.debug(Linkset.class, "Failed linksetVocabularyQuery");
Log.debug(Linkset.class, e.getStackTrace().toString());
} finally {
qexec.close();
}
}
示例7: checkObjectPropertyRange
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
public boolean checkObjectPropertyRange(OntModel theJenaModel2, OntProperty pred, OntResource obj, boolean isList, EObject expr) throws CircularDependencyException {
if (pred.isObjectProperty()) {
if (checkRangeForMatch(theJenaModel2, pred, obj, isList)) {
return true;
}
ExtendedIterator<? extends OntProperty> propitr = pred.listSuperProperties(false);
while (propitr.hasNext()) {
OntProperty sprop = propitr.next();
if (checkRangeForMatch(theJenaModel2, sprop, obj, isList)) {
propitr.close();
return true;
}
}
return false;
}
return true;
}
示例8: addUnittedQuantityAsInstancePropertyValue
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private void addUnittedQuantityAsInstancePropertyValue(Individual inst, OntProperty oprop, OntResource rng,
String literalNumber, String unit) {
Individual unittedVal;
if (rng != null && rng.canAs(OntClass.class)) {
unittedVal = getTheJenaModel().createIndividual(rng.as(OntClass.class));
} else {
unittedVal = getTheJenaModel().createIndividual(
getTheJenaModel().getOntClass(SadlConstants.SADL_IMPLICIT_MODEL_UNITTEDQUANTITY_URI));
}
// TODO this may need to check for property restrictions on a subclass of
// UnittedQuantity
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_VALUE_URI),
getTheJenaModel().createTypedLiteral(literalNumber));
unittedVal.addProperty(getTheJenaModel().getProperty(SadlConstants.SADL_IMPLICIT_MODEL_UNIT_URI),
getTheJenaModel().createTypedLiteral(unit));
inst.addProperty(oprop, unittedVal);
}
示例9: loadPropertyPartitionStatistics
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
public void loadPropertyPartitionStatistics(OntModel voidModel) {
Query query = QueryFactory.create(propertyPartitionStatisticsQuery);
QueryExecution qexec = QueryExecutionFactory.create(query, voidModel);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource dataset = soln.getResource("Dataset").as(
OntResource.class);
OntResource property = soln.getResource("Property").as(
OntResource.class);
Integer triples = (soln.getLiteral("Triples") != null) ? soln
.getLiteral("Triples").getInt() : null;
Dataset ds = this.getDataset(dataset);
if (ds!=null)ds.getPartitions().addPropertyPartition(property, triples);
}
} catch (Exception e) {
Log.debug(
this,
"Unable to execute propertyPartitionStatisticsQuery " + query);
} finally {
qexec.close();
}
}
示例10: loadVocabularies
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
public void loadVocabularies() {
QuerySolutionMap binding = new QuerySolutionMap();
binding.add("dataset", dataset);
Query query = QueryFactory.create(datasetVocabularyQuery);
QueryExecution qexec = QueryExecutionFactory.create(query, voidInstance.getVoidModel(),
binding);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource vocabulary = soln.getResource("vocabulary").as(
OntResource.class);
vocabularies.add(vocabulary);
}
} catch (Exception e) {
Log.debug(Dataset.class, "Failed datasetVocabularyQuery");
Log.debug(Dataset.class, e.getStackTrace().toString());
} finally {
qexec.close();
}
}
示例11: updatePartitions
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
public void updatePartitions() {
//Use OntModelSpec.OWL_MEM_RDFS_INF to ensure all default classes and properties are also discovered.
OntModelSpec partitionModelSpec = new OntModelSpec(OntModelSpec.OWL_MEM_RDFS_INF);
partitionModelSpec.setDocumentManager(voidInstance.getVoidModel().getDocumentManager());
partitionModelSpec.getDocumentManager().setProcessImports(true);
OntModel partitionModel = ModelFactory
.createOntologyModel(partitionModelSpec);
for (OntResource vocabulary : this.getVocabularies()) {
try {
partitionModel.read(vocabulary.getURI());
} catch (Exception e) {
Log.debug(Void.class, "Failed to locate dataset vocabulary: "
+ vocabulary + " " + e.getMessage());
}
}
updateClassPartition(partitionModel);
updatePropertyPartition(partitionModel);
}
示例12: updateClassPartition
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private void updateClassPartition(OntModel partitionModel) {
Query query = QueryFactory.create(classPartitionQuery);
QueryExecution qexec = QueryExecutionFactory.create(query,
partitionModel);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource clazz = soln.getResource("class").as(
OntResource.class);
if (!clazz.isAnon()) partitions.addClassPartition(clazz, null);
}
} catch (Exception e) {
Log.debug(Dataset.class, "Failed to execute classPartitionQuery");
} finally {
qexec.close();
}
}
示例13: queryClassPartitionStatistics
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private void queryClassPartitionStatistics() {
Query query = QueryFactory.create(classPartitionStatisticsQuery);
QueryExecution qexec = QueryExecutionFactory.sparqlService(
this.sparqlEndPoint.toString(), query);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource clazz = soln.getResource("class").as(
OntResource.class);
Integer entities = (soln.getLiteral("count") != null) ? soln
.getLiteral("count").getInt() : null;
partitions.addClassPartition(clazz, entities);
}
} catch (Exception e) {
Log.debug(
Dataset.class,
"Unable to connect to SPARQLEndpoint to execute classPartitionStatisticsQuery: "
+ this.sparqlEndPoint.toString());
} finally {
qexec.close();
}
}
示例14: updatePropertyPartition
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
protected void updatePropertyPartition(OntModel partitionModel) {
Query query = QueryFactory.create(propertyPartitionQuery);
QueryExecution qexec = QueryExecutionFactory.create(query,
partitionModel);
try {
ResultSet results = qexec.execSelect();
for (; results.hasNext();) {
QuerySolution soln = results.nextSolution();
OntResource property = soln.getResource("property").as(
OntResource.class);
partitions.addPropertyPartition(property, null);
}
} catch (Exception e) {
Log.debug(Dataset.class,
"Failed to execute to execute propertyPartitionQuery");
} finally {
qexec.close();
}
}
示例15: checkPreviousClassList
import com.hp.hpl.jena.ontology.OntResource; //导入依赖的package包/类
private static List<OntResource> checkPreviousClassList(List<OntResource> previousClasses, OntClass cls) throws CircularDependencyException {
if (previousClasses.contains(cls)) {
StringBuilder msg = new StringBuilder("Cycle encountered while checking subclasses of ");
msg.append(previousClasses.get(0).toString());
int loopstart = previousClasses.indexOf(cls);
msg.append(" (loop contains: ");
for (int i = loopstart; i < previousClasses.size(); i++) {
if (i > loopstart) msg.append(", ");
msg.append(previousClasses.get(i).toString());
}
msg.append(")");
throw new CircularDependencyException(msg.toString());
}
previousClasses.add(cls);
return previousClasses;
}