use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method updateSchema.
@SuppressWarnings("unchecked")
private void updateSchema() {
Object updateObject = result.getUpdateObject();
if (updateObject == null) {
return;
}
if (updateObject instanceof Node) {
// opened job
Node node = (Node) updateObject;
boolean builtIn = true;
final IExternalNode externalNode = node.getExternalNode();
if (result.getResultType() == EUpdateResult.UPDATE) {
if (result.isChecked()) {
if (result.getParameter() instanceof List) {
// for ebcdic
if (PluginChecker.isEBCDICPluginLoaded()) {
IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
if (service != null) {
if (service.isEbcdicNode(node)) {
List<Object> parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 2) {
IMetadataTable newTable = (IMetadataTable) parameter.get(0);
String schemaName = (String) parameter.get(1);
IMetadataTable metadataTable = MetadataToolHelper.getMetadataTableFromNodeLabel(node, schemaName);
if (metadataTable != null) {
MetadataToolHelper.copyTable(newTable, metadataTable);
}
syncSchemaForEBCDIC(node, metadataTable);
}
return;
}
}
}
// for tMap
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
if (service != null && externalNode != null && externalNode.getExternalData() != null) {
List<Object> parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 2) {
if (node.getComponent() != null && "tMap".equals(node.getComponent().getName())) {
//$NON-NLS-1$
IMetadataTable newTable = (IMetadataTable) parameter.get(0);
String schemaId = (String) parameter.get(1);
service.updateMapperTableEntries(externalNode, schemaId, newTable);
node.setMetadataList(externalNode.getMetadataList());
syncSchemaForTMap(node);
// update metadataList,or it will cause bug 21080
for (IExternalMapTable latestTable : externalNode.getExternalData().getOutputTables()) {
for (IMetadataTable tableExsit : node.getMetadataList()) {
// find table,and update the table
if (latestTable.getName().equals(tableExsit.getTableName())) {
List<IMetadataColumn> newColumns = newTable.getListColumns();
for (IMetadataColumn column : tableExsit.getListColumns()) {
for (IMetadataColumn newColumn : newColumns) {
if (tableExsit.getTableName().equals(newTable.getTableName()) && newColumn.getLabel().equals(column.getLabel())) {
column.setTalendType(newColumn.getTalendType());
column.setNullable(newColumn.isNullable());
column.setComment(newColumn.getComment());
column.setDefault(newColumn.getDefault());
column.setLength(newColumn.getLength());
column.setType(newColumn.getType());
column.setKey(newColumn.isKey());
column.setPrecision(newColumn.getPrecision());
break;
}
}
}
break;
}
}
}
}
}
}
}
} else if (result.getParameter() instanceof IMetadataTable) {
IMetadataTable newTable = (IMetadataTable) result.getParameter();
// getListColumns());
if (newTable != null) {
INodeConnector nodeConnector = node.getConnectorFromName(newTable.getAttachedConnector());
// if (nodeConnector.getBaseSchema().equals(newTable.getAttachedConnector())) {
if (nodeConnector != null) {
List<IElementParameter> params = node.getElementParametersFromField(EParameterFieldType.SCHEMA_TYPE);
if (params == null || params.isEmpty()) {
params = node.getElementParametersFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
// node.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (params != null) {
for (IElementParameter param : params) {
if (!newTable.getAttachedConnector().equals(param.getContext())) {
continue;
}
ChangeMetadataCommand cmd = null;
if (param.getChildParameters() != null && param.getChildParameters().get("REPOSITORY_SCHEMA_TYPE") != null && result.getContextModeConnectionItem() != null) {
final Object value = param.getChildParameters().get("REPOSITORY_SCHEMA_TYPE").getValue();
// for sap
String remark = result.getRemark();
String namePrefix = "";
if (remark != null) {
String[] split = remark.split(UpdatesConstants.SEGMENT_LINE);
if (split.length == 2) {
String tableName = split[1];
String[] tableSplit = tableName.split("/");
if (tableSplit.length == 3) {
namePrefix = tableSplit[0] + "/" + tableSplit[1] + "/";
}
}
}
String idAndName = result.getContextModeConnectionItem().getProperty().getId() + UpdatesConstants.SEGMENT_LINE + namePrefix + newTable.getLabel();
if (idAndName.equals(value)) {
cmd = new ChangeMetadataCommand(node, param, null, newTable);
}
} else {
cmd = new ChangeMetadataCommand(node, param, null, newTable);
}
if (cmd != null) {
// wzhang added to fix 9251. get the current connection.
String propertyValue = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById(propertyValue);
Connection repositoryConn = null;
if (lastVersion != null) {
final Item item = lastVersion.getProperty().getItem();
if (item != null && item instanceof ConnectionItem) {
repositoryConn = ((ConnectionItem) item).getConnection();
}
}
cmd.setConnection(repositoryConn);
if (node.getProcess() instanceof IProcess2) {
IUpdateManager updateManager = ((IProcess2) node.getProcess()).getUpdateManager();
if (updateManager instanceof AbstractUpdateManager) {
cmd.setColumnRenameMap(((AbstractUpdateManager) updateManager).getColumnRenamedMap());
}
}
cmd.setRepositoryMode(true);
cmd.execute(true);
}
}
} else {
MetadataToolHelper.copyTable(newTable, node.getMetadataFromConnector(nodeConnector.getName()));
}
// }
}
builtIn = false;
}
}
}
} else if (result.getResultType() == EUpdateResult.RENAME) {
List<Object> parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 3) {
IMetadataTable newTable = (IMetadataTable) parameter.get(0);
String oldSourceId = (String) parameter.get(1);
String newSourceId = (String) parameter.get(2);
// for ebcdic
if (PluginChecker.isEBCDICPluginLoaded()) {
IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
if (service != null) {
if (service.isEbcdicNode(node)) {
String[] sourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName(oldSourceId);
final String oldSchemaName = sourceIdAndChildName[1];
sourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName(newSourceId);
final String newSchemaName = sourceIdAndChildName[1];
IMetadataTable metadataTable = MetadataToolHelper.getMetadataTableFromNodeLabel(node, oldSchemaName);
if (metadataTable != null && oldSchemaName != null) {
List<Map<String, Object>> paramValues = (List<Map<String, Object>>) node.getPropertyValue(IEbcdicConstant.TABLE_SCHEMAS);
for (Map<String, Object> line : paramValues) {
if (line.get(IEbcdicConstant.FIELD_SCHEMA).equals(oldSchemaName)) {
line.remove(IEbcdicConstant.FIELD_SCHEMA);
line.put(IEbcdicConstant.FIELD_SCHEMA, newSchemaName);
}
}
PropertyChangeCommand cmd = new PropertyChangeCommand(node, IEbcdicConstant.TABLE_SCHEMAS, paramValues);
cmd.execute();
MetadataToolHelper.copyTable(newTable, metadataTable);
metadataTable.setLabel(newSchemaName);
syncSchemaForEBCDIC(node, metadataTable);
}
}
}
}
// for tmap
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
if (service != null && externalNode != null && externalNode.getExternalData() != null) {
parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 3) {
if (node.getComponent() != null && "tMap".equals(node.getComponent().getName())) {
//$NON-NLS-1$
newTable = (IMetadataTable) parameter.get(0);
String schemaId = (String) parameter.get(1);
String newSchemaId = (String) parameter.get(2);
service.renameMapperTable(externalNode, schemaId, newSchemaId, newTable);
node.setMetadataList(externalNode.getMetadataList());
syncSchemaForTMap(node);
}
}
}
}
String schemaParamName = UpdatesConstants.SCHEMA + UpdatesConstants.COLON + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
IElementParameter repositoryParam = node.getElementParameter(schemaParamName);
if (repositoryParam == null) {
schemaParamName = UpdatesConstants.SCHEMA_FLOW + UpdatesConstants.COLON + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
repositoryParam = node.getElementParameter(schemaParamName);
}
if (repositoryParam == null) {
IElementParameter schemaParentParam = node.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
if (schemaParentParam != null) {
schemaParamName = schemaParentParam.getName() + UpdatesConstants.COLON + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
repositoryParam = node.getElementParameter(schemaParamName);
}
}
if (repositoryParam != null && oldSourceId.equals(repositoryParam.getValue())) {
node.setPropertyValue(schemaParamName, newSourceId);
if (newTable != null) {
for (INodeConnector nodeConnector : node.getListConnector()) {
if (nodeConnector.getBaseSchema().equals(newTable.getAttachedConnector())) {
MetadataToolHelper.copyTable(newTable, node.getMetadataFromConnector(nodeConnector.getName()));
}
}
}
builtIn = false;
}
String inputSchemaParamName = UpdatesConstants.INPUT_SCHEMA + UpdatesConstants.COLON + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
IElementParameter inputRepositoryParam = node.getElementParameter(inputSchemaParamName);
if (inputRepositoryParam != null && oldSourceId.equals(inputRepositoryParam.getValue())) {
node.setPropertyValue(inputSchemaParamName, newSourceId);
if (newTable != null) {
for (INodeConnector nodeConnector : node.getListConnector()) {
if (nodeConnector.getBaseSchema().equals(newTable.getAttachedConnector())) {
MetadataToolHelper.copyTable(newTable, node.getMetadataFromConnector(nodeConnector.getName()));
}
}
}
builtIn = false;
}
// for tELTAggregate
schemaParamName = UpdatesConstants.SCHEMA_TARGET + UpdatesConstants.COLON + EParameterName.REPOSITORY_SCHEMA_TYPE.getName();
repositoryParam = node.getElementParameter(schemaParamName);
if (repositoryParam != null && oldSourceId.equals(repositoryParam.getValue())) {
node.setPropertyValue(schemaParamName, newSourceId);
if (newTable != null) {
for (INodeConnector nodeConnector : node.getListConnector()) {
if (nodeConnector.getBaseSchema().equals(repositoryParam.getContext())) {
MetadataToolHelper.copyTable(newTable, node.getMetadataFromConnector(nodeConnector.getName()));
}
}
}
builtIn = false;
}
}
} else if (result.getResultType() == EUpdateResult.BUIL_IN) {
// for tELTAgrregate
if (UpdatesConstants.SCHEMA_TARGET.equals(result.getParameter())) {
node.setPropertyValue(UpdatesConstants.SCHEMA_TARGET + ":" + EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
} else {
// for ebcdic
if (PluginChecker.isEBCDICPluginLoaded()) {
IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
if (service != null) {
if (service.isEbcdicNode(node)) {
Object parameter = result.getParameter();
if (parameter instanceof Map) {
Map<String, Object> lineValue = (Map<String, Object>) parameter;
lineValue.remove(IEbcdicConstant.FIELD_SCHEMA + IEbcdicConstant.REF_TYPE);
}
// since it is a build-in ebcdic,should change its property before return
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
return;
}
}
}
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (service != null && service.isJobletInOutComponent(node)) {
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName() + ":" + EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
}
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
for (IElementParameter param : node.getElementParameters()) {
SAPParametersUtils.setNoRepositoryParams(param);
}
}
} else if (result.getResultType() == EUpdateResult.DELETE) {
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
} else if (result.getResultType() == EUpdateResult.RELOAD) {
List<Object> parameter = (List<Object>) result.getParameter();
String connectionId = null;
String tableLabel = null;
IRepositoryViewObject toReload = null;
IMetadataTable tableToReload = null;
if (parameter instanceof List) {
List listParameter = parameter;
connectionId = (String) node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
tableLabel = ((String) listParameter.get(0)).split(UpdatesConstants.SEGMENT_LINE)[0];
}
if (connectionId != null) {
try {
toReload = ProxyRepositoryFactory.getInstance().getLastVersion(connectionId);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
if (toReload != null) {
Set<MetadataTable> newTables = null;
Item item = toReload.getProperty().getItem();
if (item instanceof DatabaseConnectionItem) {
DatabaseConnectionItem dbItem = (DatabaseConnectionItem) item;
Connection connection = dbItem.getConnection();
if (connection instanceof DatabaseConnection) {
DatabaseConnection dbConn = (DatabaseConnection) connection;
Set<MetadataTable> tables = ProjectNodeHelper.getTablesFromSpecifiedDataPackage(dbConn);
if (tables != null && !tables.isEmpty()) {
Iterator it = tables.iterator();
while (it.hasNext() && tableToReload == null) {
MetadataTable table = (MetadataTable) it.next();
String label = table.getLabel();
if (tableLabel != null) {
if (label != null && label.equals(tableLabel)) {
tableToReload = ConvertionHelper.convert(table);
break;
}
}
}
}
newTables = ConnectionHelper.getTables(connection);
}
} else {
IGenericWizardService wizardService = null;
if (GlobalServiceRegister.getDefault().isServiceRegistered(IGenericWizardService.class)) {
wizardService = (IGenericWizardService) GlobalServiceRegister.getDefault().getService(IGenericWizardService.class);
}
if (wizardService != null && wizardService.isGenericItem(item)) {
Connection connection = ((ConnectionItem) item).getConnection();
List<MetadataTable> metadataTables = wizardService.getMetadataTables(connection);
newTables = new HashSet<>(metadataTables);
}
}
if (newTables != null && !newTables.isEmpty() && tableToReload == null) {
Iterator<MetadataTable> it = newTables.iterator();
while (it.hasNext() && tableToReload == null) {
MetadataTable table = it.next();
String label = table.getLabel();
if (tableLabel != null) {
if (label != null && label.equals(tableLabel)) {
tableToReload = ConvertionHelper.convert(table);
break;
}
}
}
}
if (tableToReload != null) {
int index = -1;
List<IMetadataTable> tablesInNode = node.getMetadataList();
for (IMetadataTable table : tablesInNode) {
if (table.getLabel().equals(tableToReload.getLabel())) {
index = tablesInNode.indexOf(table);
break;
}
}
if (index >= 0) {
IMetadataTable oldTable = tablesInNode.get(index);
/* dbms and Connector should be transfer when reloaded the table,20024 */
tableToReload.setAttachedConnector(oldTable.getAttachedConnector());
tableToReload.setDbms(oldTable.getDbms());
tablesInNode.remove(index);
tablesInNode.add(index, tableToReload);
builtIn = false;
}
}
}
}
// bug 23326
if (builtIn) {
// bult-in
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateNodePathCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
IUpdateItemType updateType = result.getUpdateType();
if (result == null || updateType == null) {
return;
}
Object updateObject = result.getUpdateObject();
if (updateObject == null || (!(updateObject instanceof Node))) {
return;
}
// instance of node before might not be good (loaded while check updates needed)
// so get the instance of the node of the current job in this object.
IProcess process = (IProcess) result.getJob();
for (INode node : process.getGraphicalNodes()) {
if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
updateObject = node;
result.setUpdateObject(updateObject);
break;
}
}
Node node = (Node) updateObject;
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case MAP_PATH:
Object parameter = result.getParameter();
if (!(parameter instanceof List)) {
return;
}
List<Object> params = (List<Object>) parameter;
if (params.size() != 3) {
return;
}
IElementParameter param = (IElementParameter) params.get(0);
if (param == null) {
return;
}
String oldPath = (String) params.get(1);
String newPath = (String) params.get(2);
String relativeNewPath = new Path(newPath).removeFirstSegments(2).removeFileExtension().toPortableString();
String fullOldPath = new Path(oldPath).removeFileExtension().toPortableString();
String relativeOldPath = new Path(oldPath).removeFirstSegments(2).removeFileExtension().toPortableString();
Object value = TalendTextUtils.removeQuotes(String.valueOf(param.getValue()));
if (!fullOldPath.equals(value) && !relativeOldPath.equals(value)) {
return;
}
if (fullOldPath.equals(value)) {
String newValue = TalendTextUtils.addQuotes(new Path(newPath).removeFileExtension().toPortableString());
param.setValue(newValue);
} else if (relativeOldPath.equals(value)) {
param.setValue(TalendTextUtils.addQuotes(relativeNewPath));
}
break;
default:
}
}
if (node.getProcess() instanceof IProcess2) {
PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
boolean executed = false;
if (process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
}
}
if (!executed) {
pcc.execute();
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateContextParameterCommand method doExecute.
private void doExecute() {
if (result == null) {
return;
}
Object job = result.getJob();
if (job == null) {
return;
}
if (job instanceof IProcess2) {
IProcess2 process = (IProcess2) job;
ContextParameterMap deleteParameters = new ContextParameterMap();
Object updateObject = result.getUpdateObject();
List<IContext> listContext = process.getContextManager().getListContext();
if (updateObject instanceof Set) {
Set<String> names = (Set<String>) updateObject;
if (result.getResultType() == EUpdateResult.ADD && result.isChecked()) {
// check parameters that have been added to repository context group
checkNewRepositoryParameters(process, names);
return;
}
for (IContext context : listContext) {
for (IContextParameter param : context.getContextParameterList()) {
ContextItem item = null;
if (names != null && names.contains(param.getName())) {
switch(result.getResultType()) {
case DELETE:
item = (ContextItem) result.getParameter();
if (item != null && item.getProperty().getId().equals(param.getSource()) && result.isChecked()) {
// delete it later
deleteParameters.addParameter(context, param);
} else {
param.setSource(IContextParameter.BUILT_IN);
}
break;
case UPDATE:
item = (ContextItem) result.getParameter();
if (item != null && item.getProperty().getId().equals(param.getSource()) && result.isChecked()) {
ContextUtils.updateParameterFromRepository(item, param, context.getName());
} else {
param.setSource(IContextParameter.BUILT_IN);
}
break;
case RENAME:
List<Object> parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 3) {
item = (ContextItem) parameter.get(0);
String sourceId = item.getProperty().getId();
String oldName = (String) parameter.get(1);
String newName = (String) parameter.get(2);
if (oldName.equals(param.getName()) && sourceId.equals(param.getSource())) {
if (newName != null) {
param.setName(newName);
ContextUtils.updateParameterFromRepository(item, param, context.getName());
}
}
}
break;
// built-in
case BUIL_IN:
default:
param.setSource(IContextParameter.BUILT_IN);
break;
}
}
}
}
}
if (updateObject instanceof JobContext) {
if (result.getResultType() == EUpdateResult.ADD && result.getUpdateType() == EUpdateItemType.CONTEXT_GROUP && result.isChecked()) {
IContext context = (IContext) updateObject;
String name = context.getName();
if (!listContext.contains(context) && result.getParameter() instanceof ContextItem) {
ContextItem item = (ContextItem) result.getParameter();
JobContext newContext = new JobContext(name);
List<IContextParameter> newParamList = new ArrayList<IContextParameter>();
newContext.setContextParameterList(newParamList);
JobContextParameter param = null;
// add other context params to the new group
for (IContextParameter contextParam : process.getContextManager().getDefaultContext().getContextParameterList()) {
boolean exist = false;
for (IContextParameter existParam : context.getContextParameterList()) {
if (contextParam.getName().equals(existParam.getName())) {
exist = true;
}
}
if (exist) {
continue;
}
param = (JobContextParameter) contextParam.clone();
param.setContext(newContext);
newParamList.add(param);
}
// current context params for the new group
for (int i = 0; i < context.getContextParameterList().size(); i++) {
IContextParameter oldParam = context.getContextParameterList().get(i);
param = (JobContextParameter) oldParam.clone();
param.setSource(item.getProperty().getId());
param.setContext(newContext);
newParamList.add(param);
}
listContext.add(newContext);
}
} else if (result.getResultType() == EUpdateResult.DELETE && result.getUpdateType() == EUpdateItemType.CONTEXT_GROUP && result.isChecked()) {
IContext context = (IContext) updateObject;
if (result.getParameter() instanceof ContextItem) {
ContextItem item = (ContextItem) result.getParameter();
List<IContext> listC = new ArrayList<IContext>(listContext);
for (IContext con : listC) {
if (con.getName().equals(context.getName())) {
for (IContextParameter oldParam : con.getContextParameterList()) {
if (item.getProperty().getId().equals(oldParam.getSource())) {
listContext.remove(con);
}
}
}
}
}
return;
} else if (result.getResultType() == EUpdateResult.RENAME && result.getUpdateType() == EUpdateItemType.CONTEXT_GROUP && result.isChecked()) {
IContext context = (IContext) updateObject;
IContextManager contextManager = process.getContextManager();
Map<IContext, String> renameGroupContext = ((JobContextManager) contextManager).getRenameGroupContext();
String oldName = renameGroupContext.get(context);
if (result.getParameter() instanceof ContextItem) {
ContextItem item = (ContextItem) result.getParameter();
for (IContext con : listContext) {
if (con.getName().equals(oldName)) {
for (IContextParameter oldParam : con.getContextParameterList()) {
if (item.getProperty().getId().equals(oldParam.getSource())) {
con.setName(context.getName());
}
}
}
}
}
}
return;
}
// delete parameters
deleteParameters.removeFromContext();
// update parameters
if (result.getResultType() == EUpdateResult.RENAME) {
List<Object> parameter = (List<Object>) result.getParameter();
if (parameter.size() >= 3) {
String oldName = (String) parameter.get(1);
String newName = (String) parameter.get(2);
UpdateContextVariablesHelper.updateProcessForRenamed(process, oldName, newName);
// tRunJob parameters rename
IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
Map<String, String> renamedMap = new HashMap<String, String>();
renamedMap.put(newName, oldName);
UpdateRunJobComponentContextHelper.updateOpenedJobRunJobComponentReference(processes, renamedMap, process.getId(), null);
try {
// perhaps, need optimize.
UpdateRunJobComponentContextHelper.updateItemRunJobComponentReference(DesignerPlugin.getDefault().getProxyRepositoryFactory(), renamedMap, process.getId(), null);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
}
}
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateJobletNodeCommand method needPropagate.
private boolean needPropagate(Node jobletNode) {
List<IProcess2> openedProcesses = UpdateManagerUtils.getOpenedProcess();
boolean opened = false;
for (IProcess2 process : openedProcesses) {
if (process.getId().equals(jobletNode.getProcess().getId())) {
opened = true;
}
}
if (!opened) {
return false;
}
AbstractProcessProvider jobletProcessProvider = AbstractProcessProvider.findProcessProviderFromPID(IComponent.JOBLET_PID);
if (jobletProcessProvider != null) {
List<UpdateResult> resultList = jobletProcessProvider.checkJobletNodeSchema(jobletNode.getProcess());
if (resultList.size() <= 0) {
return false;
} else {
return true;
}
}
return false;
}
use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.
the class UpdateJunitNodeCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
Object job = result.getJob();
if (job == null) {
return;
}
if (job instanceof IProcess2) {
Item item = ((IProcess2) job).getProperty().getItem();
if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
if (testContainerService != null) {
boolean isTestContainer = testContainerService.isTestContainerItem(item);
if (!isTestContainer) {
return;
}
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case JUNIT_RELOAD:
List<Node> junitsNodes = (List<Node>) result.getUpdateObject();
if (junitsNodes != null && !junitsNodes.isEmpty()) {
for (Node node : junitsNodes) {
testContainerService.reloadJunitsNodes(node);
}
}
default:
}
}
}
}
}
}
Aggregations