use of io.jmix.core.entity.EntityValues in project jmix by jmix-framework.
the class DynAttrManagerImpl method loadValues.
protected List<CategoryAttributeValue> loadValues(MetaClass metaClass, Collection<AccessConstraint<?>> accessConstraints, List<Object> entityIds) {
List<CategoryAttributeValue> mainAttributeValues = findValuesByEntityIds(metaClass, entityIds);
List<CategoryAttributeValue> entityValues = mainAttributeValues.stream().filter(v -> v.getObjectEntityValueId() != null).collect(Collectors.toList());
List<CategoryAttributeValue> collectionValues = mainAttributeValues.stream().filter(v -> BooleanUtils.isTrue(v.getCategoryAttribute().getIsCollection())).collect(Collectors.toList());
if (collectionValues.isEmpty()) {
fetchEntityValues(accessConstraints, entityValues);
return mainAttributeValues;
} else {
List<CategoryAttributeValue> reloadedCollectionValues = fetchCollectionValues(collectionValues);
List<CategoryAttributeValue> values = new ArrayList<>(mainAttributeValues.size());
for (CategoryAttributeValue value : reloadedCollectionValues) {
if (value.getCategoryAttribute().getDataType() == AttributeType.ENTITY && value.getChildValues() != null) {
for (CategoryAttributeValue child : value.getChildValues()) {
if (child.getDeleteTs() == null) {
entityValues.add(child);
}
}
}
}
fetchEntityValues(accessConstraints, entityValues);
for (CategoryAttributeValue value : reloadedCollectionValues) {
if (value.getChildValues() != null) {
value.setTransientCollectionValue(value.getChildValues().stream().filter(v -> v.getDeleteTs() == null).map(CategoryAttributeValue::getValue).collect(Collectors.toList()));
}
}
for (CategoryAttributeValue value : mainAttributeValues) {
if (!reloadedCollectionValues.contains(value)) {
values.add(value);
}
}
values.addAll(reloadedCollectionValues);
return values;
}
}
Aggregations