mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-02 19:27:57 +08:00
Exception in auto-complete if entered entity name is invalid #956
This commit is contained in:
parent
cfc870b3fc
commit
921c9ccc50
@ -19,6 +19,7 @@ package com.haulmont.cuba.core.sys.jpql;
|
||||
|
||||
import com.haulmont.chile.core.model.MetaClass;
|
||||
import com.haulmont.cuba.core.global.ExtendedEntities;
|
||||
import com.haulmont.cuba.core.global.Metadata;
|
||||
import com.haulmont.cuba.core.sys.jpql.model.JpqlEntityModel;
|
||||
|
||||
import javax.annotation.concurrent.NotThreadSafe;
|
||||
@ -31,10 +32,12 @@ import java.util.stream.Collectors;
|
||||
public class DomainModel {
|
||||
protected Map<String, JpqlEntityModel> entities = new HashMap<>();
|
||||
protected ExtendedEntities extendedEntities;
|
||||
protected Metadata metadata;
|
||||
|
||||
public DomainModel(ExtendedEntities extendedEntities, JpqlEntityModel... initialEntities) {
|
||||
public DomainModel(ExtendedEntities extendedEntities, Metadata metadata, JpqlEntityModel... initialEntities) {
|
||||
this(initialEntities);
|
||||
this.extendedEntities = extendedEntities;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public DomainModel(JpqlEntityModel... initialEntities) {
|
||||
@ -59,6 +62,9 @@ public class DomainModel {
|
||||
|
||||
public JpqlEntityModel getEntityByName(String requiredEntityName) throws UnknownEntityNameException {
|
||||
if (extendedEntities != null) {
|
||||
if (metadata.getSession().getClass(requiredEntityName) == null) {
|
||||
throw new UnknownEntityNameException(requiredEntityName);
|
||||
}
|
||||
MetaClass effectiveMetaClass = extendedEntities.getEffectiveMetaClass(requiredEntityName);
|
||||
requiredEntityName = effectiveMetaClass.getName();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class DomainModelBuilder {
|
||||
|
||||
public DomainModel produce() {
|
||||
Collection<MetaClass> classes = metadata.getSession().getClasses();
|
||||
DomainModel result = new DomainModel(extendedEntities);
|
||||
DomainModel result = new DomainModel(extendedEntities, metadata);
|
||||
|
||||
EntityBuilder builder = new EntityBuilder();
|
||||
for (MetaClass aClass : classes) {
|
||||
|
Loading…
Reference in New Issue
Block a user