public static Branch of(Project project, NameDescription nameDescription) { return of(project, nameDescription.asState()); }
public Branch update(NameDescriptionState form) { return of(project, form).withId(id).withDisabled(form.isDisabled()); } }
protected Branch createBranchForTemplateInstance(Branch templateBranch, String branchName) { return structureService.newBranch( Branch.of( templateBranch.getProject(), NameDescription.nd( NameDescription.escapeName(branchName), "" ) ) ); }
protected Branch toBranch(ResultSet rs, Function<ID, Project> projectSupplier) throws SQLException { ID projectId = id(rs, "projectId"); ID branchId = id(rs); return Branch.of( projectSupplier.apply(projectId), new NameDescription( rs.getString("name"), rs.getString("description") ) ) .withId(branchId) .withSignature(readSignature(rs)) .withType(getBranchType(branchId)) .withDisabled(rs.getBoolean("disabled")); }
protected Branch doCreateBranch(Project project, NameDescription nameDescription) throws Exception { return asUser().with(project.id(), BranchCreate.class).call(() -> structureService.newBranch( Branch.of(project, nameDescription) )); }
@Override public Branch cloneBranch(Branch sourceBranch, BranchCloneRequest request) { // Replacement function Function<String, String> replacementFn = replacementFn(request.getReplacements()); // Description of the target branch String targetDescription = replacementFn.apply(sourceBranch.getDescription()); // Creates the branch Branch targetBranch = structureService.newBranch( Branch.of( sourceBranch.getProject(), NameDescription.nd(request.getName(), targetDescription) ) ); // Copies the configuration doCopy(sourceBranch, targetBranch, replacementFn, SyncPolicy.COPY); // OK return targetBranch; }
@Override public Project cloneProject(Project sourceProject, ProjectCloneRequest request) { // Replacement function Function<String, String> replacementFn = replacementFn(request.getReplacements()); // Description of the target project String targetProjectDescription = replacementFn.apply(sourceProject.getDescription()); // Creates the project Project targetProject = structureService.newProject( Project.of( NameDescription.nd(request.getName(), targetProjectDescription) ) ); // Copies the properties for the project doCopyProperties(sourceProject, targetProject, replacementFn, SyncPolicy.COPY); // Creates a copy of the branch Branch sourceBranch = structureService.getBranch(request.getSourceBranchId()); String targetBranchName = replacementFn.apply(sourceBranch.getName()); String targetBranchDescription = replacementFn.apply(sourceBranch.getDescription()); Branch targetBranch = structureService.newBranch( Branch.of( targetProject, NameDescription.nd(targetBranchName, targetBranchDescription) ) ); // Configuration of the new branch doCopy(sourceBranch, targetBranch, replacementFn, SyncPolicy.COPY); // OK return targetProject; }