/** * {@code fromProject}의 {@code fromBranch}에서 보낸 가장 최근 코드보내기 요청을 찾는다. * * <p>fromProject와 toProject가 같은 수도 있다고 가정한다. {@code fromProject}가 fork 프로젝트 일때는 upstream으로 보낸 * 코드보내기 요청을 포함하여 찾는다. * * <p>when: 코드 메뉴의 브랜치 탭에서 브랜치 목록을 보여줄 때 특정 브랜치와 관련있는 코드보내기 요청을 찾을 때 사용한다. * * @param fromProject * @param fromBranch * @return */ public static PullRequest findTheLatestOneFrom(Project fromProject, String fromBranch) { ExpressionList<PullRequest> el = finder.where().eq("fromProject", fromProject).eq("fromBranch", fromBranch); if (fromProject.isForkedFromOrigin()) { el.in("toProject", fromProject, fromProject.originalProject); } else { el.eq("toProject", fromProject); } return el.order().desc("number").setMaxRows(1).findUnique(); }
@Override @PreAuthorize("hasRole('ROLE_ADMIN')") public Project clone() throws CloneNotSupportedException { Project clonedProject = (Project) super.clone(); clonedProject.setExpenses(null); clonedProject.setLocations(null); clonedProject.setRevisions(null); clonedProject.setMakerProjects(null); // clonedProject.setProductGroupMakers(null); Date date = Calendar.getInstance().getTime(); clonedProject.setCreatedDate(date); clonedProject.setLmodDate(date); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss.SSS"); String timeStamp = sdf.format(date); clonedProject.setStatus(ProjectStatus.ONGOING); String projectCode = clonedProject.getProjectCode() + "_" + timeStamp; String projectName = clonedProject.getProjectName() + "_" + timeStamp; projectCode = (projectCode.length() >= 200) ? projectCode.substring(0, 199) : projectCode; projectName = (projectName.length() >= 200) ? projectName.substring(0, 199) : projectName; clonedProject.setProjectCode(projectCode); clonedProject.setProjectName(projectName); clonedProject.setProjectId(null); return clonedProject; }
public Project removeProject(Project project) { getProjects().remove(project); project.setOrg(null); return project; }
public Project addProject(Project project) { getProjects().add(project); project.setOrg(this); return project; }
public static Project create(String name, String folder, String owner) { Project project = new Project(name, folder, User.find.ref(owner)); project.save(); project.saveManyToManyAssociations("members"); return project; }
public Project() { this.id = Project.nextId(); }
/** * 이 객체를 리소스로 반환한다. * * <p>when: 권한검사시 사용 * * @return 리소스 */ @Override public Resource asResource() { boolean isContainerProject = containerType.equals(ResourceType.PROJECT); final Project project; final Resource container; if (isContainerProject) { project = Project.find.byId(Long.parseLong(containerId)); if (project == null) { throw new RuntimeException(messageForLosingProject()); } container = project.asResource(); } else { container = Resource.get(containerType, containerId); if (!(container instanceof GlobalResource)) { project = container.getProject(); if (project == null) { throw new RuntimeException(messageForLosingProject()); } } else { project = null; } } if (project != null) { return new Resource() { @Override public String getId() { return id.toString(); } @Override public Project getProject() { return project; } @Override public ResourceType getType() { return ResourceType.ATTACHMENT; } @Override public Resource getContainer() { return container; } }; } else { return new GlobalResource() { @Override public String getId() { return id.toString(); } @Override public ResourceType getType() { return ResourceType.ATTACHMENT; } @Override public Resource getContainer() { return container; } }; } }