Java Code Examples for org.apache.commons.collections4.ListUtils#intersection()

The following examples show how to use org.apache.commons.collections4.ListUtils#intersection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultSearchService.java    From archiva with Apache License 2.0 6 votes vote down vote up
@Override
public GroupIdList getAllGroupIds( List<String> selectedRepos )
    throws ArchivaRestServiceException
{
    List<String> observableRepos = getObservableRepos();
    List<String> repos = ListUtils.intersection( observableRepos, selectedRepos );
    if ( repos == null || repos.isEmpty() )
    {
        return new GroupIdList( Collections.<String>emptyList() );
    }
    try
    {
        return new GroupIdList( new ArrayList<>( repositorySearch.getAllGroupIds( getPrincipal(), repos ) ) );
    }
    catch ( RepositorySearchException e )
    {
        log.error( e.getMessage(), e );
        throw new ArchivaRestServiceException( e.getMessage(), e );
    }

}
 
Example 2
Source File: ActionListWithPersonComplex.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 从可见的application中获取一份ids<br/>
 * 从可启动的process中获取一份ids <br/>
 * 两份ids的交集,这样避免列示只有application没有可以启动process的应用
 */
private List<String> list(Business business, EffectivePerson effectivePerson, List<String> roles,
		List<String> identities, List<String> units) throws Exception {
	List<String> ids = this.listFromApplication(business, effectivePerson, roles, identities, units);
	List<String> fromProcessIds = this.listFromProcess(business, effectivePerson, roles, identities, units);
	return ListUtils.intersection(ids, fromProcessIds);
}
 
Example 3
Source File: ListTools.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
public static <T> List<T> includesExcludes(List<T> list, List<T> includes, List<T> excludes) {
	if (isEmpty(list)) {
		return list;
	}
	if (isNotEmpty(includes)) {
		list = ListUtils.intersection(list, includes);
	}
	if (isNotEmpty(excludes)) {
		list = ListUtils.subtract(list, excludes);
	}
	return list;
}
 
Example 4
Source File: EraseContentProcessPlatform.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
protected void run() throws Exception {
	logger.print("clean {} content data, start at {}.", name, DateTools.format(start));
	this.classNames = ListUtils.intersection(this.classNames,
			(List<String>) Config.resource(Config.RESOURCE_CONTAINERENTITYNAMES));
	StorageMappings storageMappings = Config.storageMappings();
	File persistence = new File(Config.dir_local_temp_classes(),
			DateTools.compact(this.start) + "_eraseContent.xml");
	PersistenceXmlHelper.write(persistence.getAbsolutePath(), classNames);
	for (int i = 0; i < classNames.size(); i++) {
		Class<? extends JpaObject> cls = (Class<? extends JpaObject>) Class.forName(classNames.get(i));
		EntityManagerFactory emf = OpenJPAPersistence.createEntityManagerFactory(cls.getName(),
				persistence.getName(), PersistenceXmlHelper.properties(cls.getName(), Config.slice().getEnable()));
		EntityManager em = emf.createEntityManager();
		try {
			if (DataItem.class.isAssignableFrom(cls)) {
				logger.print("erase {} content data:{}, total:{}.", name, cls.getName(),
						this.estimateItemCount(em, cls));
				this.eraseItem(cls, em);
			} else {
				logger.print("erase {} content data:{}, total:{}.", name, cls.getName(),
						this.estimateCount(em, cls));
				this.erase(cls, em, storageMappings);
			}
		} finally {
			System.gc();
		}
	}
	Date end = new Date();
	logger.print("erase {} completed at {}, elapsed: {} ms.", name, DateTools.format(end),
			(end.getTime() - start.getTime()));
}
 
Example 5
Source File: PluginExtensionsAndVersionValidatorImpl.java    From gocd with Apache License 2.0 5 votes vote down vote up
private void validateExtensionVersions(ValidationResult validationResult, String extensionType, List<Double> gocdSupportedExtensionVersions, List<String> requiredExtensionVersionsByPlugin) {
    final List<Double> requiredExtensionVersions = requiredExtensionVersionsByPlugin.stream()
            .map(parseToDouble())
            .collect(toList());

    final List<Double> intersection = ListUtils.intersection(gocdSupportedExtensionVersions, requiredExtensionVersions);

    if (intersection.isEmpty()) {
        validationResult.addError(format(UNSUPPORTED_VERSION_ERROR_MESSAGE, extensionType, requiredExtensionVersionsByPlugin, gocdSupportedExtensionVersions));
    }
}
 
Example 6
Source File: ActionListWithPersonLike.java    From o2oa with GNU Affero General Public License v3.0 4 votes vote down vote up
private List<String> list(Business business, EffectivePerson effectivePerson, List<String> roles,
		List<String> identities, List<String> units, String key) throws Exception {
	List<String> ids = this.listFromApplication(business, effectivePerson, roles, identities, units);
	List<String> fromProcessIds = this.listFromProcess(business, effectivePerson, roles, identities, units, key);
	return ListUtils.intersection(ids, fromProcessIds);
}