Package org.kie.internal.executor.api

Examples of org.kie.internal.executor.api.ExecutionResults


                }
                break;
            default:
                logger.error("Unknown " + JobType.class.getSimpleName() + " type (" + jobType.toString() + "), not taking any action");
        }
        ExecutionResults results = new ExecutionResults();
        results.setData("Result", success);
        return results;
    }
View Full Code Here


    protected JobRequest getJobRequest(CommandContext ctx) {
        return (JobRequest) ctx.getData(JOB_REQUEST_KEY);
    }

    protected ExecutionResults getEmptyResult() {
        return new ExecutionResults();
    }
View Full Code Here

 
  private static final Logger logger = LoggerFactory.getLogger(MavenDeployProjectCommand.class);

  @Override
  public ExecutionResults execute(CommandContext ctx) throws Exception {
    ExecutionResults executionResults = new ExecutionResults();
    String deployOutcome = "UNKNOWN";
    String uri = (String) getParameter(ctx, "Uri");
    String branchToBuild = (String) getParameter(ctx, "BranchToBuild");
   
    String projectUri = "default://"+branchToBuild+"@"+uri;
    String gav = (String) getParameter(ctx, "GAV");
    String[] gavElements = gav.split(":");
   
    BeanManager beanManager = CDIUtils.lookUpBeanManager(ctx);
    logger.debug("BeanManager " + beanManager);

        BuildService builder = CDIUtils.createBean(BuildService.class, beanManager);
    logger.debug("Builder " + builder);
   
    IOService ioService = CDIUtils.createBean(IOService.class, beanManager, new NamedLiteral("ioStrategy"));
    logger.debug("IoService " + ioService);
    if (ioService != null) {
      Path projectPath  = ioService.get(URI.create(projectUri));
      logger.debug("Project path is " + projectPath);
     
      ProjectService projectService = CDIUtils.createBean(ProjectService.class, beanManager);
      Project project = projectService.resolveProject(Paths.convert(projectPath));

            BuildResults results = builder.buildAndDeploy(project);

            // dump to debug if enabled
            if (logger.isDebugEnabled()) {
                logger.debug("Errors " + results.getErrorMessages().size());
                logger.debug("Warnings " + results.getWarningMessages().size());
                logger.debug("Info " + results.getInformationMessages().size());
                for (BuildMessage msg : results.getErrorMessages()) {
                    logger.debug("Error " + msg);
                }
            }
            if (results.getErrorMessages().isEmpty()) {
                deployOutcome = "SUCCESSFUL";
            } else {
                deployOutcome = "FAILURE";
            }
            executionResults.setData("Errors", results.getErrorMessages());
            executionResults.setData("Warnings", results.getWarningMessages());
            executionResults.setData("Info", results.getInformationMessages());
            executionResults.setData("GAV", results.getGAV().toString());
    }
    executionResults.setData("MavenDeployOutcome", deployOutcome);
   

    return executionResults;
  }
View Full Code Here

        List<BranchInfo> branchInfos = new ArrayList<BranchInfo>();
        for (String branch : branchNames) {
          branchInfos.add(new BranchInfo("default://"+branch+"@"+gitRepo, branch));
        }

        ExecutionResults results = new ExecutionResults();
        results.setData("Branches", branchInfos);
        return results;
    }
View Full Code Here

 
  private static final Logger logger = LoggerFactory.getLogger(UpdateProjectVersionCommand.class);

  @Override
  public ExecutionResults execute(CommandContext ctx) throws Exception {
    ExecutionResults executionResults = new ExecutionResults();
   
   
    String uri = (String) getParameter(ctx, "Uri");
    String branchToUpdate = (String) getParameter(ctx, "BranchToUpdate");
    String version = (String) getParameter(ctx, "Version");
   
    String projectUri = "default://"+branchToUpdate+"@"+uri;
       
    BeanManager beanManager = CDIUtils.lookUpBeanManager(ctx);
    logger.debug("BeanManager " + beanManager);
   
    POMService pomService = CDIUtils.createBean(POMService.class, beanManager);
    logger.debug("POMService " + pomService);
       
    IOService ioService = CDIUtils.createBean(IOService.class, beanManager, new NamedLiteral("ioStrategy"));
    logger.debug("IoService " + ioService);
    if (ioService != null) {
      Path projectPath  = ioService.get(URI.create(projectUri));
      logger.debug("Project path is " + projectPath);
     
      if (projectPath == null) {
        throw new IllegalArgumentException("Unable to find project location " + projectUri);
      }
     
      ProjectService projectService = CDIUtils.createBean(ProjectService.class, beanManager);
      Project project = projectService.resolveProject(Paths.convert(projectPath));
     
      if (project == null) {
        throw new IllegalArgumentException("Unable to find project " + projectUri);
      }
     
      POM pom = pomService.load(project.getPomXMLPath());
      pom.getGav().setVersion(version);
      pomService.save(project.getPomXMLPath(), pom, null, "Update project version during release");
      executionResults.setData("GAV", pom.getGav().toString());
    }

    return executionResults;
  }
View Full Code Here

        } catch (Exception e) {
            outcome = "failure : " + e.getMessage();
            logger.error("Error when cherry picking commits from {} to {}", fromBranchName, toBranchName, e);
        }

        ExecutionResults results = new ExecutionResults();
        results.setData("CherryPickResult", outcome);

        return results;
    }
View Full Code Here

        ioService.copy(branchOriginPath, branchPath);

        beanManager.fireEvent( new NewBranchEvent( gitRepo, branchName, Paths.convert(branchPath), System.currentTimeMillis() ) );

        ExecutionResults results = new ExecutionResults();
        return results;
    }
View Full Code Here

 
  private static final Logger logger = LoggerFactory.getLogger(ConfigureDevelopmentBranchCommand.class);

  @Override
  public ExecutionResults execute(CommandContext ctx) throws Exception {
    ExecutionResults executionResults = new ExecutionResults();
   
   
    String repository = (String) getParameter(ctx, "GitRepository");
    if (repository.endsWith(".git")) {
      repository = repository.substring(0, repository.length() - 4);
    }
    String branchToUpdate = (String) getParameter(ctx, "BranchName");
    String version = (String) getParameter(ctx, "Version");
    if (version == null) {
      version = "1.0.0-SNAPSHOT";
    } else if (!version.endsWith("-SNAPSHOT")) {
      version = version.concat("-SNAPSHOT");
    }
   
       
    BeanManager beanManager = CDIUtils.lookUpBeanManager(ctx);
    logger.debug("BeanManager " + beanManager);
   
    POMService pomService = CDIUtils.createBean(POMService.class, beanManager);   
    logger.debug("POMService " + pomService);
       
    IOService ioService = CDIUtils.createBean(IOService.class, beanManager, new NamedLiteral("ioStrategy"));
    logger.debug("IoService " + ioService);
    if (ioService != null) {

     
      ProjectService projectService = CDIUtils.createBean(ProjectService.class, beanManager);
 
      RepositoryService repositoryService = CDIUtils.createBean(RepositoryService.class, beanManager);
      logger.debug("RepositoryService " + repositoryService);
     
      if (repositoryService != null) {
         
        Repository repo = repositoryService.getRepository(repository);
       
        Map<String, Object> config = new HashMap<String, Object>();
        config.put("branch", branchToUpdate + "-" + version);
       
        repo = repositoryService.updateRepository(repo, config);
        logger.debug("Updated repository " + repo);
 
        // update all pom.xml files of projects on the dev branch       
        Set<Project> projects = getProjects(repo, ioService, projectService);
       
        for (Project project : projects) {
         
          POM pom = pomService.load(project.getPomXMLPath());
          pom.getGav().setVersion(version);
          pomService.save(project.getPomXMLPath(), pom, null, "Update project version on development branch");
          executionResults.setData(project.getProjectName() "-GAV", pom.getGav().toString());
        }
      }
    }

    return executionResults;
View Full Code Here

        logger.debug("IoService " + ioService);
        if (ioService != null) {
            ioService.delete(ioService.get(URI.create("default://" + branchName + "@" + gitRepo)));
        }

        ExecutionResults results = new ExecutionResults();

        return results;
    }
View Full Code Here

    private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

    @Override
    public ExecutionResults execute(CommandContext commandContext) throws Exception {
        ExecutionResults results = new ExecutionResults();
        String gitRepo = (String) getParameter(commandContext, "GitRepository");
        String branchName = (String) getParameter(commandContext, "BranchName");
        String compareToBranchName = (String) getParameter(commandContext, "CompareToBranchName");
        String fromDate = (String) getParameter(commandContext, "FromDate");

        Date startCommitDate = null;
        if (fromDate != null) {
            startCommitDate = dateFormat.parse(fromDate);
        }

        Set<String> existingCommits = new LinkedHashSet<String>();

        BeanManager beanManager = CDIUtils.lookUpBeanManager(commandContext);
        logger.debug("BeanManager " + beanManager);


        IOService ioService = CDIUtils.createBean(IOService.class, beanManager, new NamedLiteral("ioStrategy"));
        logger.debug("IoService " + ioService);

        Path branchPath = ioService.get(URI.create("git://" + branchName + "@" + gitRepo));

        if (compareToBranchName != null) {
            Path compareToBranchPath = ioService.get(URI.create("git://" + compareToBranchName + "@" + gitRepo));
            VersionAttributeView compareView = ioService.getFileAttributeView( compareToBranchPath, VersionAttributeView.class );
            List<VersionRecord> compareLogs = compareView.readAttributes().history().records();

            for (VersionRecord ccommit : compareLogs) {
                if (startCommitDate != null && startCommitDate.after(ccommit.date())) {
                    break;
                }
                existingCommits.add(ccommit.id());
            }
        }

        VersionAttributeView vinit = ioService.getFileAttributeView( branchPath, VersionAttributeView.class );
        List<VersionRecord> logs = vinit.readAttributes().history().records();

        List<CommitInfo> commits = new ArrayList<CommitInfo>();
        JGitFileSystem fs = (JGitFileSystem)ioService.getFileSystem(branchPath.toUri());
        Collections.reverse(logs);

        for (VersionRecord commit : logs) {

            // check if there are already commits in compare to branch
            if (existingCommits.contains(commit.id())) {
                continue;
            }
            String shortMessage = commit.comment();
            Date commitDate = commit.date();

            if (startCommitDate != null && startCommitDate.after(commitDate)) {
                break;
            }

            List<String> files = getFilesInCommit(fs.gitRepo().getRepository(), JGitUtil.resolveObjectId(fs.gitRepo(), commit.id()));
            CommitInfo commitInfo = new CommitInfo(commit.id(), shortMessage, commit.author(), commitDate, files);
            commits.add(commitInfo);
            logger.debug("Found commit {}", commitInfo);

        }



        String commitsString = dumpToStringCommit(commits);
        Map<String, List<String>> commitsPerFileMap = sortByFileName(commits);

        results.setData("Commits", commits);
        results.setData("CommitsPerFile", commitsPerFileMap);
        results.setData("CommitsPerFileString", dumpToStringFiles(commitsPerFileMap.keySet()));
        results.setData("CommitsPerFileMap", commitsPerFileMap);
        results.setData("CommitsString", commitsString);

        return results;
    }
View Full Code Here

TOP

Related Classes of org.kie.internal.executor.api.ExecutionResults

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.