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


Java ResourceFactory類代碼示例

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


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

示例1: addQualityReport

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
public Resource addQualityReport(Model model) {
    Resource qualityReport = model.createResource(LDQM.QUALITY_REPORT_PREFIX + UUID.randomUUID().toString(),QPRO.QualityReport);
    qualityReport.addProperty(QPRO.computedOn, ResourceFactory.createTypedLiteral(DATE_FORMAT.format(new Date()), XSDDatatype.XSDdateTime));
    Resource noDerefSubjectsProblem = model.createResource(QPRO.QualityProblem);
    noDerefSubjectsProblem.addProperty(QPRO.isDescribedBy, LDQM.IRIdereferenceability);
    for (HttpResponse response : responseMap.values()) {
        if (response.getStatusCode() >= 300 || response.getStatusCode() < 200) {
            Resource errSubject = model.createResource(LDQM.Defect_UndereferenceableURI);
            errSubject.addProperty(DCTerms.subject,response.getUri());
            if (response.getStatusCode() > 0) {
                errSubject.addLiteral(HTTP.statusCodeValue, model.createTypedLiteral(response.getStatusCode(), XSDDatatype.XSDint));
            }
            errSubject.addLiteral(HTTP.methodName, response.getMethod());
            if (response.getReason() != null) {
                errSubject.addLiteral(HTTP.reasonPhrase, response.getReason());
            }
            noDerefSubjectsProblem.addProperty(QPRO.problematicThing, errSubject);
        }
    }
    qualityReport.addProperty(QPRO.hasProblem, noDerefSubjectsProblem);
    qualityReport.addProperty(PROV.wasGeneratedBy, evaluation);
    return qualityReport;
}
 
開發者ID:nandana,項目名稱:ld-sniffer,代碼行數:24,代碼來源:Evaluation.java

示例2: Message

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
/**
 * @param problem
 * @param term
 * @param detailCode Optional error code; indicates a subclass of problems
 * @param details Optional string containing error details
 * @param contextResource May be null
 * @param contextProperty May be null
 */
public Message(Problem problem, MappingTerm term, 
		String detailCode, String details, 
		Resource contextResource, Property contextProperty) {
	this.problem = problem;
	this.subject = contextResource; 
	this.predicates = 
		contextProperty == null 
				? Collections.<Property>emptyList() 
				: Collections.singletonList(contextProperty);
	this.objects = 
		term == null
				? Collections.<RDFNode>emptyList()
				: Collections.<RDFNode>singletonList(ResourceFactory.createPlainLiteral(term.toString()));
	this.detailCode = detailCode;
	this.details = details;
	this.cause = null;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:26,代碼來源:Message.java

示例3: toTurtle

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private String toTurtle(RDFNode r) {
	if (r.isURIResource()) {
		return PrettyPrinter.qNameOrURI(relativize(r.asResource().getURI()), prefixes);
	} else if (r.isLiteral()) {
		StringBuffer result = new StringBuffer(quote(r.asLiteral().getLexicalForm()));
		if (!"".equals(r.asLiteral().getLanguage())) {
			result.append("@");
			result.append(r.asLiteral().getLanguage());
		} else if (r.asLiteral().getDatatype() != null) {
			result.append("^^");
			result.append(toTurtle(ResourceFactory.createResource(r.asLiteral().getDatatypeURI())));
		}
		return result.toString();
	} else {
		if (!blankNodeMap.containsKey(r)) {
			blankNodeMap.put(r.asResource(), "_:b" + blankNodeCounter++);
		}
		return blankNodeMap.get(r);
	}
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:21,代碼來源:PrettyTurtleWriter.java

示例4: printTranslationTable

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private void printTranslationTable(TranslationTable table) {
	printMapObject(table, D2RQ.TranslationTable);
	out.printURIProperty(D2RQ.href, table.getHref());
	out.printProperty(D2RQ.javaClass, table.getJavaClass());
	Iterator<Translation> it = table.getTranslations().iterator();
	List<Map<Property,RDFNode>> values = new ArrayList<Map<Property,RDFNode>>();
	while (it.hasNext()) {
		Translation translation = it.next();
		Map<Property,RDFNode> r = new LinkedHashMap<Property,RDFNode>();
		r.put(D2RQ.databaseValue, 
				ResourceFactory.createPlainLiteral(translation.dbValue()));
		r.put(D2RQ.rdfValue, 
				ResourceFactory.createPlainLiteral(translation.rdfValue()));
		values.add(r);
	}
	out.printCompactBlankNodeProperties(D2RQ.translation, values);
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:18,代碼來源:D2RQWriter.java

示例5: generateMapping

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private Mapping generateMapping() {
	Mapping mapping = new Mapping();
	Database database = new Database(dbURI);
	database.setJdbcURL(jdbcURL);
	database.setJDBCDriver(driver);
	database.setUsername(user);
	database.setPassword(password);
	if (scriptURL != null) {
		database.setStartupSQLScript(ResourceFactory.createResource(scriptURL));
	}
	mapping.addDatabase(database);
	ClassMap classMap = new ClassMap(classMapURI);
	classMap.setDatabase(database);
	classMap.setURIPattern("row/@@T_" + datatype + "[email protected]@");
	mapping.addClassMap(classMap);
	PropertyBridge propertyBridge = new PropertyBridge(propertyBridgeURI);
	propertyBridge.setBelongsToClassMap(classMap);
	propertyBridge.addProperty(valueProperty);
	propertyBridge.setColumn(ColumnName.parse("T_" + datatype + ".VALUE"));
	return mapping;
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:22,代碼來源:DatatypeTestBase.java

示例6: testDownloadMap

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
@Test
public void testDownloadMap() {
	sql.executeSQL("CREATE TABLE \"People\" (\"ID\" INT PRIMARY KEY, \"pic\" VARCHAR(50))");
	DownloadMap dl = new DownloadMap(ResourceFactory.createResource());
	dl.setDatabase(database);
	dl.setURIPattern("http://example.org/downloads/@@[email protected]@");
	dl.setMediaType("image/png");
	dl.setContentDownloadColumn("People.pic");
	mapping.addDownloadMap(dl);
	CompiledD2RQMapping compiled = mapping.compile();
	assertEquals(1, compiled.getDownloadRelations().size());
	DownloadRelation d = compiled.getDownloadRelations().iterator().next();
	assertNotNull(d);
	assertEquals(Node.createLiteral("image/png"), 
			d.nodeMaker(DownloadRelation.MEDIA_TYPE).makeNode(
					new ResultRow(null) {public String get(ColumnName column) {return null;}}));
	assertEquals(Microsyntax.parseColumn("People.pic"), d.getContentDownloadColumn());
	assertEquals("URI(http://example.org/downloads/{\"People\".\"ID\"})", 
			d.nodeMaker(DownloadRelation.RESOURCE).toString());
	assertFalse(d.getBaseTabular().getUniqueKeys().isEmpty());
	assertEquals(ColumnList.create(
				Microsyntax.parseColumn("People.ID"),
				Microsyntax.parseColumn("People.pic")), 
			d.getBaseTabular().getColumns());
}
 
開發者ID:d2rq,項目名稱:r2rml-kit,代碼行數:26,代碼來源:D2RQCompilerTest.java

示例7: testGenerateDownloadMap

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
public void testGenerateDownloadMap() {
	Mapping m = MappingHelper.readFromTestFile("parser/download-map.ttl");
	MappingHelper.connectToDummyDBs(m);
	Resource name = ResourceFactory.createResource("http://example.org/dm");
	assertTrue(m.downloadMapResources().contains(name));
	DownloadMap d = m.downloadMap(name);
	assertNotNull(d);
	assertEquals("image/png", 
			d.getMediaTypeValueMaker().makeValue(
					new ResultRow() {public String get(ProjectionSpec column) {return null;}}));
	assertEquals("People.pic", d.getContentDownloadColumn().qualifiedName());
	assertEquals("URI(Pattern(http://example.org/downloads/@@[email protected]@))", 
			d.nodeMaker().toString());
	assertEquals(
			new HashSet<ProjectionSpec>() {{ 
				add(SQL.parseAttribute("People.ID"));
				add(SQL.parseAttribute("People.pic"));
			}}, 
			d.getRelation().projections());
	assertTrue(d.getRelation().isUnique());
	assertTrue(d.getRelation().condition().isTrue());
	assertTrue(d.getRelation().joinConditions().isEmpty());
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:24,代碼來源:ParserTest.java

示例8: generateMapping

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private Mapping generateMapping() {
	Mapping mapping = new Mapping();
	Database database = new Database(dbURI);
	database.setJDBCDSN(jdbcURL);
	database.setJDBCDriver(driver);
	database.setUsername(user);
	database.setPassword(password);
	database.setStartupSQLScript(ResourceFactory.createResource("file:" + script));
	mapping.addDatabase(database);
	ClassMap classMap = new ClassMap(classMapURI);
	classMap.setDatabase(database);
	classMap.setURIPattern("row/@@T_" + datatype + "[email protected]@");
	mapping.addClassMap(classMap);
	PropertyBridge propertyBridge = new PropertyBridge(propertyBridgeURI);
	propertyBridge.setBelongsToClassMap(classMap);
	propertyBridge.addProperty(valueProperty);
	propertyBridge.setColumn("T_" + datatype + ".VALUE");
	classMap.addPropertyBridge(propertyBridge);
	return mapping;
}
 
開發者ID:aitoralmeida,項目名稱:c4a_data_repository,代碼行數:21,代碼來源:DatatypeTestBase.java

示例9: isDisambiguationResource

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
public boolean isDisambiguationResource(String uri) {
    
    if(!linksLoaded){
        System.out.println(Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET);
        System.out.println(Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET);
        InputStream in1 = FileManager.get().open( Settings.EN_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in2 = FileManager.get().open( Settings.DE_DBPEDIA_DISAMBIGUATION_DATASET );
        InputStream in3 = FileManager.get().open( Settings.NL_DBPEDIA_DISAMBIGUATION_DATASET );
        model.read(in1, null, "N-TRIPLES");
        System.out.println("Loaded English disambiguation dataset.");
        model.read(in2, null, "N-TRIPLES");
        System.out.println("Loaded German disambiguation dataset.");
        model.read(in3, null, "N-TRIPLES");
        System.out.println("Loaded Dutch disambiguation dataset.");
        linksLoaded = true;
    }
    
    StmtIterator iter = model.listStatements( new SimpleSelector(
            ResourceFactory.createResource(uri), 
            ResourceFactory.createProperty("http://dbpedia.org/ontology/wikiPageDisambiguates"), 
                    (RDFNode)null));
    
    return iter.hasNext();
}
 
開發者ID:entityclassifier-eu,項目名稱:entityclassifier-core,代碼行數:26,代碼來源:DisambiguationPageValidator.java

示例10: getHierarchyModel

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
public Model getHierarchyModel(String uri){
    
    // returns all subclasses for given URI
    Model m = ModelFactory.createDefaultModel();
    OntoRecord initRecord = new OntoRecord();
    initRecord.setUri(uri);
    
    while(initRecord !=null){
        
        initRecord = getSuperclass(initRecord.getUri());
        
        if(initRecord != null){
            StmtIterator iter1 = model.listStatements( new SimpleSelector(ResourceFactory.createResource(uri), RDFS.subClassOf,  (RDFNode)null));                
            m.add(iter1);
        }
    }
     
    return m;
}
 
開發者ID:entityclassifier-eu,項目名稱:entityclassifier-core,代碼行數:20,代碼來源:YagoOntologyManager.java

示例11: getSubclass

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
public OntoRecord getSubclass(String resourceURI, String lang){
    
    StmtIterator iter1 = model.listStatements( new SimpleSelector(ResourceFactory.createResource(resourceURI), ResourceFactory.createProperty("http://www.w3.org/2000/01/rdf-schema#subClassOf"),  (RDFNode)null));
    OntoRecord record = new OntoRecord();
    StmtIterator iter2;
    
    while(iter1.hasNext()) {
        record.setUri(iter1.next().getObject().toString());
        iter2 = model.listStatements( new SimpleSelector(ResourceFactory.createResource(record.getUri()), ResourceFactory.createProperty("http://www.w3.org/2000/01/rdf-schema#label"),  (RDFNode)null));
        
        while(iter2.hasNext()){
            Literal res = (Literal) iter2.next().getObject();                
            String tmpLang = res.getLanguage();
            
            if( tmpLang.equals("en") ){
                record.setLabel(res.getString());
                return record;
                
            }
        }
    }
    return null;        
}
 
開發者ID:entityclassifier-eu,項目名稱:entityclassifier-core,代碼行數:24,代碼來源:DBpediaOntologyManager.java

示例12: addRowToMODEL

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private void addRowToMODEL(List<Statement> sa, String key, String puri) {
	for (Statement s : sa) {
		if (MODEL.contains(s)) {
			continue;
		}
		// add to existing resource with same key if exists
		if (s.getPredicate().getLocalName().equals(key)) {
			ResIterator it	=	MODEL.listResourcesWithProperty(s.getPredicate(), s.getObject());
			if (it.hasNext()) { // assume all members are equal
				Resource rsc	= it.nextResource(); // get parent
				Property p	= ResourceFactory.createProperty(genOURI(), puri);
				Statement st	= ResourceFactory.createStatement(rsc, p, s.getSubject());

				MODEL.add(st);

				continue;
			}
		}

		MODEL.add(s);
	}
}
 
開發者ID:wxwilcke,項目名稱:mdb2rdf,代碼行數:23,代碼來源:RdbToRdf.java

示例13: convertRowToStatement

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private List<Statement> convertRowToStatement(Table table, Row row, Resource rcs) {
	List<Statement> sa	= new ArrayList<Statement>(row.size()); 
	int i = 0;
	
	Set<String> attrs = row.keySet();
	for (String attr : attrs) {
		RDFNode attrRcs;
		Object value	= row.get(attr);
		if (value == null || excludedValue(attr.toString(), value.toString())) { // dealing with empty and excluded values
			continue;
		} else {
			attrRcs	= createRDFNode(table.getColumn(attr), value);
		}

		Property p	= ResourceFactory.createProperty(genOURI(), attr.toString());
		Statement s	= ResourceFactory.createStatement(rcs, p, attrRcs);
		
		sa.add(s);
	}

	return sa;
}
 
開發者ID:wxwilcke,項目名稱:mdb2rdf,代碼行數:23,代碼來源:RdbToRdf.java

示例14: addTopics

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
private void addTopics() {
	String[] topicNames = {
			"http://vivoweb.org/ontology/core#FacultyMember",
			"http://xmlns.com/foaf/0.1/Person",
			"http://xmlns.com/foaf/0.1/Organization",
			"http://vivoweb.org/ontology/core#Project",
			"http://purl.org/ontology/bibo/Conference",
			"http://purl.org/ontology/bibo/Workshop",
			"http://vivoweb.org/ontology/core#Grant",
			"http://purl.org/NET/c4dm/event.owl#Event"
			};


	for (String t : topicNames) {
		this.topics.add(ResourceFactory.createResource(t));
	}
	
}
 
開發者ID:christoff-buerger,項目名稱:reneviz,代碼行數:19,代碼來源:TopicRegistry.java

示例15: loadClassList

import com.hp.hpl.jena.rdf.model.ResourceFactory; //導入依賴的package包/類
/**
 * @param path
 * @return
 */
public static HashMap<String, List<Resource>> loadClassList(String path) {
	HashMap<String, List<Resource>> res = new HashMap<>();
	// load specification file
	Model model = RDFDataMgr.loadModel(path);
	// get all graphs
	Iterator<Statement> statIt = model.listStatements((Resource) null, 
			ResourceFactory.createProperty("http://aksw.org/deduplication/relatedGraph"), (RDFNode) null);
	while(statIt.hasNext()) {
		Statement s = statIt.next();
		Resource dataset = s.getSubject();
		String graph = s.getObject().as(Resource.class).getURI();
		// get all classes for each graph
		ArrayList<Resource> classes = new ArrayList<>();
		Iterator<RDFNode> nodeIt = model.listObjectsOfProperty(dataset, ResourceFactory.createProperty("http://aksw.org/deduplication/requiredClasses"));
		while(nodeIt.hasNext()) {
			Resource c = nodeIt.next().as(Resource.class);
			classes.add(c);
		}
		res.put(graph, classes);
	}
	return res;
}
 
開發者ID:AKSW,項目名稱:rocker,代碼行數:27,代碼來源:ModelManager.java


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