当前位置: 首页>>代码示例>>Java>>正文


Java MetaPropertyPath.getMetaProperty方法代码示例

本文整理汇总了Java中com.haulmont.chile.core.model.MetaPropertyPath.getMetaProperty方法的典型用法代码示例。如果您正苦于以下问题:Java MetaPropertyPath.getMetaProperty方法的具体用法?Java MetaPropertyPath.getMetaProperty怎么用?Java MetaPropertyPath.getMetaProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.haulmont.chile.core.model.MetaPropertyPath的用法示例。


在下文中一共展示了MetaPropertyPath.getMetaProperty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addInitialColumns

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected void addInitialColumns(CollectionDatasource datasource) {
    if (this.columns.isEmpty()) {
        MessageTools messageTools = AppBeans.get(MessageTools.NAME);
        MetaClass metaClass = datasource.getMetaClass();
        Collection<MetaPropertyPath> paths = datasource.getView() != null ?
                // if a view is specified - use view properties
                metadataTools.getViewPropertyPaths(datasource.getView(), metaClass) :
                // otherwise use all properties from meta-class
                metadataTools.getPropertyPaths(metaClass);
        for (MetaPropertyPath metaPropertyPath : paths) {
            MetaProperty property = metaPropertyPath.getMetaProperty();
            if (!property.getRange().getCardinality().isMany() && !metadataTools.isSystem(property)) {
                String propertyName = property.getName();
                ColumnImpl column = new ColumnImpl(propertyName, metaPropertyPath, this);
                MetaClass propertyMetaClass = metadataTools.getPropertyEnclosingMetaClass(metaPropertyPath);
                column.setCaption(messageTools.getPropertyCaption(propertyMetaClass, propertyName));

                addColumn(column);
            }
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:23,代码来源:WebDataGrid.java

示例2: getParamBuilder

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
@Override
public Param.Builder getParamBuilder(AbstractCondition condition) {
    Param.Builder builder = super.getParamBuilder(condition);
    MetaPropertyPath propertyPath = condition.getDatasource().getMetaClass().getPropertyPath(condition.getName());
    MetaProperty metaProperty = propertyPath != null ? propertyPath.getMetaProperty() : null;
    if (!condition.getUnary())
        builder.setJavaClass(condition.getJavaClass())
                .setProperty(metaProperty);

    if (condition.getOperator() == Op.DATE_INTERVAL) {
        builder.setIsDateInterval(true);
        builder.setJavaClass(String.class);
    }

    return builder;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:17,代码来源:ConditionParamBuilderImpl.java

示例3: initRequired

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected void initRequired(MetaPropertyPath metaPropertyPath) {
    MetaProperty metaProperty = metaPropertyPath.getMetaProperty();

    boolean newRequired = metaProperty.isMandatory();
    Object notNullUiComponent = metaProperty.getAnnotations().get(NotNull.class.getName() + "_notnull_ui_component");
    if (Boolean.TRUE.equals(notNullUiComponent)) {
        newRequired = true;
    }
    setRequired(newRequired);

    if (StringUtils.isEmpty(getRequiredMessage())) {
        MessageTools messageTools = AppBeans.get(MessageTools.NAME);
        setRequiredMessage(messageTools.getDefaultRequiredMessage(metaPropertyPath.getMetaClass(), metaPropertyPath.toString()));
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:16,代码来源:WebAbstractField.java

示例4: getColumnCaption

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected String getColumnCaption(Object columnId, Column column) {
    String caption = column.getCaption();

    if (caption != null) {
        return caption;
    }

    if (!(columnId instanceof MetaPropertyPath)) {
        return StringUtils.capitalize(getColumnCaption(columnId));
    }

    MetaPropertyPath mpp = (MetaPropertyPath) columnId;
    MetaProperty metaProperty = mpp.getMetaProperty();

    if (DynamicAttributesUtils.isDynamicAttribute(metaProperty)) {
        CategoryAttribute categoryAttribute = DynamicAttributesUtils.getCategoryAttribute(metaProperty);
        if (LocaleHelper.isLocalizedValueDefined(categoryAttribute.getLocaleNames())) {
            return categoryAttribute.getLocaleName();
        }

        caption = StringUtils.capitalize(categoryAttribute.getName());
    } else {
        caption = StringUtils.capitalize(getColumnCaption(columnId));
    }

    return caption;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:28,代码来源:WebAbstractTable.java

示例5: loadValidators

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected void loadValidators(FieldGroup fieldGroup, FieldGroup.FieldConfig field) {
    MetaPropertyPath metaPropertyPath = rds.getMetaClass().getPropertyPath(field.getProperty());
    if (metaPropertyPath != null) {
        MetaProperty metaProperty = metaPropertyPath.getMetaProperty();
        Field.Validator validator = getValidator(metaProperty);

        if (validator != null) {
            field.addValidator(validator);
        }
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:12,代码来源:RuntimePropertiesFrame.java

示例6: getJavaClass

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
@Override
public Class getJavaClass() {
    MetaPropertyPath propertyPath = datasourceMetaClass.getPropertyPath(name);
    if (propertyPath != null) {
        MetaProperty metaProperty = propertyPath.getMetaProperty();
        if (metaProperty != null)
            return metaProperty.getJavaType();
    }
    throw new IllegalStateException("Unable to find property '" + name + "' in entity " + datasourceMetaClass);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:11,代码来源:PropertyConditionDescriptor.java

示例7: parsePropertyCondition

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected RestFilterPropertyCondition parsePropertyCondition(JsonObject conditionJsonObject, MetaClass metaClass) throws RestFilterParseException {
    RestFilterPropertyCondition condition = new RestFilterPropertyCondition();

    JsonElement propertyJsonElem = conditionJsonObject.get("property");
    if (propertyJsonElem == null) {
        throw new RestFilterParseException("Field 'property' is not defined for filter condition");
    }
    String propertyName = propertyJsonElem.getAsString();

    JsonElement operatorJsonElem = conditionJsonObject.get("operator");
    if (operatorJsonElem == null) {
        throw new RestFilterParseException("Field 'operator' is not defined for filter condition");
    }
    String operator = operatorJsonElem.getAsString();
    Op op = findOperator(operator);

    boolean isValueRequired = op != Op.NOT_EMPTY;
    JsonElement valueJsonElem = conditionJsonObject.get("value");
    if (valueJsonElem == null && isValueRequired) {
        throw new RestFilterParseException("Field 'value' is not defined for filter condition");
    }

    MetaPropertyPath propertyPath = metaClass.getPropertyPath(propertyName);
    if (propertyPath == null) {
        throw new RestFilterParseException("Property for " + metaClass.getName() + " not found: " + propertyName);
    }
    MetaProperty metaProperty = propertyPath.getMetaProperty();

    EnumSet<Op> opsAvailableForJavaType = opManager.availableOps(metaProperty.getJavaType());
    if (!opsAvailableForJavaType.contains(op)) {
        throw new RestFilterParseException("Operator " + operator + " is not available for java type " +
                metaProperty.getJavaType().getCanonicalName());
    }

    if (metaProperty.getRange().isClass()) {
        if (Entity.class.isAssignableFrom(metaProperty.getJavaType())) {
            MetaClass _metaClass = metadata.getClass(metaProperty.getJavaType());
            MetaProperty primaryKeyProperty = metadata.getTools().getPrimaryKeyProperty(_metaClass);
            String pkName = primaryKeyProperty.getName();
            propertyName += "." + pkName;
            propertyPath = metaClass.getPropertyPath(propertyName);
            if (propertyPath == null) {
                throw new RestFilterParseException("Property " + propertyName + " for " + metaClass.getName() + " not found");
            }
            metaProperty = propertyPath.getMetaProperty();
        }
    }

    if (isValueRequired) {
        Object value = null;
        if (op == Op.IN || op == Op.NOT_IN) {
            if (!valueJsonElem.isJsonArray()) {
                throw new RestFilterParseException("JSON array was expected as a value for condition with operator " + operator);
            }
            List<Object> parsedArrayValues = new ArrayList<>();
            for (JsonElement arrayItemElem : valueJsonElem.getAsJsonArray()) {
                parsedArrayValues.add(parseValue(metaProperty, arrayItemElem.getAsString()));
            }
            value = parsedArrayValues;
        } else {
            value = parseValue(metaProperty, valueJsonElem.getAsString());
        }
        condition.setValue(transformValue(value, op));
        condition.setQueryParamName(generateQueryParamName());
    }

    condition.setPropertyName(propertyName);
    condition.setOperator(op);

    return condition;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:72,代码来源:RestFilterParser.java

示例8: getMetaProperty

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
@Nullable
public MetaProperty getMetaProperty() {
    MetaPropertyPath propertyPath = datasourceMetaClass.getPropertyPath(name);
    if (propertyPath == null) return null;
    return propertyPath.getMetaProperty();
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:7,代码来源:PropertyConditionDescriptor.java

示例9: convertValue

import com.haulmont.chile.core.model.MetaPropertyPath; //导入方法依赖的package包/类
protected String convertValue(Entity entity, String fieldName, @Nullable Object value) {
    try {
        String valueStr;
        if (value instanceof Entity) {
            value = ((Entity) value).getId();
        } else if (value instanceof EnumClass) {
            value = ((EnumClass) value).getId();
        } else if (value instanceof Enum) {
            value = BaseEntityInternalAccess.getValue((BaseGenericIdEntity) entity, fieldName);
        }

        value = persistence.getDbTypeConverter().getSqlObject(value);

        if (value == null) {
            valueStr = null;
        } else if (value instanceof Date) {
            MetaPropertyPath propertyPath = metaClass.getPropertyPath(fieldName);
            if (propertyPath != null) {
                MetaProperty property = propertyPath.getMetaProperty();
                Datatype datatype = property.getRange().asDatatype();

                if (datatype.getJavaClass().equals(java.sql.Date.class)) {
                    valueStr = dateFormat.format((Date) value);
                } else if (datatype.getJavaClass().equals(Time.class)) {
                    valueStr = timeFormat.format((Date) value);
                } else {
                    valueStr = dateTimeFormat.format((Date) value);
                }
            } else {
                valueStr = dateTimeFormat.format((Date) value);
            }
        } else if (value instanceof String
                || value instanceof UUID
                || value.getClass().getName().toLowerCase().contains("uuid")
                || value instanceof Character) {
            if (value instanceof String) {
                value = ((String) value).replaceAll("\'", "''");
            }

            valueStr = format("'%s'", value);
        } else {
            valueStr = value.toString();
        }
        return valueStr;
    } catch (Exception e) {
        throw new RuntimeException(format("An error occurred while converting object [%s] for SQL query", value), e);
    }
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:49,代码来源:EntitySqlGenerator.java


注:本文中的com.haulmont.chile.core.model.MetaPropertyPath.getMetaProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。