@Override public Collection<PromotionLevel> getSourceItems() { return structureService.getPromotionLevelListForBranch(sourceBranch.getId()); }
@Override public Collection<ValidationStamp> getSourceItems() { return structureService.getValidationStampListForBranch(sourceBranch.getId()); }
@Override public JobRun getTask() { return runListener -> syncTemplateDefinition(branch.getId(), runListener); }
@Override public Collection<PromotionLevel> getTargetItems() { return structureService.getPromotionLevelListForBranch(targetBranch.getId()); }
@Override public Collection<ValidationStamp> getTargetItems() { return structureService.getValidationStampListForBranch(targetBranch.getId()); }
protected JobKey getSvnBuildSyncJobKey(Branch branch) { return SVN_BUILD_SYNC_JOB.getKey(String.valueOf(branch.getId())); }
@Override public List<PromotionRun> getLastPromotionRunsForBuild(Build build) { // Branch Branch branch = build.getBranch(); // Promotion levels for the branch List<PromotionLevel> promotionLevels = getPromotionLevelListForBranch(branch.getId()); // Gets the last promotion run for each promotion level return promotionLevels.stream() .map(promotionLevel -> getLastPromotionRun(build, promotionLevel)) .filter(Optional::isPresent) .map(Optional::get) .collect(Collectors.toList()); }
@Override public boolean isValid() { return super.isValid() && getTemplateDefinition(branch.getId()).isPresent(); } };
private DataFetcher branchPromotionLevelsFetcher() { return environment -> { Object source = environment.getSource(); if (source instanceof Branch) { Branch branch = (Branch) source; return structureService.getPromotionLevelListForBranch(branch.getId()); } else { return Collections.emptyList(); } }; }
@Override public Optional<Build> getEarliestBuild(NoConfig data, Branch branch, SVNLocation location, SVNLocation firstCopy, SVNBranchConfigurationProperty branchConfigurationProperty) { // Checks the path if (StringUtils.equals(branchConfigurationProperty.getCuredBranchPath(), location.getPath())) { String buildName = String.valueOf(location.getRevision()); return structureService.findBuildAfterUsingNumericForm(branch.getId(), buildName); } else { return Optional.empty(); } } }
private JobKey getBranchSyncJobKey(Branch branch) { return ARTIFACTORY_BUILD_SYNC_JOB.getKey(branch.getId().toString()); }
private void onDeleteValidationStamp(Event event) { // Gets the validation stamp ID int validationStampId = event.getIntValue("validation_stamp_id"); // Branch Branch branch = event.getEntity(ProjectEntityType.BRANCH); // Gets all promotion levels for this branch List<PromotionLevel> promotionLevels = structureService.getPromotionLevelListForBranch(branch.getId()); // Checks all promotion levels promotionLevels.forEach(promotionLevel -> cleanPromotionLevel(promotionLevel, validationStampId)); }
@Override public List<LinkDefinition<Branch>> getLinkDefinitions() { return Collections.singletonList( LinkDefinitions.link( "_download", branch -> MvcUriComponentsBuilder.on(SVNController.class).download( branch.getId(), "" ), (branch, rc) -> rc.isProjectFunctionGranted(branch, ProjectConfig.class) && svnService.getSVNRepository(branch).isPresent() ) ); }
@Override public Optional<Build> getEarliestBuild(RevisionPattern data, Branch branch, SVNLocation location, SVNLocation firstCopy, SVNBranchConfigurationProperty branchConfigurationProperty) { // Checks the path if (StringUtils.equals(branchConfigurationProperty.getCuredBranchPath(), location.getPath())) { return structureService.findBuild( branch.getId(), build -> { OptionalLong oRevision = getRevision(data, build, branchConfigurationProperty); return oRevision.isPresent() && oRevision.getAsLong() >= location.getRevision(); }, BuildSortDirection.FROM_OLDEST ); } else { return Optional.empty(); } } }
private void onNewValidationRun(Event event) { // Passed validation? ValidationRun validationRun = event.getEntity(ProjectEntityType.VALIDATION_RUN); if (Objects.equals( validationRun.getLastStatus().getStatusID(), ValidationRunStatusID.STATUS_PASSED)) { // Branch Branch branch = event.getEntity(ProjectEntityType.BRANCH); // Build Build build = event.getEntity(ProjectEntityType.BUILD); // Gets all promotion levels for this branch List<PromotionLevel> promotionLevels = structureService.getPromotionLevelListForBranch(branch.getId()); // Gets all validation stamps for this branch List<ValidationStamp> validationStamps = structureService.getValidationStampListForBranch(branch.getId()); // Gets the promotion levels which have an auto promotion property promotionLevels.forEach(promotionLevel -> checkPromotionLevel(build, promotionLevel, validationStamps)); } }
@Override public Branch update(Branch branch, BranchBulkUpdateRequest request) { // Replacement function Function<String, String> replacementFn = replacementFn(request.getReplacements()); // Description update Branch updatedBranch = branch.withDescription( replacementFn.apply(branch.getDescription()) ); structureService.saveBranch(updatedBranch); // Updating doCopy(branch, updatedBranch, replacementFn, new SyncPolicy( SyncPolicy.TargetPresentPolicy.REPLACE, SyncPolicy.UnknownTargetPolicy.IGNORE )); // Reloads the branch return structureService.getBranch(branch.getId()); }
@Override public Event deleteBranch(Branch branch) { return Event.of(DELETE_BRANCH) .withProject(branch.getProject()) .with("branch", branch.getName()) .with("branch_id", branch.getId().toString()) .get(); }
protected BranchTemplateSyncResult applyMissingPolicy(Branch branch, TemplateSynchronisationAbsencePolicy absencePolicy) { if (branch.isDisabled()) { return BranchTemplateSyncResult.ignored(branch.getName()); } else { switch (absencePolicy) { case DELETE: structureService.deleteBranch(branch.getId()); return BranchTemplateSyncResult.deleted(branch.getName()); case DISABLE: default: structureService.saveBranch(branch.withDisabled(true)); return BranchTemplateSyncResult.disabled(branch.getName()); } } }
@Override public List<Link> links(SVNChangeLog changeLog, ResourceContext resourceContext) { return resourceContext.links() .link("_revisions", on(SVNController.class).changeLogRevisions(changeLog.getUuid())) .link("_issues", on(SVNController.class).changeLogIssues(changeLog.getUuid()), changeLog.getRepository().getConfiguredIssueService() != null) .link("_files", on(SVNController.class).changeLogFiles(changeLog.getUuid())) .link("_changeLogFileFilters", on(SCMController.class).getChangeLogFileFilters(changeLog.getProject().getId())) .link("_diff", on(SVNController.class).diff(null)) .link("_exportFormats", on(SVNController.class).changeLogExportFormats(changeLog.getBranch().getId())) .link("_exportIssues", on(SVNController.class).changeLog(new IssueChangeLogExportRequest())) .page( "_page", "extension/svn/changelog?from=%d&to=%d", changeLog.getFrom().getBuild().id(), changeLog.getTo().getBuild().id() ) .build(); }