Examples of DendriteGraph


Examples of org.lab41.dendrite.metagraph.DendriteGraph

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/jung/betweenness-centrality", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> jungBetweennessCentrality(@PathVariable String graphId) throws Exception {

        Map<String, Object> response = new HashMap<>();

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            response.put("status", "error");
            response.put("msg", "missing graph metadata '" + graphId + "'");
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/jung/closeness-centrality", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> jungClosenessCentrality(@PathVariable String graphId) throws Exception {

        Map<String, Object> response = new HashMap<>();

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            response.put("status", "error");
            response.put("msg", "missing graph metadata '" + graphId + "'");
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/jung/eigenvector-centrality", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> jungEigenvectorCentrality(@PathVariable String graphId) throws Exception {

        Map<String, Object> response = new HashMap<>();

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            response.put("status", "error");
            response.put("msg", "missing graph metadata '" + graphId + "'");
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

            response.put("status", "error");
            response.put("msg", result.toString());
            return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
        }

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            response.put("status", "error");
            response.put("msg", "missing graph metadata '" + graphId + "'");
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

                "name:A",
                0);

        branchCommitSubsetJob.run();

        DendriteGraph dstGraph = metaGraph.getGraph(branchCommitSubsetJob.getDstGraphId());
        Assert.assertNotNull(dstGraph);

        DendriteGraphTx dstTx = dstGraph.newTransaction();

        try {
            Vertex dstAVertex = dstTx.getVertices("name", "A").iterator().next();
            Assert.assertNotNull(dstAVertex);
            Assert.assertEquals(dstAVertex.getProperty("name"), "A");
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

                "name:A",
                1);

        branchCommitSubsetJob.run();

        DendriteGraph dstGraph = metaGraph.getGraph(branchCommitSubsetJob.getDstGraphId());
        Assert.assertNotNull(dstGraph);

        DendriteGraphTx dstTx = dstGraph.newTransaction();

        try {
            Vertex dstAVertex = dstTx.getVertices("name", "A").iterator().next();
            Assert.assertNotNull(dstAVertex);
            Assert.assertEquals(dstAVertex.getProperty("name"), "A");
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

                "name:A",
                2);

        branchCommitSubsetJob.run();

        DendriteGraph dstGraph = metaGraph.getGraph(branchCommitSubsetJob.getDstGraphId());
        Assert.assertNotNull(dstGraph);

        DendriteGraphTx dstTx = dstGraph.newTransaction();

        try {
            Vertex dstAVertex = dstTx.getVertices("name", "A").iterator().next();
            Assert.assertNotNull(dstAVertex);
            Assert.assertEquals(dstAVertex.getProperty("name"), "A");
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

            GraphMetadata graphMetadata = tx.getGraph(graphId);
            if (graphMetadata == null) {
                throw new NotFound(GraphMetadata.class, graphId);
            }

            DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);

            DendriteGraphTx dendriteGraphTx = graph.buildTransaction().readOnly().start();

            try {
                Map<Object, Object> verticesMap = new HashMap<>();
                Map<Object, Object> edgesMap = new HashMap<>();
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

                + " job " + jobId
                + " " + Thread.currentThread().getName());

        setJobState(jobId, JobMetadata.RUNNING);

        DendriteGraph srcGraph = metaGraph.getGraph(srcGraphId);
        DendriteGraph dstGraph = metaGraph.getGraph(dstGraphId);

        try {
            copyIndices(srcGraph, dstGraph);
            copyGraph(srcGraph, dstGraph);

            // Update the branch to point the new graph.
            MetaGraphTx tx = metaGraph.newTransaction();
            try {
                BranchMetadata branchMetadata = tx.getBranch(branchId);
                branchMetadata.setGraph(tx.getGraph(dstGraph.getId()));
                tx.commit();
            } catch (Throwable t) {
                tx.rollback();
                throw t;
            }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.DendriteGraph

        logger.debug("receiving file: '" +  file.getOriginalFilename() + "'");
        logger.debug("file format: '" +  format + "'");
        logger.debug("search keys: '" + searchKeys + "'");

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            response.put("status", "error");
            response.put("msg", "cannot find graph '" + graphId + "'");
            return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
        }

        try {
            // extract search indices from client JSON
            JSONObject jsonKeys = new JSONObject(searchKeys);
            JSONArray jsonVertices = jsonKeys.getJSONArray("vertices");
            JSONArray jsonEdges = jsonKeys.getJSONArray("edges");

            // build search indices for vertices
            for (int i = 0; i < jsonVertices.length(); ++i){
              JSONObject jsonVertex = jsonVertices.getJSONObject(i);
              String key = jsonVertex.getString("name");
              String type = jsonVertex.getString("type");

              // create the search index (if it doesn't already exist and isn't a reserved key)
              if (graph.getType(key) == null && !RESERVED_KEYS.contains(key)) {
                  Class cls;
                  List<Parameter> parameters = new ArrayList<>();

                  if (type.equals("string")) {
                      cls = String.class;
                      parameters.add(Parameter.of(Mapping.MAPPING_PREFIX, Mapping.STRING));
                  } else if (type.equals("text")) {
                      cls = String.class;
                      parameters.add(Parameter.of(Mapping.MAPPING_PREFIX, Mapping.TEXT));
                  } else if (type.equals("integer")) {
                      cls = Integer.class;
                  } else if (type.equals("float")) {
                      cls = FullFloat.class;
                  } else if (type.equals("double")) {
                      cls = FullDouble.class;
                  } else if (type.equals("geocoordinate")) {
                      cls = Geoshape.class;
                  } else {
                      graph.rollback();
                      response.put("status", "error");
                      response.put("msg", "unknown type '" + type + "'");
                      return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
                  }

                  graph.makeKey(key)
                          .dataType(cls)
                          .indexed(Vertex.class)
                          .indexed(DendriteGraph.INDEX_NAME, Vertex.class, parameters.toArray(new Parameter[parameters.size()]))
                          .make();
              }
            }

            // build search indices for edges
            for (int i = 0; i < jsonEdges.length(); ++i){
              JSONObject jsonEdge = jsonEdges.getJSONObject(i);
              String key = jsonEdge.getString("name");
              String type = jsonEdge.getString("type");

              // create the search index (if it doesn't already exist and isn't a reserved key)
              if (graph.getType(key) == null && !RESERVED_KEYS.contains(key)) {
                  Class cls;
                  List<Parameter> parameters = new ArrayList<>();

                  if (type.equals("string")) {
                      cls = String.class;
                      parameters.add(Parameter.of(Mapping.MAPPING_PREFIX, Mapping.STRING));
                  } else if (type.equals("text")) {
                      cls = String.class;
                      parameters.add(Parameter.of(Mapping.MAPPING_PREFIX, Mapping.TEXT));
                  } else if (type.equals("integer")) {
                      cls = Integer.class;
                  } else if (type.equals("float")) {
                      cls = FullFloat.class;
                  } else if (type.equals("double")) {
                      cls = FullDouble.class;
                  } else if (type.equals("geocoordinate")) {
                      cls = Geoshape.class;
                  } else {
                      graph.rollback();
                      response.put("status", "error");
                      response.put("msg", "unknown type '" + type + "'");
                      return new ResponseEntity<>(response, HttpStatus.NOT_FOUND);
                  }

                  graph.makeKey(key)
                          .dataType(cls)
                          .indexed(Edge.class)
                          .indexed(DendriteGraph.INDEX_NAME, Edge.class, parameters.toArray(new Parameter[parameters.size()]))
                          .make();
              }
            }

            // commit the indices
            graph.commit();

            InputStream inputStream = file.getInputStream();
            if (format.equalsIgnoreCase("GraphSON")) {
                GraphSONReader.inputGraph(graph, inputStream);
            } else if (format.equalsIgnoreCase("GraphML")) {
                GraphMLReader.inputGraph(graph, inputStream);
            } else if (format.equalsIgnoreCase("GML")) {
                GMLReader.inputGraph(graph, inputStream);
            } else if (format.equalsIgnoreCase("FaunusGraphSON")) {
                FaunusGraphSONReader.inputGraph(graph, inputStream);
            } else {
                graph.rollback();

                response.put("status", "error");
                response.put("msg", "unknown format '" + format + "'");
                inputStream.close();
                return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
            }
            inputStream.close();
        } catch (Throwable t) {
            t.printStackTrace();

            graph.rollback();

            response.put("status", "error");
            response.put("msg", "exception: " + t.toString());

            return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.