use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class DesignerMapperService method updateEntriesByMetaColumns.
private void updateEntriesByMetaColumns(String schemaId, IMetadataTable metadataTable, ExternalMapperTable table, MapperComponent component) {
String id = table.getId();
if (schemaId.equals(id)) {
List<ExternalMapperTableEntry> mapperTableEntries = table.getMetadataTableEntries();
List<ExternalMapperTableEntry> newTableEntries = new ArrayList<ExternalMapperTableEntry>();
/* bug 21080 */
for (ExternalMapperTableEntry oldEntry : mapperTableEntries) {
String expression = oldEntry.getExpression();
String columnname = oldEntry.getName();
if (expression != null) {
oldMappingMap.put(columnname, expression);
}
}
List<IMetadataColumn> columns = metadataTable.getListColumns();
if (columns != null) {
for (IMetadataColumn metadataColumn : columns) {
ExternalMapperTableEntry tableEntry = new ExternalMapperTableEntry();
tableEntry.setName(metadataColumn.getLabel());
tableEntry.setType(metadataColumn.getTalendType());
tableEntry.setNullable(metadataColumn.isNullable());
ExternalMapperTableEntry sameEntry = null;
for (ExternalMapperTableEntry oldEntry : mapperTableEntries) {
if (oldEntry.getName().equals(metadataColumn.getLabel())) {
sameEntry = oldEntry;
}
}
if (sameEntry != null) {
tableEntry.setExpression(sameEntry.getExpression());
tableEntry.setOperator(sameEntry.getOperator());
String oldExpression = oldMappingMap.get(tableEntry.getName());
if (oldExpression != null) {
tableEntry.setExpression(oldExpression);
}
}
newTableEntries.add(tableEntry);
}
}
mapperTableEntries.clear();
table.setMetadataTableEntries(newTableEntries);
final IMetadataTable mapperTabel = getMetadataTable(component, table.getName());
if (mapperTabel != null) {
if (mapperTabel.getListColumns() != null) {
mapperTabel.getListColumns().clear();
mapperTabel.getListColumns().addAll(metadataTable.getListColumns());
} else {
mapperTabel.setListColumns(metadataTable.getListColumns());
}
}
}
oldMappingMap.clear();
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class MapperComponent method getHashConfiguration.
/*
* (non-Javadoc)
*
* @see org.talend.core.model.process.IHashableInputConnections#getHashConfiguration(java.lang.String)
*/
public IHashConfiguration getHashConfiguration(String connectionName) {
IHashConfiguration hashConfigurationForMapper = null;
ExternalMapperData externalData = (ExternalMapperData) getExternalData();
List<ExternalMapperTable> inputTables = externalData.getInputTables();
List<IHashableColumn> hashableColumns = new ArrayList<IHashableColumn>();
for (ExternalMapperTable inputTable : inputTables) {
if (inputTable.getName().equals(connectionName)) {
List<ExternalMapperTableEntry> metadataTableEntries = inputTable.getMetadataTableEntries();
if (metadataTableEntries != null) {
int metadataTableEntriesListSize = metadataTableEntries.size();
for (int i = 0; i < metadataTableEntriesListSize; i++) {
ExternalMapperTableEntry entry = metadataTableEntries.get(i);
if (entry.getExpression() != null && !entry.getExpression().trim().equals("")) {
//$NON-NLS-1$
hashableColumns.add(new HashableColumn(entry.getName(), i));
}
}
}
IMatchingMode matchingMode = MATCHING_MODE.parse(inputTable.getMatchingMode());
if (matchingMode == null) {
matchingMode = MATCHING_MODE.UNIQUE_MATCH;
}
ILookupMode lookupMode = LOOKUP_MODE.parse(inputTable.getLookupMode());
if (lookupMode == null) {
lookupMode = LOOKUP_MODE.LOAD_ONCE;
}
//$NON-NLS-1$
IElementParameter tempFolderElem = getElementParameter("TEMPORARY_DATA_DIRECTORY");
// modified by wzhang to fix 7824
String tempFolder = null;
if (tempFolderElem != null) {
tempFolder = (String) tempFolderElem.getValue();
}
if (("").equals(tempFolder)) {
//$NON-NLS-1$ //$NON-NLS-2$
tempFolder = (String) this.getProcess().getElementParameter("COMP_DEFAULT_FILE_DIR").getValue() + "/temp";
tempFolder = TalendTextUtils.addQuotes(tempFolder);
}
//$NON-NLS-1$
IElementParameter rowsBufferSizeElem = getElementParameter("ROWS_BUFFER_SIZE");
String rowsBufferSize = null;
if (rowsBufferSizeElem != null) {
rowsBufferSize = (String) rowsBufferSizeElem.getValue();
}
hashConfigurationForMapper = new HashConfiguration(hashableColumns, matchingMode, inputTable.isPersistent(), tempFolder, rowsBufferSize);
break;
}
}
return hashConfigurationForMapper;
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(Collection<? extends AbstractDataMapTable> tables) {
for (IDataMapTable table : tables) {
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
fillExternalTable(table, externalMapperTable);
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
boolean isVarTable = table instanceof VarsTable;
boolean isInputTable = table instanceof InputTable;
for (ITableEntry dataMapTableEntry : table.getColumnEntries()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(dataMapTableEntry.getExpression());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
if (isVarTable) {
externalMapperTableEntry.setType(((VarTableEntry) dataMapTableEntry).getType());
externalMapperTableEntry.setNullable(((VarTableEntry) dataMapTableEntry).isNullable());
} else {
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
}
if (isInputTable) {
externalMapperTableEntry.setOperator(((InputColumnTableEntry) dataMapTableEntry).getOperator());
}
perTableEntries.add(externalMapperTableEntry);
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
}
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class ExternalDataConverter method loadInExternalData.
private void loadInExternalData(List<? extends AbstractDataMapTable> tables, List<? extends AbstractDataMapTable> intables) {
// for (int i = 0; i < tables.size(); i++) {
if (tables.size() <= 0 || intables.size() <= 0) {
return;
}
IDataMapTable outtable = tables.get(0);
IDataMapTable intable = intables.get(0);
ExternalMapperTable externalMapperTable = new ExternalMapperTable();
fillExternalTable(outtable, externalMapperTable);
ArrayList<ExternalMapperTableEntry> perTableEntries = new ArrayList<ExternalMapperTableEntry>();
List<IMetadataColumn> columnList = null;
if (mapperManager != null && mapperManager.getAbstractMapComponent() != null) {
List<? extends IConnection> connList = mapperManager.getAbstractMapComponent().getOutgoingConnections();
if (connList != null && connList.size() >= 1) {
List<IMetadataTable> metaList = connList.get(0).getTarget().getMetadataList();
if (metaList != null && metaList.size() >= 1) {
columnList = metaList.get(0).getListColumns();
}
}
}
for (ITableEntry dataMapTableEntry : intable.getColumnEntries()) {
if (columnList != null) {
boolean find = false;
for (IMetadataColumn column : columnList) {
if (dataMapTableEntry.getName().equals(column.getLabel())) {
find = true;
break;
}
}
if (find) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
} else {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(intable.getName() + "." + dataMapTableEntry.getName());
externalMapperTableEntry.setName(dataMapTableEntry.getName());
externalMapperTableEntry.setType(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().getTalendType());
externalMapperTableEntry.setNullable(((AbstractInOutTableEntry) dataMapTableEntry).getMetadataColumn().isNullable());
perTableEntries.add(externalMapperTableEntry);
}
}
externalMapperTable.setMetadataTableEntries(perTableEntries);
// }
}
use of org.talend.designer.mapper.external.data.ExternalMapperTableEntry in project tdi-studio-se by Talend.
the class ExternalDataConverter method fillExternalTable.
/**
* DOC amaumont Comment method "process".
*
* @param externalMapperTable
* @param table
*/
private void fillExternalTable(OutputTable table, ExternalMapperTable externalMapperTable) {
fillExternalTableWithCommonsData(table, externalMapperTable);
externalMapperTable.setReject(table.isReject());
externalMapperTable.setRejectInnerJoin(table.isRejectInnerJoin());
externalMapperTable.setErrorRejectTable(table.isErrorRejectTable());
externalMapperTable.setIsJoinTableOf(table.getIsJoinTableOf());
externalMapperTable.setActivateExpressionFilter(table.isActivateExpressionFilter());
externalMapperTable.setActivateCondensedTool(table.isActivateCondensedTool());
externalMapperTable.setActivateColumnNameFilter(table.isActivateColumnNameFilter());
externalMapperTable.setExpressionFilter(table.getExpressionFilter() != null && isFilterEqualsToDefault(table.getExpressionFilter().getExpression()) ? null : table.getExpressionFilter().getExpression());
externalMapperTable.setId(table.getId());
if (mapperManager.isAdvancedMap()) {
externalMapperTable.setConstraintTableEntries(null);
} else {
ArrayList<ExternalMapperTableEntry> constraintTableEntries = new ArrayList<ExternalMapperTableEntry>();
for (FilterTableEntry constraintTableEntry : table.getFilterEntries()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(constraintTableEntry.getExpression());
externalMapperTableEntry.setName(constraintTableEntry.getName());
constraintTableEntries.add(externalMapperTableEntry);
}
externalMapperTable.setConstraintTableEntries(constraintTableEntries);
}
outputTables.add(externalMapperTable);
}
Aggregations