use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class ChangeMappingParameter4Redshift method execute.
@Override
public ExecutionResult execute(Item item) {
final ProcessType processType = getProcessType(item);
//$NON-NLS-1$ //$NON-NLS-2$
String[] compNames = { "tRedshiftInput", "tRedshiftOutput" };
IComponentConversion changeDBName4Hive = new IComponentConversion() {
public void transform(NodeType node) {
if (node == null) {
return;
}
//$NON-NLS-1$
ElementParameterType dbId = ComponentUtilities.getNodeProperty(node, "MAPPING");
if (dbId == null) {
return;
}
//$NON-NLS-1$
dbId.setValue("redshift_id");
}
};
for (String name : compNames) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(changeDBName4Hive));
} 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.ProcessType in project tdi-studio-se by Talend.
the class ChangeOptionDefaultValueFortNormalize method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tNormalize");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR") == null) {
ComponentUtilities.addNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR", "CHECK");
ElementParameterType useCSVOption = ComponentUtilities.getNodeProperty(node, "CSV_OPTION");
if (useCSVOption != null && "false".equals(useCSVOption.getValue())) {
ComponentUtilities.getNodeProperty(node, "DISCARD_TRAILING_EMPTY_STR").setValue("true");
}
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class ChangeOracleJarName4OracleComponents 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$
"tOracleOutput", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleOutputBulk", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleOutputBulkExec", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleRollback", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"tOracleRow", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
"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$
"tAmazonOracleCommit", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"tAmazonOracleConnection", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
"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$
"tCreateTable", //$NON-NLS-1$ //$NON-NLS-2$
"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-11g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc6.jar");
} else if ("ojdbc5-11g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc5.jar");
} else if ("ojdbc14-10g.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc14.jar");
} else if ("ojdbc14-9i.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
// db_version.setValue("ojdbc14-9i.jar");
} else if ("ojdbc12-8i.jar".equalsIgnoreCase(jarValue)) {
//$NON-NLS-1$
//$NON-NLS-1$
dbVersion.setValue("ojdbc12.jar");
}
}
}
};
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.ProcessType in project tdi-studio-se by Talend.
the class ChangeValueTDIBug19870 method execute.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@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[] { "tHDFSOutput" };
try {
for (int i = 0; i < componentsName.length; i++) {
IComponentFilter filter = new NameComponentFilter(componentsName[i]);
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "FILE_ACTION") == null || "false".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("CREATE");
} else if ("true".equals(ComponentUtilities.getNodeProperty(node, "FILE_ACTION").getValue())) {
ComponentUtilities.getNodeProperty(node, "FILE_ACTION").setValue("OVERWRITE");
}
}
}));
}
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class ChangeSqlPatternValueMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.ProcessItem)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<IComponentConversion> list = new ArrayList<IComponentConversion>();
list.add(new PropertyConversion());
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, list);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
if (modified) {
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
try {
factory.save(item, new boolean[] { true });
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
Aggregations