本文整理汇总了Java中com.hp.hpl.jena.vocabulary.RDFS类的典型用法代码示例。如果您正苦于以下问题:Java RDFS类的具体用法?Java RDFS怎么用?Java RDFS使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RDFS类属于com.hp.hpl.jena.vocabulary包,在下文中一共展示了RDFS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkContainment
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
public static boolean checkContainment(CompanyModel c){
String queryString =
"ASK" +
// check whether any manager is an employee in any other department
"{?dept1" + " <" + c.MANAGER + "> " + "?manager" + ". " +
" ?dept2" + " <" + c.EMPLOYEES + "> " + "?employees1" + ". " +
" ?employees1" + " <" + RDFS.member + "> " + "?employee1" + ". " +
" FILTER (?manager = ?employee1) " +
// check whether any employee occurs more than once
" ?dept3 " + " <" + c.EMPLOYEES + "> " + "?employees2" + ". " +
" ?employees2" + " <" + RDFS.member + "> " + "?employee2" + ". " +
" FILTER (?employee1 = ?employee2)" +
// check whether any department occurs more than once
" ?upperDept1" + " <" + c.DEPTS + "> " + "?dept4" + ". " +
" ?upperDept2" + " <" + c.DEPTS + "> " + "?dept5" + ". " +
" FILTER (?dept4 = ?dept5) " +
"}";
Query query = QueryFactory.create(queryString);
QueryExecution qe = QueryExecutionFactory.create(query, c.getModel());
boolean out = qe.execAsk();
qe.close();
return !out;
}
示例2: expandSubClasses
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private List<Statement> expandSubClasses(Model model){
List<Statement> stmts = new ArrayList<Statement>();
String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
+ "SELECT DISTINCT ?class ?synonym "
+ "WHERE { "
+ "?class rdfs:subClassOf+ ?subClass . "
+ "?subClass <" + synonym + "> ?synonym"
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
ResultSet resultSet = queryExecution.execSelect();
resultSet.forEachRemaining(querySolution -> {
stmts.add(new StatementImpl(querySolution.getResource("class"), synonym, querySolution.getLiteral("synonym")));
});
return stmts;
}
示例3: expandSubProperties
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private List<Statement> expandSubProperties(Model model){
List<Statement> stmts = new ArrayList<Statement>();
String sparql = "PREFIX rdfs: <" + RDFS.getURI() + ">"
+ "SELECT DISTINCT ?property ?synonym "
+ "WHERE { "
+ "?property rdfs:subPropertyOf+ ?subProperty . "
+ "?subProperty <" + synonym + "> ?synonym"
+ "}";
Query query = QueryFactory.create(sparql, Syntax.syntaxARQ);
QueryExecution queryExecution = QueryExecutionFactory.create(query, model);
ResultSet resultSet = queryExecution.execSelect();
resultSet.forEachRemaining(querySolution -> {
stmts.add(new StatementImpl(querySolution.getResource("property"), synonym, querySolution.getLiteral("synonym")));
});
return stmts;
}
示例4: doGet
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
D2RServer server = D2RServer.fromServletContext(getServletContext());
server.checkMappingFileChanged();
if (request.getPathInfo() == null) {
new ModelResponse(classMapListModel(), request, response).serve();
return;
}
String classMapName = request.getPathInfo().substring(1);
Model resourceList = getClassMapLister().classMapInventory(classMapName);
if (resourceList == null) {
response.sendError(404, "Sorry, class map '" + classMapName + "' not found.");
return;
}
Resource classMap = resourceList.getResource(server.baseURI() + "all/" + classMapName);
Resource directory = resourceList.createResource(server.baseURI() + "all");
classMap.addProperty(RDFS.seeAlso, directory);
classMap.addProperty(RDFS.label, "List of all instances: " + classMapName);
directory.addProperty(RDFS.label, "D2R Server contents");
server.addDocumentMetadata(resourceList, classMap);
new ModelResponse(resourceList, request, response).serve();
}
示例5: testLang
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
public void testLang()
{
List<Triple> pattern = new ArrayList<Triple>();
pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation label_fr_be = search("table1", "label_fr_be", rels);
NodeRelation label_en = search("table1", "label_en", rels);
NodeRelation label_noLang = search("table1", "label", rels);
Expr filterFR = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr"));
Expr filterEN_TAG_EN = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeNode("en", "en", (String) null));
Expr filterFR_BE = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString("fr-BE"));
Expr filter = new E_Equals(new E_Lang(new ExprVar("o")), NodeValue.makeString(""));
assertEquals("LANG(label_fr_be) = \"fr\" should be FALSE", Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_fr_be));
assertEquals("LANG(label_en) = \"fr\" should be FALSE", Expression.FALSE, TransformExprToSQLApplyer.convert(filterFR, label_en));
assertEquals("LANG(label_fr_be) = \"fr_be\" should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterFR_BE, label_fr_be));
assertEquals("LANG(label_en) = \"en\"@en should be FALSE", Expression.FALSE, TransformExprToSQLApplyer.convert(filterEN_TAG_EN, label_en));
assertEquals("LANG(label_noLang) = \"\" should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filter, label_noLang));
}
示例6: testDataType
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
public void testDataType()
{
List<Triple> pattern = new ArrayList<Triple>();
pattern.add(Triple.create(Node.createVariable("s"), Node.createURI("http://example.org/value"), Node.createVariable("o")));
NodeRelation[] rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation intvalue = search("table2", "intvalue", rels);
NodeRelation value = search("table2", "value", rels);
pattern.clear();
pattern.add(Triple.create(Node.createVariable("s"), RDFS.label.asNode(), Node.createVariable("o")));
rels = translate(pattern, "optimizer/filtertests.n3");
NodeRelation langliteral = search("table1", "label_en", rels);
Expr filterint = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDint.getURI())));
Expr filterstring = new E_Equals(new E_Datatype(new ExprVar("o")), NodeValueNode.makeNode(Node.createURI(XSDDatatype.XSDstring.getURI())));
assertEquals("DATATYPE(intliteral) = xsd:int should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterint, intvalue));
assertEquals("DATATYPE(simpleliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, value));
assertEquals("DATATYPE(langliteral) = xsd:string should be TRUE", Expression.TRUE, TransformExprToSQLApplyer.convert(filterstring, langliteral));
}
示例7: exportEnumerationTypeInfo
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private void exportEnumerationTypeInfo(IfcEnumerationTypeInfo typeInfo) {
String typeUri = super.formatTypeName(typeInfo);
Resource typeResource = createUriResource(typeUri);
if (!context.isEnabledOption(Ifc2RdfConversionOptionsEnum.ForceConvertEnumerationValuesToString)) {
adapter.exportTriple(typeResource, RDF.type, OWL.Class);
List<Resource> nodes = new ArrayList<>();
List<String> enumValues = typeInfo.getValues();
for (String value : enumValues) {
nodes.add(super.createUriResource(super.formatOntologyName(value)));
}
RDFList rdfList = super.createList(nodes);
adapter.exportTriple(typeResource, OWL.oneOf, rdfList);
} else {
adapter.exportTriple(typeResource, RDF.type, RDFS.Datatype);
adapter.exportTriple(typeResource, RDFS.subClassOf, XSD.xstring);
// List<String> values = typeInfo.getValues();
// String valueString = StringUtils.collectionToString(values, "(", ")", String.format("\"%%s\"^^%s", RdfVocabulary.XSD_STRING.getShortForm()), " ");
// adapter.writeRdfTriple(ExportAdapter.CURRENT_SUBJECT, OWL.oneOf, valueString);
}
}
示例8: exportLiteralTypeInfo
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private void exportLiteralTypeInfo(IfcLiteralTypeInfo typeInfo) {
Resource typeResource = super.createUriResource(formatTypeName(typeInfo));
// adapter.exportTriple(typeResource, RDF.type, RDFS.Datatype);
// adapter.exportTriple(typeResource, OWL.sameAs, super.getXsdDataType(typeInfo));
adapter.exportTriple(typeResource, RDF.type, OWL.Class);
Resource xsdDataType = super.getXsdDataType(typeInfo);
Property property = getHasProperty(typeInfo);
adapter.exportTriple(property, RDF.type, OWL.DatatypeProperty);
if (owlProfileList.supportsRdfProperty(OWL.FunctionalProperty, null)) {
adapter.exportTriple(property, RDF.type, RdfVocabulary.OWL.FunctionalDataProperty);
}
adapter.exportTriple(property, RDFS.subPropertyOf, Ifc2RdfVocabulary.EXPRESS.hasValue);
adapter.exportTriple(property, RDFS.domain, typeResource);
adapter.exportTriple(property, RDFS.range, xsdDataType);
// if (owlProfileList.supportsRdfProperty(OWL.allValuesFrom, null)) {
//
// writePropertyRestriction(typeResource, Ifc2RdfVocabulary.EXPRESS.value, OWL.allValuesFrom, super.getXsdDataType((IfcLiteralTypeInfo)baseTypeInfo));
//
// }
}
示例9: exportSelectTypeInfo
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private void exportSelectTypeInfo(IfcSelectTypeInfo typeInfo) {
Resource typeResource = super.createUriResource(super.formatTypeName(typeInfo));
adapter.exportTriple(typeResource, RDF.type, OWL.Class);
adapter.exportTriple(typeResource, RDFS.subClassOf, Ifc2RdfVocabulary.EXPRESS.Select);
List<String> subTypeNames = typeInfo.getSelectTypeInfoNames();
List<Resource> subTypeResources = new ArrayList<>();
for (String typeName : subTypeNames) {
subTypeResources.add(super.createUriResource(super.formatOntologyName(typeName)));
}
if (owlProfileList.supportsRdfProperty(OWL.unionOf, EnumSet.of(RdfTripleObjectTypeEnum.ZeroOrOneOrMany)) && subTypeResources.size() > 1) {
RDFList rdfList = super.createList(subTypeResources);
// See samples: [2, p.250]
adapter.exportTriple(typeResource, OWL.unionOf, rdfList);
} else {
subTypeResources.stream().forEach(subTypeResource ->
adapter.exportTriple((Resource)subTypeResource, RDFS.subClassOf, typeResource));
}
}
示例10: addToJenaModelDocTimeInterval
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
public void addToJenaModelDocTimeInterval(Model model) {
if (this.getPhraseCounts().size() > 0) {
OwlTime owlTime = new OwlTime();
owlTime.parsePublicationDate(getPhrase());
owlTime.addToJenaModelOwlTimeInstant(model);
Resource resource = model.createResource(this.getURI());
for (int i = 0; i < this.getPhraseCounts().size(); i++) {
PhraseCount phraseCount = this.getPhraseCounts().get(i);
if (!phraseCount.getPhrase().isEmpty()) {
resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
}
}
resource.addProperty(RDF.type, Sem.Time);
Resource interval = model.createResource(ResourcesUri.owltime + "Interval");
resource.addProperty(RDF.type, interval);
Resource value = model.createResource(owlTime.getDateStringURI());
Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
resource.addProperty(property, value);
}
}
示例11: setModelPrefix
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
public static void setModelPrefix(Model model){
model.setNsPrefix("biopax", Biopax_level3.getURI());
model.setNsPrefix("gpml", Gpml.getURI());
model.setNsPrefix("wp", Wp.getURI());
model.setNsPrefix("xsd", XSD.getURI());
model.setNsPrefix("rdf", RDF.getURI());
model.setNsPrefix("rdfs", RDFS.getURI());
model.setNsPrefix("dcterms", DCTerms.getURI());
model.setNsPrefix("wprdf", "http://rdf.wikipathways.org/");
model.setNsPrefix("foaf", FOAF.getURI());
model.setNsPrefix("dc", DC.getURI());
model.setNsPrefix("skos", Skos.getURI());
model.setNsPrefix("void", Void.getURI());
model.setNsPrefix("wprdf", "http://rdf.wikipathways.org/");
model.setNsPrefix("pav", Pav.getURI());
model.setNsPrefix("prov", Prov.getURI());
model.setNsPrefix("dcterms", DCTerms.getURI());
model.setNsPrefix("freq", Freq.getURI());
}
示例12: getDescriptorsForNoteUris
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
private ResourceDescriptor[] getDescriptorsForNoteUris(boolean skipDiscarded, Model model, String[] conceptUris) {
if(model==null) {
return new ResourceDescriptor[0];
}
ArrayList<ResourceDescriptor> result = new ArrayList<ResourceDescriptor>();
for (int i = 0; i < conceptUris.length; i++) {
com.hp.hpl.jena.rdf.model.Resource conceptRdfResource = model.getResource(conceptUris[i]);
try {
if(skipDiscarded && model.contains(conceptRdfResource, MindRaiderVocabulary.isDiscarded, true)) {
continue;
} else {
result.add(
new ResourceDescriptor(conceptRdfResource.getProperty(RDFS.label).getObject().toString(),
conceptUris[i]));
}
}
catch (Exception e) {
logger.debug("Error: ", e);
}
}
return result.toArray(new ResourceDescriptor[result.size()]);
}
示例13: save
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
/**
* Save concept resource and update metadata in the given model.
*
* @param noteResource
* the concept resource to save.
* @param model
* the metadata model.
*/
public void save(ConceptResource conceptResource, Model model) {
if (conceptResource == null || model == null) {
return;
}
URI conceptResourceUri = conceptResource.resource.getMetadata()
.getUri();
// build path
String conceptFilename = getConceptResourceFilename(conceptResource
.getNotebookUri(), conceptResourceUri.toString());
conceptResource.resource.toXmlFile(conceptFilename);
com.hp.hpl.jena.rdf.model.Resource conceptRdfResource = model
.getResource(conceptResourceUri.toString());
conceptRdfResource.removeAll(RDFS.label);
conceptRdfResource.addProperty(RDFS.label,
(conceptResource.getLabel() != null ? conceptResource
.getLabel() : ""));
conceptRdfResource.removeAll(RDFS.comment);
conceptRdfResource.addProperty(RDFS.comment,
OutlineTreeInstance.getAnnotationCite(conceptResource
.getAnnotation()));
}
示例14: getLabelDescriptors
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
/**
* Get descriptors of all folders.
*
* @return folder descriptors.
*/
public ResourceDescriptor[] getLabelDescriptors() {
ArrayList<ResourceDescriptor> result = new ArrayList<ResourceDescriptor>();
Seq mindMap = labelsModel.getModel().getSeq(MindRaiderVocabulary.getMindMapUri());
if (mindMap != null) {
String folderUri;
for (int i = 0; i < mindMap.size(); i++) {
folderUri = mindMap.getResource(i + 1).toString();
if (!LABEL_TRASH_URI.equals(folderUri)) {
String folderLabel = labelsModel.getModel().getResource(folderUri).getProperty(RDFS.label)
.getString();
result.add(new ResourceDescriptor(folderLabel, folderUri));
}
}
}
if (result.size() == 0) {
return null;
}
return (ResourceDescriptor[]) (result.toArray(new ResourceDescriptor[result.size()]));
}
示例15: rename
import com.hp.hpl.jena.vocabulary.RDFS; //导入依赖的package包/类
/**
* Rename folder.
*
* @param folderUri
* the folder Uri
* @param newLabel
* the new label
* @throws Exception
* a generic exception
*/
public void rename(String folderUri, String newLabel) throws Exception {
logger.debug("Renaming folder '" + folderUri + "' to '" + newLabel + "'");
if (folderUri != null && newLabel != null) {
// rename folder resource
FolderResource folderResource = new FolderResource(get(folderUri));
folderResource.getLabelProperty().setLabelContent(newLabel);
folderResource.save();
// change label in the tree
Seq folderSeq = labelsModel.getModel().getSeq(folderUri);
if (folderSeq != null) {
folderSeq.removeAll(RDFS.label);
folderSeq.addProperty(RDFS.label, newLabel);
labelsModel.save();
}
}
}