use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericConnectionUtil method synNamePropertyWithItem.
/**
* Syncronize the value of <code>name</code> property between component properties and connection item.
*
* @param item the item which name property belong to.
* @return return true if property is updated, otherwise return false;
*/
public static boolean synNamePropertyWithItem(GenericConnectionItem item) {
GenericConnection connection = (GenericConnection) item.getConnection();
String compPropertiesStr = connection.getCompProperties();
if (compPropertiesStr == null) {
return false;
}
ComponentProperties componentProperties = ComponentsUtils.getComponentPropertiesFromSerialized(compPropertiesStr, connection);
if (componentProperties == null) {
return false;
}
Property nameProperty = (Property) componentProperties.getProperty(IGenericConstants.NAME_PROPERTY);
if (nameProperty == null) {
return false;
}
Object namePropertyVal = nameProperty.getValue();
String newName = item.getProperty().getLabel();
if (newName != null && !newName.equals(namePropertyVal)) {
nameProperty.setValue(newName);
connection.setCompProperties(componentProperties.toSerialized());
return true;
}
return false;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericContextUtil method revertPropertiesForContextMode.
public static void revertPropertiesForContextMode(Connection connection, ContextType contextType) {
if (connection instanceof GenericConnection) {
GenericConnection conn = (GenericConnection) connection;
ComponentProperties componentProperties = getComponentProperties(conn);
revertPropertiesValues(componentProperties, contextType);
updateComponentProperties(conn, componentProperties);
}
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericContextUtil method setPropertiesForExistContextMode.
public static void setPropertiesForExistContextMode(Connection connection, Set<IConnParamName> paramSet, Map<ContextItem, List<ConectionAdaptContextVariableModel>> adaptMap) {
if (connection == null) {
return;
}
if (connection instanceof GenericConnection) {
GenericConnection genericConn = (GenericConnection) connection;
ComponentProperties componentProperties = getComponentProperties(genericConn);
ContextItem currentContext = null;
for (IConnParamName param : paramSet) {
if (param instanceof GenericConnParamName) {
String genericVariableName = null;
GenericConnParamName genericParam = (GenericConnParamName) param;
if (adaptMap != null && adaptMap.size() > 0) {
for (Map.Entry<ContextItem, List<ConectionAdaptContextVariableModel>> entry : adaptMap.entrySet()) {
currentContext = entry.getKey();
List<ConectionAdaptContextVariableModel> modelList = entry.getValue();
for (ConectionAdaptContextVariableModel model : modelList) {
if (model.getValue().equals(genericParam.getName())) {
genericVariableName = model.getName();
break;
}
}
}
}
if (genericVariableName != null) {
genericVariableName = getCorrectVariableName(currentContext, genericVariableName, genericParam);
matchContextForAttribues(componentProperties, genericParam, genericVariableName);
}
}
}
updateComponentProperties(genericConn, componentProperties);
}
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class GenericContextUtil method createContextParameters.
public static List<IContextParameter> createContextParameters(String prefixName, Connection connection, Set<IConnParamName> paramSet) {
List<IContextParameter> varList = new ArrayList<>();
if (connection instanceof GenericConnection) {
GenericConnection conn = (GenericConnection) connection;
if (conn == null || prefixName == null || paramSet == null || paramSet.isEmpty()) {
return Collections.emptyList();
}
String paramPrefix = prefixName + ConnectionContextHelper.LINE;
String paramName = null;
for (IConnParamName param : paramSet) {
if (param instanceof GenericConnParamName) {
GenericConnParamName connParamName = (GenericConnParamName) param;
String name = connParamName.getName();
ComponentProperties componentProperties = getComponentProperties((GenericConnection) connection);
Property<?> property = componentProperties.getValuedProperty(name);
paramName = paramPrefix + connParamName.getContextVar();
JavaType type = JavaTypesManager.STRING;
if (property.isFlag(Property.Flags.ENCRYPT)) {
type = JavaTypesManager.PASSWORD;
}
if (GenericTypeUtils.isIntegerType(property)) {
type = JavaTypesManager.INTEGER;
}
String value = property == null || property.getValue() == null ? null : StringEscapeUtils.escapeJava(String.valueOf(property.getValue()));
ConnectionContextHelper.createParameters(varList, paramName, value, type);
}
}
}
return varList;
}
use of org.talend.components.api.properties.ComponentProperties in project tdi-studio-se by Talend.
the class DynamicComposite method propertyChange.
@Override
public void propertyChange(PropertyChangeEvent event) {
String propertyName = event.getPropertyName();
if (IElementParameterEventProperties.EVENT_PROPERTY_VALUE_CHANGED.equals(propertyName)) {
reset(true);
} else if (IElementParameterEventProperties.EVENT_VALIDATE_RESULT_UPDATE.equals(propertyName)) {
Object newValue = event.getNewValue();
if (newValue instanceof ValidationResult) {
updateValidationStatus((ValidationResult) newValue);
}
} else if (IElementParameterEventProperties.EVENT_SHOW_DIALOG.equals(propertyName)) {
Object newValue = event.getNewValue();
if (newValue instanceof Form) {
GenericDialog genericDialog = new GenericDialog(getShell(), (Form) newValue);
genericDialog.setConnectionItem(connectionItem);
genericDialog.open();
}
} else if (IContextEventProperties.EVENT_PROPERTY_EXPORT_CONTEXT.equals(propertyName)) {
resetComponentProperties();
} else if (IContextEventProperties.EVENT_PROPERTY_REFRESH_UI.equals(propertyName)) {
Object newValue = event.getNewValue();
if (newValue instanceof ComponentProperties) {
ComponentProperties newComponentProperties = (ComponentProperties) newValue;
form.getProperties().copyValuesFrom(newComponentProperties);
reset(true);
}
}
}
Aggregations