当前位置: 首页>>代码示例>>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;未经允许,请勿转载。