use of org.talend.core.model.metadata.builder.connection.impl.ConnectionFactoryImpl in project tdi-studio-se by Talend.
the class MetadataExtPasteCommand method createPastableBeansList.
@Override
public List createPastableBeansList(ExtendedTableModel extendedTable, List copiedObjectsList) {
ArrayList list = new ArrayList();
ArrayList countList = new ArrayList();
ArrayList<String> labelsExisted = getLabelsExisted(extendedTable);
for (Object current : copiedObjectsList) {
if (current instanceof IMetadataColumn) {
IMetadataColumn copy = ((IMetadataColumn) current).clone();
String nextGeneratedColumnName = ((MetadataTableEditor) extendedTable).getNextGeneratedColumnName(copy.getLabel());
if (labelsExisted.contains(nextGeneratedColumnName)) {
nextGeneratedColumnName = validateColumnName(nextGeneratedColumnName, labelsExisted);
}
labelsExisted.add(nextGeneratedColumnName);
copy.setLabel(nextGeneratedColumnName);
if (copy instanceof MetadataColumnExt) {
list.add(copy);
} else {
MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
list.add(metadataColumnExt);
}
} else if (current instanceof org.talend.core.model.metadata.builder.connection.MetadataColumn) {
MetadataTableEditor tableEditor = (MetadataTableEditor) extendedTable;
org.talend.core.model.metadata.builder.connection.MetadataColumn metadataColumn = (org.talend.core.model.metadata.builder.connection.MetadataColumn) current;
String nextGeneratedColumnName = metadataColumn.getLabel();
//$NON-NLS-1$
String tempNewColumnName = "";
boolean iMetaColumnUnique = false;
boolean metaColumnUnique = false;
while (iMetaColumnUnique == false || metaColumnUnique == false) {
nextGeneratedColumnName = tableEditor.getNextGeneratedColumnName(nextGeneratedColumnName, null);
iMetaColumnUnique = true;
metaColumnUnique = false;
if (list.size() == 0)
metaColumnUnique = true;
else {
tempNewColumnName = this.getUniqueString(list, nextGeneratedColumnName);
if (tempNewColumnName.equals(nextGeneratedColumnName))
metaColumnUnique = true;
else {
metaColumnUnique = false;
nextGeneratedColumnName = tempNewColumnName;
}
}
}
org.talend.core.model.metadata.builder.connection.MetadataColumn newColumnCopy = new ConnectionFactoryImpl().copy(metadataColumn, nextGeneratedColumnName);
IMetadataColumn copy = (ConvertionHelper.convertToIMetaDataColumn(newColumnCopy)).clone();
copy.setLabel(nextGeneratedColumnName);
MetadataColumnExt metadataColumnExt = new MetadataColumnExt((MetadataColumn) copy);
metadataColumnExt.setFunction(functionManagerExt.getDefaultFunction(metadataColumnExt, metadataColumnExt.getTalendType()));
list.add(metadataColumnExt);
countList.add(nextGeneratedColumnName);
}
}
return list;
}
Aggregations