Package org.lab41.dendrite.metagraph

Examples of org.lab41.dendrite.metagraph.MetaGraphTx


        Set<String> graphNames = new TreeSet<>();

        MetaGraphTx tx = metaGraphService.buildTransaction().readOnly().start();

        try {
            UserMetadata userMetadata = tx.getOrCreateUser(authentication);

            for (GraphMetadata graphMetadata: userMetadata.getGraphs()) {
                graphNames.add(graphMetadata.getId().toString());
            }
        } finally {
            tx.commit();
        }
View Full Code Here


    @PreAuthorize("hasPermission(#jobId, 'job', 'admin')")
    @RequestMapping(value = "/jobs/{jobId}", method = RequestMethod.DELETE)
    @ResponseBody
    public DeleteJobResponse deleteJob(@PathVariable String jobId) throws NotFound {
        MetaGraphTx tx = metaGraphService.newTransaction();
        DeleteJobResponse deleteJobResponse;

        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            if (jobMetadata == null) {
                throw new NotFound(JobMetadata.class, jobId);
            }

            tx.deleteJob(jobMetadata);

            deleteJobResponse = new DeleteJobResponse();
        } catch (Throwable t) {
            tx.rollback();
            throw t;
        }
View Full Code Here

    }

    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ExceptionHandler(NotFound.class)
    public ErrorResponse handleNotFound(NotFound notFound) {
        return new ErrorResponse(notFound.getLocalizedMessage());
    }
View Full Code Here

    }

    @ResponseStatus(HttpStatus.BAD_REQUEST)
    @ExceptionHandler(BindingException.class)
    public ErrorResponse handleBindingException(BindingException bindingException) {
        return new ErrorResponse(bindingException.getLocalizedMessage());
    }
View Full Code Here

    }

    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ExceptionHandler(CannotDeleteCurrentBranchException.class)
    public ErrorResponse handleCannotDeleteCurrentBranch() {
        return new ErrorResponse("cannot delete current branch");
    }
View Full Code Here

            List<GetJobResponse> jobs = new ArrayList<>();

            for (ProjectMetadata projectMetadata : userMetadata.getProjects()) {
                for (JobMetadata jobMetadata : projectMetadata.getJobs()) {
                    jobs.add(new GetJobResponse(jobMetadata));
                }
            }

            getJobsResponse = new GetJobsResponse(jobs);
        } catch (Throwable t) {
View Full Code Here

            JobMetadata jobMetadata = tx.getJob(jobId);
            if (jobMetadata == null) {
                throw new NotFound(JobMetadata.class, jobId);
            }

            return new GetJobResponse(jobMetadata);
        } finally {
            tx.commit();
        }
    }
View Full Code Here

                throw new NotFound(ProjectMetadata.class, projectId);
            }

            List<GetJobResponse> jobs = new ArrayList<>();
            for (JobMetadata jobMetadata : project.getJobs()) {
                jobs.add(new GetJobResponse(jobMetadata));
            }

            return new GetJobsResponse(jobs);
        } finally {
            tx.commit();
View Full Code Here

    @ResponseBody
    public GetJobsResponse getJobs(Principal principal) {

        // This needs to be a read/write transaction as we might make a user.
        MetaGraphTx tx = metaGraphService.buildTransaction().start();
        GetJobsResponse getJobsResponse;

        try {
            UserMetadata userMetadata = tx.getOrCreateUser(principal);

            List<GetJobResponse> jobs = new ArrayList<>();

            for (ProjectMetadata projectMetadata : userMetadata.getProjects()) {
                for (JobMetadata jobMetadata : projectMetadata.getJobs()) {
                    jobs.add(new GetJobResponse(jobMetadata));
                }
            }

            getJobsResponse = new GetJobsResponse(jobs);
        } catch (Throwable t) {
            tx.rollback();
            throw t;
        }
View Full Code Here

            List<GetJobResponse> jobs = new ArrayList<>();
            for (JobMetadata jobMetadata : project.getJobs()) {
                jobs.add(new GetJobResponse(jobMetadata));
            }

            return new GetJobsResponse(jobs);
        } finally {
            tx.commit();
        }
    }
View Full Code Here

TOP

Related Classes of org.lab41.dendrite.metagraph.MetaGraphTx

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.