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


Java Model類代碼示例

本文整理匯總了Java中com.hp.hpl.jena.rdf.model.Model的典型用法代碼示例。如果您正苦於以下問題:Java Model類的具體用法?Java Model怎麽用?Java Model使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Model類屬於com.hp.hpl.jena.rdf.model包,在下文中一共展示了Model類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: parse

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Parse RDF input as string
 *
 * @param input RDF values as String
 * @return an {@link Request} object which contains information about latitude, longitude and date
 * @throws IllegalStateException if RDF is not literal
 * @throws NullPointerException  if input is null
 */
public static Request parse(String input) {
    Objects.requireNonNull(input);
    Model model = ModelFactory.createDefaultModel();
    model.read(new ByteArrayInputStream(input.getBytes()), null, "TURTLE");

    Map<String, Object> map = new HashMap<>();
    model.listStatements().forEachRemaining(statement -> {
        RDFNode rdfNode = statement.getObject();
        if (rdfNode.isLiteral()) {
            try {
                map.put(statement.getPredicate().getLocalName(), statement.getObject().asLiteral().getValue());
            } catch (Exception e) {
                LOGGER.error("RDF statement is not literal");
                throw new IllegalStateException(e.getMessage());
            }
        }
    });

    model.close();
    return getDataFromMap(map);
}
 
開發者ID:IKB4Stream,項目名稱:IKB4Stream,代碼行數:30,代碼來源:RDFParser.java

示例2: writeTo

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
@Override
public void writeTo(Model t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
		MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
		throws IOException, WebApplicationException {
	
	Lang lang = null;
	
	if(mediaType.equals(KRFormat.N3_TYPE))
		lang = Lang.N3;
	else if(mediaType.equals(KRFormat.N_TRIPLE_TYPE))
		lang = Lang.NTRIPLES;
	else if(mediaType.equals(KRFormat.RDF_JSON_TYPE))
		lang = Lang.RDFJSON;
	else if(mediaType.equals(new MediaType("application", "json-ld")))
		lang = Lang.JSONLD;
	else lang = Lang.TURTLE;
	
	RDFDataMgr.write(entityStream, t, lang);
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:21,代碼來源:ModelWriter.java

示例3: expandSubClasses

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的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;
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:20,代碼來源:IndexingJob.java

示例4: expandSubProperties

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的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;
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:19,代碼來源:IndexingJob.java

示例5: doIndexing

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
private void doIndexing(String ontologyId, String name, String description, String iri){
	Model model = FileManager.get().loadModel(iri);
	
	IndexingJobInput indexingJobInput = null;
	if(ontologyId == null) indexingJobInput = new IndexingJobInput(name, description, iri, model);
	else indexingJobInput = new IndexingJobInput(ontologyId, name, description, iri, model);
	try {
		String jobId = indexOntology(indexingJobInput);
		while(!jobManager.ping(jobId).isDone())
			Thread.sleep(1000);
		
	} catch (OntologyAlreadyExistingException | InterruptedException e) {
		log.error(e.getMessage(), e);
	}
	
}
 
開發者ID:teamdigitale,項目名稱:ontonethub,代碼行數:17,代碼來源:OntoNetHubImpl.java

示例6: 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

示例7: addOrganizationStatusToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
    * Add to the model the organization statuses.
    * 
    * @param Model the model we are currently working with
    */
public void addOrganizationStatusToModel(Model model) {
	
	List<String> statusesList = Arrays.asList("Active", "Inactive", "Pending");
	
	for (String status : statusesList) {
		/** statusResource **/
		Resource statusResource = model.createResource(Ontology.instancePrefix + "OrganizationStatus/" + status, Ontology.organizationStatusResource);
		model.createResource(Ontology.instancePrefix + "OrganizationStatus/" + status, Ontology.conceptResource);
		/** configure prefLabel **/
		String[] statusDtls = hm.findOrganizationStatusDetails(status);
		statusResource.addProperty(Ontology.prefLabel, statusDtls[1], "el");
		statusResource.addProperty(Ontology.prefLabel, statusDtls[2], "en");
       }
	
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:21,代碼來源:MonthlyRdfActions.java

示例8: addBudgetTypeToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
    * Add to the model the budget types.
    * 
    * @param Model the model we are currently working with
    */
public void addBudgetTypeToModel(Model model) {
	
	List<String> budgetTypeList = Arrays.asList("Τακτικός Προϋπολογισμός", "Πρόγραμμα Δημοσίων Επενδύσεων", "Ίδια Έσοδα", "Συγχρηματοδοτούμενο Έργο");
	
	for (String budgetType : budgetTypeList) {
		String[] budgetDtls = hm.findBudgetTypeIndividual(budgetType);
		/** statusResource **/
		Resource statusResource = model.createResource(budgetDtls[0], Ontology.budgetCategoryResource);
		model.createResource(budgetDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		statusResource.addProperty(Ontology.prefLabel, budgetDtls[1], "el");
		statusResource.addProperty(Ontology.prefLabel, budgetDtls[2], "en");
       }
	
}
 
開發者ID:YourDataStories,項目名稱:harvesters,代碼行數:21,代碼來源:MonthlyRdfActions.java

示例9: addDecisionStatusToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the decision statuses.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addDecisionStatusToModel(Model model) {

	List<String> statusesList = Arrays.asList("Published", "Pending_Revocation", "Revoked", "Submitted");

	for (String status : statusesList) {
		String[] statusDtls = hm.findDecisionStatusIndividual(status);
		/** statusResource **/
		Resource statusResource = model.createResource(statusDtls[0], Ontology.decisionStatusResource);
		model.createResource(statusDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		statusResource.addProperty(Ontology.prefLabel, statusDtls[1], "el");
		statusResource.addProperty(Ontology.prefLabel, statusDtls[2], "en");
	}

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

示例10: addKanonistikiToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the Regular Acts.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addKanonistikiToModel(Model model) {

	List<String> regularList = Arrays.asList("Υπουργική Απόφαση",
			"Πράξη Γενικού Γραμματέα Αποκεντρωμένης Διοίκησης", "Πράξη Οργάνου Διοίκησης Ν.Π.Δ.Δ.",
			"Πράξη Οργάνου Διοίκησης ΟΤΑ Α’ και Β’ Βαθμού (και εποπτευόμενων φορέων τους)",
			"Λοιπές Κανονιστικές Πράξεις");

	for (String regular : regularList) {
		String[] regularDtls = hm.findKanonistikiIndividual(regular);
		/** regulatoryResource **/
		Resource regularResource = model.createResource(regularDtls[0], Ontology.regulatoryActResource);
		model.createResource(regularDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		regularResource.addProperty(Ontology.prefLabel, regularDtls[1], "el");
		regularResource.addProperty(Ontology.prefLabel, regularDtls[2], "en");
	}

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

示例11: addOpinionToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the Opinion Types.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addOpinionToModel(Model model) {

	List<String> opinionList = Arrays.asList("Ανεξάρτητη Αρχή", "ΝΣΚ");

	for (String opinion : opinionList) {
		String[] opinionDtls = hm.findOpinionOrgIndividual(opinion);
		/** opinionResource **/
		Resource opinionResource = model.createResource(opinionDtls[0], Ontology.opinionResource);
		model.createResource(opinionDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		opinionResource.addProperty(Ontology.prefLabel, opinionDtls[1], "el");
		opinionResource.addProperty(Ontology.prefLabel, opinionDtls[2], "en");
	}

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

示例12: addAccountTypeToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the Account Types.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addAccountTypeToModel(Model model) {

	List<String> accountList = Arrays.asList("Ισολογισμός", "Απολογισμός", "Ισολογισμός και Απολογισμός");

	for (String account : accountList) {
		String[] accountDtls = hm.findAccountTypeIndividual(account);
		/** accountResource **/
		Resource accountResource = model.createResource(accountDtls[0], Ontology.accountResource);
		model.createResource(accountDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		accountResource.addProperty(Ontology.prefLabel, accountDtls[1], "el");
		accountResource.addProperty(Ontology.prefLabel, accountDtls[2], "en");
	}

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

示例13: runQueryOnInstance

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Runs a given Jena Query on a given instance and adds the inferred triples
 * to a given Model.
 * @param queryWrapper  the wrapper of the CONSTRUCT query to execute
 * @param queryModel  the query Model
 * @param newTriples  the Model to write the triples to
 * @param instance  the instance to run the inferences on
 * @param checkContains  true to only call add if a Triple wasn't there yet
 * @return true if changes were done (only meaningful if checkContains == true)
 */
public static boolean runQueryOnInstance(QueryWrapper queryWrapper, Model queryModel, Model newTriples, Resource instance, boolean checkContains) {
	boolean changed = false;
	QueryExecution qexec = ARQFactory.get().createQueryExecution(queryWrapper.getQuery(), queryModel);
	QuerySolutionMap bindings = new QuerySolutionMap();
	bindings.add(SPIN.THIS_VAR_NAME, instance);
	Map<String,RDFNode> initialBindings = queryWrapper.getTemplateBinding();
	if(initialBindings != null) {
		for(String varName : initialBindings.keySet()) {
			RDFNode value = initialBindings.get(varName);
			bindings.add(varName, value);
		}
	}
	qexec.setInitialBinding(bindings);
	Model cm = qexec.execConstruct();
	StmtIterator cit = cm.listStatements();
	while(cit.hasNext()) {
		Statement s = cit.nextStatement();
		if(!checkContains || !queryModel.contains(s)) {
			changed = true;
			newTriples.add(s);
		}
	}
	return changed;
}
 
開發者ID:BenzclyZhang,項目名稱:BimSPARQL,代碼行數:35,代碼來源:SPINInferencesWithoutConstructor.java

示例14: addVacancyTypeToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the Vacancy Types.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addVacancyTypeToModel(Model model) {

	List<String> vacancyList = Arrays.asList(
			"Προκήρυξη Πλήρωσης Θέσεων με διαγωνισμό ή επιλογή στις οποίες περιλαμβάνονται και οι προκηρύξεις για επιλογή και πλήρωση θέσεων διευθυντικών στελεχών των ΝΠΔΔ, φορέων του ευρύτερου δημόσιου τομέα, και των επιχειρήσεων και φορέων των ΟΤΑ Α’ & Β’ βαθμού",
			"Προκήρυξη Πλήρωσης Θέσεων Εκπαιδευτικού Προσωπικού (ΕΠ) Τεχνολογικού τομέα της Ανώτατης Εκπαίδευσης",
			"Προκήρυξη Πλήρωσης Θέσεων Διδακτικού Ερευνητικού Προσωπικού (ΔΕΠ) Πανεπιστημιακού τομέα");

	for (String vacancy : vacancyList) {
		String[] vacancyDtls = hm.findVacancyTypeIndividual(vacancy);
		/** vacancyTypeResource **/
		Resource vacancyTypeResource = model.createResource(vacancyDtls[0], Ontology.vacancyTypeResource);
		model.createResource(vacancyDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		vacancyTypeResource.addProperty(Ontology.prefLabel, vacancyDtls[1], "el");
		vacancyTypeResource.addProperty(Ontology.prefLabel, vacancyDtls[2], "en");
	}

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

示例15: addAdminChangeToModel

import com.hp.hpl.jena.rdf.model.Model; //導入依賴的package包/類
/**
 * Add to the model the Administrative Changes.
 * 
 * @param Model
 *            the model we are currently working with
 */
public void addAdminChangeToModel(Model model) {

	List<String> changeList = Arrays.asList("Μετάταξη", "Λύση Υπαλληλικής Σχέσης", "Υποβιβασμός",
			"Αποδοχή Παραίτησης");

	for (String change : changeList) {
		String[] changeDtls = hm.findAdministrativeChangeIndividual(change);
		/** adminChangeResource **/
		Resource adminChangeResource = model.createResource(changeDtls[0], Ontology.adminChangeResource);
		model.createResource(changeDtls[0], Ontology.conceptResource);
		/** configure prefLabel **/
		adminChangeResource.addProperty(Ontology.prefLabel, changeDtls[1], "el");
		adminChangeResource.addProperty(Ontology.prefLabel, changeDtls[2], "en");
	}

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


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