use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class CorrectBatchModeForDBComponents 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("tOracleOutput");
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");
}
//Use Existing Conn == true
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("false")) {
elementParaType.setValue("true");
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
}
}
}
};
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 CorrectBatchModeForJDBCOutput 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;
}
//groupx
List<String> filterList = Arrays.asList("tJDBCOutput");
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 useBatchSizePara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (useBatchSizePara == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").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");
}
}
};
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 CorrectBatchModeForTeradataOutput 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;
}
//groupx
List<String> filterList = Arrays.asList("tTeradataOutput");
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");
}
boolean useExistConn = ComponentUtilities.getNodeProperty(node, "USE_EXISTING_CONNECTION").getValue().equalsIgnoreCase("true");
ElementParameterType useBatchSizePara = ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE");
if (useBatchSizePara == null) {
ComponentUtilities.addNodeProperty(node, "USE_BATCH_SIZE", "CHECK");
ComponentUtilities.getNodeProperty(node, "USE_BATCH_SIZE").setValue("false");
}
boolean useBatchExistAndCheckForPreviousVersion = useBatchSizePara != null && useBatchSizePara.getValue().equalsIgnoreCase("true");
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(useBatchExistAndCheckForPreviousVersion ? "true" : "false");
}
boolean useBatchExistAndUncheckForPreviousVersion = useBatchSizePara != null && useBatchSizePara.getValue().equalsIgnoreCase("false");
if (useExistConn) {
if (useBatchExistAndUncheckForPreviousVersion) {
ComponentUtilities.getNodeProperty(node, "USE_BATCH_AND_USE_CONN").setValue("true");
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
}
} else {
if (useBatchExistAndUncheckForPreviousVersion) {
useBatchSizePara.setValue("true");
ComponentUtilities.getNodeProperty(node, "BATCH_SIZE").setValue("0");
}
}
}
};
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 AbstractProcessAction method checkUnLoadedNodeForProcess.
public void checkUnLoadedNodeForProcess(JobEditorInput fileEditorInput) {
if (fileEditorInput == null || fileEditorInput.getLoadedProcess() == null) {
return;
}
IProcess2 loadedProcess = fileEditorInput.getLoadedProcess();
List<NodeType> unloadedNode = loadedProcess.getUnloadedNode();
if (unloadedNode != null && !unloadedNode.isEmpty()) {
String message = "Some Component are not loaded:\n";
for (int i = 0; i < unloadedNode.size(); i++) {
message = message + unloadedNode.get(i).getComponentName() + "\n";
}
if (!CommonsPlugin.isHeadless() && PlatformUI.isWorkbenchRunning()) {
Display display = Display.getCurrent();
if (display == null) {
display = Display.getDefault();
}
if (display != null) {
final Display tmpDis = display;
final String tmpMess = message;
display.syncExec(new Runnable() {
public void run() {
Shell shell = null;
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
shell = activeWorkbenchWindow.getShell();
} else {
if (tmpDis != null) {
shell = tmpDis.getActiveShell();
} else {
shell = new Shell();
}
}
MessageDialog.openWarning(shell, "Warning", tmpMess);
}
});
}
}
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.NodeType in project tdi-studio-se by Talend.
the class DBMapSplitTableConstraintFiltersMigrationTask method execute.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
*/
@Override
public ExecutionResult execute(Item item) {
IProxyRepositoryFactory factory = CorePlugin.getDefault().getRepositoryService().getProxyRepositoryFactory();
ProcessType processType = getProcessType(item);
boolean modified = false;
if (processType != null) {
for (Object obj : processType.getNode()) {
NodeType nodeType = (NodeType) obj;
AbstractExternalData externalData = nodeType.getNodeData();
if (externalData instanceof DBMapData) {
DBMapData mapperData = (DBMapData) externalData;
for (OutputTable pTable : mapperData.getOutputTables()) {
int i = 0;
List<FilterEntry> needSplitFilters = new ArrayList<FilterEntry>();
List<FilterEntry> newFilters = new ArrayList<FilterEntry>();
for (FilterEntry pFilter : pTable.getFilterEntries()) {
String expression = pFilter.getExpression();
if (expression != null && !expression.trim().isEmpty()) {
if (!DbGenerationManager.containWith(expression, DbMapSqlConstants.GROUP_BY_PATTERN, false) && !DbGenerationManager.containWith(expression, DbMapSqlConstants.ORDER_BY_PATTERN, false)) {
continue;
} else {
// can not split the clause directly here, because clause like this(a = b GROUP BY
// c) will be put at
// the end of where clause
needSplitFilters.add(pFilter);
}
}
}
if (!needSplitFilters.isEmpty()) {
EList<FilterEntry> entryList = pTable.getFilterEntries();
for (FilterEntry pFilter : needSplitFilters) {
String expression = pFilter.getExpression().trim();
int splitIndex = firstIndexInString(expression, DbMapSqlConstants.GROUP_BY_PATTERN);
int orderIndex = firstIndexInString(expression, DbMapSqlConstants.ORDER_BY_PATTERN);
if (splitIndex < 0 || (0 <= orderIndex && orderIndex < splitIndex)) {
splitIndex = orderIndex;
}
if (splitIndex == 0) {
// keep the order of "GROUP BY" and "ORDER BY"
pFilter.setFilterKind(FilterTableEntry.OTHER_FILTER);
entryList.remove(pFilter);
newFilters.add(pFilter);
} else {
String whereClause = expression.substring(0, splitIndex);
if (//$NON-NLS-1$
!DbGenerationManager.containWith(expression, DbMapSqlConstants.OR + "\\b", true) && !DbGenerationManager.containWith(expression, DbMapSqlConstants.AND + "\\b", true)) {
//$NON-NLS-1$
//$NON-NLS-1$
whereClause = DbMapSqlConstants.AND + " " + whereClause;
}
pFilter.setExpression(whereClause);
FilterEntry tFilter = DbmapFactory.eINSTANCE.createFilterEntry();
//$NON-NLS-1$
tFilter.setName("newFilterSplited" + ++i);
tFilter.setExpression(expression.substring(splitIndex).trim());
tFilter.setFilterKind(FilterTableEntry.OTHER_FILTER);
entryList.remove(pFilter);
entryList.add(pFilter);
newFilters.add(tFilter);
}
modified = true;
}
if (!newFilters.isEmpty()) {
pTable.getFilterEntries().addAll(newFilters);
modified = true;
}
}
}
}
}
}
try {
if (modified) {
factory.save(item, true);
return ExecutionResult.SUCCESS_WITH_ALERT;
} else {
return ExecutionResult.SUCCESS_NO_ALERT;
}
} catch (Exception e) {
ExceptionHandler.process(e);
return ExecutionResult.FAILURE;
}
}
Aggregations