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()));
}
}
}
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;
}
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()));
}
}
}
Aggregations