PL-8926 When the entity with composite key has dynamic attribute an attempt to read it leads to exception

This commit is contained in:
Andrey Subbotin 2017-04-19 12:05:08 +04:00
parent ef89ad7e32
commit cf4fa68b1b
2 changed files with 9 additions and 2 deletions

View File

@ -29,6 +29,7 @@ import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.app.dynamicattributes.PropertyType;
import com.haulmont.cuba.core.entity.CategoryAttribute;
import com.haulmont.cuba.core.entity.Entity;
import com.haulmont.cuba.core.entity.HasUuid;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator;
import com.haulmont.cuba.gui.ScreensHelper;
@ -238,9 +239,11 @@ public class AttributeEditor extends AbstractEditor<CategoryAttribute> {
MetaClass entityType = null;
for (MetaClass metaClass : metadataTools.getAllPersistentMetaClasses()) {
if (!metadataTools.isSystemLevel(metaClass)) {
if (metadata.getTools().hasCompositePrimaryKey(metaClass) && !HasUuid.class.isAssignableFrom(metaClass.getJavaClass())) {
continue;
}
options.put(messageTools.getDetailedEntityCaption(metaClass), metaClass.getJavaClass().getName());
if (attribute != null
&& metaClass.getJavaClass().getName().equals(attribute.getEntityClass())) {
if (attribute != null && metaClass.getJavaClass().getName().equals(attribute.getEntityClass())) {
entityType = metaClass;
}
}

View File

@ -19,6 +19,7 @@ package com.haulmont.cuba.gui.app.core.categories;
import com.haulmont.chile.core.model.MetaClass;
import com.haulmont.cuba.core.entity.Category;
import com.haulmont.cuba.core.entity.HasUuid;
import com.haulmont.cuba.core.global.*;
import com.haulmont.cuba.gui.components.AbstractEditor;
import com.haulmont.cuba.gui.components.CheckBox;
@ -59,6 +60,9 @@ public class CategoryEditor extends AbstractEditor<Category> {
for (MetaClass metaClass : metadata.getTools().getAllPersistentMetaClasses()) {
String storeName = metadata.getTools().getStoreName(metaClass);
if (Stores.isMain(storeName)) {
if (metadata.getTools().hasCompositePrimaryKey(metaClass) && !HasUuid.class.isAssignableFrom(metaClass.getJavaClass())) {
continue;
}
options.put(messageTools.getDetailedEntityCaption(metaClass), metaClass);
}
}