response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Type", "application/json");
String jsonString = request.getParameter("schema");
JSONObject json = ParsingUtilities.evaluateJsonStringToObject(jsonString);
final RdfSchema schema = RdfSchema.reconstruct(json);
RdfRowVisitor visitor = new RdfRowVisitor(schema) {
final int limit = 10;
int _count;
@Override
public boolean visit(Project project, int rowIndex, Row row) {
if(_count>=limit){
return true;
}
for(Node root:roots){
root.createNode(baseUri, factory, con, project, row, rowIndex,blanks);
}
_count +=1;
return false;
}
};
Repository model = RdfExporter.buildModel(project, engine, visitor);
StringWriter sw = new StringWriter();
try{
RepositoryConnection con = model.getConnection();
try{
RDFWriter w = Rio.createWriter(RDFFormat.TURTLE, sw);
for(Vocabulary v:schema.getPrefixesMap().values()){
w.handleNamespace(v.getName(), v.getUri());
}
con.export(w);
}finally{
con.close();