use of org.talend.core.model.metadata.ColumnNameChanged in project tdi-studio-se by Talend.
the class DbMapComponent method inputMetadataColumnAmountChanged.
private void inputMetadataColumnAmountChanged(IODataComponent dataComponent, IExternalNode externalNode) {
List<ColumnNameChanged> removedMetadataColumns = dataComponent.getRemoveMetadataColumns();
IExternalData iExternalData = externalNode.getExternalData();
if (iExternalData == null || removedMetadataColumns == null || removedMetadataColumns.size() == 0) {
return;
}
List<ExternalDbMapTable> metaTableList = (List<ExternalDbMapTable>) iExternalData.getInputTables();
if (metaTableList == null || metaTableList.size() == 0) {
return;
}
// in the eltmap, the input table name is same with it's input connection name
String tableName = dataComponent.getName();
if (StringUtils.isEmpty(tableName)) {
return;
}
for (ExternalDbMapTable metaTable : metaTableList) {
if (tableName.equals(metaTable.getTableName())) {
List<IExternalMapEntry> externalMapEntryList = (List<IExternalMapEntry>) metaTable.returnTableEntries();
if (externalMapEntryList == null || externalMapEntryList.size() == 0) {
continue;
}
if (removedMetadataColumns != null && 0 < removedMetadataColumns.size()) {
for (ColumnNameChanged removedMetadataColumn : removedMetadataColumns) {
if ("".equals(removedMetadataColumn.getNewName())) {
//$NON-NLS-1$
String columnName = removedMetadataColumn.getOldName();
for (int i = externalMapEntryList.size() - 1; 0 <= i; i--) {
IExternalMapEntry mapEntry = externalMapEntryList.get(i);
if (columnName.equals(mapEntry.getName())) {
externalMapEntryList.remove(i);
break;
}
}
}
}
}
}
}
}
use of org.talend.core.model.metadata.ColumnNameChanged in project tdi-studio-se by Talend.
the class ChangeMetadataCommand method updateColumnList.
@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);
}
use of org.talend.core.model.metadata.ColumnNameChanged in project tdi-studio-se by Talend.
the class FileOutputXMLComponent method metadataInputChanged.
@Override
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
List<Map<String, String>> listRoot = new ArrayList<Map<String, String>>();
if (this.getElementParameter(ROOT) != null && this.getElementParameter(ROOT).getValue() != null) {
listRoot.addAll((List<Map<String, String>>) this.getElementParameter(ROOT).getValue());
}
boolean flagRoot = false;
List<Map<String, String>> listGroup = new ArrayList<Map<String, String>>();
if (this.getElementParameter(GROUP) != null && this.getElementParameter(GROUP).getValue() != null) {
listGroup.addAll((List<Map<String, String>>) this.getElementParameter(GROUP).getValue());
}
boolean flagGroup = false;
List<Map<String, String>> listLoop = new ArrayList<Map<String, String>>();
if (this.getElementParameter(LOOP) != null && this.getElementParameter(LOOP).getValue() != null) {
listLoop.addAll((List<Map<String, String>>) this.getElementParameter(LOOP).getValue());
}
boolean flagLoop = false;
// add by wzhang. column show with schema name added for mutiSchema
//$NON-NLS-1$
String schemaId = "";
if (istFileOutputMSXML()) {
//$NON-NLS-1$
schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":";
}
for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) {
for (Map<String, String> map : listRoot) {
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
map.put(COLUMN, schemaId + col.getNewName());
flagRoot = true;
}
}
for (Map<String, String> map : listGroup) {
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
map.put(COLUMN, schemaId + col.getNewName());
flagGroup = true;
}
}
for (Map<String, String> map : listLoop) {
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
map.put(COLUMN, schemaId + col.getNewName());
flagLoop = true;
}
}
}
if (flagRoot) {
this.getElementParameter(ROOT).setValue(listRoot);
}
if (flagGroup) {
this.getElementParameter(GROUP).setValue(listGroup);
}
if (flagLoop) {
this.getElementParameter(LOOP).setValue(listLoop);
}
}
use of org.talend.core.model.metadata.ColumnNameChanged in project tdi-studio-se by Talend.
the class HL7InputComponent method metadataInputChanged.
/*
* (non-Javadoc)
*
* @seeorg.talend.core.model.process.AbstractExternalNode#metadataInputChanged(org.talend.core.model.components.
* IODataComponent, java.lang.String)
*/
@Override
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
super.metadataInputChanged(dataComponent, connectionToApply);
List<Map<String, String>> listRoot = (List<Map<String, String>>) this.getElementParameter(ROOT).getValue();
boolean flagRoot = false;
//$NON-NLS-1$
String schemaId = "";
if (isHL7Output()) {
//$NON-NLS-1$
schemaId = dataComponent.getConnection().getMetadataTable().getLabel() + ":";
}
for (ColumnNameChanged col : dataComponent.getColumnNameChanged()) {
for (Map<String, String> map : listRoot) {
if (map.get(COLUMN).equals(schemaId + col.getOldName())) {
map.put(COLUMN, schemaId + col.getNewName());
flagRoot = true;
}
}
}
if (flagRoot) {
this.getElementParameter(ROOT).setValue(listRoot);
}
}
use of org.talend.core.model.metadata.ColumnNameChanged in project tdi-studio-se by Talend.
the class ExternalNodeChangeCommand method propagateInput.
private void propagateInput() {
for (Connection connection : (List<Connection>) node.getIncomingConnections()) {
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.DATA)) {
IODataComponent currentIO = inAndOut.getDataComponent(connection);
currentIO.setColumnOption(IMetadataColumn.OPTIONS_NONE);
if (currentIO.hasChanged()) {
IMetadataTable metadata = inAndOut.getTable(connection);
INode sourceNode = currentIO.getSource();
sourceNode.metadataOutputChanged(currentIO, currentIO.getName());
// It's better to clone, because will change that, if apply, bug 13325
// IMetadataTable oldMetadata = connection.getMetadataTable().clone();
IMetadataTable newMetadata = metadata.clone();
currentIO.setTable(newMetadata);
String schemaType = (String) connection.getSource().getPropertyValue(EParameterName.SCHEMA_TYPE.getName());
if (schemaType != null) {
// if there is a SCHEMA_TYPE, then switch it to BUILT_IN if REPOSITORY is set.
if (schemaType.equals(EmfComponent.REPOSITORY)) {
connection.getSource().setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), EmfComponent.BUILTIN);
metadataInputWasRepository.put(connection, Boolean.TRUE);
}
}
// for bug 9849
List<IMetadataColumn> listColumns = connection.getMetadataTable().getListColumns();
// before is empty
boolean empty = listColumns.isEmpty();
List<IMetadataColumn> newListColumns = newMetadata.getListColumns();
List<ColumnNameChanged> columnNameChangeds = new ArrayList<ColumnNameChanged>();
int size = listColumns.size();
int newSize = newListColumns.size();
if (newSize < size) {
size = newSize;
}
for (int i = 0; i < size; i++) {
IMetadataColumn metadataColumn = listColumns.get(i);
IMetadataColumn newMetadataColumn = newListColumns.get(i);
if (metadataColumn != null && newMetadataColumn != null) {
String oldId = metadataColumn.getId();
String oldLabel = metadataColumn.getLabel();
String newLabel = newMetadataColumn.getLabel();
String newId = newMetadataColumn.getId();
if (oldId != null && oldLabel != null && newId != null && oldId.equals(newId) && !oldLabel.equals(newLabel)) {
columnNameChangeds.add(new ColumnNameChanged(oldLabel, newLabel));
}
}
}
connection.getMetadataTable().setListColumns(newListColumns);
// some pig component have FLOW_MAIN && PIGCOMBINE two connector type
if (connection.getConnectorName() != null && connection.getConnectorName().equals("PIGCOMBINE")) {
IMetadataTable table = sourceNode.getMetadataFromConnector(EConnectionType.FLOW_MAIN.getName());
if (table != null) {
table.setListColumns(newListColumns);
}
}
ColumnListController.updateColumnList(sourceNode, columnNameChangeds, false);
if (empty) {
// trace init
connection.initTraceParamters();
}
}
}
}
}
Aggregations