use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class BulkEditorWindow method getManagedFields.
protected List<ManagedField> getManagedFields(MetaClass metaClass) {
List<ManagedField> managedFields = new ArrayList<>();
// sort Fields
for (MetaProperty metaProperty : metaClass.getProperties()) {
if (isManagedAttribute(metaClass, metaProperty)) {
String propertyCaption = messageTools.getPropertyCaption(metaClass, metaProperty.getName());
if (!metadataTools.isEmbedded(metaProperty)) {
managedFields.add(new ManagedField(metaProperty.getName(), metaProperty, propertyCaption, null));
} else {
List<ManagedField> nestedFields = getManagedFields(metaProperty, metaProperty.getName(), propertyCaption);
if (nestedFields.size() > 0) {
managedEmbeddedProperties.add(metaProperty.getName());
}
managedFields.addAll(nestedFields);
}
}
}
if (loadDynamicAttributes) {
List<CategoryAttribute> categoryAttributes = (List<CategoryAttribute>) dynamicAttributes.getAttributesForMetaClass(metaClass);
if (!categoryAttributes.isEmpty()) {
for (CategoryAttribute attribute : categoryAttributes) {
MetaPropertyPath metaPropertyPath = DynamicAttributesUtils.getMetaPropertyPath(metaClass, attribute);
String propertyCaption = attribute.getLocaleName();
if (isManagedDynamicAttribute(metaClass, metaPropertyPath.getMetaProperty())) {
managedFields.add(new ManagedField(metaPropertyPath.getMetaProperty().getName(), metaPropertyPath.getMetaProperty(), propertyCaption, null));
}
}
}
}
return managedFields;
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class PropertyCondition method updateText.
@Override
protected void updateText() {
Metadata metadata = AppBeans.get(Metadata.class);
MetadataTools metadataTools = metadata.getTools();
String nameToUse = name;
boolean useCrossDataStoreRefId = false;
String thisStore = metadataTools.getStoreName(datasource.getMetaClass());
MetaPropertyPath propertyPath = datasource.getMetaClass().getPropertyPath(name);
if (propertyPath != null) {
String refIdProperty = metadataTools.getCrossDataStoreReferenceIdProperty(thisStore, propertyPath.getMetaProperty());
if (refIdProperty != null) {
useCrossDataStoreRefId = true;
int lastdDot = nameToUse.lastIndexOf('.');
if (lastdDot == -1) {
nameToUse = refIdProperty;
} else {
nameToUse = nameToUse.substring(0, lastdDot + 1) + refIdProperty;
}
}
}
if (operator == Op.DATE_INTERVAL) {
text = dateIntervalConditionToJpql(nameToUse);
return;
}
StringBuilder sb = new StringBuilder();
if (operator == Op.NOT_IN) {
sb.append("((");
}
sb.append(entityAlias).append(".").append(nameToUse);
if (Param.Type.ENTITY == param.getType() && !useCrossDataStoreRefId) {
com.haulmont.chile.core.model.MetaClass metaClass = metadata.getClassNN(param.getJavaClass());
String primaryKeyName = metadataTools.getPrimaryKeyName(metaClass);
sb.append(".").append(primaryKeyName);
}
if (operator != Op.NOT_EMPTY)
sb.append(" ").append(operator.forJpql());
if (!operator.isUnary()) {
sb.append(" :").append(param.getName());
if (operator == Op.ENDS_WITH || operator == Op.STARTS_WITH || operator == Op.CONTAINS || operator == Op.DOES_NOT_CONTAIN) {
sb.append(" ESCAPE '").append(QueryUtils.ESCAPE_CHARACTER).append("' ");
}
if (operator == Op.NOT_IN) {
sb.append(") or (").append(entityAlias).append(".").append(nameToUse).append(" is null)) ");
}
}
if (operator == Op.NOT_EMPTY) {
sb.append(BooleanUtils.isTrue((Boolean) param.getValue()) ? " is not null" : " is null");
}
text = sb.toString();
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class PropertyConditionDescriptor method createCondition.
@Override
public AbstractCondition createCondition() {
OpManager opManager = AppBeans.get(OpManager.class);
MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
PropertyCondition propertyCondition = new PropertyCondition(this, entityAlias);
MetaPropertyPath propertyPath = datasourceMetaClass.getPropertyPath(name);
if (propertyPath == null) {
throw new IllegalStateException(String.format("Unable to find property '%s' in entity %s", name, datasourceMetaClass));
}
MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
EnumSet<Op> ops = opManager.availableOps(propertyMetaClass, propertyPath.getMetaProperty());
propertyCondition.setOperator(ops.iterator().next());
return propertyCondition;
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class PropertyOperationEditor method createComponent.
@Override
protected Component createComponent() {
OpManager opManager = AppBeans.get(OpManager.class);
MetadataTools metadataTools = AppBeans.get(MetadataTools.class);
componentsFactory = AppBeans.get(ComponentsFactory.class);
popupButton = componentsFactory.createComponent(PopupButton.class);
MetaClass metaClass = condition.getDatasource().getMetaClass();
MetaPropertyPath propertyPath = metaClass.getPropertyPath(condition.getName());
if (propertyPath == null) {
throw new IllegalStateException(String.format("Unable to find property '%s' in entity %s", condition.getName(), metaClass));
}
MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(propertyPath);
for (Op op : opManager.availableOps(propertyMetaClass, propertyPath.getMetaProperty())) {
OperatorChangeAction operatorChangeAction = new OperatorChangeAction(op);
popupButton.addAction(operatorChangeAction);
}
popupButton.setCaption(condition.getOperator().getLocCaption());
popupButton.setStyleName("condition-operation-button");
return popupButton;
}
use of com.haulmont.chile.core.model.MetaPropertyPath in project cuba by cuba-platform.
the class AbstractTreeTableDatasource method createEntityNodeComparator.
protected Comparator<Node<T>> createEntityNodeComparator() {
final MetaPropertyPath propertyPath = sortInfos[0].getPropertyPath();
final boolean asc = Order.ASC.equals(sortInfos[0].getOrder());
return new TreeTableNodeComparator<>(propertyPath, asc);
}
Aggregations