use of org.talend.core.model.process.node.IExternalMapEntry 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.process.node.IExternalMapEntry in project tdi-studio-se by Talend.
the class MapDataDelegateHelper method addAll.
private void addAll(Map<IExternalMapTable, List<IExternalMapEntry>> targetMap, Map<IExternalMapTable, List<IExternalMapEntry>> sourceMap) {
for (IExternalMapTable table : sourceMap.keySet()) {
List<IExternalMapEntry> tlist = targetMap.get(table);
List<IExternalMapEntry> sList = sourceMap.get(table);
if (sList != null) {
if (tlist == null) {
targetMap.put(table, sList);
} else {
for (IExternalMapEntry entry : sList) {
if (!tlist.contains(entry)) {
tlist.add(entry);
}
}
}
}
}
}
use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.
the class MapDataDelegateHelper method getExpressionColumns.
/**
*
* ggu Comment method "getExpressionColumns".
*
* @param expression -> if null, will return the all table for type
* @param types ->
* @return
*/
public Map<IExternalMapTable, List<IExternalMapEntry>> getExpressionColumns(String expression, ExternalDataType... types) {
Map<IExternalMapTable, List<IExternalMapEntry>> tableMap = new HashMap<IExternalMapTable, List<IExternalMapEntry>>();
if (types != null && types.length > 0) {
for (ExternalDataType type : types) {
switch(type) {
case INPUT:
return getExpressionColumns(getInputTables(), expression);
case OUTPUT:
return getExpressionColumns(getOutputTables(), expression);
case VAR:
return getExpressionColumns(getVarsTables(), expression);
default:
}
}
} else {
addAll(tableMap, getExpressionColumns(getInputTables(), expression));
addAll(tableMap, getExpressionColumns(getOutputTables(), expression));
addAll(tableMap, getExpressionColumns(getVarsTables(), expression));
}
return tableMap;
}
use of org.talend.core.model.process.node.IExternalMapEntry in project tdi-studio-se by Talend.
the class MapperComponent method checkNeededRoutines.
@Override
public List<String> checkNeededRoutines(List<String> possibleRoutines, String additionalString) {
List<String> routinesToAdd = new ArrayList<String>();
for (String routine : possibleRoutines) {
List<ExternalMapperTable> listOutput = (List<ExternalMapperTable>) this.getExternalData().getOutputTables();
for (ExternalMapperTable outTable : listOutput) {
List<IExternalMapEntry> listOutEntry = (List<IExternalMapEntry>) outTable.returnTableEntries();
if (listOutEntry != null && !listOutEntry.isEmpty()) {
for (IExternalMapEntry outEntry : listOutEntry) {
String expression = outEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
List<ExternalMapperTable> listInput = (List<ExternalMapperTable>) this.getExternalData().getInputTables();
for (ExternalMapperTable inputTable : listInput) {
List<IExternalMapEntry> listInEntry = (List<IExternalMapEntry>) inputTable.returnTableEntries();
if (listInEntry != null && !listInEntry.isEmpty()) {
for (IExternalMapEntry inEntry : listInEntry) {
String expression = inEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
List<ExternalMapperTable> listVar = (List<ExternalMapperTable>) this.getExternalData().getVarsTables();
for (IExternalMapTable varTable : listVar) {
List<IExternalMapEntry> listVarEntry = (List<IExternalMapEntry>) varTable.returnTableEntries();
if (listVarEntry != null && !listVarEntry.isEmpty()) {
for (IExternalMapEntry varEntry : listVarEntry) {
String expression = varEntry.getExpression();
if (expression != null && !routinesToAdd.contains(routine) && expression.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerMapperService.class)) {
IDesignerMapperService service = (IDesignerMapperService) GlobalServiceRegister.getDefault().getService(IDesignerMapperService.class);
List<String> experssionFilters = service.getExpressionFilter(this.getExternalData());
if (!experssionFilters.isEmpty()) {
for (String experssion : experssionFilters) {
if (experssion != null && !routinesToAdd.contains(routine) && experssion.contains(routine + additionalString)) {
routinesToAdd.add(routine);
}
}
}
}
}
return routinesToAdd;
}
Aggregations