@Override public boolean apply(@Nullable final ProjectComponent input) { return user.getKey().equals(input.getLead()); } }));
private String findAComponentLead(final Issue issue) { // Loop over the components until we find a non-null component lead for (ProjectComponent component : issue.getComponentObjects()) { String leadKey = component.getLead(); if (leadKey != null) { return leadKey; } } return null; }
public List<NotificationRecipient> getRecipients(IssueEvent event, String argument) { final Issue issue = event.getIssue(); if (issue == null) { return Collections.emptyList(); } final UserManager userManager = ComponentAccessor.getUserManager(); final Set<NotificationRecipient> recipients = new HashSet<NotificationRecipient>(); for (ProjectComponent component : issue.getComponentObjects()) { final String leadKey = component.getLead(); final ApplicationUser lead = userManager.getUserByKey(leadKey); if (lead != null) { recipients.add(new NotificationRecipient(lead)); } else if (leadKey != null) { log.warn("Nonexistent user with key '" + leadKey + "' listed as component lead"); } } return new ArrayList<NotificationRecipient>(recipients); } }
/** * 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; }
return getDefaultAssignee(project, component.getLead());
@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()); }
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; }