use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ChangeValuesFromRepository method setOtherProperties.
/**
* qzhang Comment method "setOtherProperties".
*/
private void setOtherProperties() {
boolean metadataInput = false;
IElementParameter currentParam = elem.getElementParameter(propertyName);
Item item = null;
IElementParameter repositoryParam = elem.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
if (repositoryParam != null) {
item = UpdateRepositoryUtils.getConnectionItemByItemId((String) repositoryParam.getValue());
}
if (elem instanceof Node) {
Node node = (Node) elem;
if (node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_MAIN) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.FLOW_REF) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE) > 0 || node.getCurrentActiveLinksNbInput(EConnectionType.TABLE_REF) > 0) {
metadataInput = true;
}
boolean hasSchema = elem.getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE) != null ? true : elem.getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE) != null;
if (value.equals(EmfComponent.BUILTIN)) {
if (!metadataInput && hasSchema) {
elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), value);
}
elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(), value);
} else {
if (hasSchema) {
for (IElementParameter param : new ArrayList<IElementParameter>(elem.getElementParameters())) {
if (param.getFieldType().equals(EParameterFieldType.SCHEMA_TYPE) || (param.getFieldType().equals(EParameterFieldType.SCHEMA_REFERENCE) && EConnectionType.FLOW_MAIN.getName().equals(param.getContext()))) {
if (!metadataInput) {
IElementParameter repositorySchemaTypeParameter = param.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
String repositoryTable = null;
if (propertyName.split(":")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
//$NON-NLS-1$
repositoryTable = (String) repositorySchemaTypeParameter.getValue();
} else if (item != null) {
if (item instanceof SAPConnectionItem) {
if (getCurrentTableName() != null) {
repositoryTable = item.getProperty().getId() + " - " + getCurrentTableName();
}
} else {
//$NON-NLS-1$
repositoryTable = item.getProperty().getId() + " - " + getFirstRepositoryTable(item);
}
repositorySchemaTypeParameter.setValue(repositoryTable);
}
if (isNotSim) {
if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null) {
if (repositoryTable != null && !"".equals(repositoryTable)) {
//$NON-NLS-1$
param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(repositoryTable);
// repositoryTableMap.get(repositoryTable);
if (table != null) {
table = table.clone();
setDBTableFieldValue(node, table.getTableName(), null);
setSAPFunctionName(node, table.getLabel());
table.setTableName(node.getMetadataList().get(0).getTableName());
if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(node, param, null, table, param);
cmd.setConnection(connection);
cmd.setRepositoryMode(true);
cmd.execute(true);
}
}
}
}
} else if (isMdmOutput()) {
if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() > 0) {
if (repositoryTable != null && !"".equals(repositoryTable)) {
//$NON-NLS-1$
param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(repositoryTable);
// repositoryTableMap.get(repositoryTable);
if (table != null) {
table = table.clone();
setDBTableFieldValue(node, table.getTableName(), null);
setSAPFunctionName(node, table.getLabel());
table.setTableName(node.getMetadataList().get(0).getTableName());
ChangeMetadataCommand cmd = new ChangeMetadataCommand(node, param, null, table, param);
cmd.setConnection(connection);
cmd.setRepositoryMode(true);
cmd.execute(true);
}
}
}
} else {
if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 1) {
if (repositoryTable != null && !"".equals(repositoryTable)) {
//$NON-NLS-1$
param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(repositoryTable);
// repositoryTableMap.get(repositoryTable);
if (table != null) {
table = table.clone();
setDBTableFieldValue(node, table.getTableName(), null);
setSAPFunctionName(node, table.getLabel());
table.setTableName(node.getMetadataList().get(0).getTableName());
if (!table.sameMetadataAs(node.getMetadataList().get(0))) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(node, param, null, table, param);
cmd.setConnection(connection);
cmd.setRepositoryMode(true);
cmd.execute(true);
}
}
}
} else // schema,it is invisible which design in the component
if (item != null && UpdateRepositoryUtils.getMetadataTablesFromItem(item) != null && (((INode) elem).getComponent().getName().equals("tWebService") || ((INode) elem).getComponent().getName().equals("tBRMS")) && UpdateRepositoryUtils.getMetadataTablesFromItem(item).size() == 2) {
final List<MetadataTable> tables = UpdateRepositoryUtils.getMetadataTablesFromItem(item);
if (tables != null && !tables.isEmpty()) {
if (param.getName().equals("INPUT_SCHEMA")) {
repositoryTable = item.getProperty().getId() + " - " + "Input";
repositorySchemaTypeParameter.setValue(repositoryTable);
} else {
repositoryTable = item.getProperty().getId() + " - " + "Output";
repositorySchemaTypeParameter.setValue(repositoryTable);
}
if (repositoryTable != null && !"".equals(repositoryTable)) {
//$NON-NLS-1$
param.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
IMetadataTable table = MetadataToolHelper.getMetadataFromRepository(repositoryTable);
if (table != null) {
table = table.clone();
setDBTableFieldValue(node, table.getTableName(), null);
setSAPFunctionName(node, table.getLabel());
INodeConnector mainConnector = node.getConnectorFromType(EConnectionType.FLOW_MAIN);
IMetadataTable stable = null;
INodeConnector outputConnector = mainConnector;
if (mainConnector.getMaxLinkOutput() == 0) {
for (INodeConnector currentConnector : node.getListConnector()) {
if (!currentConnector.getBaseSchema().equals(EConnectionType.FLOW_MAIN.getName()) && currentConnector.getMaxLinkOutput() > 0) {
outputConnector = currentConnector;
}
}
}
if (param.getName().equals("INPUT_SCHEMA")) {
stable = node.getMetadataFromConnector("FLOW");
} else if (param.getName().equals("SCHEMA")) {
stable = node.getMetadataFromConnector("OUTPUT");
}
if (stable != null) {
table.setTableName(stable.getTableName());
if (!table.sameMetadataAs(stable)) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand(node, param, null, table, param);
cmd.setConnection(connection);
cmd.setRepositoryMode(true);
cmd.execute(true);
// break;
}
}
}
}
}
}
}
} else {
Node sourceNode = getRealSourceNode((INode) elem);
if (sourceNode != null) {
IMetadataTable sourceMetadataTable = sourceNode.getMetadataList().get(0);
Object sourceSchema = sourceNode.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
boolean isTake = !sourceNode.isExternalNode() && sourceSchema != null && elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()) != null;
if (isTake && getTake()) {
ChangeMetadataCommand cmd = new ChangeMetadataCommand((Node) elem, param, null, sourceMetadataTable, param);
cmd.setConnection(connection);
cmd.execute(true);
elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), sourceSchema);
if (sourceSchema.equals(EmfComponent.REPOSITORY)) {
elem.setPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), sourceNode.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()));
}
}
}
}
}
}
}
}
IElementParameter queryParam = elem.getElementParameterFromField(EParameterFieldType.QUERYSTORE_TYPE, currentParam.getCategory());
IElementParameter queryStoreType = null;
if (queryParam != null) {
queryStoreType = queryParam.getChildParameters().get(EParameterName.QUERYSTORE_TYPE.getName());
}
if (item != null) {
final List<Query> queries = UpdateRepositoryUtils.getQueriesFromItem(item);
if (propertyName.split(":")[1].equals(EParameterName.PROPERTY_TYPE.getName())) {
//$NON-NLS-1$
if (queries != null && !queries.isEmpty()) {
if (queryParam != null) {
queryStoreType.setValue(value);
if (value.equals(EmfComponent.REPOSITORY)) {
setQueryToRepositoryMode(queryParam, queries, item);
}
}
// query change
}
} else {
if (queryParam != null) {
if (this.isGuessQuery || queries == null || (queries != null && queries.isEmpty())) {
queryStoreType.setValue(EmfComponent.BUILTIN);
} else {
queryStoreType.setValue(EmfComponent.REPOSITORY);
setQueryToRepositoryMode(queryParam, queries, item);
}
}
List<MetadataTable> tables = UpdateRepositoryUtils.getMetadataTablesFromItem(item);
if (tables == null || tables.isEmpty()) {
elem.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
} else {
if (table != null && table.getTableName() != null) {
setDBTableFieldValue(node, table.getTableName(), null);
}
}
}
}
}
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ConnectionCreateCommand method execute.
@Override
public void execute() {
canExecute();
if (connectionName == null) {
// ask for the name if there is no
final INodeConnector mainConnector;
EConnectionType connecType;
if (source.isELTComponent()) {
connecType = EConnectionType.TABLE;
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connecType = EConnectionType.ROUTE;
if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
connecType = camelService.getTargetConnectionType(source);
} else {
connecType = EConnectionType.ROUTE;
}
} else {
connecType = EConnectionType.FLOW_MAIN;
}
mainConnector = NodeUtil.getValidConnector(source);
if (source.getConnectorFromName(connectorName).isMultiSchema()) {
boolean connectionOk = false;
while (!connectionOk) {
connectionName = askForConnectionName(source.getLabel(), connectionName);
if (StringUtils.isEmpty(connectionName)) {
creatingConnection = false;
connectionName = null;
dispose();
return;
}
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
if ((connecType.equals(EConnectionType.TABLE) || source.getProcess().checkValidConnectionName(connectionName)) && (ConnectionManager.canConnectToTarget(source, null, target, source.getConnectorFromName(connectorName).getDefaultConnectionType(), connectorName, connectionName))) {
connectionOk = true;
} else {
String message = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ConnectionCreateAction.errorCreateConnectionName", connectionName);
//$NON-NLS-1$
MessageDialog.openError(null, Messages.getString("ConnectionCreateAction.error"), message);
}
}
// add for feature TDI-17358
//$NON-NLS-1$
IElementParameter elementParameter = source.getElementParameter("SCHEMAS");
if (elementParameter != null) {
Map<String, Object> map = new HashMap<String, Object>();
Object[] itemsValue = elementParameter.getListItemsValue();
String[] items = elementParameter.getListItemsDisplayCodeName();
map.put(IEbcdicConstant.FIELD_CODE, newMetadata.getTableName());
map.put(IEbcdicConstant.FIELD_SCHEMA, newMetadata.getTableName());
for (int i = 1; i < items.length; i++) {
map.put(items[i], ((IElementParameter) itemsValue[i]).getValue());
}
Object value = elementParameter.getValue();
if (value instanceof List) {
List list = (List) value;
list.add(map);
}
ComponentSettings.switchToCurComponentSettingsView();
}
} else {
newMetadata = null;
if (source.isELTComponent()) {
if (source.getElementParameter("ELT_SCHEMA_NAME") != null) {
connectionName = askForConnectionSchemaAndTableName(source.getLabel(), connectionName);
} else {
connectionName = askForConnectionName(source.getLabel(), connectionName);
}
} else if (ComponentCategory.CATEGORY_4_CAMEL.getName().equals(source.getComponent().getType())) {
connectionName = ConnectionUtil.generateUniqueConnectionName(connecType, source.getProcess(), source.getConnectorFromType(connecType));
} else {
IMetadataTable metaTable = source.getMetadataFromConnector(mainConnector.getName());
if (metaTable != null) {
metaName = metaTable.getTableName();
}
String baseName = source.getConnectionName();
if (source.getProcess().checkValidConnectionName(baseName)) {
connectionName = source.getProcess().generateUniqueConnectionName(baseName);
}
}
}
}
if (insertTMap) {
metaName = connectionName;
newMetadata = getNewMetadataTable();
newMetadata.setTableName(connectionName);
newMetadata.setLabel(connectionName);
newMetadata.setAttachedConnector(connectorName);
}
// Default not monitor the connection
boolean monitorConnection = false;
if (newLineStyle == null) {
newLineStyle = source.getConnectorFromName(connectorName).getDefaultConnectionType();
}
if (connection == null) {
if (newMetadata != null) {
// add for eltmap
if (source instanceof Node && source.isELTMapComponent()) {
for (IMetadataTable metaTable : source.getMetadataList()) {
String tableName = metaTable.getTableName();
if (tableName != null && source.getProcess().checkValidConnectionName(tableName)) {
source.getProcess().addUniqueConnectionName(tableName);
}
}
}
source.getMetadataList().add(newMetadata);
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, monitorConnection);
} else {
this.connection = new Connection(source, target, newLineStyle, connectorName, metaName, connectionName, metaName, monitorConnection);
}
} else {
// in case of redo, reuse the same instance
if (newMetadata != null) {
source.getMetadataList().add(newMetadata);
}
connection.reconnect(source, target, newLineStyle);
}
INodeConnector nodeConnectorSource, nodeConnectorTarget;
nodeConnectorSource = connection.getSourceNodeConnector();
nodeConnectorSource.setCurLinkNbOutput(nodeConnectorSource.getCurLinkNbOutput() + 1);
nodeConnectorTarget = connection.getTargetNodeConnector();
nodeConnectorTarget.setCurLinkNbInput(nodeConnectorTarget.getCurLinkNbInput() + 1);
creatingConnection = false;
((Process) source.getProcess()).checkStartNodes();
source.checkAndRefreshNode();
boolean isJoblet = false;
if (PluginChecker.isJobLetPluginLoaded()) {
IJobletProviderService jobletService = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
if (jobletService != null && jobletService.isJobletComponent(target)) {
jobletService.upateJobletComonentList(target);
isJoblet = true;
}
}
if (!isJoblet) {
target.checkAndRefreshNode();
}
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ChangeMetadataCommand method execute.
@Override
public void execute() {
propagatedChange.clear();
propagateDatas(true);
if (currentInputMetadata != null) {
if (!currentInputMetadata.sameMetadataAs(newInputMetadata, IMetadataColumn.OPTIONS_NONE)) {
if (!currentInputMetadata.sameMetadataAs(newInputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED)) {
String type = (String) inputNode.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
if (type != null) {
if (type.equals(EmfComponent.REPOSITORY)) {
inputWasRepository = true;
inputNode.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
}
}
MetadataToolHelper.copyTable(newInputMetadata, currentInputMetadata);
}
}
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
if (!currentOutputMetadata.sameMetadataAs(newOutputMetadata, IMetadataColumn.OPTIONS_IGNORE_USED)) {
String type = (String) node.getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
if (type != null && type.equals(EmfComponent.REPOSITORY) && !repositoryMode) {
// for one node has several schema_type,set mode for the current one
if ((node.getElementParameter("SCHEMA_TYPE").getContext().equals(currentOutputMetadata.getAttachedConnector()))) {
outputWasRepository = true;
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
}
}
MetadataToolHelper.copyTable(newOutputMetadata, currentOutputMetadata);
}
if (inputSchemaParam != null && inputSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()) != null && EmfComponent.REPOSITORY.equals(inputSchemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).getValue())) {
// add by wzhang to fix bug 7898.
IElementParameter elementParameter = node.getElementParameter(EParameterName.MAPPING.getName());
if (elementParameter != null) {
if (elementParameter.getValue() instanceof String) {
String value = (String) elementParameter.getValue();
if (!isDBComponent(value)) {
schemaParam.getChildParameters().get(EParameterName.SCHEMA_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
schemaParam.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()).setValue(inputSchemaParam.getChildParameters().get(EParameterName.REPOSITORY_SCHEMA_TYPE.getName()).getValue());
}
}
}
}
for (INodeConnector connector : node.getListConnector()) {
if ((!connector.getName().equals(currentConnector)) && connector.getBaseSchema().equals(currentConnector)) {
// if there is some other schema dependant of this one, modify them
MetadataToolHelper.copyTable(newOutputMetadata, node.getMetadataFromConnector(connector.getName()));
updateComponentSchema(node, node.getMetadataFromConnector(connector.getName()));
}
}
updateComponentSchema(node, currentOutputMetadata);
List<ColumnNameChanged> columnNameChanged = MetadataToolHelper.getColumnNameChanged(oldOutputMetadata, newOutputMetadata);
ColumnListController.updateColumnList(node, columnNameChanged, true);
if (inputNode != null) {
updateComponentSchema(inputNode, currentInputMetadata);
List<ColumnNameChanged> inputColumnNameChangedExt = MetadataToolHelper.getColumnNameChangedExt(inputNode, oldInputMetadata, newInputMetadata);
ColumnListController.updateColumnList(node, inputColumnNameChangedExt);
}
//
List<ColumnNameChanged> outputColumnNameChangedExt = MetadataToolHelper.getColumnNameChangedExt(node, oldOutputMetadata, newOutputMetadata);
syncOutputNodeColumnsList(outputColumnNameChangedExt);
setTableMAPPING();
if (!internal) {
updateColumnList(oldOutputMetadata, newOutputMetadata);
((Process) node.getProcess()).checkProcess();
}
refreshMetadataChanged();
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class ChangeMetadataCommand method undo.
@Override
public void undo() {
propagateDatas(false);
if (currentInputMetadata != null) {
if (!currentInputMetadata.sameMetadataAs(oldInputMetadata, IMetadataColumn.OPTIONS_NONE)) {
currentInputMetadata.setListColumns(oldInputMetadata.getListColumns());
if (inputWasRepository) {
inputNode.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.REPOSITORY);
}
}
}
if (!currentOutputMetadata.sameMetadataAs(oldOutputMetadata, IMetadataColumn.OPTIONS_NONE)) {
List<IMetadataColumn> currentColumns = new ArrayList<IMetadataColumn>(oldOutputMetadata.getListColumns());
currentOutputMetadata.setListColumns(currentColumns);
MetadataToolHelper.copyTable(oldOutputMetadata, currentOutputMetadata);
}
for (INodeConnector connector : node.getListConnector()) {
if ((!connector.getName().equals(currentConnector)) && connector.getBaseSchema().equals(currentConnector)) {
MetadataToolHelper.copyTable(oldOutputMetadata, node.getMetadataFromConnector(connector.getName()));
}
}
if (outputWasRepository) {
node.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.REPOSITORY);
}
for (ChangeMetadataCommand cmd : propagatedChange) {
cmd.undo();
}
List<ColumnNameChanged> columnNameChanged = MetadataToolHelper.getColumnNameChanged(oldOutputMetadata, newOutputMetadata);
ColumnListController.updateColumnList(node, columnNameChanged, true);
if (!internal) {
updateColumnList(newOutputMetadata, oldOutputMetadata);
((Process) node.getProcess()).checkProcess();
}
refreshMetadataChanged();
}
use of org.talend.core.model.process.INodeConnector in project tdi-studio-se by Talend.
the class JobletConnectionReconnectCommand 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);
if (connector != null) {
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
connector = newSource.getConnectorFromName(connectorName);
if (connector != null) {
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);
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
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);
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
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(), EmfComponent.BUILTIN);
}
if (oldSourceSchemaType != null) {
oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
} else {
if (newSource.getJobletNode() != null) {
connection.setMetaName(newSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(newSource.getUniqueName());
}
connection.reconnect(newSource, oldTarget, newLineStyle);
connection.updateName();
if (newSourceSchemaType != null && connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA) && connector != null) {
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())) {
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(oldTarget, null, 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) {
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);
if (newTarget.getJobletNode() != null) {
IProcess2 jobletProcess = (IProcess2) newTarget.getJobletNode().getComponent().getProcess();
ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(jobletProcess.getProperty().getItem());
if (!status.equals(ERepositoryStatus.READ_ONLY)) {
// For the auto propagate.
if (!sameFlag && newTarget.getComponent().isSchemaAutoPropagated() && (targetOldMetadataTable.getListColumns().isEmpty() || getPropagateDialog())) {
ChangeMetadataCommand changeMetadataCmd = new ChangeMetadataCommand(newTarget, null, null, oldMetadataTable);
changeMetadataCmd.execute(true);
metadataChanges.add(changeMetadataCmd);
}
}
}
}
}
newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
}
// ((Process) oldTarget.getProcess()).checkStartNodes();
// ((Process) oldTarget.getProcess()).checkProcess();
} else {
//$NON-NLS-1$
throw new IllegalStateException("Should not happen");
}
}
Aggregations