WorkflowSchemeBean asBean(AssignableWorkflowScheme parent, DraftWorkflowScheme child) { final WorkflowSchemeBean bean = new WorkflowSchemeBean(); bean.setName(parent.getName()); bean.setDescription(parent.getDescription()); WorkflowScheme scheme = child != null ? child : parent; bean.setDefaultWorkflow(scheme.getConfiguredDefaultWorkflow()); bean.setIssueTypeMappings(asIssueTypeMap(scheme)); bean.setId(scheme.getId()); bean.setDraft(scheme.isDraft()); bean.setDefaultWorkflow(scheme.getActualDefaultWorkflow()); final IssueTypeBeanBuilder builder = new IssueTypeBeanBuilder().context(info).jiraBaseUrls(jiraBaseUrls); bean.setIssueTypes( Maps.uniqueIndex( Collections2.transform( issueTypeManager.getIssueTypes(), new Function<IssueType, IssueTypeJsonBean>() { @Override public IssueTypeJsonBean apply(IssueType issueType) { return builder.issueType(issueType).build(); } }), new Function<IssueTypeJsonBean, String>() { @Override public String apply(IssueTypeJsonBean issueType) { return issueType.getId(); } })); if (child != null) { bean.setLastModifiedUser(beanForUser(child.getLastModifiedUser())); bean.setLastModified(formatter.forLoggedInUser().format(child.getLastModifiedDate())); bean.setOriginalIssueTypeMappings(asIssueTypeMap(parent)); bean.setSelf(getUrlForParent(parent).path("draft").build()); bean.setOriginalDefaultWorkflow(child.getParentScheme().getActualDefaultWorkflow()); } else { bean.setSelf(getUrlForParent(parent).build()); } return bean; }
private UriBuilder getUrlForParent(AssignableWorkflowScheme scheme) { return info.getBaseUriBuilder() .path(WorkflowSchemeResource.class) .path(String.valueOf(scheme.getId())); }