List of usage examples for org.apache.commons.collections.set ListOrderedSet addAll
public boolean addAll(Collection coll)
From source file:net.sourceforge.vulcan.core.support.ProjectImporterImpl.java
@Override public void createProjectsForUrl(String startUrl, String username, String password, boolean createSubprojects, NameCollisionResolutionMode nameCollisionResolutionMode, String[] schedulerNames, Set<String> labels, ProjectImportStatusDto statusDto) throws ConfigException, StoreException, DuplicateNameException { final List<RepositoryAdaptorPlugin> repositoryPlugins = pluginManager .getPlugins(RepositoryAdaptorPlugin.class); final List<BuildToolPlugin> buildToolPlugins = pluginManager.getPlugins(BuildToolPlugin.class); final ListOrderedSet urls = new ListOrderedSet(); urls.add(startUrl);// w w w. ja va 2 s. com final List<ProjectConfigDto> newProjects = new ArrayList<ProjectConfigDto>(); final List<ProjectRepositoryConfigurator> repoConfigurators = new ArrayList<ProjectRepositoryConfigurator>(); final List<String> existingProjectNames = new ArrayList<String>(stateManager.getProjectConfigNames()); for (int i = 0; i < urls.size(); i++) { final String url = (String) urls.get(i); if (statusDto != null) { statusDto.setCurrentUrl(url); statusDto.setNumProjectsCreated(newProjects.size()); statusDto.setNumRemainingModules(urls.size() - i); } final ProjectConfigDto projectConfig = new ProjectConfigDto(); projectConfig.setSchedulerNames(schedulerNames); final ProjectRepositoryConfigurator repoConfigurator = createRepositoryConfiguratorForUrl( repositoryPlugins, projectConfig, url, username, password); File buildSpecFile = null; final ProjectBuildConfigurator buildConfigurator; try { buildSpecFile = downloadBuildSpecFile(repoConfigurator); final Document xmlDocument = tryParse(buildSpecFile); buildConfigurator = createBuildToolConfigurator(buildToolPlugins, projectConfig, url, buildSpecFile, xmlDocument); } finally { deleteIfPresent(buildSpecFile); } final boolean shouldCreate = configureProject(projectConfig, repoConfigurator, buildConfigurator, url, existingProjectNames, nameCollisionResolutionMode, createSubprojects, labels); if (createSubprojects) { final List<String> subprojectUrls = buildConfigurator.getSubprojectUrls(); makeAbsolute(url, subprojectUrls); if (subprojectUrls != null) { urls.addAll(subprojectUrls); } } if (shouldCreate) { existingProjectNames.add(projectConfig.getName()); newProjects.add(projectConfig); repoConfigurators.add(repoConfigurator); log.info("Configured project " + projectConfig.getName()); } else { log.info("Skipping project " + projectConfig.getName()); } } final Map<String, PluginConfigDto> pluginConfigs = new HashMap<String, PluginConfigDto>(); for (int i = 0; i < newProjects.size(); i++) { final ProjectConfigDto projectConfig = newProjects.get(i); try { final String pluginId = projectConfig.getRepositoryAdaptorPluginId(); PluginConfigDto pluginConfig = pluginConfigs.get(pluginId); if (pluginConfig == null) { pluginConfig = (PluginConfigDto) pluginManager.getPluginConfigInfo(pluginId).copy(); } if (repoConfigurators.get(i).updateGlobalConfig(pluginConfig)) { pluginConfigs.put(pluginId, pluginConfig); } } catch (PluginNotConfigurableException ignore) { } catch (PluginNotFoundException e) { throw new RuntimeException(e); } } final ConfigUpdatesDto updates = new ConfigUpdatesDto(); updates.setNewProjectConfigs(newProjects); if (!pluginConfigs.isEmpty()) { updates.setModifiedPluginConfigs(pluginConfigs); } try { stateManager.applyMultipleUpdates(updates); } catch (PluginNotFoundException e) { // Very unlikely... throw new RuntimeException(e); } log.info("Successfully imported project(s) for URL " + startUrl); }
From source file:org.dentaku.services.metadata.validator.ValidatingVisitorBase.java
private ListOrderedSet getVisitMethodsForClass(Class c) { ListOrderedSet result = (ListOrderedSet) superclassCache.get(c); if (result == null) { result = new ListOrderedSet(); superclassCache.put(c, result);/*ww w. ja v a 2 s . com*/ Class current = c; while (current != null) { Class interfaces[] = current.getInterfaces(); try { Method method = getClass().getMethod("visit", new Class[] { current, Object.class }); if (!methodFilter.contains(method)) { result.add(method); } } catch (NoSuchMethodException e) { // do nothing and loop } for (int i = 0; i < interfaces.length; i++) { Class thisInterface = interfaces[i]; result.addAll(getVisitMethodsForClass(thisInterface)); } current = current.getSuperclass(); } } return result; }
From source file:org.encuestame.persistence.dao.imp.AccountDaoImp.java
public List<UserAccount> getPublicProfiles(final String keyword, final Integer maxResults, final Integer startOn) { final List<UserAccount> searchResult = (List<UserAccount>) getHibernateTemplate() .execute(new HibernateCallback() { public Object doInHibernate(org.hibernate.Session session) { List<UserAccount> searchResult = new ArrayList<UserAccount>(); long start = System.currentTimeMillis(); final Criteria criteria = session.createCriteria(UserAccount.class); //only shared profiles. criteria.add(Restrictions.eq("sharedProfile", Boolean.TRUE)); // limit results if (maxResults != null) { criteria.setMaxResults(maxResults.intValue()); }/*w w w .j a v a 2 s.c o m*/ // start on page x if (startOn != null) { criteria.setFirstResult(startOn.intValue()); } searchResult = (List<UserAccount>) fetchMultiFieldQueryParserFullText(keyword, new String[] { "completeName, username" }, UserAccount.class, criteria, new SimpleAnalyzer()); final List listAllSearch = new LinkedList(); listAllSearch.addAll(searchResult); // Fetch result by phrase final List<UserAccount> phraseFullTestResult = (List<UserAccount>) fetchPhraseFullText( keyword, "completeName", UserAccount.class, criteria, new SimpleAnalyzer()); log.debug("phraseFullTestResult:{" + phraseFullTestResult.size()); listAllSearch.addAll(phraseFullTestResult); // Fetch result by wildcard final List<UserAccount> wildcardFullTextResult = (List<UserAccount>) fetchWildcardFullText( keyword, "completeName", UserAccount.class, criteria, new SimpleAnalyzer()); log.debug("wildcardFullTextResult:{" + wildcardFullTextResult.size()); listAllSearch.addAll(wildcardFullTextResult); // Fetch result by prefix final List<UserAccount> prefixQueryFullTextResuslts = (List<UserAccount>) fetchPrefixQueryFullText( keyword, "completeName", UserAccount.class, criteria, new SimpleAnalyzer()); log.debug("prefixQueryFullTextResuslts:{" + prefixQueryFullTextResuslts.size()); listAllSearch.addAll(prefixQueryFullTextResuslts); // Fetch fuzzy results final List<UserAccount> fuzzyQueryFullTextResults = (List<UserAccount>) fetchFuzzyQueryFullText( keyword, "completeName", UserAccount.class, criteria, new SimpleAnalyzer(), SIMILARITY_VALUE); log.debug("fuzzyQueryFullTextResults: {" + fuzzyQueryFullTextResults.size()); listAllSearch.addAll(fuzzyQueryFullTextResults); log.debug("listAllSearch size:{" + listAllSearch.size()); // removing duplcates final ListOrderedSet totalResultsWithoutDuplicates = ListOrderedSet .decorate(new LinkedList()); totalResultsWithoutDuplicates.addAll(listAllSearch); /* * Limit results if is enabled. */ List<UserAccount> totalList = totalResultsWithoutDuplicates.asList(); if (maxResults != null && startOn != null) { log.debug("split to " + maxResults + " starting on " + startOn + " to list with size " + totalList.size()); totalList = totalList.size() > maxResults ? totalList.subList(startOn, maxResults) : totalList; } long end = System.currentTimeMillis(); log.debug("UserAccount{ totalResultsWithoutDuplicates:{" + totalList.size() + " items with search time:" + (end - start) + " milliseconds"); return totalList; } }); return searchResult; }
From source file:org.encuestame.persistence.dao.imp.CommentDao.java
@SuppressWarnings("unchecked") public List<Comment> getCommentsByKeyword(final String keyword, final Integer maxResults, final Long[] excludes) { log.info("keyword " + keyword); List<Comment> searchResult = (List) getHibernateTemplate().execute(new HibernateCallback() { @SuppressWarnings("deprecation") public Object doInHibernate(org.hibernate.Session session) { List<Comment> searchResult = new ArrayList<Comment>(); long start = System.currentTimeMillis(); final Criteria criteria = session.createCriteria(Comment.class); // limit results if (maxResults != null) { criteria.setMaxResults(maxResults.intValue()); }/* www . j av a 2s . c o m*/ if (excludes != null && excludes.length > 0) { for (int i = 0; i < excludes.length; i++) { log.debug("excluding hashtag... " + excludes[i]); criteria.add(Restrictions.ne("commentId", excludes[i])); } } searchResult = (List<Comment>) fetchMultiFieldQueryParserFullText(keyword, new String[] { "comment" }, Comment.class, criteria, new SimpleAnalyzer()); final List<Comment> listAllSearch = new LinkedList<Comment>(); listAllSearch.addAll(searchResult); // Fetch result by phrase final List<Comment> phraseFullTestResult = (List<Comment>) fetchPhraseFullText(keyword, "comment", Comment.class, criteria, new SimpleAnalyzer()); log.debug("phraseFullTestResult comment:{" + phraseFullTestResult.size()); listAllSearch.addAll(phraseFullTestResult); // Fetch result by wildcard final List<Comment> wildcardFullTextResult = (List<Comment>) fetchWildcardFullText(keyword, "comment", Comment.class, criteria, new SimpleAnalyzer()); log.debug("wildcardFullTextResult comment:{" + wildcardFullTextResult.size()); listAllSearch.addAll(wildcardFullTextResult); // Fetch result by prefix final List<Comment> prefixQueryFullTextResuslts = (List<Comment>) fetchPrefixQueryFullText(keyword, "comment", Comment.class, criteria, new SimpleAnalyzer()); log.debug("prefixQueryFullTextResuslts comment:{" + prefixQueryFullTextResuslts.size()); listAllSearch.addAll(prefixQueryFullTextResuslts); // Fetch fuzzy results final List<Comment> fuzzyQueryFullTextResults = (List<Comment>) fetchFuzzyQueryFullText(keyword, "comment", Comment.class, criteria, new SimpleAnalyzer(), SIMILARITY_VALUE); log.debug("fuzzyQueryFullTextResults comment: {" + fuzzyQueryFullTextResults.size()); listAllSearch.addAll(fuzzyQueryFullTextResults); log.debug("listAllSearch size:{" + listAllSearch.size()); // removing duplcates final ListOrderedSet totalResultsWithoutDuplicates = ListOrderedSet.decorate(new LinkedList()); totalResultsWithoutDuplicates.addAll(listAllSearch); /* * Limit results if is enabled. */ List<Comment> totalList = totalResultsWithoutDuplicates.asList(); if (maxResults != null) { log.debug("split to " + maxResults + " to list with size " + totalList.size()); totalList = totalList.size() > maxResults ? totalList.subList(0, maxResults) : totalList; } long end = System.currentTimeMillis(); //log.debug("HashTag{ totalResultsWithoutDuplicates:{" // + totalList.size() + " items with search time:" // + (end - start) + " milliseconds"); return totalList; } }); return searchResult; }