use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method creatMeatadataColumn.
private void creatMeatadataColumn(IMetadataColumn columnSource, String targetNodeName, AbstractNode sourceNode, IMetadataTable metadataTarget, int index) {
IMetadataColumn createNewColumn = null;
if (columnSource != null) {
// dnd schema column
createNewColumn = new MetadataColumn(columnSource);
createNewColumn.setLabel(targetNodeName);
} else {
// dnd doc child
createNewColumn = new MetadataColumn();
createNewColumn.setLabel(targetNodeName);
createNewColumn.setType(sourceNode.getType());
createNewColumn.setTalendType(sourceNode.getType());
if (sourceNode instanceof TreeNode) {
createNewColumn.setKey(((TreeNode) sourceNode).isKey());
createNewColumn.setNullable(((TreeNode) sourceNode).isNullable());
createNewColumn.setPattern(((TreeNode) sourceNode).getPattern());
}
}
if (index != -1) {
metadataTarget.getListColumns().add(index, createNewColumn);
} else {
metadataTarget.getListColumns().add(createNewColumn);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class InsertNewColumnCommand method getSourceColumn.
private IMetadataColumn getSourceColumn(String sourceTreeName, String sourceNodeName) {
List<IODataComponent> inputs = manager.getMapperComponent().getIODataComponents().getInputs();
IMetadataColumn columnSource = null;
for (IODataComponent incoming : inputs) {
if (sourceTreeName != null && sourceTreeName.equals(incoming.getConnection().getName())) {
IMetadataTable metadataSource = incoming.getTable();
for (IMetadataColumn column : metadataSource.getListColumns()) {
if (column.getLabel().equals(sourceNodeName)) {
columnSource = column;
break;
}
}
break;
}
}
return columnSource;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ProblemsAnalyserTest method prepareExternalData.
private ExternalMapperTable prepareExternalData(IMetadataTable table) {
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
for (IMetadataColumn column : table.getListColumns()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setName(column.getLabel());
externalMapperTableEntry.setType(column.getTalendType());
externalMapperTableEntry.setNullable(column.isNullable());
perTableEntries.add(externalMapperTableEntry);
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
return externalMapperTable;
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ScdComponent method metadataInputChanged.
@Override
public void metadataInputChanged(IODataComponent dataComponent, String connectionToApply) {
List<ColumnNameChanged> columnNameList = dataComponent.getColumnNameChanged();
if (columnNameList != null && columnNameList.size() > 0) {
return;
}
// when delete columns,synchronization filed type
IMetadataTable metadataTable = dataComponent.getTable();
List<IMetadataColumn> listColumns = metadataTable.getListColumns();
List<String> listNames = new ArrayList<String>();
for (IMetadataColumn meta : listColumns) {
listNames.add(meta.getLabel());
}
List<? extends IElementParameter> list = this.getElementParameters();
// update sorcekeys
IElementParameter param = getElementParameter(ScdParameterConstants.SOURCE_KEYS_PARAM_NAME);
List<Map<String, String>> sorcevalues = (List<Map<String, String>>) param.getValue();
updateFileds(listNames, list, sorcevalues, param, null);
// update zero filed type
IElementParameter useL0 = getElementParameter(ScdParameterConstants.USE_L0);
if (useL0 != null && useL0.getValue().equals(Boolean.TRUE)) {
IElementParameter l0FieldsParam = getElementParameter(ScdParameterConstants.L0_FIELDS_PARAM_NAME);
List<Map<String, String>> values = (List<Map<String, String>>) l0FieldsParam.getValue();
updateFileds(listNames, list, values, l0FieldsParam, useL0);
}
// update one filed type
IElementParameter useL1 = getElementParameter(ScdParameterConstants.USE_L1);
if (useL1 != null && useL1.getValue().equals(Boolean.TRUE)) {
IElementParameter l1FieldsParam = getElementParameter(ScdParameterConstants.L1_FIELDS_PARAM_NAME);
List<Map<String, String>> values = (List<Map<String, String>>) l1FieldsParam.getValue();
updateFileds(listNames, list, values, l1FieldsParam, useL1);
}
// update two filed type
IElementParameter useL2 = getElementParameter(ScdParameterConstants.USE_L2);
if (useL2 != null && useL2.getValue().equals(Boolean.TRUE)) {
IElementParameter l2FieldsParam = getElementParameter(ScdParameterConstants.L2_FIELDS_PARAM_NAME);
List<Map<String, String>> values = (List<Map<String, String>>) l2FieldsParam.getValue();
updateFileds(listNames, list, values, l2FieldsParam, useL2);
}
// update three filed type
IElementParameter useL3 = getElementParameter(ScdParameterConstants.USE_L3);
if (useL3 != null && useL3.getValue().equals(Boolean.TRUE)) {
IElementParameter l3FieldsParam = getElementParameter(ScdParameterConstants.L3_FIELDS_PARAM_NAME);
List<Map<String, String>> values = (List<Map<String, String>>) l3FieldsParam.getValue();
updateFileds(listNames, list, values, l3FieldsParam, useL3);
}
}
use of org.talend.core.model.metadata.IMetadataColumn in project tdi-studio-se by Talend.
the class ScdManager method getOutputColumns.
/**
* DOC hcw Comment method "getOutputColumns".
*
* @param node
* @return
*/
public List<IMetadataColumn> getOutputColumns(INode node) {
List<IMetadataTable> metaDataList = node.getMetadataList();
List<IMetadataColumn> columns = new ArrayList<IMetadataColumn>();
if (metaDataList != null) {
for (IMetadataTable table : metaDataList) {
columns.addAll(table.getListColumns());
}
}
return columns;
}
Aggregations