Search in sources :

Example 1 with EnumProperty

use of org.talend.daikon.properties.property.EnumProperty in project tdi-studio-se by Talend.

the class Salesforce620Migration method updateSubProperties.

/**
     * DOC nrousseau Comment method "updateSubProperties".
     * 
     * @param properties
     * @param newProperties
     */
private void updateSubProperties(ComponentProperties properties, ComponentProperties newProperties) {
    if (newProperties == null) {
        return;
    }
    for (NamedThing nt : properties.getProperties()) {
        if (nt instanceof Property) {
            Property property = (Property) nt;
            Object storedValue = property.getStoredValue();
            if (storedValue instanceof String) {
                String stringValue = (String) storedValue;
                if (ContextParameterUtils.isContainContextParam(stringValue)) {
                    continue;
                }
                Property newProperty = (Property) newProperties.getProperty(property.getName());
                if (newProperty != null) {
                    if (GenericTypeUtils.isBooleanType(newProperty)) {
                        if (stringValue.isEmpty()) {
                            property.setValue(Boolean.FALSE);
                        } else {
                            property.setValue(new Boolean(stringValue));
                        }
                    } else if (GenericTypeUtils.isEnumType(newProperty) && (!(newProperty instanceof EnumProperty))) {
                        property.setStoredValue(TalendQuoteUtils.removeQuotes(stringValue));
                    } else if (GenericTypeUtils.isEnumType(newProperty)) {
                        List<?> propertyPossibleValues = ((Property<?>) newProperty).getPossibleValues();
                        if (propertyPossibleValues != null) {
                            for (Object possibleValue : propertyPossibleValues) {
                                if (possibleValue.toString().equals(storedValue)) {
                                    property.setStoredValue(possibleValue);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        } else if (nt instanceof ComponentProperties) {
            updateSubProperties((ComponentProperties) nt, (ComponentProperties) newProperties.getProperty(nt.getName()));
        }
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) EnumProperty(org.talend.daikon.properties.property.EnumProperty) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property) EnumProperty(org.talend.daikon.properties.property.EnumProperty)

Example 2 with EnumProperty

use of org.talend.daikon.properties.property.EnumProperty in project tdi-studio-se by Talend.

the class WidgetFieldTypeMapper method getFieldType.

public static EParameterFieldType getFieldType(Widget widget, NamedThing widgetProperty) {
    // init
    mappingReader.init();
    Property property = null;
    if (widgetProperty instanceof Property) {
        property = (Property) widgetProperty;
    }
    String fieldType = mappingReader.getFieldType(widget.getWidgetType(), widgetProperty, property != null ? property.getType() : null);
    if (widgetProperty instanceof EnumProperty) {
        return EParameterFieldType.CLOSED_LIST;
    }
    return fieldType != null ? EParameterFieldType.valueOf(fieldType.toUpperCase()) : null;
}
Also used : EnumProperty(org.talend.daikon.properties.property.EnumProperty) EnumProperty(org.talend.daikon.properties.property.EnumProperty) Property(org.talend.daikon.properties.property.Property)

Example 3 with EnumProperty

use of org.talend.daikon.properties.property.EnumProperty in project tdi-studio-se by Talend.

the class Salesforce620WizardMigration method updateSubProperties.

/**
     * DOC nrousseau Comment method "updateSubProperties".
     * 
     * @param properties
     * @param newProperties
     */
private void updateSubProperties(ComponentProperties properties, ComponentProperties newProperties) {
    if (newProperties == null) {
        return;
    }
    for (NamedThing nt : properties.getProperties()) {
        if (nt instanceof Property) {
            Property property = (Property) nt;
            Object storedValue = property.getStoredValue();
            if (storedValue instanceof String) {
                String stringValue = (String) storedValue;
                if (ContextParameterUtils.isContainContextParam(stringValue)) {
                    continue;
                }
                Property newProperty = (Property) newProperties.getProperty(property.getName());
                if (newProperty != null) {
                    if (GenericTypeUtils.isBooleanType(newProperty)) {
                        if (stringValue.isEmpty()) {
                            property.setValue(Boolean.FALSE);
                        } else {
                            property.setValue(new Boolean(stringValue));
                        }
                    } else if (GenericTypeUtils.isEnumType(newProperty) && (!(newProperty instanceof EnumProperty))) {
                        property.setStoredValue(TalendQuoteUtils.removeQuotes(stringValue));
                    } else if (GenericTypeUtils.isEnumType(newProperty)) {
                        List<?> propertyPossibleValues = ((Property<?>) newProperty).getPossibleValues();
                        if (propertyPossibleValues != null) {
                            for (Object possibleValue : propertyPossibleValues) {
                                if (possibleValue.toString().equals(storedValue)) {
                                    property.setStoredValue(possibleValue);
                                    break;
                                }
                            }
                        }
                    }
                }
            } else {
                Property newProperty = (Property) newProperties.getProperty(property.getName());
                if (GenericTypeUtils.isBooleanType(newProperty)) {
                    // value can only be null (so false)
                    property.setValue(Boolean.FALSE);
                }
            }
        } else if (nt instanceof ComponentProperties) {
            updateSubProperties((ComponentProperties) nt, (ComponentProperties) newProperties.getProperty(nt.getName()));
        }
    }
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) EnumProperty(org.talend.daikon.properties.property.EnumProperty) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property) EnumProperty(org.talend.daikon.properties.property.EnumProperty)

Aggregations

EnumProperty (org.talend.daikon.properties.property.EnumProperty)3 Property (org.talend.daikon.properties.property.Property)3 ComponentProperties (org.talend.components.api.properties.ComponentProperties)2 NamedThing (org.talend.daikon.NamedThing)2