use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getManyToManyCondition.
@Nullable
protected AbstractCondition getManyToManyCondition(List<Object> parentIds, MetaClass metaClass, String filterComponentName, String relatedPrimaryKey, MetaDataDescriptor descriptor) {
MetaClass parentMetaClass = descriptor.getMetaClass();
String parentPrimaryKey = metadataTools.getPrimaryKeyName(parentMetaClass);
CustomCondition customCondition = getParentEntitiesCondition(parentIds, parentPrimaryKey, metaClass, filterComponentName, parentMetaClass);
String parentEntityAlias = RandomStringUtils.randomAlphabetic(6);
String entityAlias = RandomStringUtils.randomAlphabetic(6);
String select = String.format("select %s.%s from %s %s ", entityAlias, relatedPrimaryKey, parentMetaClass, parentEntityAlias);
String joinWhere = String.format("join %s.%s %s where %s.%s in :%s", parentEntityAlias, descriptor.getMetaProperty().getName(), entityAlias, parentEntityAlias, parentPrimaryKey, customCondition.getParam().getName());
String whereString = String.format("{E}.%s in (%s)", relatedPrimaryKey, select + joinWhere);
customCondition.setWhere(whereString);
return customCondition;
}
use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getOneToManyCondition.
@Nullable
protected AbstractCondition getOneToManyCondition(List<Object> parentIds, MetaClass metaClass, String filterComponentName, MetaDataDescriptor descriptor) {
MetaProperty inverseField = descriptor.getMetaProperty().getInverse();
if (inverseField == null) {
return null;
}
MetaClass parentMetaClass = descriptor.getMetaClass();
String parentPrimaryKey = metadataTools.getPrimaryKeyName(parentMetaClass);
CustomCondition customCondition = getParentEntitiesCondition(parentIds, parentPrimaryKey, metaClass, filterComponentName, parentMetaClass);
String whereString = String.format("{E}.%s.%s in :%s", inverseField.getName(), parentPrimaryKey, customCondition.getParam().getName());
customCondition.setWhere(whereString);
return customCondition;
}
use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getParentEntitiesCondition.
protected CustomCondition getParentEntitiesCondition(List<Object> parentIds, String parentPrimaryKey, CollectionDatasource datasource, String filterComponentName, MetaClass parentMetaClass) {
String conditionName = String.format("related_%s", RandomStringUtils.randomAlphabetic(6));
CustomCondition condition = new CustomCondition(getConditionXmlElement(conditionName, parentMetaClass), AppConfig.getMessagesPack(), filterComponentName, datasource);
Class<?> parentPrimaryKeyClass = parentMetaClass.getPropertyNN(parentPrimaryKey).getJavaType();
condition.setJavaClass(parentPrimaryKeyClass);
condition.setHidden(true);
condition.setInExpr(true);
int randInt = new Random().nextInt((99999 - 11111) + 1) + 11111;
String paramName = String.format("component$%s.%s%s", filterComponentName, conditionName, randInt);
condition.setParam(getParentEntitiesParam(parentIds, parentPrimaryKey, datasource, parentPrimaryKeyClass, paramName, parentMetaClass));
return condition;
}
use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getManyToManyCondition.
@Nullable
protected AbstractCondition getManyToManyCondition(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 parentEntityAlias = RandomStringUtils.randomAlphabetic(6);
String entityAlias = RandomStringUtils.randomAlphabetic(6);
String select = String.format("select %s.%s from %s %s ", entityAlias, relatedPrimaryKey, metaClass, parentEntityAlias);
String joinWhere = String.format("join %s.%s %s where %s.%s in :%s", parentEntityAlias, descriptor.getMetaProperty().getName(), entityAlias, parentEntityAlias, parentPrimaryKey, customCondition.getParam().getName());
String whereString = String.format("{E}.%s in (%s)", relatedPrimaryKey, select + joinWhere);
customCondition.setWhere(whereString);
return customCondition;
}
use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getOneToManyCondition.
@Nullable
protected AbstractCondition getOneToManyCondition(List<Object> parentIds, CollectionDatasource datasource, String filterComponentName, MetaDataDescriptor descriptor) {
MetaProperty inverseField = descriptor.getMetaProperty().getInverse();
if (inverseField == null) {
return null;
}
MetaClass metaClass = descriptor.getMetaClass();
String parentPrimaryKey = metadataTools.getPrimaryKeyName(metaClass);
CustomCondition customCondition = getParentEntitiesCondition(parentIds, parentPrimaryKey, datasource, filterComponentName, metaClass);
String whereString = String.format("{E}.%s.%s in :%s", inverseField.getName(), parentPrimaryKey, customCondition.getParam().getName());
customCondition.setWhere(whereString);
return customCondition;
}
Aggregations