Package org.lab41.dendrite.jobs.jung

Examples of org.lab41.dendrite.jobs.jung.EigenvectorCentralityJob


            GraphMetadata graphMetadata = userMetadata.getGraph(new GraphMetadata.Id(graphId));
            if (graphMetadata == null) {
                return null;
            }

            DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
            if (graph == null) {
                return null;
            }

            List<String> allowableNamespaces = new ArrayList<>();
View Full Code Here


        if (result.hasErrors()) {
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }

        DendriteGraph graph = metaGraphService.getDendriteGraph(graphId);
        if (graph == null) {
            return new ResponseEntity<>(HttpStatus.NOT_FOUND);
        }

        logger.debug("exporting graph '" + graphId + "'");

        String format = item.getFormat();
        HttpHeaders headers = new HttpHeaders();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

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

        try {
            if (format.equalsIgnoreCase("GraphSON")) {
                headers.setContentType(new MediaType("application", "vnd.rexster+json"));
                headers.set("Content-Disposition", "attachment; filename=\"graph.json\"");
View Full Code Here

        } catch (Throwable t) {
            metaGraphTx.rollback();
            throw t;
        }

        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);
        }

        logger.debug("saving graph '" + graphId + "'");

        // extract the storage location for the history
        String format = item.getFormat();

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

        try {
            try {
                String path;
View Full Code Here

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/{algorithm}", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> startJob(@PathVariable String graphId, @PathVariable String algorithm) 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

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/titan-degrees", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> startJob(@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

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/faunus-degrees", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> startFaunusJob(@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

    @RequestMapping(value = "/api/graphs/{graphId}/analysis/snap/{algorithm}", method = RequestMethod.POST)
    public ResponseEntity<Map<String, Object>> startJob(@PathVariable String graphId, @PathVariable String algorithm) 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

        String format = item.getFormat();
        HttpHeaders headers = new HttpHeaders();
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();

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

        try {
            if (format.equalsIgnoreCase("GraphSON")) {
                headers.setContentType(new MediaType("application", "vnd.rexster+json"));
                headers.set("Content-Disposition", "attachment; filename=\"graph.json\"");

                GraphSONWriter.outputGraph(tx, byteArrayOutputStream);
            } else if (format.equalsIgnoreCase("GraphML")) {
                headers.setContentType(new MediaType("application", "vnd.rexster+xml"));
                headers.set("Content-Disposition", "attachment; filename=\"graph.xml\"");

                GraphMLWriter.outputGraph(tx, byteArrayOutputStream);
            } else if (format.equalsIgnoreCase("GML")) {
                headers.setContentType(new MediaType("application", "vnd.rexster+gml"));
                headers.set("Content-Disposition", "attachment; filename=\"graph.gml\"");

                GMLWriter.outputGraph(tx, byteArrayOutputStream);
            } else {
                tx.rollback();

                return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
            }
        } catch (IOException e) {
            tx.rollback();

            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }

        tx.commit();

        return new ResponseEntity<>(byteArrayOutputStream.toByteArray(), headers, HttpStatus.OK);
    }
View Full Code Here

        logger.debug("saving graph '" + graphId + "'");

        // extract the storage location for the history
        String format = item.getFormat();

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

        try {
            try {
                String path;

                if (format.equalsIgnoreCase("GraphSON")) {
                    path = new File(git.getRepository().getWorkTree(), graphId + ".json").getPath();
                    GraphSONWriter.outputGraph(tx, path);
                } else if (format.equalsIgnoreCase("GraphML")) {
                    path = new File(git.getRepository().getWorkTree(), graphId + ".xml").getPath();
                    GraphMLWriter.outputGraph(tx, path);
                } else if (format.equalsIgnoreCase("GML")) {
                    path = new File(git.getRepository().getWorkTree(), graphId + ".gml").getPath();
                    GMLWriter.outputGraph(tx, path);
                } else {
                    tx.rollback();

                    response.put("status", "error");
                    response.put("msg", "unknown format '" + format + "'");
                    return new ResponseEntity<>(response, HttpStatus.BAD_REQUEST);
                }

                git.add()
                        .addFilepattern(".")
                        .call();

                git.commit()
                        .setAuthor(authentication.getName(), "")
                        .setMessage("commit")
                        .call();
            } finally {
                git.close();
            }
        } catch (IOException e) {
            tx.rollback();

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

        tx.commit();

        response.put("status", "ok");

        return new ResponseEntity<>(response, HttpStatus.NO_CONTENT);
    }
View Full Code Here

    @PreAuthorize("hasPermission(#branchId, 'branch', 'admin')")
    @RequestMapping(value = "/api/branches/{branchId}/search", method = RequestMethod.POST)
    public ResponseEntity<String> branchSearch(@PathVariable String branchId,
                                               @RequestBody String body) throws JSONException, UnsupportedEncodingException {

        MetaGraphTx tx = metaGraphService.newTransaction();

        try {
            BranchMetadata branchMetadata = tx.getBranch(branchId);
            if (branchMetadata == null) {
                HttpHeaders responseHeaders = new HttpHeaders();
                responseHeaders.setContentType(MediaType.APPLICATION_JSON);

                JSONObject json = new JSONObject();
                json.put("status", "error");
                json.put("msg", "unknown branch '" + branchId + "'");

                return new ResponseEntity<>(json.toString(), responseHeaders, HttpStatus.BAD_REQUEST);
            }

            GraphMetadata graphMetadata = branchMetadata.getGraph();
            if (graphMetadata == null) {
                HttpHeaders responseHeaders = new HttpHeaders();
                responseHeaders.setContentType(MediaType.APPLICATION_JSON);

                JSONObject json = new JSONObject();
                json.put("status", "error");
                json.put("msg", "branch '" + branchId + "' does not point at a graph!");

                return new ResponseEntity<>(json.toString(), responseHeaders, HttpStatus.BAD_REQUEST);
            }

            return graphSearch(graphMetadata.getId().toString(), body);
        } finally {
            tx.rollback();
        }
    }
View Full Code Here

TOP

Related Classes of org.lab41.dendrite.jobs.jung.EigenvectorCentralityJob

Copyright © 2018 www.massapicom. 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.