/** * Check whether component with specified name is stored. * * @param name component name, null will cause IllegalArgumentException * @param projectId project ID * @return true if new name is stored */ public boolean containsName(String name, Long projectId) { return store.containsName(name, projectId); }
@Override public Collection<ProjectComponent> load(@Nonnull final Long projectId) { return sortByComponentNames(CachingProjectComponentStore.this.delegateStore.findAllForProject(projectId)); } }
public Long findProjectIdForComponent(Long id) throws EntityNotFoundException { return store.findProjectIdForComponent(id); }
/** * Removes the component from the persistent storage and a cache. * * @param componentId the id of the component to delete * @throws EntityNotFoundException if component does not exist (maybe was removed previously :-) */ public void delete(Long componentId) throws EntityNotFoundException { ProjectComponent component = null; if (componentId != null) { component = delegateStore.find(componentId); } delegateStore.delete(componentId); if (componentId != null) { componentIdToComponentMap.remove(componentId); } if (component != null) { projectIdToComponentsMap.remove(component.getProjectId()); } }
/** * Find the component with the specified ID * * @param id component ID to search for * @return ProjectComponent with the specified ID * @throws EntityNotFoundException if the component is not found */ public ProjectComponent find(Long id) throws EntityNotFoundException { return convertToProjectComponent(store.find(id)); }
public ProjectComponent getProjectComponent(final Long projectComponentId) { return store.getProjectComponent(projectComponentId); }
public Collection<ProjectComponent> findAll() { return convertToProjectComponents(store.findAll()); }
public ProjectComponent findByComponentName(Long projectId, String componentName) { MutableProjectComponent pc; try { pc = store.findByComponentName(projectId, componentName); return pc == null ? null : convertToProjectComponent(pc); } catch (EntityNotFoundException e) { return null; } }
public Collection<ProjectComponent> findByComponentNameCaseInSensitive(String componentName) { return convertToProjectComponents(store.findByComponentNameCaseInSensitive(componentName)); }
/** * Retrieve a collection of components - where the lead of each component is * the specified user. * * @param userName the lead user name * @return collection of components - where the lead of each component is the specified user */ public Collection<ProjectComponent> findComponentsByLead(String userName) { ApplicationUser appUser = userManager.getUserByName(userName); if (appUser == null) { return Collections.emptyList(); } return store.findComponentsBylead(appUser.getKey()); }
/** * Delete the component. * * @param componentId component id * @throws EntityNotFoundException if the component is not found */ public void delete(Long componentId) throws EntityNotFoundException { ProjectComponent projectComponent = null; if (componentId != null) { projectComponent = find(componentId); } store.delete(componentId); if (componentId != null) { eventPublisher.publish(new ProjectComponentDeletedEvent(projectComponent)); } }
@Override public CacheObject<ProjectComponent> load(@Nonnull final Long id) { try { return new CacheObject<ProjectComponent>(CachingProjectComponentStore.this.delegateStore.find(id)); } catch (EntityNotFoundException e) { return CacheObject.NULL(); } } }
/** * Find all components associated with the project with the ID specified * * @param projectId ID of project to search for * @return collection of ProjectComponent objects associated with the project with the ID specified */ public Collection<ProjectComponent> findAllForProject(Long projectId) { return convertToProjectComponents(store.findAllForProject(projectId)); }
@Override public Collection<String> findAllUniqueNamesForProjects(Collection<Long> projectIds) { Set<String> uniqueNames = Sets.newTreeSet(ProjectComponentComparator.COMPONENT_NAME_COMPARATOR); for (Long projectId : projectIds) { Collection<MutableProjectComponent> projectComponents = store.findAllForProject(projectId); if (projectComponents != null) { for (MutableProjectComponent component : projectComponents) { uniqueNames.add(component.getName()); } } } return uniqueNames; }
@Override @SuppressWarnings("unchecked") public Collection<String> findAllUniqueNamesForProjectObjects(Collection<Project> projects) { Set<String> uniqueNames = Sets.newTreeSet(ProjectComponentComparator.COMPONENT_NAME_COMPARATOR); for (Project project : projects) { Collection<MutableProjectComponent> projectComponents = store.findAllForProject(project.getId()); if (projectComponents != null) { for (MutableProjectComponent component : projectComponents) { uniqueNames.add(component.getName()); } } } return uniqueNames; }