本文整理汇总了Java中com.hp.hpl.jena.rdf.model.Model.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java Model.getResource方法的具体用法?Java Model.getResource怎么用?Java Model.getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.hp.hpl.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.getResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createSupervisorOrganization
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Add to the model the supervisor of the current Organization
*
* @param Model the model we are currently working with
* @param Resource the current organization
* @param Organization the supervisor of the organization
*/
private void createSupervisorOrganization(Model model, Resource orgResource, Organization supervisor) {
Resource supervisorResource = model.getResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber());
if (model.containsResource(supervisorResource)) {
orgResource.addProperty(Ontology.hasSupervisorOrganization, supervisorResource);
} else {
supervisorResource = model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(), Ontology.organizationResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(), Ontology.businessEntityResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(), Ontology.orgOrganizationResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(), Ontology.registeredOrganizationResource);
if (supervisor.getVatNumber() != "") {
supervisorResource.addLiteral(Ontology.vatId, supervisor.getVatNumber());
} else {
supervisorResource.addLiteral(Ontology.vatId, "Empty vatID");
}
supervisorResource.addLiteral(Ontology.organizationId, supervisor.getUid());
/** organization - Supervisor **/
orgResource.addProperty(Ontology.hasSupervisorOrganization, supervisorResource);
}
}
示例2: doGet
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的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();
}
示例3: createFekResource
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Add to the model the the Fek that is related to the Organization
*
* @param Model the model we are currently working with
* @param Resource the resource of the related organization
* @param String the issue type of the Fek
* @param String the year that Fek was published
* @param String the number of the Fek
*/
private void createFekResource(Model model, Resource orgResource, String fekIssue, String fekYear, String fekNumber, boolean newOrganizationFlag) {
String fekUriName = "";
if ( (fekIssue != null) && (fekIssue != "") ) {
fekUriName = fekIssue + "/" + fekYear + "/" + fekNumber;
} else {
fekUriName = fekYear + "/" + fekNumber;
}
Resource fekResource = model.getResource(Ontology.instancePrefix + "Fek/" + fekUriName);
if (model.containsResource(fekResource)) { //if Fek resource exists use it
orgResource.addProperty(Ontology.relatedFek, fekResource);
} else { //...else create it
fekResource = model.createResource(Ontology.instancePrefix + "Fek/" + fekUriName, Ontology.fekResource);
fekResource.addProperty(Ontology.fekNumber, fekNumber);
fekResource.addProperty(Ontology.fekYear, fekYear);
if ( (fekIssue != null) && (fekIssue != "") ) {
fekResource.addProperty(Ontology.fekIssue, model.getResource(Ontology.instancePrefix + "FekType/" + fekIssue));
}
}
/** Organization - FEK **/
if (newOrganizationFlag) {
orgResource.addProperty(Ontology.relatedFek, fekResource);
} else {
orgResource.removeAll(Ontology.relatedFek); //delete the old relationships
orgResource.addProperty(Ontology.relatedFek, fekResource);
}
}
示例4: createFekResource
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Add to the model the the Fek that is related to the Organization
*
* @param Model
* the model we are currently working with
* @param Resource
* the resource of the related organization
* @param String
* the issue type of the Fek
* @param String
* the year that Fek was published
* @param String
* the number of the Fek
*/
private void createFekResource(Model model, Resource orgResource, String fekIssue, String fekYear, String fekNumber,
boolean newOrganizationFlag) {
String fekUriName = "";
if ((fekIssue != null) && (fekIssue != "")) {
fekUriName = fekIssue + "/" + fekYear + "/" + fekNumber;
} else {
fekUriName = fekYear + "/" + fekNumber;
}
Resource fekResource = model.getResource(Ontology.instancePrefix + "Fek/" + fekUriName);
if (model.containsResource(fekResource)) { // if Fek resource exists use
// it
orgResource.addProperty(Ontology.relatedFek, fekResource);
} else { // ...else create it
fekResource = model.createResource(Ontology.instancePrefix + "Fek/" + fekUriName, Ontology.fekResource);
fekResource.addProperty(Ontology.fekNumber, fekNumber);
fekResource.addProperty(Ontology.fekYear, fekYear);
if ((fekIssue != null) && (fekIssue != "")) {
fekResource.addProperty(Ontology.fekIssue,
model.getResource(Ontology.instancePrefix + "FekType/" + fekIssue));
}
}
/** Organization - FEK **/
if (newOrganizationFlag) {
orgResource.addProperty(Ontology.relatedFek, fekResource);
} else {
orgResource.removeAll(Ontology.relatedFek); // delete the old
// relationships
orgResource.addProperty(Ontology.relatedFek, fekResource);
}
}
示例5: createSupervisorOrganization
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
/**
* Add to the model the supervisor of the current Organization
*
* @param Model
* the model we are currently working with
* @param Resource
* the current organization
* @param Organization
* the supervisor of the organization
*/
private void createSupervisorOrganization(Model model, Resource orgResource, Organization supervisor) {
Resource supervisorResource = model
.getResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber());
if (model.containsResource(supervisorResource)) {
orgResource.addProperty(Ontology.hasSupervisorOrganization, supervisorResource);
} else {
supervisorResource = model.createResource(
Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(),
Ontology.organizationResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(),
Ontology.businessEntityResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(),
Ontology.orgOrganizationResource);
model.createResource(Ontology.instancePrefix + "Organization/" + supervisor.getVatNumber(),
Ontology.registeredOrganizationResource);
if (supervisor.getVatNumber() != "") {
supervisorResource.addLiteral(Ontology.vatId, supervisor.getVatNumber());
} else {
supervisorResource.addLiteral(Ontology.vatId, "Empty vatID");
}
supervisorResource.addLiteral(Ontology.organizationId, supervisor.getUid());
/** organization - Supervisor **/
orgResource.addProperty(Ontology.hasSupervisorOrganization, supervisorResource);
}
}
示例6: loadPropertyBridges
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static Collection<TripleRelation> loadPropertyBridges(String mappingFileName) {
Model m = loadTurtle(mappingFileName);
Resource dummyDB = m.getResource(DummyDatabase);
dummyDB.addProperty(RDF.type, D2RQ.Database);
Mapping mapping = new D2RQReader(m, "http://example.org/").getMapping();
return mapping.compile().getTripleRelations();
}
示例7: loadPropertyBridges
import com.hp.hpl.jena.rdf.model.Model; //导入方法依赖的package包/类
public static Collection<TripleRelation> loadPropertyBridges(String mappingFileName) {
Model m = ModelFactory.createDefaultModel();
Resource dummyDB = m.getResource(Test.DummyDatabase.getURI());
dummyDB.addProperty(RDF.type, D2RQ.Database);
m.read(D2RQTestSuite.class.getResourceAsStream(mappingFileName), null, "TURTLE");
Mapping mapping = new MapParser(m, null).parse();
return mapping.compiledPropertyBridges();
}
示例8: 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();
}