use of com.haulmont.cuba.core.entity.CategoryAttributeValue in project cuba by cuba-platform.
the class GlobalPersistentAttributesLoadChecker method isLoaded.
@Override
public boolean isLoaded(Object entity, String property) {
MetaClass metaClass = metadata.getClassNN(entity.getClass());
if (isDynamicAttribute(property)) {
@SuppressWarnings("unchecked") Map<String, CategoryAttributeValue> dynamicAttributes = ((BaseGenericIdEntity) entity).getDynamicAttributes();
if (dynamicAttributes == null) {
return false;
}
String attributeCode = decodeAttributeCode(property);
return dynamicAttributes.containsKey(attributeCode);
}
MetaProperty metaProperty = metaClass.getPropertyNN(property);
if (!metadataTools.isPersistent(metaProperty)) {
List<String> relatedProperties = metadataTools.getRelatedProperties(metaProperty);
if (relatedProperties.isEmpty()) {
return true;
} else {
for (String relatedProperty : relatedProperties) {
if (!isLoaded(entity, relatedProperty))
return false;
}
return true;
}
}
PropertyLoadedState isLoaded = isLoadedCommonCheck(entity, property);
if (isLoaded != PropertyLoadedState.UNKNOWN) {
return isLoaded == PropertyLoadedState.YES;
}
return isLoadedSpecificCheck(entity, property, metaClass, metaProperty);
}
use of com.haulmont.cuba.core.entity.CategoryAttributeValue in project cuba by cuba-platform.
the class DynamicAttributesEntity method setValue.
@Override
@SuppressWarnings("unchecked")
public void setValue(String name, Object value) {
mainItem.setValue(name, value);
// if we set an attribute from another type of entity, we need to set reference to CategoryAttribute manually
// this is workaround to make #PL-5770 logic works with modern RuntimePropertiesDatasource
String attributeCode = DynamicAttributesUtils.decodeAttributeCode(name);
Map<String, CategoryAttributeValue> dynamicAttributes = mainItem.getDynamicAttributes();
if (dynamicAttributes != null) {
CategoryAttributeValue categoryAttributeValue = dynamicAttributes.get(attributeCode);
if (categoryAttributeValue != null && categoryAttributeValue.getCategoryAttribute() == null) {
categoryAttributeValue.setCategoryAttribute(attributesMap.get(attributeCode));
}
}
}
Aggregations