use of com.haulmont.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class RelatedEntitiesBean method getManyToOneCondition.
@Nullable
protected AbstractCondition getManyToOneCondition(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 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, parentMetaClass.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.cuba.gui.components.filter.condition.CustomCondition in project cuba by cuba-platform.
the class FilteringLookupAction method createCustomCondition.
protected CustomCondition createCustomCondition(Filter filterComponent) {
CustomCondition condition = new CustomCondition(createConditionXmlElement(), AppConfig.getMessagesPack(), getFilterComponentName(filterComponent), ((FilterImplementation) filterComponent).getEntityMetaClass());
condition.setUnary(true);
condition.setHidden(true);
condition.setWhere(whereClause.replaceAll("\\?", ":" + condition.getParamName()));
condition.setJoin(joinClause);
ConditionParamBuilder paramBuilder = AppBeans.get(ConditionParamBuilder.class);
Param param = Param.Builder.getInstance().setName(paramBuilder.createParamName(condition)).setJavaClass(Boolean.class).setEntityWhere("").setEntityView("").setMetaClass(((FilterImplementation) filterComponent).getEntityMetaClass()).setInExpr(true).setRequired(true).build();
param.setValue(true);
condition.setParam(param);
return condition;
}
Aggregations