List of usage examples for org.apache.commons.collections CollectionUtils collect
public static Collection collect(Iterator inputIterator, Transformer transformer)
From source file:org.squashtest.tm.service.internal.requirement.CustomRequirementVersionManagerServiceImpl.java
@Override public Collection<Long> findBindedMilestonesIdForMassModif(List<Long> reqVersionIds) { Collection<Milestone> milestones = null; for (Long reqVersionId : reqVersionIds) { Set<Milestone> mil = requirementVersionDao.findOne(reqVersionId).getMilestones(); if (milestones != null) { // keep only milestone that in ALL selected requirementVersion milestones.retainAll(mil);/*from w w w.ja v a2 s. c o m*/ } else { // populate the collection for the first time milestones = new ArrayList<>(mil); } } filterLockedAndPlannedStatus(milestones); return CollectionUtils.collect(milestones, new Transformer() { @Override public Object transform(Object milestone) { return ((Milestone) milestone).getId(); } }); }
From source file:org.squashtest.tm.service.internal.testautomation.AutomatedSuiteManagerServiceImpl.java
/** * * @see org.squashtest.tm.service.testautomation.AutomatedSuiteManagerService#delete(org.squashtest.tm.domain.testautomation.AutomatedSuite) *///from w w w. ja va 2s . c om @SuppressWarnings("unchecked") @Override // security handled in the code public void delete(AutomatedSuite suite) { PermissionsUtils.checkPermission(permissionService, suite.getExecutionExtenders(), DELETE); List<AutomatedExecutionExtender> toremove = new ArrayList<>(suite.getExecutionExtenders()); suite.getExecutionExtenders().clear(); List<Execution> execs = new ArrayList<>(CollectionUtils.collect(toremove, new ExecutionCollector())); deletionHandler.deleteExecutions(execs); autoSuiteDao.delete(suite); }
From source file:org.squashtest.tm.service.internal.testcase.CustomTestCaseModificationServiceImpl.java
@Override public Collection<Long> findBindedMilestonesIdForMassModif(List<Long> testCaseIds) { Collection<Milestone> milestones = null; for (Long testCaseId : testCaseIds) { Set<Milestone> mil = testCaseDao.findById(testCaseId).getMilestones(); if (milestones != null) { //keep only milestone that in ALL selected tc milestones.retainAll(mil);/*from w ww . j a va2 s . c om*/ } else { //populate the collection for the first time milestones = new ArrayList<>(mil); } } filterLockedAndPlannedStatus(milestones); return CollectionUtils.collect(milestones, new Transformer() { @Override public Object transform(Object milestone) { return ((Milestone) milestone).getId(); } }); }
From source file:org.squashtest.tm.web.internal.controller.customfield.CustomFieldController.java
@RequestMapping(value = "/tags/{boundEntity}", method = RequestMethod.GET) @ResponseBody//from ww w. ja v a 2 s.c o m public List<String> getPossibleTagValues(@PathVariable("boundEntity") String boundEntity) { List<Long> projectIds = (List<Long>) CollectionUtils.collect(projectFinder.findAllOrderedByName(), new Transformer() { @Override public Object transform(Object input) { return ((GenericProject) input).getId(); } }); return customFieldManager.getAvailableTagsForEntity(boundEntity, projectIds); }
From source file:org.squashtest.tm.web.internal.controller.report.ReportController.java
public List<String> getPossibleTagValues(String boundEntity) { List<Long> projectIds = (List<Long>) CollectionUtils.collect(projectFinder.findAllOrderedByName(), new Transformer() { @Override// ww w.j a va 2s . com public Object transform(Object input) { return ((GenericProject) input).getId(); } }); return customFieldFinder.getAvailableTagsForEntity(boundEntity, projectIds); }
From source file:org.squashtest.tm.web.internal.controller.users.TeamController.java
@SuppressWarnings("unchecked") @RequestMapping(value = TEAM_ID_URL + "/non-members", headers = "Accept=application/json") @ResponseBody//from ww w . j a va2s .c om public Collection<UserModel> getNonMembers(@PathVariable(TEAM_ID) long teamId) { List<User> nonMembers = service.findAllNonMemberUsers(teamId); return CollectionUtils.collect(nonMembers, new UserModelCreator()); }
From source file:org.squashtest.tm.web.internal.controller.users.UserController.java
@RequestMapping(value = USER_ID_URL + "/non-associated-teams", headers = "Accept=application/json") @ResponseBody/*from w ww.ja va 2s . com*/ public Map<String, Object> getNonAssociatedTeams(@PathVariable(USER_ID) long userId) { LOGGER.info("Find teams where user #{} is not a member.", userId); Map<String, Object> result = new HashMap<>(); long teamTot = teamFinder.countAll(); if (teamTot <= 0) { result.put("status", "no-team"); } else { List<Team> nonAssociatedTeams = service.findAllNonAssociatedTeams(userId); if (nonAssociatedTeams.isEmpty()) { result.put("status", "no-more-teams"); } else { result.put("status", "ok"); result.put("teams", CollectionUtils.collect(nonAssociatedTeams, new TeamModelCreator())); } } return result; }
From source file:org.squashtest.tm.web.internal.interceptor.ExcludeRequestInterceptorWrapper.java
/** * @param excludedExtensions//from ww w . ja v a2 s. co m * the excludedExtensions to set */ @SuppressWarnings("unchecked") public void setExcludedExtensions(String[] excludedExtensions) { Assert.parameterNotNull(excludedExtensions, "excludedExtensions"); LOGGER.debug("Excluded extensions : {} ({} excluded extensions)", excludedExtensions, excludedExtensions.length); // had to cast to call the right method Collection<String> nonNullExtensions = CollectionUtils.select(Arrays.asList(excludedExtensions), NotNullPredicate.getInstance()); this.excludedExtensions = CollectionUtils.collect(nonNullExtensions, new Transformer() { @Override public Object transform(Object input) { return ((String) input).trim().toLowerCase(); } }); }
From source file:org.squashtest.tm.web.internal.model.json.JsonChartWizardData.java
private void addCustomFields(List<Project> projects) { // NOSONAR not used yet, should be later for (Project project : projects) { List<CustomFieldBinding> cufBindings = cufBindingService .findCustomFieldsForGenericProject(project.getId()); @SuppressWarnings("unchecked") List<CustomField> cufs = (List<CustomField>) CollectionUtils.collect(cufBindings, new Transformer() { @Override//from ww w .java2s . c o m public Object transform(Object input) { return ((CustomFieldBinding) input).getCustomField(); } }); customFields.put(project.getId().toString(), new HashSet<>(cufs)); } }
From source file:script.manager.Printer.java
public static List<String> generateLivePathList() { List<File> files = (List<File>) FileUtils.listFiles(new File(EnvSetter.fetchHomePath()), new String[] { EnvSetter.fetchFileExtension() }, true); List<String> livePathList = (ArrayList<String>) CollectionUtils.collect(files, new Transformer() { @Override/*w w w.ja va 2 s. c o m*/ public String transform(Object input) { try { return ((File) input).getCanonicalPath(); } catch (IOException ex) { LOG.log(Level.SEVERE, null, ex); throw new IllegalStateException(ex); } } }); Collections.sort(livePathList); return livePathList; }