@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)); } } }
String code = DynamicAttributesUtils.encodeAttributeCode(categoryAttribute.getCode()); if (entityIsCategorized && !categoryAttribute.getCategory().equals(((Categorized) item).getCategory())) { item.setValue(code, null);//cleanup attributes from not dedicated category continue; .setParameter("entityId", categoryAttribute.getDefaultValue()); Entity defaultEntity = dataManager.load(lc); item.setValue(code, defaultEntity); } else if (Boolean.TRUE.equals(categoryAttribute.getIsCollection())) { List<Object> list = new ArrayList<>(); list.add(categoryAttribute.getDefaultValue()); item.setValue(code, list); } else { item.setValue(code, categoryAttribute.getDefaultValue()); item.setValue(code, currentTimestamp);
if (filteredData != null && filteredData.containsEntry(property.getName(), referenceToEntitySupport.getReferenceId((Entity) value))) { baseGenericIdEntity.setValue(property.getName(), null); } else { applyConstraints((Entity) value, handled);
public InstanceRef(EntityLoadInfo loadInfo) throws InstantiationException, IllegalAccessException { if (loadInfo == null) throw new NullPointerException("No load info passed"); this.loadInfo = loadInfo; MetaClass childMetaClass = loadInfo.getMetaClass(); if (!Strings.isNullOrEmpty(loadInfo.getViewName()) && !loadInfo.isNewEntity()) { DataService dataService = AppBeans.get(DataService.class); LoadContext<BaseGenericIdEntity<Object>> ctx = new LoadContext<>(loadInfo.getMetaClass()); ctx.setId(loadInfo.getId()).setView(loadInfo.getViewName()); instance = dataService.load(ctx); if (instance == null) { throw new RuntimeException("Entity with loadInfo " + loadInfo + " not found"); } } else { //noinspection unchecked instance = (BaseGenericIdEntity<Object>) AppBeans.get(Metadata.class).create(childMetaClass); if (!loadInfo.isNewEntity()) { for (MetaProperty metaProperty : childMetaClass.getProperties()) { if (!metaProperty.getRange().isClass()) { try { instance.setValue(metaProperty.getName(), null); } catch (Exception ignored) { } } } } } instance.setId(this.loadInfo.getId()); }
category = getDefaultCategory(); if (baseGenericIdEntity.getMetaClass().getProperty("category") != null) { baseGenericIdEntity.setValue("category", category);