use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ConnectionDeleteCommand method undo.
@Override
public void undo() {
Process process = (Process) connectionList.get(0).getSource().getProcess();
for (Connection connection : connectionList) {
collpseJoblet(connection);
ConnectionDeletedInfo deletedInfo = connectionDeletedInfosMap.get(connection);
if (deletedInfo != null) {
INode source = connection.getSource();
if (source != null && deletedInfo.metadataTable != null) {
List<IMetadataTable> metaList = source.getMetadataList();
if (!metaList.contains(deletedInfo.metadataTable)) {
metaList.add(deletedInfo.metadataTableIndex, deletedInfo.metadataTable);
}
}
}
connection.reconnect();
INode target = connection.getTarget();
if (target.getExternalNode() instanceof AbstractNode) {
((AbstractNode) target.getExternalNode()).addInput(connection);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
if (nodeConnectorSource != null) {
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
}
nodeConnectorTarget = connection.getTargetNodeConnector();
if (nodeConnectorTarget != null) {
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
}
}
process.checkStartNodes();
process.checkProcess();
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ConnectionReconnectCommand method execute.
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.commands.Command#execute()
*/
@Override
public void execute() {
metadataChanges.clear();
if (newSource != null) {
INodeConnector connector = oldSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
connector = newSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
newSourceSchemaType = (String) newSource.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
if ((!builtInNewSource) && (!builtInOldSource)) {
setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
connection.setMetaName(newSource.getUniqueName());
} else {
if (!builtInNewSource) {
int num = 0;
for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
IMetadataTable meta = oldSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
oldSource.getMetadataList().remove(num);
setSchemaToNotBuiltInNode(oldSource, newSource, oldMetadataTable);
connection.setMetaName(newSource.getUniqueName());
}
if (!builtInOldSource) {
IMetadataTable meta = oldMetadataTable.clone();
meta.setTableName(connection.getUniqueName());
newSource.getMetadataList().add(meta);
connection.setMetaName(meta.getTableName());
}
if ((builtInOldSource) && (builtInNewSource)) {
int num = 0;
for (int i = 0; i < oldSource.getMetadataList().size(); i++) {
IMetadataTable meta = oldSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
oldSource.getMetadataList().remove(num);
newSource.getMetadataList().add(oldMetadataTable);
}
}
// if (newSourceSchemaType != null) {
// newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newSourceSchemaType);
// }
// if (oldSourceSchemaType != null) {
// oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
// }
} else {
connection.setMetaName(newSource.getUniqueName());
}
connection.reconnect(newSource, oldTarget, newLineStyle);
connection.updateName();
if (newSourceSchemaType != null && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IMetadataTable sourceMetadataTable = newSource.getMetadataFromConnector(connector.getName());
// IMetadataTable targetMetadataTable = oldTarget.getMetadataFromConnector(connector.getName());
if (oldMetadataTable != null && sourceMetadataTable != null) {
boolean sameFlag = oldMetadataTable.sameMetadataAs(sourceMetadataTable, IMetadataColumn.OPTIONS_NONE);
// For the auto propagate.
if (!sameFlag && oldTarget.getComponent().isSchemaAutoPropagated() && (oldMetadataTable.getListColumns().isEmpty() || getPropagateDialog())) {
IElementParameter param = oldTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (param == null) {
param = oldTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
}
if (param != null && param.getContext() != null && !param.getContext().equals(connection.getLineStyle().getName())) {
param = null;
}
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(oldTarget, param, null, sourceMetadataTable);
changeMetadataCmd.execute(true);
metadataChanges.add(changeMetadataCmd);
}
}
}
((Process) newSource.getProcess()).checkStartNodes();
((Process) newSource.getProcess()).checkProcess();
} else if (newTarget != null) {
newTargetSchemaType = (String) newTarget.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
connector = newTarget.getConnectorFromType(newLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
connection.reconnect(oldSource, newTarget, newLineStyle);
connection.updateName();
if (newTargetSchemaType != null) {
// TDI-28557:if target is repository mode,can not propagate to target and set to build-in,or target is
// build-in mode,need user to choose by the pop up dialog
boolean isPropagate = false;
boolean isRepoMode = newTargetSchemaType.equals(EmfComponent.REPOSITORY);
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && !connection.getLineStyle().equals(EConnectionType.FLOW_REF)) {
IMetadataTable targetOldMetadataTable = newTarget.getMetadataFromConnector(connector.getName());
if (oldMetadataTable != null && targetOldMetadataTable != null) {
boolean sameFlag = oldMetadataTable.sameMetadataAs(targetOldMetadataTable, IMetadataColumn.OPTIONS_NONE);
isPropagate = (!sameFlag && newTarget.getComponent().isSchemaAutoPropagated() && !isRepoMode && (targetOldMetadataTable.getListColumns().isEmpty() || getPropagateDialog()));
// For the auto propagate.
if (isPropagate) {
IElementParameter param = newTarget.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
if (param != null && param.getContext() != null && !param.getContext().equals(connection.getLineStyle().getName())) {
param = null;
}
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(newTarget, param, null, oldMetadataTable);
changeMetadataCmd.execute(true);
metadataChanges.add(changeMetadataCmd);
}
}
}
if (isPropagate) {
newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
}
((Process) oldSource.getProcess()).checkStartNodes();
((Process) oldSource.getProcess()).checkProcess();
} else {
//$NON-NLS-1$
throw new IllegalStateException("Should not happen");
}
if (oldSource instanceof Node) {
if (((Node) oldSource).isJoblet()) {
((Node) oldSource).getNodeContainer().setInputs(new HashSet<IConnection>(((Node) oldSource).getInputs()));
((Node) oldSource).getNodeContainer().setOutputs(new HashSet<IConnection>(((Node) oldSource).getOutputs()));
}
}
if (oldTarget instanceof Node) {
if (((Node) oldTarget).isJoblet()) {
((Node) oldTarget).getNodeContainer().setInputs(new HashSet<IConnection>(((Node) oldTarget).getInputs()));
((Node) oldTarget).getNodeContainer().setOutputs(new HashSet<IConnection>(((Node) oldTarget).getOutputs()));
}
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ConnectionReconnectCommand method undo.
@Override
public void undo() {
if (newSource != null) {
INodeConnector connector = oldSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
connector = newSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
if ((!builtInNewSource) && (!builtInOldSource)) {
setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
connection.setMetaName(oldSource.getUniqueName());
} else {
if (!builtInNewSource) {
oldSource.getMetadataList().add(oldMetadataTable);
connection.setMetaName(oldMetadataTable.getTableName());
}
if (!builtInOldSource) {
int num = 0;
for (int i = 0; i < newSource.getMetadataList().size(); i++) {
IMetadataTable meta = newSource.getMetadataList().get(i);
if (meta.getTableName().equals(connection.getUniqueName())) {
num = i;
}
}
newSource.getMetadataList().remove(num);
setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
connection.setMetaName(oldSource.getUniqueName());
}
if ((builtInOldSource) && (builtInNewSource)) {
int num = 0;
for (int i = 0; i < newSource.getMetadataList().size(); i++) {
IMetadataTable meta = newSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
newSource.getMetadataList().remove(num);
oldSource.getMetadataList().add(oldMetadataTable);
}
}
if (newSourceSchemaType != null) {
for (ChangeMetadataCommand cmd : metadataChanges) {
cmd.undo();
}
newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newSourceSchemaType);
}
if (oldSourceSchemaType != null) {
oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), oldSourceSchemaType);
}
} else {
connection.setMetaName(oldSource.getUniqueName());
}
} else if (newTarget != null) {
INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
connector = newTarget.getConnectorFromType(newLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
if (newTargetSchemaType != null) {
for (ChangeMetadataCommand cmd : metadataChanges) {
cmd.undo();
}
newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newTargetSchemaType);
}
}
connection.reconnect(oldSource, oldTarget, oldLineStyle);
connection.updateName();
((Process) oldSource.getProcess()).checkStartNodes();
((Process) oldSource.getProcess()).checkProcess();
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ExternalNodeChangeCommand method undo.
@Override
public void undo() {
for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN) || connection.getLineStyle().equals(EConnectionType.FLOW_REF) || connection.getLineStyle().equals(EConnectionType.TABLE) || connection.getLineStyle().equals(EConnectionType.TABLE_REF)) {
IODataComponent currentIO = inAndOut.getDataComponent(connection);
if (currentIO.hasChanged()) {
// IMetadataTable metadata = inAndOut.getTable(connection);
INode sourceNode = currentIO.getSource();
sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
// IMetadataTable oldMetadata = connection.getMetadataTable().clone();
// currentIO.setTable(oldMetadata);
// connection.getMetadataTable().setListColumns(metadata.getListColumns());
IMetadataTable oldMetadata = currentIO.getConnMetadataTable();
// currentIO.setTable(oldMetadata);
connection.getMetadataTable().setListColumns(oldMetadata.getListColumns());
if (metadataInputWasRepository.get(connection) != null) {
connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.REPOSITORY);
}
}
}
}
metadataInputWasRepository.clear();
node.setExternalData(oldExternalData);
node.setMetadataList(oldMetaDataList);
for (Connection connection : connectionsToDelete.keySet()) {
connection.reconnect();
Node prevNode = (Node) connection.getSource();
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = prevNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
Node nextNode = (Node) connection.getTarget();
nodeConnectorTarget = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
if (connectionsToDelete.get(connection) != null) {
inAndOut.getOuputs().add(connectionsToDelete.get(connection));
}
}
for (ChangeMetadataCommand cmd : metadataOutputChanges) {
cmd.undo();
}
((Process) node.getProcess()).checkProcess();
if (!isMetaLanguage) {
refreshCodeView();
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ExternalNodeChangeCommand method execute.
@Override
public void execute() {
propagateInput();
// bug 0020749
if (!oldMetaDataList.isEmpty() && !newMetaDataList.isEmpty() && !oldMetaDataList.get(0).sameMetadataAs(newMetaDataList.get(0))) {
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
metadataOutputChanges.clear();
List<IConnection> initTraceList = new ArrayList<IConnection>();
for (IConnection connection : node.getOutgoingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IODataComponent dataComponent = inAndOut.getDataComponent(connection);
boolean sameMetadataAs = connection.getMetadataTable().sameMetadataAs(dataComponent.getTable());
IMetadataTable tempTable = null;
boolean isSchemaAutoPropagated = true;
if (connection.getTarget().getComponent() instanceof EmfComponent) {
EmfComponent component = (EmfComponent) connection.getTarget().getComponent();
isSchemaAutoPropagated = component.isSchemaAutoPropagated();
}
if (sameMetadataAs || !isSchemaAutoPropagated) {
for (IMetadataTable itable : newMetaDataList) {
if (connection.getMetadataTable().getTableName().equals(itable.getTableName())) {
sameMetadataAs = connection.getMetadataTable().sameMetadataAs(itable);
tempTable = itable;
break;
}
}
} else {
IMetadataTable table = connection.getMetadataTable();
if (table == null || table.getListColumns().isEmpty()) {
initTraceList.add(connection);
}
INode connTar = connection.getTarget();
boolean isAllowedPropagated = connTar.getComponent().isAllowedPropagated();
boolean openDialog = false;
Map<String, Boolean> jobletMap = new HashMap<String, Boolean>();
if (isForTemlate()) {
openDialog = true;
} else if (!isAllowedPropagated) {
openDialog = false;
} else {
openDialog = getPropagate(connection, jobletMap);
}
if (openDialog) {
IElementParameter schemaParam = null;
if (connection != null) {
IMetadataTable connTable = connection.getMetadataTable();
IMetadataTable dataTable = dataComponent.getTable();
if (tempTable != null) {
dataTable = tempTable;
}
for (IElementParameter param : ((Node) connection.getTarget()).getElementParameters()) {
if (EParameterFieldType.SCHEMA_TYPE.equals(param.getFieldType()) || EParameterFieldType.SCHEMA_REFERENCE.equals(param.getFieldType())) {
INodeConnector connector = connection.getTarget().getConnectorFromName(connection.getConnectorName());
if (connector != null && param.getContext().equals(connector.getBaseSchema())) {
schemaParam = param;
break;
}
}
}
if (schemaParam != null) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getTarget(), schemaParam, connTable, dataTable);
cmd.execute(true);
metadataOutputChanges.add(cmd);
}
for (IElementParameter param : ((Node) connection.getSource()).getElementParameters()) {
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) && param.getContext().equals(connection.getSource().getConnectorFromName(connection.getConnectorName()).getBaseSchema())) {
schemaParam = param;
break;
}
}
if (schemaParam != null) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(connection.getSource(), schemaParam, connTable, dataTable);
cmd.execute(true);
metadataOutputChanges.add(cmd);
}
if (((Node) connTar).isJoblet()) {
IElementParameter param = connTar.getElementParameter(connection.getTarget().getUniqueName());
if (param != null) {
IMetadataTable originaleOutputTable = connTar.getMetadataFromConnector(param.getContext());
if (originaleOutputTable != null) {
MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
}
}
} else if (((Node) connTar).getJobletNode() != null) {
IElementParameter param = ((Node) connTar).getJobletNode().getElementParameter(connection.getTarget().getUniqueName());
if (param != null) {
IMetadataTable originaleOutputTable = ((Node) connTar).getJobletNode().getMetadataFromConnector(param.getContext());
if (originaleOutputTable != null) {
MetadataToolHelper.copyTable(dataTable, originaleOutputTable);
}
}
}
}
if (((Node) connTar).isJoblet()) {
changeCollapsedState(true, jobletMap, connTar);
}
} else {
// no matter propagate or not the metadata change will be propagate to xmlmap emf data
final Node target = (Node) connection.getTarget();
if (target != null && target.getExternalNode() != null) {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IXmlMapService.class)) {
final IXmlMapService service = (IXmlMapService) GlobalServiceRegister.getDefault().getService(IXmlMapService.class);
if (service.isXmlMapComponent(target.getExternalNode())) {
IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
target.metadataInputChanged(output, connection.getUniqueName());
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkMapService.class)) {
final ISparkMapService service = (ISparkMapService) GlobalServiceRegister.getDefault().getService(ISparkMapService.class);
if (service.isSparkMapComponent(target.getExternalNode())) {
IODataComponent output = new IODataComponent(connection, dataComponent.getTable());
target.metadataInputChanged(output, connection.getUniqueName());
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDQComponentService.class)) {
final IDQComponentService service = (IDQComponentService) GlobalServiceRegister.getDefault().getService(IDQComponentService.class);
service.externalComponentChange(connection, dataComponent.getTable());
}
}
}
}
if (connection instanceof Connection) {
((Connection) connection).updateName();
}
}
}
node.setExternalData(newExternalData);
/*
* It's better to clone, because will change that, if apply, bug 13325
*/
// node.setExternalData(newExternalData.clone()); //should test later.
List<IMetadataTable> cloneNewMetadata = new ArrayList<IMetadataTable>();
if (newMetaDataList != null) {
for (IMetadataTable t : newMetaDataList) {
cloneNewMetadata.add(t.clone(true));
}
}
node.setMetadataList(cloneNewMetadata);
// init trace
for (IConnection conn : initTraceList) {
if (conn instanceof Connection) {
((Connection) conn).initTraceParamters();
}
}
for (Connection connection : connectionsToDelete.keySet()) {
connection.disconnect();
INode prevNode = connection.getSource();
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = prevNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() - 1);
INode nextNode = connection.getTarget();
nodeConnectorTarget = nextNode.getConnectorFromType(connection.getLineStyle());
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() - 1);
inAndOut.getOuputs().remove(connectionsToDelete.get(connection));
((Process) node.getProcess()).checkStartNodes();
}
((Process) node.getProcess()).checkProcess();
if (!isMetaLanguage) {
refreshCodeView();
ComponentSettings.switchToCurComponentSettingsView();
}
}
Aggregations