package no.deichman.services.repository;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryFactory;

public class QueryBuilder {

    public static Query getGetWorkByIdQuery(String id) {
        String queryString =
                "PREFIX dcterms: <http://purl.org/dc/terms/>\n"
                + "PREFIX deichman: <http://deichman.no/ontology#>\n"
                + "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\n"
                + "CONSTRUCT {\n"
                + "?url a deichman:Work ;\n"
                + "     dcterms:identifier ?id ;\n"
                + "     dcterms:creator ?creator ;\n"
                + "     dcterms:date ?date ;\n"
                + "     dcterms:title ?title ;\n"
                + "     deichman:hasEditions ?edition .\n"
                + "} WHERE {\n"
                + "?url a deichman:Work ;\n"
                + "     dcterms:identifier \"" + id + "\" .\n"
                + "OPTIONAL {?url dcterms:creator ?c .\n"
                + "?c foaf:name ?creator .}\n"
                + "OPTIONAL {?url dcterms:title ?t}\n"
                + "OPTIONAL {?url dcterms:date ?d}\n"
                + "OPTIONAL {?url deichman:hasEditions ?edition}\n"
                + "BIND (str(?d) as ?date)\n"
                + "BIND (str(?t) as ?title)\n"
                + "}";
        return QueryFactory.create(queryString);
    }

    public static Query getListWorkQuery() {
        String queryString =
                "PREFIX deichman: <http://deichman.no/ontology#>\n"
                + "describe ?s where\n"
                + " {\n"
                + " ?s a deichman:Work"
                + "}";
        return QueryFactory.create(queryString);

    }

    public static String getCreateWorkQueryString(String work) {
        String queryString =
                "PREFIX deichman: <http://deichman.no/ontology#>\n"
                + "PREFIX dcterms: <http://purl.org/dc/terms/>\n"
                + "INSERT DATA {\n"
                + " <http://deichman.no/work/"+ work + "> a deichman:Work ;\n"
                + " dcterms:identifier \""+ work + "\";\n"
                + "}";
        System.out.println("queryString: " +  queryString);
        return queryString;

    }
}

@@ -2120,68 +2120,8 @@
 %7D%22;%0A
-        System.out.println(%22queryString: %22 +  queryString);%0A
     

Remove print to stdout