List of usage examples for org.apache.commons.collections CollectionUtils select
public static void select(Collection inputCollection, Predicate predicate, Collection outputCollection)
From source file:com.dp2345.dao.impl.ParameterGroupDaoImpl.java
/** * ???/*w w w. j a va 2 s .co m*/ * * @param parameterGroup * ? * @return ? */ @Override public ParameterGroup merge(ParameterGroup parameterGroup) { Assert.notNull(parameterGroup); Set<Parameter> excludes = new HashSet<Parameter>(); CollectionUtils.select(parameterGroup.getParameters(), new Predicate() { public boolean evaluate(Object object) { Parameter parameter = (Parameter) object; return parameter != null && parameter.getId() != null; } }, excludes); List<Parameter> parameters = parameterDao.findList(parameterGroup, excludes); for (int i = 0; i < parameters.size(); i++) { Parameter parameter = parameters.get(i); String jpql = "select product from Product product join product.parameterValue parameterValue where index(parameterValue) = :parameter"; List<Product> products = entityManager.createQuery(jpql, Product.class) .setFlushMode(FlushModeType.COMMIT).setParameter("parameter", parameter).getResultList(); for (Product product : products) { product.getParameterValue().remove(parameter); if (i % 20 == 0) { super.flush(); super.clear(); } } } return super.merge(parameterGroup); }
From source file:com.dp2345.service.impl.PluginServiceImpl.java
public List<PaymentPlugin> getPaymentPlugins(final boolean isEnabled) { List<PaymentPlugin> result = new ArrayList<PaymentPlugin>(); CollectionUtils.select(paymentPlugins, new Predicate() { public boolean evaluate(Object object) { PaymentPlugin paymentPlugin = (PaymentPlugin) object; return paymentPlugin.getIsEnabled() == isEnabled; }/* ww w . ja v a 2 s . c om*/ }, result); Collections.sort(result); return result; }
From source file:com.safetys.framework.jmesa.core.filter.SimpleRowFilter.java
public Collection<?> filterItems(Collection<?> items, Limit limit) { FilterSet filterSet = limit.getFilterSet(); boolean filtered = filterSet.isFiltered(); if (filtered) { Collection<?> collection = new ArrayList<Object>(); Map<Filter, FilterMatcher> filterMatchers = getFilterMatchers(items, filterSet); Predicate filterPredicate = getPredicate(filterMatchers, filterSet); CollectionUtils.select(items, filterPredicate, collection); return collection; }// ww w . java2 s .c o m return items; }
From source file:com.dp2345.service.impl.PluginServiceImpl.java
public List<StoragePlugin> getStoragePlugins(final boolean isEnabled) { List<StoragePlugin> result = new ArrayList<StoragePlugin>(); CollectionUtils.select(storagePlugins, new Predicate() { public boolean evaluate(Object object) { StoragePlugin storagePlugin = (StoragePlugin) object; return storagePlugin.getIsEnabled() == isEnabled; }/*from www .j a v a 2 s . com*/ }, result); Collections.sort(result); return result; }
From source file:net.shopxx.service.impl.PluginServiceImpl.java
public List<PaymentPlugin> getPaymentPlugins(final boolean isEnabled) { List<PaymentPlugin> result = new ArrayList<PaymentPlugin>(); CollectionUtils.select(paymentPlugins, new Predicate() { public boolean evaluate(Object object) { PaymentPlugin paymentPlugin = (PaymentPlugin) object; return paymentPlugin.getIsEnabled() == isEnabled; }/*from www.j av a2s . c om*/ }, result); Collections.sort(result); return result; }
From source file:com.dp2345.service.impl.GoodsServiceImpl.java
@Override @Transactional/*from w w w. java2s. c o m*/ @CacheEvict(value = { "product", "productCategory", "review", "consultation" }, allEntries = true) public Goods update(Goods goods) { Assert.notNull(goods); Set<Product> excludes = new HashSet<Product>(); CollectionUtils.select(goods.getProducts(), new Predicate() { public boolean evaluate(Object object) { Product product = (Product) object; return product != null && product.getId() != null; } }, excludes); List<Product> products = productDao.findList(goods, excludes); for (Product product : products) { staticService.delete(product); } Goods pGoods = super.update(goods); goodsDao.flush(); if (pGoods.getProducts() != null) { for (Product product : pGoods.getProducts()) { staticService.build(product); } } return pGoods; }
From source file:com.googlecode.jtiger.modules.ecside.table.callback.ProcessRowsCallback.java
public Collection filterRows(TableModel model, Collection rows) throws Exception { boolean filtered = model.getLimit().isFiltered(); boolean cleared = model.getLimit().isCleared(); if (!filtered || cleared) { return rows; }/* w ww . jav a2 s.c om*/ if (filtered) { Collection collection = new ArrayList(); FilterPredicate filterPredicate = new FilterPredicate(model); CollectionUtils.select(rows, filterPredicate, collection); return collection; } return rows; }
From source file:net.shopxx.service.impl.PluginServiceImpl.java
public List<StoragePlugin> getStoragePlugins(final boolean isEnabled) { List<StoragePlugin> result = new ArrayList<StoragePlugin>(); CollectionUtils.select(storagePlugins, new Predicate() { public boolean evaluate(Object object) { StoragePlugin storagePlugin = (StoragePlugin) object; return storagePlugin.getIsEnabled() == isEnabled; }// w w w . j a v a2s .c om }, result); Collections.sort(result); return result; }
From source file:gov.nih.nci.cabig.caaers.web.ae.AdditionalInformationTab.java
@Override public Map<String, Object> referenceData(HttpServletRequest request, ExpeditedAdverseEventInputCommand command) { Map<String, Object> refdata = super.referenceData(command); Map<String, List<AdditionalInformationDocument>> documents = new HashMap<String, List<AdditionalInformationDocument>>(); Integer additionalInformationId = command.getAeReport().getAdditionalInformation().getId(); List<AdditionalInformationDocument> additionalInformationDocuments = additionalInformationDocumentService .findByAdditionalInformationId(additionalInformationId); String baseName = "aeReport.additionalInformation"; for (final AdditionalInformationDocumentType documentType : AdditionalInformationDocumentType.values()) { List<AdditionalInformationDocument> select = new ArrayList<AdditionalInformationDocument>(); CollectionUtils.select(additionalInformationDocuments, new Predicate() { public boolean evaluate(Object o) { AdditionalInformationDocument additionalInformationDocument = (AdditionalInformationDocument) o; return additionalInformationDocument.getAdditionalInformationDocumentType() .equals(documentType); }//from ww w. j a va2s. c om }, select); documents.put(String.format("%s.%s", baseName, documentType.getCode()), select); } refdata.put("documents", documents); refdata.put("additionalInformationId", additionalInformationId); return refdata; }
From source file:net.sourceforge.fenixedu.domain.phd.ExternalPhdProgram.java
public static List<ExternalPhdProgram> readExternalPhdProgramsForCollaborationType( final PhdIndividualProgramCollaborationType type) { List<ExternalPhdProgram> phdProgramList = new ArrayList<ExternalPhdProgram>(); CollectionUtils.select(Bennu.getInstance().getExternalPhdProgramsSet(), new Predicate() { @Override//from w ww.j a v a 2 s .co m public boolean evaluate(Object arg0) { return ((ExternalPhdProgram) arg0).isForCollaborationType(type); } }, phdProgramList); return phdProgramList; }