use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class AbstractMultiPageTalendEditor method covertJobscriptOnPageChange.
private void covertJobscriptOnPageChange() {
try {
boolean isDirty = jobletEditor.isDirty();
jobletEditor.doSave(null);
IProcess2 oldProcess = getProcess();
ICreateXtextProcessService n = CorePlugin.getDefault().getCreateXtextProcessService();
Item item = oldProcess.getProperty().getItem();
ProcessType processType = null;
if (item instanceof ProcessItem) {
processType = n.convertDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
} else if (item instanceof JobletProcessItem) {
processType = n.convertJobletDesignerEditorInput(((IFile) jobletEditor.getEditorInput().getAdapter(IResource.class)).getLocation().toOSString(), oldProcess.getProperty());
}
if (item instanceof ProcessItem) {
((Process) oldProcess).updateProcess(processType);
} else if (item instanceof JobletProcessItem) {
((Process) oldProcess).updateProcess(processType);
}
oldProcess.getUpdateManager().updateAll();
designerEditor.setDirty(isDirty);
List<Node> nodes = (List<Node>) oldProcess.getGraphicalNodes();
List<Node> newNodes = new ArrayList<Node>();
newNodes.addAll(nodes);
for (Node node : newNodes) {
node.getProcess().checkStartNodes();
node.checkAndRefreshNode();
IElementParameter ep = node.getElementParameter("ACTIVATE");
if (ep != null && ep.getValue().equals(Boolean.FALSE)) {
node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
} else if (ep != null && ep.getValue().equals(Boolean.TRUE)) {
node.setPropertyValue(EParameterName.ACTIVATE.getName(), false);
node.setPropertyValue(EParameterName.ACTIVATE.getName(), true);
}
for (IElementParameter param : node.getElementParameters()) {
if (!param.getChildParameters().isEmpty()) {
if (param.getValue() != null && param.getValue() instanceof String && ((String) param.getValue()).contains(":")) {
String[] splited = ((String) param.getValue()).split(":");
String childNameNeeded = splited[0].trim();
String valueChild = TalendQuoteUtils.removeQuotes(splited[1].trim());
if (param.getChildParameters().containsKey(childNameNeeded)) {
param.getChildParameters().get(childNameNeeded).setValue(valueChild);
}
}
}
}
if (node.getNodeContainer() instanceof JobletContainer) {
JobletContainer jc = (JobletContainer) node.getNodeContainer();
if (node.isMapReduceStart()) {
//$NON-NLS-1$
jc.updateState("UPDATE_STATUS", "", jc.getPercentMap(), jc.getPercentReduce());
}
}
}
} catch (PersistenceException e) {
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class UseOracleSIDAsDefaultOracleTypeMigrationTask method execute.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.migration.AbstractJobMigrationTask#executeOnProcess(org.talend.core.model.properties.
* ProcessItem)
*/
@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
ProcessType processType = getProcessType(item);
if (processType == null) {
return ExecutionResult.NOTHING_TO_DO;
}
EList parameters = null;
try {
parameters = processType.getParameters().getElementParameter();
} catch (Exception e) {
// ignore it
}
if (parameters != null) {
for (int i = 0; i < parameters.size(); i++) {
ElementParameterType parameter = (ElementParameterType) parameters.get(i);
if ((parameter.getName().equals(EParameterName.DB_TYPE.getName()) || parameter.getName().equals(//$NON-NLS-1$
"DB_TYPE_IMPLICIT_CONTEXT")) && parameter.getField().equals(EParameterFieldType.CLOSED_LIST.getName())) {
String value = parameter.getValue();
if (value.equalsIgnoreCase("tOracleOutput")) {
//$NON-NLS-1$
// Default set to Orace SID(see bug 5315) //$NON-NLS-1$
parameter.setValue("tOracleOutput_sid");
}
}
}
}
return ExecutionResult.SUCCESS_WITH_ALERT;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class NewProcessWizard method createProcessItem.
@SuppressWarnings("unchecked")
protected void createProcessItem() {
try {
property.setId(repositoryFactory.getNextId());
// changed by hqzhang for TDI-19527, label=displayName
property.setLabel(property.getDisplayName());
ProcessType process = TalendFileFactory.eINSTANCE.createProcessType();
ParametersType parameterType = TalendFileFactory.eINSTANCE.createParametersType();
// add depended routines.
List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
parameterType.getRoutinesParameter().addAll(dependenciesInPreference);
process.setParameters(parameterType);
processItem.setProcess(process);
repositoryFactory.create(processItem, mainPage.getDestinationPath());
} catch (PersistenceException e) {
MessageDialog.openError(getShell(), Messages.getString("NewProcessWizard.failureTitle"), //$NON-NLS-1$
Messages.getString("NewProcessWizard.failureText") + " : " + //$NON-NLS-1$ //$NON-NLS-2$
e.getMessage());
ExceptionHandler.process(e);
}
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType in project tdi-studio-se by Talend.
the class SaveAsProcessWizard method performFinish.
@Override
public boolean performFinish() {
boolean ok = false;
try {
IProcess2 loadedProcess = jobEditorInput.getLoadedProcess();
ProcessType processType = loadedProcess.saveXmlFile();
isUpdate = isUpdate();
if (isUpdate) {
update(processType);
} else {
processItem.setProcess(processType);
property.setId(repositoryFactory.getNextId());
// don't need to add depended routines.
repositoryFactory.create(processItem, mainPage.getDestinationPath());
RelationshipItemBuilder.getInstance().addOrUpdateItem(processItem);
}
ok = true;
} catch (Exception e) {
MessageDialog.openError(getShell(), "Error", "Job could not be saved" + " : " + e.getMessage());
ExceptionHandler.process(e);
}
return ok;
}
use of org.talend.designer.core.model.utils.emf.talendfile.ProcessType 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