本文整理汇总了Java中org.apache.clerezza.rdf.core.Graph类的典型用法代码示例。如果您正苦于以下问题:Java Graph类的具体用法?Java Graph怎么用?Java Graph使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Graph类属于org.apache.clerezza.rdf.core包,在下文中一共展示了Graph类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateRdf
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
/**
* Get SIOC content from the RDF as text and return it.
*
* @param entity
* @return
* @throws IOException
*/
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
String text = "";
Graph graph = Parser.getInstance().parse(entity.getData(), "text/turtle");
Iterator<Triple> triples = graph.filter(null, SIOC.content, null);
if (triples.hasNext()) {
Literal literal = (Literal) triples.next().getObject();
text = literal.getLexicalForm();
}
final TripleCollection result = new SimpleMGraph();
final Resource resource = entity.getContentLocation() == null
? new BNode()
: new UriRef(entity.getContentLocation().toString());
final GraphNode node = new GraphNode(resource, result);
node.addProperty(RDF.type, TEXUAL_CONTENT);
node.addPropertyValue(SIOC.content, text);
node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
return result;
}
示例2: testSilkRdfTurtle
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void testSilkRdfTurtle() throws IOException {
Response response
= RestAssured.given().header("Accept", "text/turtle")
.contentType("text/turtle;charset=UTF-8")
.content(ttlData)
.expect().statusCode(HttpStatus.SC_OK).content(new StringContains("http://www.w3.org/2002/07/owl#sameAs")).header("Content-Type", SupportedFormat.TURTLE).when()
.post();
Graph graph = Parser.getInstance().parse(response.getBody().asInputStream(), "text/turtle");
Iterator<Triple> typeTriples = graph.filter(null, OWL.sameAs, null);
Assert.assertTrue("No equivalent entities found", typeTriples.hasNext());
}
示例3: testRemoteConfig
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void testRemoteConfig() {
// Set up a service in the mock server to respond to a get request that must be sent by the transformer
// to fetch the silk config file
stubFor(get(urlEqualTo("/fusepoolp3/silk-config-file.xml"))
.willReturn(aResponse()
.withStatus(HttpStatus.SC_OK)
.withHeader("Content-Type", "text/xml")
.withBody(silkconf)));
// The response object acts as a transformer's client. It sends a post request
// to the transformer with the url of the silk config file, the data to be interlinked
// and gets the result from the transformer.
Response response =
RestAssured.given().header("Accept", "text/turtle")
.contentType("text/turtle")
.content(ttlData)
.expect().statusCode(HttpStatus.SC_OK).when()
.post("/?config=http://localhost:" + mockPort +"/fusepoolp3/silk-config-file.xml");
Graph graph = Parser.getInstance().parse(response.getBody().asInputStream(), SupportedFormat.TURTLE);
Iterator<Triple> typeTriples = graph.filter(null, OWL.sameAs, null);
Assert.assertTrue("No equivalent entities found", typeTriples.hasNext());
}
示例4: testXML
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void testXML() throws Exception {
Transformer t = new TransformerClientImpl(setUpDataServer());
// the transformer fetches the xml data from the data server, geocode the address
// and sends the RDF result to the client
{
Entity response = t.transform(new WritingEntity() {
@Override
public MimeType getType() {
return inputDataMimeType;
}
@Override
public void writeData(OutputStream out) throws IOException {
out.write(inputData);
}
}, transformerMimeType );
// the client receives the response from the transformer
Assert.assertEquals("Wrong media Type of response", TRANSFORMER_MIME_TYPE, response.getType().toString());
// Parse the RDF data returned by the transformer after the geocoding
final Graph responseGraph = Parser.getInstance().parse(response.getData(), "text/turtle");
//checks for the presence of a specific property added by the transformer to the input data
final Iterator<Triple> propertyIter = responseGraph.filter(null, geo_lat, null);
Assert.assertTrue("No specific property found in response", propertyIter.hasNext());
//verify that the xml has been loaded from the data server (one call)
//verify(1,getRequestedFor(urlEqualTo("/xml/" + XML_DATA)));
}
}
示例5: turtleOnGet
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void turtleOnGet() throws UnsupportedEncodingException {
Response response = RestAssured.given().header("Accept", "text/turtle")
.expect().statusCode(HttpStatus.SC_OK).header("Content-Type", "text/turtle").when()
.get(baseURI + "?t=" + transformerURI0 + "&t=" + transformerURI1 + "&t=" + transformerURI2);
Graph graph = Parser.getInstance().parse(response.getBody().asInputStream(), "text/turtle");
System.out.println(graph.toString());
}
示例6: turtlePost
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void turtlePost() {
Response response = RestAssured.given()
.header("Accept", "application/x-turtle; q=0.8, application/rdf+xml; q=0.9, text/turtle; q=1.0")
.header("Content-Location", "http://example.com/test1")
.contentType("text/plain;charset=UTF-8")
.content("hello")
.expect().statusCode(HttpStatus.SC_OK).header("Content-Type", "text/turtle").when()
.post(baseURI + "?t=" + transformerURI0 + "&t=" + transformerURI1 + "&t=" + transformerURI2);
Graph graph = Parser.getInstance().parse(response.getBody().asInputStream(), "text/turtle");
Assert.assertTrue("Result doesn't contain originally posted text", graph.toString().contains("hello"));
}
示例7: turtlePost
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
@Test
public void turtlePost() {
Response response = RestAssured.given().header("Accept", "text/turtle")
.contentType("text/plain;charset=UTF-8")
.content(testText)
.expect().statusCode(HttpStatus.SC_OK).header("Content-Type", "text/turtle").when()
.post(baseURI + "?taxonomy=" + testTaxonomy);
System.out.println(response.getBody().toString());
Graph graph = Parser.getInstance().parse(response.getBody().asInputStream(), "text/turtle");
Iterator<Triple> typeTriples = graph.filter(null, RDF.type, FAM.LinkedEntity);
Assert.assertTrue("No type triple found", typeTriples.hasNext());
}
示例8: testTransformation
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
/**
* The transformer receives RDF data and a url from the client, fetches the SILK config file from the url, applies the linkage rules
* and then check if the transformation is compatible with the expected result.
* @throws Exception
*/
@Test
public void testTransformation() throws Exception {
Transformer t = new TransformerClientImpl(setUpMockServer());
// the transformer fetches the SILK config file from the mock server, applies its rules and sends the RDF result to the client
{
Entity response = t.transform(new WritingEntity() {
@Override
public MimeType getType() {
return clientDataMimeType;
}
@Override
public void writeData(OutputStream out) throws IOException {
out.write(ttlData);
}
}, transformerMimeType);
// the client receives the response from the transformer
Assert.assertEquals("Wrong media Type of response", transformerMimeType.toString(), response.getType().toString());
// Parse the RDF data returned by the transformer after the xslt transformation has been applied to the xml data
final Graph responseGraph = Parser.getInstance().parse(response.getData(), "text/turtle");
//checks for the presence of a specific property added by the transformer
final Iterator<Triple> propertyIter = responseGraph.filter(null, OWL.sameAs, null);
Assert.assertTrue("No specific property found in response", propertyIter.hasNext());
}
}
示例9: okGraphResponse
import org.apache.clerezza.rdf.core.Graph; //导入依赖的package包/类
private Response okGraphResponse(HttpHeaders headers, Graph graph){
ResponseBuilder rb = Response.ok(graph);
if (headers.getAcceptableMediaTypes().isEmpty()) {
// use RDF/XML as default format to keep compat with OpenCalaisclients
System.out.println("NO ACCEPTABLE MEDIA TYPE");
rb.header(HttpHeaders.CONTENT_TYPE, RDF_XML+"; charset=UTF-8");
}
log.error("je passe bien ici allow bien");
//rb.header(\"Access-Control-Allow-Headers", \"Authorization");
//rb.header(\"Access-Control-Allow-Origin", \"*");
enableCORS(servletContext,rb, headers);
//addCORSOrigin(servletContext,rb, headers);
return rb.build();
}