Search in sources :

Example 6 with HashGraph

use of org.sbpax.impl.HashGraph in project vcell by virtualcell.

the class ModelComparer method createDiff.

public static Graph createDiff(Graph model1, Graph model2) {
    Graph graph = new HashGraph();
    graph.addAll(model1);
    graph.removeAll(model2);
    return graph;
}
Also used : HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) HashGraph(org.sbpax.impl.HashGraph)

Example 7 with HashGraph

use of org.sbpax.impl.HashGraph in project vcell by virtualcell.

the class PCNeighborsRequest method response.

@Override
public PathwayCommonsResponse response() {
    PathwayCommonsResponse response = null;
    try {
        URL url = url();
        URLConnection connection = url.openConnection();
        String text = StringUtil.textFromInputStream(connection.getInputStream());
        if (PathwayCommonsUtil.isErrorResponse(text)) {
            response = new PCErrorResponse(this, PCErrorResponse.errorElement(text));
        } else {
            try {
                Graph graph = new HashGraph();
                Map<String, String> nsMap = new HashMap<String, String>();
                SesameRioUtil.readRDFFromString(text, graph, nsMap, RDFFormat.RDFXML, uriBase);
                response = new PCTextModelResponse(this, text, graph);
            } catch (Throwable t) {
                response = new PCTextResponse(this, text);
            }
        }
    } catch (MalformedURLException e) {
        response = new PCExceptionResponse(this, e);
    } catch (IOException e) {
        response = new PCExceptionResponse(this, e);
    } catch (SAXException e) {
        response = new PCExceptionResponse(this, e);
    } catch (ParserConfigurationException e) {
        response = new PCExceptionResponse(this, e);
    }
    return response;
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) PathwayCommonsResponse(org.vcell.sybil.util.http.pathwaycommons.PathwayCommonsResponse) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection) SAXException(org.xml.sax.SAXException) HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) HashGraph(org.sbpax.impl.HashGraph) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) PCExceptionResponse(org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse)

Example 8 with HashGraph

use of org.sbpax.impl.HashGraph in project vcell by virtualcell.

the class UniProtRDFRequest method response.

public Response response() {
    Response response = null;
    try {
        Graph model = new HashGraph();
        // print out debug messsage to console -------- can be uncommented later.
        // Debug.message(urlRDF());
        URL url = new URL(urlRDF());
        URLConnection connection = url.openConnection();
        Map<String, String> nsMap = new HashMap<String, String>();
        SesameRioUtil.readRDFFromStream(connection.getInputStream(), model, nsMap, RDFFormat.RDFXML, uri());
        response = new ModelResponse(this, model);
    } catch (Exception exception) {
        response = new ExceptionResponse(this, exception);
    }
    return response;
}
Also used : HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) HashGraph(org.sbpax.impl.HashGraph) HashMap(java.util.HashMap) URL(java.net.URL) URLConnection(java.net.URLConnection)

Example 9 with HashGraph

use of org.sbpax.impl.HashGraph in project vcell by virtualcell.

the class PCIDRequest method response.

@Override
public PathwayCommonsResponse response() {
    try {
        URL url = url();
        URLConnection connection = url.openConnection();
        String text = StringUtil.textFromInputStream(connection.getInputStream());
        Graph graph = new HashGraph();
        Map<String, String> nsMap = new HashMap<String, String>();
        SesameRioUtil.readRDFFromString(text, graph, nsMap, RDFFormat.RDFXML, uriBase);
        try {
            return new PCTextModelResponse(this, text, graph);
        } catch (Throwable t) {
            return new PCTextResponse(this, text);
        }
    } catch (MalformedURLException e) {
        return new PCExceptionResponse(this, e);
    } catch (IOException e) {
        return new PCExceptionResponse(this, e);
    } catch (RDFParseException e) {
        return new PCExceptionResponse(this, e);
    } catch (RDFHandlerException e) {
        return new PCExceptionResponse(this, e);
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) HashMap(java.util.HashMap) IOException(java.io.IOException) URL(java.net.URL) URLConnection(java.net.URLConnection) HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) HashGraph(org.sbpax.impl.HashGraph) RDFHandlerException(org.openrdf.rio.RDFHandlerException) PCExceptionResponse(org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse) RDFParseException(org.openrdf.rio.RDFParseException)

Aggregations

Graph (org.openrdf.model.Graph)9 HashGraph (org.sbpax.impl.HashGraph)9 HashMap (java.util.HashMap)5 IOException (java.io.IOException)3 URL (java.net.URL)3 URLConnection (java.net.URLConnection)3 RDFHandlerException (org.openrdf.rio.RDFHandlerException)3 MalformedURLException (java.net.MalformedURLException)2 Resource (org.openrdf.model.Resource)2 Statement (org.openrdf.model.Statement)2 URI (org.openrdf.model.URI)2 RDFParseException (org.openrdf.rio.RDFParseException)2 PCExceptionResponse (org.vcell.sybil.util.http.pathwaycommons.PCExceptionResponse)2 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Vector (java.util.Vector)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 Element (org.jdom.Element)1 Value (org.openrdf.model.Value)1