本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Model.setNsPrefixes方法的典型用法代码示例。如果您正苦于以下问题:Java Model.setNsPrefixes方法的具体用法?Java Model.setNsPrefixes怎么用?Java Model.setNsPrefixes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.setNsPrefixes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInventoryModel
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public Model getInventoryModel(int limit) {
log.info("Listing entity set: " + entityMaker);
Model result = ModelFactory.createDefaultModel();
result.setNsPrefixes(mapping.getPrefixes());
FindQuery query = new FindQuery(Triple.ANY, inventory, limit,
new ExecutionContext(mapping.getContext(), null, null, null));
Iterator<Triple> it = TripleQueryIter.create(query.iterator());
while (it.hasNext()) {
result.getGraph().add(it.next());
}
return result;
}
示例2: classMapInventory
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public Model classMapInventory(String classMapName, int limitPerClassMap) {
log.info("Listing class map: " + classMapName);
List<TripleRelation> inventoryBridges = classMapInventoryBridges.get(classMapName);
if (inventoryBridges == null) {
return null;
}
Model result = ModelFactory.createDefaultModel();
result.setNsPrefixes(mapping.getPrefixMapping());
FindQuery query = new FindQuery(Triple.ANY, inventoryBridges, limitPerClassMap, null);
result.getGraph().getBulkUpdateHandler().add(TripleQueryIter.create(query.iterator()));
return result;
}
示例3: doGet
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws IOException, ServletException {
D2RServer server = D2RServer.fromServletContext(getServletContext());
server.checkMappingFileChanged();
String relativeResourceURI = request.getRequestURI().substring(
request.getContextPath().length()
+ request.getServletPath().length());
// Some servlet containers keep the leading slash, some don't
if (!"".equals(relativeResourceURI)
&& "/".equals(relativeResourceURI.substring(0, 1))) {
relativeResourceURI = relativeResourceURI.substring(1);
}
if (request.getQueryString() != null) {
relativeResourceURI = relativeResourceURI + "?"
+ request.getQueryString();
}
/* Determine service stem, i.e. vocab/ in /[vocab/]data */
int servicePos;
if (-1 == (servicePos = request.getServletPath().indexOf(
"/" + D2RServer.getDataServiceName())))
throw new ServletException("Expected to find service path /"
+ D2RServer.getDataServiceName());
String serviceStem = request.getServletPath().substring(1,
servicePos + 1);
String resourceURI = RequestParamHandler
.removeOutputRequestParam(server.resourceBaseURI(serviceStem)
+ relativeResourceURI);
String documentURL = server.dataURL(serviceStem, relativeResourceURI);
String pageURL = server.pageURL(serviceStem, relativeResourceURI);
String sparqlQuery = "DESCRIBE <" + resourceURI + ">";
QueryExecution qe = QueryExecutionFactory.create(sparqlQuery,
server.dataset());
if (server.getConfig().getPageTimeout() > 0) {
qe.setTimeout(Math.round(server.getConfig().getPageTimeout() * 1000));
}
Model description = qe.execDescribe();
qe.close();
if (description.size() == 0) {
response.sendError(404);
}
if (description.qnameFor(FOAF.primaryTopic.getURI()) == null
&& description.getNsPrefixURI("foaf") == null) {
description.setNsPrefix("foaf", FOAF.NS);
}
Resource resource = description.getResource(resourceURI);
Resource document = description.getResource(documentURL);
document.addProperty(FOAF.primaryTopic, resource);
Statement label = resource.getProperty(RDFS.label);
if (label != null) {
document.addProperty(RDFS.label,
"RDF Description of " + label.getString());
}
server.addDocumentMetadata(description, document);
if (server.getConfig().serveMetadata()) {
// add document metadata from template
Model resourceMetadataTemplate = server.getConfig().getResourceMetadataTemplate(
server, getServletContext());
MetadataCreator resourceMetadataCreator = new MetadataCreator(
server, resourceMetadataTemplate);
description.add(resourceMetadataCreator.addMetadataFromTemplate(
resourceURI, documentURL, pageURL));
Map<String, String> descPrefixes = description.getNsPrefixMap();
descPrefixes.putAll(resourceMetadataTemplate.getNsPrefixMap());
description.setNsPrefixes(descPrefixes);
}
// TODO: Add a Content-Location header
new ModelResponse(description, request, response).serve();
}
示例4: extract
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static void extract(Model m,String name){
Property groups=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#groups");
Property isGroupedBy=m.createProperty("http://www.buildingsmart-tech.org/ifc/IFC4/final#isGroupedBy");
Resource SingleValue=m.createResource("http://www.buildingsmart-tech.org/ifc/IFC4/final#P_SINGLEVALUE");
Model vocabulary=ModelFactory.createDefaultModel();
StmtIterator stmt1=m.listStatements(null, RDFS.comment,(String)null);
StmtIterator stmt2=m.listStatements(null,RDFS.domain,(RDFNode)null);
StmtIterator stmt3=m.listStatements(null,RDFS.range,(RDFNode)null);
StmtIterator stmt4=m.listStatements(null, RDF.type, RDF.Property);
StmtIterator stmt6=m.listStatements(null, RDFS.label, (String)null);
StmtIterator stmt8=m.listStatements(null, groups, (RDFNode)null);
StmtIterator stmt9=m.listStatements(null, isGroupedBy, (RDFNode)null);
vocabulary.add(stmt1);
vocabulary.add(stmt2);
vocabulary.add(stmt3);
vocabulary.add(stmt4);
vocabulary.add(stmt6);
vocabulary.add(stmt8);
vocabulary.add(stmt9);
m.remove(vocabulary);
StmtIterator stmt7=m.listStatements(null, RDF.type, (RDFNode)null);
List<Statement> ss=new ArrayList<Statement>();
while(stmt7.hasNext()){
Statement s=stmt7.next();
if(s.getObject().asResource().getURI().startsWith("http://www.buildingsmart-tech.org/ifc/IFC4/final")){
ss.add(s);
}
}
m.remove(ss);
try {
OutputStream voc=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+".ttl");
OutputStream rule=new FileOutputStream("C:\\users\\chi\\desktop\\output\\"+name+"_rule.ttl");
vocabulary.setNsPrefixes(m.getNsPrefixMap());
vocabulary.write(voc,"TTL");
m.write(rule,"TTL");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}