@SuppressWarnings("unchecked") protected void updateColumnList(IMetadataTable oldTable, IMetadataTable newTable) { final List<ColumnNameChanged> columnNameChanged = MetadataToolHelper.getColumnNameChanged(oldTable, newTable); if (inputNode != null) { List<IElementParameter> eps = (List<IElementParameter>) inputNode.getElementParameters(); if (eps != null) { boolean end = false; for (int i = 0; i < eps.size() && !end; i++) { IElementParameter parameter = eps.get(i); if (parameter.getFieldType() == EParameterFieldType.TABLE) { end = true; if (parameter != null) { List<Map<String, Object>> map2 = (List<Map<String, Object>>) parameter.getValue(); if (map2 != null && inputNode.getMetadataList().get(0).getListColumns().size() != map2.size()) { ColumnListController.updateColumnList(inputNode, columnNameChanged); } } } } } inputNode.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE); } node.setPropertyValue(EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE); }
@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); // newOutputMetadata.setListColumns(new // ArrayList<IMetadataColumn>(oldOutputMetadata.getListColumns())); if (!internal) { updateColumnList(newOutputMetadata, oldOutputMetadata); ((Process) node.getProcess()).checkProcess(); } refreshMetadataChanged(); }
@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 (node.getComponent() != null && "tSalesforceOutput".equals(node.getComponent().getName()) && "REJECT".equals(connector.getName())) { IMetadataTable clone = newOutputMetadata.clone(true); Iterator<IMetadataColumn> iterator = clone.getListColumns().iterator(); while (iterator.hasNext()) { IMetadataColumn column = iterator.next(); if (column.isCustom()) { iterator.remove(); } } MetadataToolHelper.copyTable(clone, node.getMetadataFromConnector(connector.getName())); } else { // if there is some other schema dependant of this one, modify them MetadataToolHelper.copyTable( newOutputMetadata, node.getMetadataFromConnector(connector.getName())); } } } List<ColumnNameChanged> columnNameChanged = MetadataToolHelper.getColumnNameChanged(oldOutputMetadata, newOutputMetadata); ColumnListController.updateColumnList(node, columnNameChanged, true); if (inputNode != null) { List<ColumnNameChanged> inputColumnNameChangedExt = MetadataToolHelper.getColumnNameChangedExt(inputNode, oldInputMetadata, newInputMetadata); ColumnListController.updateColumnList(node, inputColumnNameChangedExt); } // List<ColumnNameChanged> outputColumnNameChangedExt = MetadataToolHelper.getColumnNameChangedExt(node, oldOutputMetadata, newOutputMetadata); syncOutputNodeColumnsList(outputColumnNameChangedExt); setXMLMAPPING(); if (!internal) { updateColumnList(oldOutputMetadata, newOutputMetadata); ((Process) node.getProcess()).checkProcess(); } refreshMetadataChanged(); }