@Override public String get(ProjectComponent component) { return component.getName(); } }));
public boolean apply(final ProjectComponent input) { return (name.equals(input.getName())); } });
private Collection<String> getComponentNames(Collection<ProjectComponent> components) { Collection<String> componentNames = new HashSet<String>(); for (final ProjectComponent component : components) { componentNames.add(component.getName()); } return componentNames; }
static boolean containsNameIgnoreCase(Collection<ProjectComponent> components, String name) { boolean containsName = false; if (components != null) { for (ProjectComponent component : components) { String componentName = component.getName(); if (name.equalsIgnoreCase(componentName)) { containsName = true; } } } return containsName; }
public String get(final Object input) { try { return projectComponentManager.find((Long) input).getName(); } catch (EntityNotFoundException e) { throw new RuntimeException(e); } } };
public static RemoteComponent[] convertComponentsToRemoteObject(Collection components) { RemoteComponent[] result = new RemoteComponent[components.size()]; int count = 0; for (Iterator iterator = components.iterator(); iterator.hasNext();) { ProjectComponent component = (ProjectComponent) iterator.next(); result[count++] = new RemoteComponent(component.getId().toString(), component.getName()); } return result; }
@Override public String transformFromComponent(final String fieldType, final Object input, final String url) { if (input == null) { return i18nBean.getText("gadget.filterstats.component.nocomponent"); } else { return htmlEncode(((ProjectComponent) input).getName().trim()); } }
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; }
public void populateForMove(Map<String, Object> fieldValuesHolder, Issue originalIssue, Issue targetIssue) { // Preselect components with the same name final Collection<String> currentComponentNames = getComponentNames(originalIssue.getComponentObjects()); final Collection<ProjectComponent> possibleComponents = getComponents(targetIssue.getProjectObject()); final List<Long> componentIds = new LinkedList<Long>(); for (ProjectComponent possibleComponent : possibleComponents) { if (currentComponentNames.contains(possibleComponent.getName())) { componentIds.add(possibleComponent.getId()); } } fieldValuesHolder.put(getId(), new LongIdsValueHolder(componentIds)); }
@Override public RecordRequest apply(final List<ChangedValue> changedValues) { return new RecordRequest(AuditingCategory.PROJECTS, "jira.auditing.project.component.updated") .forObject(AssociatedItem.Type.PROJECT_COMPONENT, component.getName(), component.getId().toString()) .withAssociatedItems(getAssociatedItems(oldComponent, component)) .withChangedValues(changedValues); } });
@Override public RecordRequest onProjectComponentDeletedEvent(final ProjectComponentDeletedEvent event) { final ProjectComponent component = event.getProjectComponent(); return new RecordRequest(AuditingCategory.PROJECTS, "jira.auditing.project.component.deleted") .forObject(AssociatedItem.Type.PROJECT_COMPONENT, component.getName(), component.getId().toString()) .withAssociatedItems(new AffectedProject(getProjectOfComponent(component))); }
public Map<String, String> getComponentsUserLeadsWarning() { final Map<String, String> componentNamesAndURLs = Maps.newHashMap(); for (ProjectComponent component : getComponentsUserLeads()) { UrlBuilder fullURL = newUrlBuilder(); fullURL.addPaths("/plugins/servlet/project-config"); Project project = getProjectManager().getProjectObj(component.getProjectId()); fullURL.addPaths("/" + project.getKey() + "/components"); componentNamesAndURLs.put(component.getName(), fullURL.asUrlString()); } return componentNamesAndURLs; }
@Override public RecordRequest onProjectComponentCreatedEvent(final ProjectComponentCreatedEvent event) { final ProjectComponent component = event.getProjectComponent(); return new RecordRequest(AuditingCategory.PROJECTS, "jira.auditing.project.component.created") .forObject(AssociatedItem.Type.PROJECT_COMPONENT, component.getName(), component.getId().toString()) .withAssociatedItems(getAssociatedItems(component)) .withChangedValues(buildChangedValues(component)); }
/** * 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()); }
@Override public RecordRequest onProjectComponentMergedEvent(final ProjectComponentMergedEvent event) { final ProjectComponent component = event.getProjectComponent(); final ProjectComponent mergedComponent = event.getMergedProjectComponent(); return new RecordRequest(AuditingCategory.PROJECTS, "jira.auditing.project.component.merged") .forObject(AssociatedItem.Type.PROJECT_COMPONENT, component.getName(), component.getId().toString()) .withAssociatedItems(new AffectedProject(getProjectOfComponent(component))) .withChangedValues(buildChangedValues(mergedComponent, component)); }
/** * 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; }
/** * Getter for all the {@link Build}s related to the given {@link ProjectComponent} * * @param component the {@link ProjectComponent} to get all the builds for * @param user the current logged in {@link User} * @return the collection of {@link Build}s */ public Iterable<? extends Build> getBuildsByRelation(ProjectComponent component, User user) { LOGGER.debug("Looking for builds related to component [{}]", component.getName()); return getBuildsByRelation(JqlQueryBuilder.newBuilder().where().project(component.getProjectId()).and().addClause(JqlQueryBuilder .newClauseBuilder().component(component.getId()).buildClause()).endWhere(), user); }
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()); }
@Override public String getNavigatorUrl(final Project project, final Version version, final ProjectComponent component) { final JqlClauseBuilder builder = JqlQueryBuilder.newClauseBuilder().defaultAnd(); if (project != null) { builder.project(project.getKey()); } if (version != null) { builder.fixVersion(version.getName()); } if (component != null) { builder.component(component.getName()); } return searchService.getQueryString(authenticationContext.getUser(), builder.buildQuery()); }