Examples of MetaGraphTx


Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    protected void setJobState(JobMetadata.Id jobId, String state) {
        setJobState(jobId, state, null);
    }

    protected void setJobState(JobMetadata.Id jobId, String state, String msg) {
        MetaGraphTx tx = metaGraphService.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setState(state);
            jobMetadata.setMessage(msg);

            if (state.equals(JobMetadata.DONE)) {
                jobMetadata.setProgress(1.0f);
            }

            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    }

    @RequestMapping(value = "/users", method = RequestMethod.GET)
    @ResponseBody
    public GetUsersResponse getUsers() {
        MetaGraphTx tx = metaGraphService.buildTransaction().readOnly().start();

        try {
            List<GetUserResponse> users = new ArrayList<>();

            for (UserMetadata userMetadata : tx.getUsers()) {
                users.add(new GetUserResponse(userMetadata));
            }

            return new GetUsersResponse(users);
        } finally {
            tx.commit();
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

            throw e;
        }
    }

    protected void setJobProgress(JobMetadata.Id jobId, float progress) {
        MetaGraphTx tx = metaGraphService.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setProgress(progress);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    @RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
    @ResponseBody
    public GetUserResponse getUser(@PathVariable String userId) throws NotFound {

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

        try {
            UserMetadata userMetadata = tx.getUser(userId);

            if (userMetadata == null) {
                throw new NotFound(UserMetadata.class, userId);
            }

            return new GetUserResponse(userMetadata);
        } finally {
            tx.commit();
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    public JobMetadata.Id getJobId() {
        return jobId;
    }

    protected void setJobName(JobMetadata.Id jobId, String name) {
        MetaGraphTx tx = metaGraph.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setName(name);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    protected void setJobState(JobMetadata.Id jobId, String state) {
        setJobState(jobId, state, null);
    }

    protected void setJobState(JobMetadata.Id jobId, String state, String msg) {
        MetaGraphTx tx = metaGraph.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setState(state);
            jobMetadata.setMessage(msg);

            if (state.equals(JobMetadata.DONE)) {
                jobMetadata.setProgress(1.0f);
            }

            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

            throw e;
        }
    }

    protected void setJobProgress(JobMetadata.Id jobId, float progress) {
        MetaGraphTx tx = metaGraph.newTransaction();
        try {
            JobMetadata jobMetadata = tx.getJob(jobId);
            jobMetadata.setProgress(progress);
            tx.commit();
        } catch (TitanException e) {
            logger.debug("exception", e);
            throw e;
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    @RequestMapping(value = "/branches", method = RequestMethod.GET)
    @ResponseBody
    public GetBranchesResponse getBranches(Principal principal) {

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

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

            List<GetBranchResponse> branches = new ArrayList<>();

            for (ProjectMetadata projectMetadata : userMetadata.getProjects()) {
                for (BranchMetadata branchMetadata : projectMetadata.getBranches()) {
                    branches.add(new GetBranchResponse(branchMetadata));
                }
            }

            getBranchesResponse = new GetBranchesResponse(branches);
        } catch (Throwable t) {
            tx.rollback();
            throw t;
        }

        tx.commit();

        return getBranchesResponse;
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    @PreAuthorize("hasPermission(#branchId, 'branch', 'admin')")
    @RequestMapping(value = "/branches/{branchId}", method = RequestMethod.GET)
    @ResponseBody
    public GetBranchResponse getBranch(@PathVariable String branchId) throws NotFound {

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

        try {
            BranchMetadata branchMetadata = tx.getBranch(branchId);
            if (branchMetadata == null) {
                throw new NotFound(BranchMetadata.class, branchId);
            }

            return new GetBranchResponse(branchMetadata);
        } finally {
            tx.commit();
        }
    }
View Full Code Here

Examples of org.lab41.dendrite.metagraph.MetaGraphTx

    @PreAuthorize("hasPermission(#branchId, 'branch', 'admin')")
    @RequestMapping(value = "/branches/{branchId}", method = RequestMethod.DELETE)
    @ResponseBody
    public DeleteBranchResponse deleteBranch(@PathVariable String branchId) throws IOException, GitAPIException, CannotDeleteCurrentBranchException, NotFound {

        MetaGraphTx tx = metaGraphService.newTransaction();

        try {
            BranchMetadata branchMetadata = tx.getBranch(branchId);
            if (branchMetadata == null) {
                throw new NotFound(BranchMetadata.class, branchId);
            }

            ProjectMetadata projectMetadata = branchMetadata.getProject();
            if (projectMetadata == null) {
                throw new NotFound(ProjectMetadata.class);
            }

            Git git = historyService.projectGitRepository(projectMetadata);

            String branchName = branchMetadata.getName();

            tx.deleteBranch(branchMetadata);

            try {
                git.branchDelete()
                        .setBranchNames(branchName)
                        .call();
            } finally {
                git.close();
            }

        } catch (Throwable e) {
            tx.rollback();
            throw e;
        }

        tx.commit();

        return new DeleteBranchResponse();
    }
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.