private static ComponentBean shortComponent(final ProjectComponent component, final JiraBaseUrls jiraBaseUrls) { final ComponentBean bean = new ComponentBean(); bean.self = UriBuilder.fromPath(jiraBaseUrls.restApi2BaseUrl()).path(ComponentResource.class).path(component.getId().toString()).build(); bean.id = component.getId().toString(); bean.description = component.getDescription(); bean.name = component.getName(); return bean; }
/** * * @return null if the input is null */ public static ComponentJsonBean shortBean(final ProjectComponent component, final JiraBaseUrls urls) { if (component == null) { return null; } final ComponentJsonBean bean = new ComponentJsonBean(); bean.self = urls.restApi2BaseUrl() + "component/" + JiraUrlCodec.encode(component.getId().toString()); bean.id = component.getId().toString(); bean.description = component.getDescription(); bean.name = component.getName(); return bean; } }
/** * Convert the specified ProjectComponent to a MutableProjectComponent object and sets its project ID with the given * value. * * @param value ProjectComponent to be converted into a MutableProjectComponent. * @return new instance of MutableProjectComponent with same values as given in the parameter object and with * project ID set */ protected MutableProjectComponent convertToMutableProjectComponent(ProjectComponent value) { return new MutableProjectComponent(value.getId(), value.getName(), value.getDescription(), value.getLead(), value.getAssigneeType(), value.getProjectId()); }
/** * Copy given component * * @param c component to copy * @return new instance of MutableProjectComponent set with values of the given component */ public static MutableProjectComponent copy(final ProjectComponent c) { MutableProjectComponent mutableProjectComponent = new MutableProjectComponent(c.getId(), c.getName(), c.getDescription(), c.getLead(), c.getAssigneeType(), c.getProjectId()); mutableProjectComponent.setGenericValue(c.getGenericValue()); return mutableProjectComponent; }
private List<ChangedValue> buildChangedValues(final ProjectComponent oldComponent, final ProjectComponent component) { final ChangedValuesBuilder changedValues = new ChangedValuesBuilder(); changedValues.addIfDifferent("common.words.name", oldComponent == null ? null : oldComponent.getName(), component.getName()); changedValues.addIfDifferent("common.concepts.description", oldComponent == null ? null : oldComponent.getDescription(), component.getDescription()); changedValues.addIfDifferent("admin.projects.component.lead", oldComponent == null ? null : (oldComponent.getComponentLead() == null ? null : oldComponent.getComponentLead().getUsername()), component.getComponentLead() == null ? null : component.getComponentLead().getUsername()); changedValues.addIfDifferent("admin.projects.default.assignee", oldComponent == null ? null : pre(oldComponent.getAssigneeType()), pre(component.getAssigneeType())); return changedValues.build(); }
@Override public Map<String, Object> fieldMapFrom(final ProjectComponent projectComponent) { return new FieldMap("id", projectComponent.getId()) .add("project", projectComponent.getProjectId()) .add("name", projectComponent.getName()) .add("description", projectComponent.getDescription()) // URL is currently not included in the object // .add("url", projectComponent.getXxx()) .add("lead", projectComponent.getLead()) .add("assigneetype", projectComponent.getAssigneeType()); }
private StatsMarkup generateComponentsMarkup(final Object input, final String url, final I18nHelper i18n) { if (input != null) { final String name; final String desc; if (input instanceof ProjectComponent) { final ProjectComponent component = (ProjectComponent) input; name = component.getName(); desc = component.getDescription(); } else { final GenericValue gv = (GenericValue) input; name = gv.getString("name"); desc = gv.getString("description"); } final String html = makeMarkupForCellWithHtmlUnsafeDescriptionAndText(name, desc, url); final List<String> classes = CollectionBuilder.list("default_image", "default_image_component"); return new StatsMarkup(html, classes); } else { final String html = makeMarkupForCellWithHtmlSafeText(i18n.getText("gadget.filterstats.component.nocomponent"), url); return new StatsMarkup(html); } }
public static ComponentBean fullComponent(ProjectComponent component, Project project, JiraBaseUrls jiraBaseUrls, UserManager userManager, AvatarService avatarService, PermissionManager permissionManager, ProjectManager projectManager, JiraAvatarSupport jiraAvatarSupport) { final ComponentBean bean = shortComponent(component, jiraBaseUrls); bean.description = component.getDescription(); bean.project = project.getKey(); bean.projectId = project.getId(); final long assigneeType = project.getAssigneeType() == null ? AssigneeTypes.PROJECT_LEAD : project.getAssigneeType(); final String lead = component.getLead(); final ApplicationUser user = userManager.getUserByKeyEvenWhenUnknown(lead); final ApplicationUser projectLeadUser = userManager.getUserByName(project.getLeadUserName()); final String projectLeadUserKey = (projectLeadUser == null) ? null :projectLeadUser.getKey(); if (user != null) { bean.lead = new UserBeanBuilder(jiraBaseUrls, jiraAvatarSupport).user(user).buildShort(); } populateAssignee(bean, component, projectLeadUserKey, assigneeType, jiraBaseUrls, userManager, permissionManager, projectManager, jiraAvatarSupport); return bean; }