public ProjectComponent get(final Long id) { try { return componentManager.find(id); } catch (EntityNotFoundException e) { return null; } }
@Override void executeOnSuccess() { result = projectComponentManager.findAllForProject(projectId); }
@Override void executeOnSuccess() { try { result = projectComponentManager.create(name, description, lead, AssigneeTypes.PROJECT_DEFAULT, projectId); } catch (IllegalArgumentException e) { LOG.error("Failed to create project component", e); } }
componentNames.addAll(CollectionUtil.transform(projectComponentManager.findAllForProject(projectID), new Function<ProjectComponent, String>() if (CollectionUtils.isNotEmpty(visibleProjects)) componentNames = projectComponentManager.findAllUniqueNamesForProjectObjects(visibleProjects); componentNames = projectComponentManager.findAllUniqueNamesForProjects(validProjectIds);
final Iterable<ProjectComponent> components = projectComponentManager.findAllForProject(project.getId()); for (final ProjectComponent component : components) projectComponentManager.delete(component.getId());
private void swapComponentForAffectedIssues(final JiraServiceContext context, final ProjectComponent component, final ProjectComponent swapComponent) { // Get all issues that reference the component we are going to delete Collection<Long> affectedIssues = projectComponentManager.getIssueIdsWithComponent(component); for (final Long issueId : affectedIssues) { MutableIssue issue = issueManager.getIssueObject(issueId); Collection<ProjectComponent> newComponents = getNewComponents(issue, component, swapComponent); issue.setComponent(newComponents); // Use the backend issue update action to update the issue issueManager.updateIssue(context.getLoggedInUser(), issue, EventDispatchOption.ISSUE_UPDATED, false); } // publish project component merged event if necessary if (!affectedIssues.isEmpty() && swapComponent != null) { eventPublisher.publish(new ProjectComponentMergedEvent(swapComponent, component)); } }
public Collection<ProjectComponent> getAll() { return componentManager.findAll(); } ///CLOVER:ON
/** * Validates newName. Name must be not null and unique. * * @param oldName old name * @param newName new name * @param projectId project ID * @param handler validation and permission check handler */ protected void validateName(Handler handler, String oldName, String newName, Long projectId) { if (StringUtils.isBlank(newName)) { // New component name cannot be null or empty string handler.addErrorKey(FIELD_NAME, KEY_NAME_NOT_SET, null, ErrorCollection.Reason.VALIDATION_FAILED); } else if (!newName.equalsIgnoreCase(oldName) && projectComponentManager.containsName(newName, projectId)) { // You must specify a UNIQUE newName for this component. New name is already being used handler.addErrorKey(FIELD_NAME, KEY_NAME_NOT_UNIQUE, newName, ErrorCollection.Reason.VALIDATION_FAILED); } }
@Override void executeOnSuccess() { try { projectComponentManager.delete(componentId); } catch (EntityNotFoundException e) { if (componentId != null) { addErrorKey(KEY_NO_SUCH_COMPONENT_WITH_ID, componentId.toString(), ErrorCollection.Reason.SERVER_ERROR); } else { addErrorKey(KEY_NO_SUCH_COMPONENT, null, ErrorCollection.Reason.SERVER_ERROR); } } }
Collection<Long> issues = projectComponentManager.getIssueIdsWithComponent(component); return Response.ok(componentIssueCountsBeanFactory.createComponentBean( component, issues.size())).cacheControl(never()).build();
public Results getPossibleValues(final ApplicationUser searcher, final String jqlClauseName, final String valuePrefix, final int maxNumResults) { final List<ProjectComponent> projectComponents = new ArrayList<ProjectComponent>(projectComponentManager.findAll()); // Lets sort the whole list of components by name Collections.sort(projectComponents, new LocaleSensitiveProjectComponentNameComparator(getLocale(searcher))); final ApplicationUser sercherApplicationUser = searcher; final Set<Result> componentValues = new LinkedHashSet<Result>(); for (ProjectComponent component : projectComponents) { if (componentValues.size() == maxNumResults) { break; } // Lets do the cheapest check first final String lowerCaseCompName = component.getName().toLowerCase(); if (StringUtils.isBlank(valuePrefix) || lowerCaseCompName.startsWith(valuePrefix.toLowerCase())) { final Project project = projectManager.getProjectObj(component.getProjectId()); if (project != null && permissionManager.hasPermission(BROWSE_PROJECTS, project, sercherApplicationUser)) { componentValues.add(new Result(component.getName())); } } } return new Results(new ArrayList<Result>(componentValues)); }
@Override public boolean apply(Long componentId) { try { if (UNKNOWN_COMPONENTS_ID.equals(componentId)) { return true; } ProjectComponent component = projectComponentManager.find(componentId); return true; } catch (EntityNotFoundException e) { return false; } } };
private Collection<ProjectComponent> getComponents(Long id) { return projectComponentManager.findAllForProject(id); }
@Override void executeOnSuccess() { try { Long assigneeTypeParam = assigneeType == null ? AssigneeTypes.PROJECT_DEFAULT : assigneeType; result = projectComponentManager.create(name, description, lead, assigneeTypeParam, projectId); } catch (IllegalArgumentException e) { LOG.error("Failed to create project component", e); } }
@Override public Map<String, Object> getAnalytics() { final MapBuilder<String, Object> builder = MapBuilder.newBuilder(); builder.add("issues", ofBizDelegator.getCount(Entity.Name.ISSUE)); builder.add("projects", ofBizDelegator.getCount(Entity.Name.PROJECT)); builder.add("comments", ofBizDelegator.getCount(Entity.Name.COMMENT)); builder.add("customfields", ofBizDelegator.getCount(CustomField.ENTITY_TABLE_NAME)); builder.add("issuetypes", constantsManager.getAllIssueTypeIds().size()); builder.add("status", size(constantsManager.getStatusObjects())); builder.add("resolutions", constantsManager.getResolutionObjects().size()); builder.add("priorities", constantsManager.getPriorityObjects().size()); builder.add("versions", size(versionManager.getAllVersions())); builder.add("components", size(componentManager.findAll())); builder.add("issuesecuritylevels", size(levelManager.getAllIssueSecurityLevels())); builder.add("screens", size(screenManager.getFieldScreens())); builder.add("screensschemes", size(screenSchemeManager.getFieldScreenSchemes())); buildPermissionSchemeInfo(builder); return builder.toMap(); }
public String get(final Object input) { try { return projectComponentManager.find((Long) input).getName(); } catch (EntityNotFoundException e) { throw new RuntimeException(e); } } };
private Long findProjectComponent(final String name, final long projectId) { Collection<ProjectComponent> projectComponents = projectComponentManager.findAllForProject(projectId); try { ProjectComponent projectComponent = Iterables.find(projectComponents, new Predicate<ProjectComponent>() { public boolean apply(final ProjectComponent input) { return (name.equals(input.getName())); } }); return projectComponent.getId(); } catch (NoSuchElementException e) { return null; } }
for (String componentName : componentNames) final ProjectComponent newComponent = projectComponentManager.create(componentName, null, null, AssigneeTypes.PROJECT_DEFAULT, issue.getProjectId()); allComponents.add(newComponent); eventPublisher.publish(new ComponentCreatedInlineEvent(newComponent));
@Override public Object getValueFromLuceneField(String documentValue) { if (documentValue == null) { return null; } long componentId = Long.parseLong(documentValue); if (componentId > 0) { try { // Retrieve current version of ProjectComponentManager ProjectComponentManager projectComponentManager = getProjectComponentManager(); return projectComponentManager.find(componentId); } catch (EntityNotFoundException e) { log.error("Indexes may be corrupt - unable to retrieve component with id '" + componentId + "'."); } } return null; }
public Collection<ProjectComponent> getComponents() { try { return projectComponentManager.findAllForProject(getProject().getId()); } catch (GenericEntityException e) { return Collections.EMPTY_LIST; } }