List of usage examples for org.apache.commons.collections CollectionUtils find
public static Object find(Collection collection, Predicate predicate)
From source file:org.opencastproject.metadata.dublincore.DublinCoreCatalogImpl.java
private boolean hasPropertyValue(EName property, final String language) { if (LANGUAGE_ANY.equals(language)) { return getValuesAsList(property).size() > 0; } else {//w ww. j ava 2 s . c o m return CollectionUtils.find(getValuesAsList(property), new Predicate() { public boolean evaluate(Object o) { return equalLanguage(((CatalogEntry) o).getAttribute(XML_LANG_ATTR), language); } }) != null; } }
From source file:org.openconcerto.sql.model.graph.DatabaseGraph.java
public synchronized Link getForeignLink(final List<SQLField> fk) { if (fk.size() == 0) throw new IllegalArgumentException("empty list"); // result can be null if (!this.foreignLink.containsKey(fk)) { this.foreignLink.put(fk, (Link) CollectionUtils.find(this.getForeignLinks(fk.get(0).getTable()), new LabelPredicate(fk))); }//from ww w. j a v a2s .c om return this.foreignLink.get(fk); }
From source file:org.openlmis.core.domain.EDIFileTemplate.java
@JsonIgnore public String getDateFormatForColumn(final String columnName) { EDIFileColumn column = (EDIFileColumn) CollectionUtils.find(this.columns, new Predicate() { @Override//from w w w. j a v a2 s . c om public boolean evaluate(Object o) { EDIFileColumn fileColumn = (EDIFileColumn) o; return fileColumn.getName().equals(columnName) && fileColumn.getInclude(); } }); return column == null ? null : column.getDatePattern(); }
From source file:org.openlmis.core.domain.ProgramSupported.java
@JsonIgnore public Double getWhoRatioFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils .find(this.getProgramProducts(), new Predicate() { @Override//from ww w . ja v a2 s.c o m public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getWhoRatio(); }
From source file:org.openlmis.core.domain.ProgramSupported.java
@JsonIgnore public Integer getPackSizeFor(final String productCode) { FacilityProgramProduct facilityProgramProduct = (FacilityProgramProduct) CollectionUtils .find(this.getProgramProducts(), new Predicate() { @Override//from w w w . ja va2 s . c o m public boolean evaluate(Object o) { return ((FacilityProgramProduct) o).getProduct().getCode().equals(productCode); } }); return (facilityProgramProduct == null) ? null : facilityProgramProduct.getProduct().getPackSize(); }
From source file:org.openlmis.distribution.service.DistributionRefrigeratorsService.java
public void save(Long facilityId, DistributionRefrigerators distributionRefrigerators) { List<RefrigeratorReading> readings = distributionRefrigerators.getReadings(); refrigeratorService.disableAllFor(facilityId); if (readings.size() == 0) { return;//from w w w .j ava 2s . c o m } List<Refrigerator> refrigeratorsForFacility = refrigeratorService.getAllBy(facilityId); for (RefrigeratorReading reading : readings) { final Refrigerator refrigerator = reading.getRefrigerator(); Refrigerator existingRefrigerator = (Refrigerator) CollectionUtils.find(refrigeratorsForFacility, new Predicate() { @Override public boolean evaluate(Object o) { return ((Refrigerator) o).getSerialNumber().equals(refrigerator.getSerialNumber()); } }); refrigerator.setEnabled(true); if (existingRefrigerator != null) { refrigerator.setId(existingRefrigerator.getId()); } else { refrigerator.setFacilityId(facilityId); } refrigeratorService.save(refrigerator); repository.saveReading(reading); } }
From source file:org.openlmis.upload.model.ModelClass.java
public Field findImportFieldWithName(final String name) { Object result = CollectionUtils.find(importFields, new Predicate() { @Override//from w w w . j ava 2s .com public boolean evaluate(Object object) { Field field = (Field) object; return field.hasName(name); } }); return (Field) result; }
From source file:org.opentestsystem.shared.permissions.dao.xml.XmlPermissionsPersister.java
@Override public Role getRoleByRoleName(final String name) throws PermissionsRetrievalException { return (Role) CollectionUtils.find(getPermissions().getRoles(), new Predicate() { @Override//from w w w . j a va2 s .c o m public boolean evaluate(Object arg) { if (StringUtils.equals(name, ((Role) arg).getRole())) return true; return false; } }); }
From source file:org.opentestsystem.shared.permissions.dao.xml.XmlPermissionsPersister.java
@Override public Component getComponentByComponentName(final String name) throws PermissionsRetrievalException { Component cx = (Component) CollectionUtils.find(getPermissions().getComponents(), new Predicate() { @Override/*from w ww . j a va2 s . com*/ public boolean evaluate(Object arg) { if (StringUtils.equals(name, ((Component) arg).getComponent())) return true; return false; } }); return cx; }
From source file:org.opentestsystem.shared.permissions.dao.xml.XmlPermissionsPersister.java
public void deleteRole(final String roleId) throws PermissionsPersistException { Permissions permissions = getPermissions(); // step 1: delete the role Role role = (Role) CollectionUtils.find(permissions.getRoles(), new Predicate() { @Override//from w w w .j av a 2s. co m public boolean evaluate(Object object) { if (StringUtils.equals(roleId, ((Role) object).getRole())) return true; return false; } }); List<Role> roles = permissions.getRoles(); roles.remove(role); // step 2: persist this modified permissions object back to disk. persist(); }