diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/IMaterialLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/IMaterialLister.java index ee0d01613ac287c2d156dcdcf293bd6e11ba0aea..17a8eb465bbc236c6bdb9143630af59ec10e4024 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/IMaterialLister.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/IMaterialLister.java @@ -28,6 +28,9 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Material; */ public interface IMaterialLister { + /** fetches and sets all properties of specified materials */ + void enrichWithProperties(List<Material> materials); + /** * Returns a sorted list of {@link Material}s matching given criteria. * diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/MaterialLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/MaterialLister.java index 93d50b6940153c7c8d100e8568bf2e0a463ecb99..4a0232a8f55f4d83dbe983b7411a040e761232fc 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/MaterialLister.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/materiallister/MaterialLister.java @@ -233,4 +233,28 @@ public class MaterialLister implements IMaterialLister }); } + private static Long2ObjectMap<Material> asMap(Iterable<Material> materials) + { + Long2ObjectMap<Material> map = new Long2ObjectOpenHashMap<Material>(); + for (Material material : materials) + { + map.put(material.getId(), material); + } + return map; + } + + public void enrichWithProperties(List<Material> materials) + { + setEmptyProperties(materials); + enrichWithProperties(asMap(materials)); + } + + private void setEmptyProperties(List<Material> materials) + { + for (Material material : materials) + { + material.setProperties(new ArrayList<IEntityProperty>()); + } + } + }