use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class RenametELTMigrationTask method execute.
public ExecutionResult execute(Item item) {
final String[] source = { "tELT", "tELTAggregate", "tELTCommit", "tELTFilterColumns", "tELTFilterRows", "tELTMerge", "tELTRollback" };
final String[] target = { "tSQLTemplate", "tSQLTemplateAggregate", "tSQLTemplateCommit", "tSQLTemplateFilterColumns", "tSQLTemplateFilterRows", "tSQLTemplateMerge", "tSQLTemplateRollback" };
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
for (int i = 0; i < source.length; i++) {
final int j = i;
IComponentFilter filter = new NameComponentFilter(source[i]);
RenameComponentConversion renameConversion = new RenameComponentConversion(target[i]);
IComponentConversion changeNodeNameConversion = new IComponentConversion() {
public void transform(NodeType node) {
ProcessType item = (ProcessType) node.eContainer();
for (Object o : item.getConnection()) {
ConnectionType connection = (ConnectionType) o;
if ("RUN_IF".equals(connection.getConnectorName())) {
for (Object obj : connection.getElementParameter()) {
ElementParameterType type = (ElementParameterType) obj;
if ("CONDITION".equals(type.getName())) {
if (type.getValue() != null && type.getValue().contains(source[j])) {
String replaceAll = type.getValue().replaceAll(source[j], target[j]);
type.setValue(replaceAll);
}
break;
}
}
}
}
for (Object o : item.getNode()) {
NodeType nt = (NodeType) o;
for (Object o1 : nt.getElementParameter()) {
ElementParameterType t = (ElementParameterType) o1;
String value = t.getValue();
if (value != null) {
if (value.contains(source[j])) {
String replaceAll = value.replaceAll(source[j], target[j]);
t.setValue(replaceAll);
}
}
if ("TABLE".equals(t.getField())) {
for (ElementValueType type : (List<ElementValueType>) t.getElementValue()) {
if (type.getValue() != null && type.getValue().contains(source[j])) {
String replaceAll = type.getValue().replaceAll(source[j], target[j]);
type.setValue(replaceAll);
}
}
}
}
}
}
};
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(renameConversion, changeNodeNameConversion));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tesb-studio-se by Talend.
the class CMessgingEndpointSwitchVersionTask method switchVersion.
private boolean switchVersion(NodeType currentNode) throws PersistenceException {
boolean needSave = false;
for (Object e : currentNode.getElementParameter()) {
ElementParameterType p = (ElementParameterType) e;
if ("HOTLIBS".equals(p.getName())) {
EList<?> elementValue = p.getElementValue();
for (Object pv : elementValue) {
ElementValueType evt = (ElementValueType) pv;
String evtValue = evt.getValue();
String switchVersion = switchVersion(evtValue);
if (switchVersion != null && !switchVersion.equals(evtValue)) {
evt.setValue(switchVersion);
needSave = true;
}
}
}
}
return needSave;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class SqlTemplateParameterRelationshipHandler method collect.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.relationship.AbstractParameterRelationshipHandler#collect(java.util.Map,
* java.util.Map)
*/
@Override
protected Set<Relation> collect(Map<String, ElementParameterType> parametersMap, Map<?, ?> options) {
Set<Relation> relationSet = new HashSet<Relation>();
//$NON-NLS-1$
ElementParameterType sqlpatternParamType = parametersMap.get("SQLPATTERN_VALUE");
// only for SQL Patterns
if (sqlpatternParamType != null) {
for (Object o3 : sqlpatternParamType.getElementValue()) {
if (o3 instanceof ElementValueType && "SQLPATTERNLIST".equals(((ElementValueType) o3).getElementRef())) {
//$NON-NLS-1$
Relation addedRelation = new Relation();
addedRelation.setId(((ElementValueType) o3).getValue());
addedRelation.setType(RelationshipItemBuilder.SQLPATTERN_RELATION);
addedRelation.setVersion(RelationshipItemBuilder.LATEST_VERSION);
relationSet.add(addedRelation);
}
}
}
return relationSet;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class UpgradetDenormalizeMigrationTask method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
try {
//$NON-NLS-1$
IComponentFilter filter1 = new NameComponentFilter("tDenormalize");
IComponentConversion conversion = new IComponentConversion() {
public void transform(NodeType node) {
List<ElementValueType> values = new ArrayList<ElementValueType>();
TalendFileFactory fileFact = TalendFileFactory.eINSTANCE;
MetadataType object = (MetadataType) node.getMetadata().get(0);
//$NON-NLS-1$
String delimiterValue = ComponentUtilities.getNodePropertyValue(node, "DELIMITER");
//$NON-NLS-1$
String mergeValue = ComponentUtilities.getNodePropertyValue(node, "MERGE");
//$NON-NLS-1$
ElementParameterType p = ComponentUtilities.getNodeProperty(node, "GROUPS");
if (p != null) {
EList<ElementValueType> es = p.getElementValue();
List<String> groups = new ArrayList<String>();
for (ElementValueType e : es) {
if (e.getElementRef().equals("INPUT_COLUMN")) {
//$NON-NLS-1$
groups.add(e.getValue());
}
}
for (Object o : object.getColumn()) {
ColumnType tagada = (ColumnType) o;
if (groups.contains(tagada.getName())) {
continue;
}
ElementValueType elementValue = fileFact.createElementValueType();
//$NON-NLS-1$
elementValue.setElementRef("INPUT_COLUMN");
elementValue.setValue(tagada.getName());
values.add(elementValue);
ElementValueType elementValue2 = fileFact.createElementValueType();
//$NON-NLS-1$
elementValue2.setElementRef("DELIMITER");
elementValue2.setValue(delimiterValue);
values.add(elementValue2);
ElementValueType elementValue3 = fileFact.createElementValueType();
//$NON-NLS-1$
elementValue3.setElementRef("MERGE");
elementValue3.setValue(mergeValue);
values.add(elementValue3);
}
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "DENORMALIZE_COLUMNS", "TABLE");
//$NON-NLS-1$
ComponentUtilities.setNodeProperty(node, "DENORMALIZE_COLUMNS", values);
//$NON-NLS-1$
ComponentUtilities.removeNodeProperty(node, "DELIMITER");
//$NON-NLS-1$
ComponentUtilities.removeNodeProperty(node, "MERGE");
//$NON-NLS-1$
ComponentUtilities.removeNodeProperty(node, "GROUPS");
}
}
};
ModifyComponentsAction.searchAndModify(item, processType, filter1, Arrays.<IComponentConversion>asList(conversion));
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementValueType in project tdi-studio-se by Talend.
the class SubstituteRemovedMDMOperatorMigrationTask method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
String[] componentsName = new String[] { "tMDMInput", "tMDMDelete", "tMDMViewSearch" };
IComponentConversion substituteRemovedOperatorsFromJobItem = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType operations = ComponentUtilities.getNodeProperty(node, "OPERATIONS");
if (operations != null && operations.getElementValue().size() > 0) {
for (ElementValueType elementValue : (List<ElementValueType>) operations.getElementValue()) {
if ("STRICTCONTAINS".equals(elementValue.getValue()) && "FUNCTION".equals(elementValue.getElementRef())) {
elementValue.setValue("CONTAINS");
}
}
}
}
};
for (String name : componentsName) {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(substituteRemovedOperatorsFromJobItem));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
Aggregations