use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class ChangeShareIdentityDefaultValueMigrationTaskIssue9519 method execute.
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$
String[] componentsName = new String[] { "tMSSqlConnection" };
for (String name : componentsName) {
//$NON-NLS-1$
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
// TODO Auto-generated method stub
//$NON-NLS-1$
ElementParameterType propertyShareIdentitySetting = ComponentUtilities.getNodeProperty(node, "SHARE_IDENTITY_SETTING");
if (propertyShareIdentitySetting == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "SHARE_IDENTITY_SETTING", "CHECK");
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.setNodeValue(node, "SHARE_IDENTITY_SETTING", "true");
}
}
}));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class ChangeSpecifyKeysAndColumnsFortCassandraInput method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tCassandraInput");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType specifyKeys = ComponentUtilities.getNodeProperty(node, "SPECIFY_KEYS");
ElementParameterType specifyColumns = ComponentUtilities.getNodeProperty(node, "SPECIFY_COLUMNS");
ElementParameterType columns = ComponentUtilities.getNodeProperty(node, "SUPER_COLUMN_KEYS");
ElementParameterType columnStart = ComponentUtilities.getNodeProperty(node, "COLUMN_START");
ElementParameterType columnEnd = ComponentUtilities.getNodeProperty(node, "COLUMN_END");
ElementParameterType columnLimit = ComponentUtilities.getNodeProperty(node, "COLUMN_LIMIT");
ElementParameterType columnFamilyType = ComponentUtilities.getNodeProperty(node, "COLUMN_FAMILY_TYPE");
ElementParameterType keyStart = ComponentUtilities.getNodeProperty(node, "KEY_START");
ElementParameterType keyEnd = ComponentUtilities.getNodeProperty(node, "KEY_END");
ElementParameterType count = ComponentUtilities.getNodeProperty(node, "COUNT");
if (specifyKeys == null && specifyColumns == null && columnStart == null && columnEnd == null && columns != null && columnLimit == null && keyStart != null && keyEnd != null && count != null) {
ComponentUtilities.addNodeProperty(node, "SPECIFY_KEYS", "CHECK");
ComponentUtilities.getNodeProperty(node, "SPECIFY_KEYS").setValue("true");
ComponentUtilities.addNodeProperty(node, "SPECIFY_COLUMNS", "CHECK");
if ("SUPER".equals(columnFamilyType.getValue()) && (!"".equals(columns.getValue())) && (!"\"\"".equals(columns.getValue()))) {
ComponentUtilities.getNodeProperty(node, "SPECIFY_COLUMNS").setValue("true");
}
ComponentUtilities.addNodeProperty(node, "COLUMNS", "TEXT");
ComponentUtilities.removeNodeProperty(node, "SUPER_COLUMN_KEYS");
ComponentUtilities.getNodeProperty(node, "COLUMNS").setValue(columns.getValue());
ComponentUtilities.addNodeProperty(node, "COLUMN_START", "TEXT");
ComponentUtilities.getNodeProperty(node, "COLUMN_START").setValue(keyStart.getValue());
ComponentUtilities.getNodeProperty(node, "KEY_START").setValue("\"\"");
ComponentUtilities.addNodeProperty(node, "COLUMN_END", "TEXT");
ComponentUtilities.getNodeProperty(node, "COLUMN_END").setValue(keyEnd.getValue());
ComponentUtilities.getNodeProperty(node, "KEY_END").setValue("\"\"");
ComponentUtilities.addNodeProperty(node, "COLUMN_LIMIT", "TEXT");
ComponentUtilities.getNodeProperty(node, "COLUMN_LIMIT").setValue(count.getValue());
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class ChangeReadByParameter4tFileInputJSON method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$
String[] compNames = { "tFileInputJSON" };
IComponentConversion action = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType originalElement = ComponentUtilities.getNodeProperty(node, "READBYXPATH");
if (originalElement == null) {
return;
}
String content = originalElement.getValue();
if (content == null) {
return;
}
ComponentUtilities.addNodeProperty(node, "READ_BY", "CLOSED_LIST");
if ("false".equals(content)) {
ComponentUtilities.setNodeValue(node, "READ_BY", "JSONPATH_WITHOUTPUT_LOOP");
} else {
//read by xpath
ComponentUtilities.setNodeValue(node, "READ_BY", "XPATH");
}
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(action));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class ChangeOracleJarName4OracleComponentsByDB_VERSION method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
String[] oracleCompNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleOutputBulk", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
"tOracleSCD", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleSCDELT", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleSP", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleTableList", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tAmazonOracleClose", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tAmazonOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tMondrianInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tOracleInvalidRows", "tOracleValidRows", "tELTOracleMap", "tOracleCDC", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
"tOracleSCDELT" };
IComponentConversion changeOracleDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType dbVersion = ComponentUtilities.getNodeProperty(node, "DB_VERSION");
if (dbVersion != null) {
String jarValue = dbVersion.getValue();
if ("ojdbc6.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ORACLE_11-6");
} else if ("ojdbc5.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ORACLE_11");
} else if ("ojdbc14.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ORACLE_10");
} else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ORACLE_9");
} else if ("ojdbc12.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ORACLE_8");
}
}
}
};
for (String name : oracleCompNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeOracleDriverJarType));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType in project tdi-studio-se by Talend.
the class ChangeOracleJarName4OracleDriver method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
String[] compNames = { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tELTJDBCMap", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tJDBCConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tJDBCInput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tJDBCOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tJDBCRow", "tJDBCSP", //$NON-NLS-1$ //$NON-NLS-2$
"tLibraryLoad" };
IComponentConversion changeOracleDriverJarType = new IComponentConversion() {
public void transform(NodeType node) {
if ("tLibraryLoad".equals(node.getComponentName())) {
//$NON-NLS-1$
//$NON-NLS-1$
ElementParameterType moduleLib = ComponentUtilities.getNodeProperty(node, "LIBRARY");
if (moduleLib != null) {
moduleLib.setValue(convert(moduleLib.getValue()));
}
//$NON-NLS-1$
ElementParameterType hotLibs = ComponentUtilities.getNodeProperty(node, "HOTLIBS");
if (hotLibs != null) {
for (Object element : hotLibs.getElementValue()) {
if (element == null) {
continue;
}
ElementValueType valueType = (ElementValueType) element;
if ("LIBPATH".equals(valueType.getElementRef())) {
//$NON-NLS-1$
valueType.setValue(convert(valueType.getValue()));
}
}
}
} else {
//$NON-NLS-1$
ElementParameterType driverJars = ComponentUtilities.getNodeProperty(node, "DRIVER_JAR");
if (driverJars != null) {
for (Object element : driverJars.getElementValue()) {
if (element == null) {
continue;
}
ElementValueType valueType = (ElementValueType) element;
if ("JAR_NAME".equals(valueType.getElementRef())) {
//$NON-NLS-1$
valueType.setValue(convert2(valueType.getValue()));
}
}
}
}
}
/**
* convert the string value that contain double quote text closure.
* @param source
* @return
*/
String convert(String source) {
if ("\"ojdbc6-11g.jar\"".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "\"ojdbc6.jar\"";
} else if ("\"ojdbc5-11g.jar\"".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "\"ojdbc5.jar\"";
} else if ("\"ojdbc14-10g.jar\"".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "\"ojdbc14.jar\"";
} else if ("\"ojdbc12-8i.jar\"".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "\"ojdbc12.jar\"";
}
return source;
}
/**
* convert the string value that not contain double quote text closure.
* @param source
* @return
*/
String convert2(String source) {
if ("ojdbc6-11g.jar".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "ojdbc6.jar";
} else if ("ojdbc5-11g.jar".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "ojdbc5.jar";
} else if ("ojdbc14-10g.jar".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "ojdbc14.jar";
} else if ("ojdbc12-8i.jar".equalsIgnoreCase(source)) {
//$NON-NLS-1$
return "ojdbc12.jar";
}
return source;
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeOracleDriverJarType));
} catch (PersistenceException e) {
// TODO Auto-generated catch block
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
Aggregations