Search in sources :

Example 1 with Property

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

the class GenericContextUtil method setPropertyValue.

private static void setPropertyValue(ComponentProperties componentProperties, String propertyName, String propertyValue, boolean isContextMode) {
    Property property = componentProperties.getValuedProperty(propertyName);
    if (property != null) {
        property.setTaggedValue(IGenericConstants.IS_CONTEXT_MODE, isContextMode);
        property.setValue(propertyValue);
    }
}
Also used : Property(org.talend.daikon.properties.property.Property)

Example 2 with Property

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

the class GenericUIBuilder method createWidgetUIByPropertyType.

private void createWidgetUIByPropertyType(Composite parent, Widget widget) {
    NamedThing property = getProperty(widget);
    if (property == null) {
        return;
    }
    int hSpan = widget.getOrder();
    if (property instanceof PresentationItem) {
        PresentationItem item = (PresentationItem) property;
        createLabel(parent, item.getDisplayName(), hSpan);
        return;
    } else if (property instanceof Property) {
        Property element = (Property) property;
        String displayName = element.getDisplayName();
        String type = element.getType();
        if (type == null) {
            createLabel(parent, displayName, hSpan);
            return;
        }
        if (GenericTypeUtils.isStringType(type)) {
            new LabelledText(parent, displayName, hSpan);
        } else if (GenericTypeUtils.isBooleanType(type)) {
        // nothing
        } else {
            new LabelledText(parent, element.getDisplayName(), hSpan);
        }
    }
}
Also used : LabelledText(org.talend.commons.ui.swt.formtools.LabelledText) PresentationItem(org.talend.daikon.properties.PresentationItem) NamedThing(org.talend.daikon.NamedThing) Property(org.talend.daikon.properties.property.Property)

Example 3 with Property

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

the class Component method getElementParameterValueFromComponentProperties.

@Override
public Object getElementParameterValueFromComponentProperties(INode iNode, IElementParameter param) {
    if (iNode != null) {
        ComponentProperties iNodeComponentProperties = iNode.getComponentProperties();
        if (iNodeComponentProperties != null && param instanceof GenericElementParameter) {
            Properties paramProperties = ComponentsUtils.getCurrentProperties(iNodeComponentProperties, param.getName());
            if (paramProperties != null) {
                // update repository value
                Property property = iNodeComponentProperties.getValuedProperty(param.getName());
                if (property != null) {
                    if (property.getTaggedValue(IGenericConstants.REPOSITORY_VALUE) != null) {
                        param.setRepositoryValue(param.getName());
                        param.setRepositoryValueUsed(true);
                    }
                }
                Object value = ComponentsUtils.getGenericPropertyValue(iNodeComponentProperties, param.getName());
                if (value == null && EParameterFieldType.TABLE.equals(param.getFieldType())) {
                    value = GenericTableUtils.getTableValues(iNodeComponentProperties.getProperties(param.getName()), param);
                }
                return value;
            }
        }
    }
    return null;
}
Also used : ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentProperties(org.talend.components.api.properties.ComponentProperties) ComponentReferenceProperties(org.talend.components.api.properties.ComponentReferenceProperties) Properties(org.talend.daikon.properties.Properties) Property(org.talend.daikon.properties.property.Property) SchemaProperty(org.talend.daikon.properties.property.SchemaProperty)

Example 4 with Property

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

the class GenericTableUtils method setTableValues.

public static void setTableValues(Properties tableProperties, List<Map<String, Object>> value, IElementParameter param) {
    List<Map<String, String>> table = ElementParameterParser.createTableValues(value, param);
    for (String column : param.getListItemsDisplayCodeName()) {
        Property property = tableProperties.getValuedProperty(column);
        if (property.getValue() instanceof List) {
            ((List) property.getValue()).clear();
        }
    }
    for (Map<String, String> line : table) {
        for (String column : line.keySet()) {
            Property property = tableProperties.getValuedProperty(column);
            List<String> values = new ArrayList<>();
            if (property.getValue() == null || (!(property.getValue() instanceof List))) {
                property.setValue(values);
            } else {
                values = (List) property.getValue();
            }
            values.add(line.get(column));
        }
    }
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) Property(org.talend.daikon.properties.property.Property)

Example 5 with Property

use of org.talend.daikon.properties.property.Property 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)

Aggregations

Property (org.talend.daikon.properties.property.Property)42 ComponentProperties (org.talend.components.api.properties.ComponentProperties)20 NamedThing (org.talend.daikon.NamedThing)17 Form (org.talend.daikon.properties.presentation.Form)13 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)10 List (java.util.List)7 Schema (org.apache.avro.Schema)7 Properties (org.talend.daikon.properties.Properties)6 SchemaProperty (org.talend.daikon.properties.property.SchemaProperty)6 PresentationItem (org.talend.daikon.properties.PresentationItem)5 StringProperty (org.talend.daikon.properties.property.StringProperty)5 HashMap (java.util.HashMap)4 SalesforceConnectionProperties (org.talend.components.salesforce.SalesforceConnectionProperties)4 TSalesforceInputProperties (org.talend.components.salesforce.tsalesforceinput.TSalesforceInputProperties)4 SimpleNamedThing (org.talend.daikon.SimpleNamedThing)4 Map (java.util.Map)3 PropertyPathConnector (org.talend.components.api.component.PropertyPathConnector)3 ComponentWizard (org.talend.components.api.wizard.ComponentWizard)3 SalesforceModuleProperties (org.talend.components.salesforce.SalesforceModuleProperties)3