use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class CorrectBatchSizeForDBComponents method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tAmazonOracleOutput", "tInformixOutput");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
if (useExistingConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
}
ElementParameterType useBatchAndUseConnPara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
if (useBatchAndUseConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
}
boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (elementParaType == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
if (!useExistConn) {
if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("true")) {
String batchSizeInStr = ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").getValue();
if (batchSizeInStr != null && !"".equals(batchSizeInStr)) {
int batchSize = Integer.valueOf(batchSizeInStr);
if (batchSize <= 0) {
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("1");
}
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class CorrectBatchSizeForDBComponentsMore method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tAS400Output", "tNetezzaOutput", "tVerticaOutput", "tDB2Output", "tMSSqlOutput", "tPostgresqlOutput", "tSybaseOutput", "tVectorWiseOutput", "tAmazonMysqlOutput");
IComponentConversion correctBatchModeForDBComponents = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useExistingConnPara = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION");
if (useExistingConnPara == null) {
ComponentUtilities.addNodeProperty(node, "USE_EXISTING_CONNECTION", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").setValue("false");
}
ElementParameterType elementParaType = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (elementParaType == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
if (elementParaType != null && elementParaType.getValue().equalsIgnoreCase("true")) {
String batchSizeInStr = ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").getValue();
if (batchSizeInStr != null && !"".equals(batchSizeInStr)) {
if (batchSizeInStr.matches("\\d+")) {
//$NON-NLS-1$
int batchSize = Integer.valueOf(batchSizeInStr);
if (batchSize <= 0) {
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("1");
}
}
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(correctBatchModeForDBComponents));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class CorrectTeradataTPTExecInserterOperatorToLoad method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
IComponentFilter filter = new NameComponentFilter("tTeradataTPTExec");
IComponentFilter filterTTeradataTPTUtility = new NameComponentFilter("tTeradataTPTUtility");
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "ACTION").getValue().equalsIgnoreCase("Insert")) {
//$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "ACTION").setValue("Load");
if (ComponentUtilities.getNodeProperty(node, "SCRIPT_PARAMETER") == null) {
ComponentUtilities.addNodeProperty(node, "SCRIPT_PARAMETER", "CHECK");
ComponentUtilities.getNodeProperty(node, "SCRIPT_PARAMETER").setValue("true");
}
}
}
}));
ModifyComponentsAction.searchAndModify(item, processType, filterTTeradataTPTUtility, Arrays.<IComponentConversion>asList(new IComponentConversion() {
@Override
public void transform(NodeType node) {
if (ComponentUtilities.getNodeProperty(node, "ACTION").getValue().equalsIgnoreCase("Insert")) {
//$NON-NLS-1$ //$NON-NLS-2$
//$NON-NLS-1$
ComponentUtilities.getNodeProperty(node, "ACTION").setValue("Load");
if (ComponentUtilities.getNodeProperty(node, "SCRIPT_PARAMETER") == null) {
ComponentUtilities.addNodeProperty(node, "SCRIPT_PARAMETER", "CHECK");
ComponentUtilities.getNodeProperty(node, "SCRIPT_PARAMETER").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.NodeType in project tdi-studio-se by Talend.
the class DisableUseBatchWhenRejectLineExists method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
List<String> filterList = Arrays.asList("tFirebirdOutput", "tGreenplumOutput", "tIngresOutput", "tInterbaseOutput", "tParAccelOutput", "tPostgresPlusOutput", "tSQLiteOutput", "tRedshiftOutput");
List<String> filterListMore = Arrays.asList("tTeradataOutput", "tOracleOutput");
IComponentConversion disableUseBatchWhenRejectLineExists = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH").setValue("false");
break;
}
}
}
};
IComponentConversion disableUseBatchWhenRejectLineExistsMore = new IComponentConversion() {
public void transform(NodeType node) {
ElementParameterType useBatch = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
ElementParameterType useBatchAndUseExistingConn = ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN");
List<ConnectionType> list = ComponentUtilities.getNodeOutputConnections(node);
for (ConnectionType connType : list) {
EConnectionType eConnType = EConnectionType.getTypeFromId(connType.getLineStyle());
if (eConnType == EConnectionType.FLOW_MAIN && connType.getConnectorName().equals("REJECT")) {
if (useBatch == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
}
if (useBatchAndUseExistingConn == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_AND_USE_CONN", "CHECK");
}
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("false");
break;
}
}
}
};
for (String componentName : filterList) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExists));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
for (String componentName : filterListMore) {
IComponentFilter filter = new NameComponentFilter(componentName);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(disableUseBatchWhenRejectLineExistsMore));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_NO_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class FileInputRegexContextVariableMigrationTask method addQuote.
private boolean addQuote(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return false;
}
ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
boolean modified = false;
EList nodes = processType.getNode();
for (Object n : nodes) {
NodeType type = (NodeType) n;
if (type.getComponentName().equals("tFileInputRegex")) {
//$NON-NLS-1$
EList elementParameterList = type.getElementParameter();
for (Object elem : elementParameterList) {
ElementParameterType elemType = (ElementParameterType) elem;
if (//$NON-NLS-1$ //$NON-NLS-2$
elemType.getName().equals("HEADER") || elemType.getName().equals("FOOTER") || elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
String oldV = elemType.getValue();
if (oldV == null || oldV.length() == 0) {
if (elemType.getName().equals("LIMIT")) {
//$NON-NLS-1$
//$NON-NLS-1$
oldV = "-1";
} else {
//$NON-NLS-1$
oldV = "0";
}
}
if (!oldV.contains("\"")) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
elemType.setValue("\"" + oldV + "\"");
}
modified = true;
}
}
}
}
return modified;
}
Aggregations