當前位置: 首頁>>代碼示例>>Java>>正文


Java Model.getResource方法代碼示例

本文整理匯總了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);
	}
	
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:33,代碼來源:MonthlyRdfActions.java

示例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();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:22,代碼來源:ClassMapServlet.java

示例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);
	}
	
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:42,代碼來源:MonthlyRdfActions.java

示例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);
	}

}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:51,代碼來源:MonthlyRdfActions.java

示例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);
	}

}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:42,代碼來源:MonthlyRdfActions.java

示例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();
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:8,代碼來源:D2RQTestUtil.java

示例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();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:9,代碼來源:MapFixture.java

示例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();
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:77,代碼來源:ResourceDescriptionServlet.java


注:本文中的com.hp.hpl.jena.rdf.model.Model.getResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。