use of org.talend.commons.exception.PersistenceException 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.commons.exception.PersistenceException 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.commons.exception.PersistenceException 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.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class EncryptPasswordInProjectSettingsMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.migration.IProjectMigrationTask#execute(org.talend.core.model.general.Project)
*/
@Override
public ExecutionResult execute(Project project) {
org.talend.core.model.properties.Project emfProject = project.getEmfProject();
StatAndLogsSettings statAndLogs = emfProject.getStatAndLogsSettings();
boolean modified = false;
if (statAndLogs != null && statAndLogs.getParameters() != null) {
ParametersType parameters = statAndLogs.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterType) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for Stat&Logs
if ("PASS".equals(name)) {
//$NON-NLS-1$
try {
if (encryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
ImplicitContextSettings implicitContext = emfProject.getImplicitContextSettings();
if (implicitContext != null && implicitContext.getParameters() != null) {
ParametersType parameters = implicitContext.getParameters();
List elementParameter = parameters.getElementParameter();
for (int i = 0; i < elementParameter.size(); i++) {
final Object object = elementParameter.get(i);
if (object instanceof ElementParameterTypeImpl) {
ElementParameterType parameterType = (ElementParameterType) object;
String name = parameterType.getName();
// variable name used for implicit context
if ("PASS_IMPLICIT_CONTEXT".equals(name)) {
//$NON-NLS-1$
try {
if (encryptValueIfNeeded(parameterType)) {
modified = true;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
}
}
}
if (modified) {
try {
IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
prf.saveProject(project);
return ExecutionResult.SUCCESS_NO_ALERT;
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.NOTHING_TO_DO;
}
use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.
the class MigrationTaskForIssue10862 method execute.
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (getProject().getLanguage() != ECodeLanguage.JAVA || processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
//$NON-NLS-1$ //$NON-NLS-2$
String[] componentsName = new String[] { "tPatternCheck", "tPatternExtract" };
for (String name : componentsName) {
IComponentFilter filter = new NameComponentFilter(name);
try {
ModifyComponentsAction.searchAndModify(item, processType, filter, Arrays.<IComponentConversion>asList(new IComponentConversion() {
public void transform(NodeType node) {
//$NON-NLS-1$
ElementParameterType patternList = ComponentUtilities.getNodeProperty(node, "PATTERN_LIST");
if (ComponentUtilities.getNodeProperty(node, "CUSTOM_PATTERN") == null) {
//$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-2$
ComponentUtilities.addNodeProperty(node, "CUSTOM_PATTERN", "CHECK");
}
//$NON-NLS-1$
ElementParameterType customPattern = ComponentUtilities.getNodeProperty(node, "CUSTOM_PATTERN");
if (patternList != null && patternList.getValue().equals("\"CUSTOM2\"")) {
//$NON-NLS-1$
//$NON-NLS-1$
customPattern.setValue("true");
} else {
//$NON-NLS-1$
customPattern.setValue("false");
}
}
}));
} catch (PersistenceException e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
Aggregations