将数据从fuseki数据集迁移到另一个fuseki数据集

时间:2016-03-03 12:05:32

标签: sparql jena fuseki

使用Sparql查询我必须从Fuseki数据集中获取数据,并需要将结果加载到另一个Fuseki数据集。使用相同的查询我应该从新数据集获得相同的结果。有没有办法实现这个目标?

查询

SELECT  distinct ?id ?attribProductType ?attribName ?attribScaleValues ?attribUom ?attribDataGroup ?attribHighRange ?attribLowRange ?attribDefaultValue  WHERE  {   
?product rdf:type ?entity .         
?product :attribCompositeId ?id  .  
?product :attribIsLatest  "Y"^^xsd:string . 
?product :attribProductType ?attribProductType . 
?product :hasAttributes ?hasAttributes.
?hasAttributes :followsUOM ?followsUOM.
?followsUOM :attribName ?attribName.
?followsUOM :attribScaleValues ?attribScaleValues.
?followsUOM :attribUom ?attribUom.
?followsUOM :attribDataGroup ?attribDataGroup.
?followsUOM :attribHighRange ?attribHighRange.
?followsUOM :attribLowRange ?attribLowRange.
?followsUOM :attribDefaultValue ?attribDefaultValue.
FILTER( str(?attribProductType) = "precision_Test1") 
}

样本输出

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| id                                                 | attribProductType             | attribName                       | attribScaleValues                 | attribUom             | attribDataGroup                     | attribHighRange       | attribLowRange    | attribDefaultValue                      |
=================================================================================================================================================================================================================================================================================================================
| "8b25aa6f-7911-4c2d-8cc7-0796b94c3e44"^^xsd:string | "precision_Test1"^^xsd:string | "Voltage"^^xsd:string            | "N/A"^^xsd:string                 | "N/A"^^xsd:string     | ""^^xsd:string                      | "N/A"^^xsd:string     | "N/A"^^xsd:string | "No"^^xsd:string                        |

代码

String host=FUSEKI_HOST+":"+FUSEKI_PORT+"/"+FUSEKI_DATASET+"/query";    
System.out.println("host:"+host);
String s2= readSparql();
System.out.println("Query:"+ s2);           
Query query = QueryFactory.create(s2);
System.out.println("query:"+query);
QueryExecution qe = QueryExecutionFactory.sparqlService(host,s2);
ResultSet results = qe.execSelect();        
OutputStream out1 = new FileOutputStream(new File("sampleRDF4.rdf"));
//added for rewindable resultset
ResultSetRewindable result =ResultSetFactory.makeRewindable( results );
System.out.println(ResultSetFormatter.asText(result));
result.reset(); 
System.out.println("Writing SPARQL result to RDF..");
ResultSetFormatter.outputAsRDF(out1, "RDF/XML", result);
qe.close();

示例RDF4.rdf存储到新的Jena,我试图使用相同的查询获取结果。但是在RDF中,关系是在新的领域,如rs:varaiable和rs:value。有没有其他方法可以创建RDF来维护数据集中的关系?

0 个答案:

没有答案