use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class RelatedEntitiesBean method getManyToOneCondition.
@Nullable
protected AbstractCondition getManyToOneCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, String relatedPrimaryKey, MetaDataDescriptor descriptor) {
MetaClass metaClass = descriptor.getMetaClass();
String parentPrimaryKey = metadataTools.getPrimaryKeyName(metaClass);
CustomCondition customCondition = getParentEntitiesCondition(parentIds, parentPrimaryKey, datasource, filterComponentName, metaClass);
String entityAlias = RandomStringUtils.randomAlphabetic(6);
String subQuery = String.format("select %s.%s.%s from %s %s where %s.%s in :%s", entityAlias, descriptor.getMetaProperty().getName(), relatedPrimaryKey, metaClass.getName(), entityAlias, entityAlias, parentPrimaryKey, customCondition.getParam().getName());
String whereString = String.format("{E}.%s in (%s)", relatedPrimaryKey, subQuery);
customCondition.setWhere(whereString);
return customCondition;
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class DsContextLoader method loadRuntimePropsDatasource.
protected RuntimePropsDatasource loadRuntimePropsDatasource(Element element) {
String id = getDatasourceId(element);
MetaClass metaClass = loadMetaClass(element);
String mainDsId = element.attributeValue("mainDs");
if (mainDsId == null) {
throw new IllegalStateException("RuntimePropsDs attributes not specified");
}
String categorizedEntityClassName = element.attributeValue("categorizedEntityClass");
MetaClass categorizedEntityMetaClass = null;
if (StringUtils.isNotBlank(categorizedEntityClassName)) {
final Class<?> aClass = ReflectionHelper.getClass(categorizedEntityClassName);
categorizedEntityMetaClass = metadata.getSession().getClass(aClass);
}
builder.reset().setMetaClass(metaClass).setId(id);
RuntimePropsDatasource datasource = builder.buildRuntimePropsDatasource(mainDsId, categorizedEntityMetaClass);
loadDatasources(element, datasource);
return datasource;
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class DsContextLoader method loadMetaClass.
protected MetaClass loadMetaClass(Element element) {
final String className = element.attributeValue("class");
if (className == null)
return null;
final Class<?> aClass = ReflectionHelper.getClass(className);
final MetaClass metaClass = metadata.getSession().getClass(aClass);
if (metaClass == null)
throw new IllegalStateException(String.format("Can't find metaClass '%s'", className));
return metaClass;
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class DsContextLoader method loadHierarchicalDatasource.
protected Datasource loadHierarchicalDatasource(Element element) {
MetaClass metaClass = loadMetaClass(element);
if (metaClass == null)
throw new DevelopmentException("'class' attribute is not set for the datasource");
initCollectionDatasourceAttributes(element, metaClass);
HierarchicalDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildHierarchicalDatasource();
String hierarchyProperty = element.attributeValue("hierarchyProperty");
if (!StringUtils.isEmpty(hierarchyProperty)) {
datasource.setHierarchyPropertyName(hierarchyProperty);
}
if (datasource instanceof CollectionDatasource.Suspendable)
((CollectionDatasource.Suspendable) datasource).setSuspended(true);
loadQuery(element, datasource);
loadDatasources(element, datasource);
return datasource;
}
use of com.haulmont.chile.core.model.MetaClass in project cuba by cuba-platform.
the class DsContextLoader method initPropertyDatasourceAttributes.
private void initPropertyDatasourceAttributes(Element element, Datasource ds, String property) {
String id = getDatasourceId(element);
MetaClass metaClass = ds.getMetaClass();
// check property existense
metaClass.getPropertyNN(property);
builder.reset().setMetaClass(metaClass).setId(id).setMaster(ds).setProperty(property).setAllowCommit(getAllowCommit(element));
}
Aggregations