@Override public Optional<URI> branchResource() { return this.enrichment.branchResource(); }
@Override public Optional<URI> commitResource() { return this.enrichment.commitResource(); }
@Override public Optional<URI> repositoryResource() { return this.enrichment.repositoryResource(); }
private void processCompletedEnrichment(final EnrichmentContext context, final Set<URI> executions) { final CompletedEnrichment completed=this.completedRepository.completedEnrichmentOfExecution(context.targetExecution().executionId()); if(completed!=null) { LOGGER.trace("{} enrichment is already completed (#{})",context,completed.id()); return; } final ExecutionEnrichment enrichment=context.enrichment(); final List<CompletedEnrichment> potentialEnrichments=this.completedRepository.findCompletedEnrichments(enrichment.repositoryResource().orNull(),enrichment.branchResource().orNull(),enrichment.commitResource().orNull()); if(!potentialEnrichments.isEmpty()) { final CompletedEnrichment delegate = potentialEnrichments.get(0); delegate.executions().addAll(executions); LOGGER.trace("{} enrichment is now completed by enrichment #{}",context,delegate.id()); return; } final CompletedEnrichment newCompleted=CompletedEnrichment.newInstance(enrichment.repositoryResource().orNull(),enrichment.branchResource().orNull(),enrichment.commitResource().orNull()); newCompleted.executions().addAll(executions); this.completedRepository.add(newCompleted); LOGGER.trace("{} enrichment is completed by {}",context,newCompleted); }
private static void populateEnrichedData(final IndividualPropertyHelper helper, final ExecutionEnrichment enrichment) { final Optional<URI> branchResource = enrichment.branchResource(); if(branchResource.isPresent()) { helper. property(CI_FOR_BRANCH). withIndividual(branchResource.get()); } final Optional<URI> commitResource = enrichment.commitResource(); if(commitResource.isPresent()) { helper. property(CI_FOR_COMMIT). withIndividual(commitResource.get()); } }
if(freshContext.requiresRepository() && !freshContext.enrichment().repositoryResource().isPresent()) { if(enrichment.repositoryResource().isPresent()) { createRepository(freshContext, enrichment, repositoryLocation); } else { if(freshContext.requiresBranch() && !freshContext.enrichment().branchResource().isPresent()) { if(enrichment.branchResource().isPresent()) { createBranch(freshContext, enrichment, repositoryLocation,branchName); } else { if(freshContext.requiresCommit() && !freshContext.enrichment().commitResource().isPresent()) { if(enrichment.commitResource().isPresent()) { createCommit(freshContext, enrichment, repositoryLocation, branchName, commitId); } else {
private void createBranch( final EnrichmentContext context, final ExecutionEnrichment enrichment, final URI repositoryLocation, final String branchName) { final URI branchResource = enrichment.branchResource().get(); this.scmService.createBranch( CreateBranchCommand. builder(). withRepositoryLocation(repositoryLocation). withBranchName(branchName). withResource(branchResource). build()); context.setBranchResource(branchResource); LOGGER.debug("Created branch {} ({}) in repository {}",branchName,branchResource,repositoryLocation); }
private void createCommit( final EnrichmentContext context, final ExecutionEnrichment enrichment, final URI repositoryLocation, final String branchName, final String commitId) { final URI commitResource = enrichment.commitResource().get(); this.scmService.createCommit( CreateCommitCommand. builder(). withRepositoryLocation(repositoryLocation). withBranchName(branchName). withCommitId(commitId). withResource(commitResource). build()); context.setCommitResource(commitResource); LOGGER.debug("Created commit {} ({}) in branch {} of repository {}",commitId,commitResource,branchName,repositoryLocation); }
private void createRepository( final EnrichmentContext context, final ExecutionEnrichment enrichment, final URI repositoryLocation) { final URI repositoryResource = enrichment.repositoryResource().get(); this.scmService.createRepository( CreateRepositoryCommand. builder(). withRepositoryLocation(repositoryLocation). withResource(repositoryResource). build()); context.setRepositoryResource(repositoryResource); LOGGER.debug("Created repository {} ({})",repositoryLocation,repositoryResource); }