use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class ExternalDataConverter method fillExternalTable.
/**
*
* DOC amaumont Comment method "fillExternalTable".
*
* @param table
* @param externalMapperTable
*/
private void fillExternalTable(InputTable table, ExternalMapperTable externalMapperTable) {
externalMapperTable.setInnerJoin(table.isInnerJoin());
externalMapperTable.setPersistent(table.isPersistent());
externalMapperTable.setActivateExpressionFilter(table.isActivateExpressionFilter());
externalMapperTable.setActivateCondensedTool(table.isActivateCondensedTool());
externalMapperTable.setActivateColumnNameFilter(table.isActivateColumnNameFilter());
externalMapperTable.setId(table.getId());
String expressionFilter = null;
if (table.getExpressionFilter() != null && table.getExpressionFilter().getExpression() != null) {
expressionFilter = table.getExpressionFilter().getExpression();
}
externalMapperTable.setExpressionFilter(expressionFilter);
String matchingMode = null;
if (table.getMatchingMode() != null) {
matchingMode = table.getMatchingMode().toString();
}
externalMapperTable.setMatchingMode(matchingMode);
String lookupMode = null;
if (table.getLookupMode() != null) {
lookupMode = table.getLookupMode().toString();
}
externalMapperTable.setLookupMode(lookupMode);
ArrayList<ExternalMapperTableEntry> globalMapEntries = new ArrayList<ExternalMapperTableEntry>();
for (GlobalMapEntry constraintTableEntry : table.getGlobalMapEntries()) {
ExternalMapperTableEntry externalMapperTableEntry = new ExternalMapperTableEntry();
externalMapperTableEntry.setExpression(constraintTableEntry.getExpression());
externalMapperTableEntry.setName(constraintTableEntry.getName());
globalMapEntries.add(externalMapperTableEntry);
}
externalMapperTable.setGlobalMapKeysValues(globalMapEntries);
fillExternalTableWithCommonsData(table, externalMapperTable);
inputTables.add(externalMapperTable);
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class LinkManager method registerLevelForNewLink.
/**
* DOC amaumont Comment method "registerLevelForNewLink".
*
* @param link
* @param graphicalLinksFromTarget
*/
public void registerLevelForNewLink(IMapperLink link, Set<IMapperLink> graphicalLinksFromTarget) {
boolean hasAlreadyInputTarget = false;
boolean hasAlreadyVarTarget = false;
ITableEntry sourceEntry = link.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
boolean hasSameZone = sourceEntry.getParent().getClass() == targetEntry.getParent().getClass();
if (hasSameZone) {
boolean isInputTarget = targetEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry || targetEntry instanceof GlobalMapEntry && targetEntry.getParent() instanceof InputTable;
boolean isVarTarget = targetEntry instanceof VarTableEntry;
List<List<IMapperLink>> leveledLinks = null;
if (isInputTarget) {
leveledLinks = getInputLinksForLevels();
}
if (isVarTarget) {
leveledLinks = getVarLinksForLevels();
}
int lstSize = leveledLinks.size();
for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
IMapperLink linkFromLevelsList = linksFromLevelsList.get(0);
ITableEntry sourceTableEntry = linkFromLevelsList.getPointLinkDescriptor1().getTableEntry();
ITableEntry targetTableEntry = linkFromLevelsList.getPointLinkDescriptor2().getTableEntry();
if (targetEntry == targetTableEntry) {
if (sourceTableEntry instanceof InputColumnTableEntry && (targetTableEntry instanceof InputColumnTableEntry || targetEntry instanceof ExpressionFilterEntry && targetEntry.getParent() instanceof InputTable)) {
hasAlreadyInputTarget = true;
}
if (sourceTableEntry instanceof VarTableEntry && targetTableEntry instanceof VarTableEntry) {
hasAlreadyVarTarget = true;
}
if (hasAlreadyInputTarget || hasAlreadyVarTarget) {
linksFromLevelsList.add(link);
link.setLevel(indexOfLeveledLink + 1);
break;
}
}
}
}
if (isInputTarget && !hasAlreadyInputTarget || isVarTarget && !hasAlreadyVarTarget) {
ArrayList<IMapperLink> list = new ArrayList<IMapperLink>();
int firstEmptyIndex = searchFirstEmptyIndexLeveledList(leveledLinks);
link.setLevel(firstEmptyIndex + 1);
list.add(link);
if (firstEmptyIndex < leveledLinks.size()) {
leveledLinks.set(firstEmptyIndex, list);
} else {
leveledLinks.add(list);
}
}
}
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class MapperManager method addNewGlobalMapEntry.
/**
*
* @param dataMapTableView
* @param index
* @param type TODO
* @param metadataColumn, can be null if added in VarsTable
*/
public GlobalMapEntry addNewGlobalMapEntry(DataMapTableView dataMapTableView, ITableEntry tableEntrySource, Integer index) {
IDataMapTable abstractDataMapTable = dataMapTableView.getDataMapTable();
GlobalMapEntry dataMapTableEntry = null;
if (dataMapTableView.getZone() == Zone.INPUTS) {
dataMapTableEntry = new GlobalMapEntry(abstractDataMapTable, "\"" + dataMapTableView.findUniqueName("myKey") + "\"", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
null);
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("MapperManager.exceptionMessage.useOtherSignature"));
}
AddGlobalMapEntryCommand command = new AddGlobalMapEntryCommand(tableEntriesManager, dataMapTableEntry, index);
executeCommand(command);
return dataMapTableEntry;
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class UIManager method getTableEntryPosition.
/**
* DOC amaumont Comment method "getTableEntryPosition".
*
* @param manager TODO
* @param tableEntry
* @param forceRecalculate TODO
* @return
*/
public Point getTableEntryPosition(ITableEntry tableEntry, boolean forceRecalculate) {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(tableEntry);
int entriesSize = 0;
int minHeight = dataMapTableView.getTableViewerCreatorForColumns().getTable().getHeaderHeight() + dataMapTableView.getTableViewerCreatorForColumns().getTable().getItemHeight();
TableItem[] tableItems = new TableItem[0];
if (tableEntry instanceof InputColumnTableEntry || tableEntry instanceof OutputColumnTableEntry) {
tableItems = dataMapTableView.getTableViewerCreatorForColumns().getTable().getItems();
AbstractInOutTable abstractInOutTable = (AbstractInOutTable) dataMapTableView.getDataMapTable();
if (dataMapTableView.getZone() == Zone.OUTPUTS) {
OutputTable outputTable = (OutputTable) abstractInOutTable;
List<IColumnEntry> oldOuputEntries = outputTable.getDataMapTableEntries();
entriesSize = oldOuputEntries.size();
}
if (dataMapTableView.getZone() == Zone.INPUTS) {
InputTable inputTable = (InputTable) abstractInOutTable;
List<IColumnEntry> oldOuputEntries = inputTable.getDataMapTableEntries();
entriesSize = oldOuputEntries.size();
}
}
Rectangle tableViewBounds = dataMapTableView.getBounds();
Point pointFromTableViewOrigin = null;
Display display = dataMapTableView.getDisplay();
Point returnedPoint = new Point(0, 0);
TableEntryProperties tableEntryProperties = null;
int itemIndex = 0;
if (tableEntry instanceof IColumnEntry || tableEntry instanceof FilterTableEntry || tableEntry instanceof GlobalMapEntry) {
tableEntryProperties = mapperManager.getTableEntryProperties(tableEntry);
returnedPoint = tableEntryProperties.position;
if (forceRecalculate || returnedPoint == null) {
int y;
TableItem tableItem = mapperManager.retrieveTableItem(tableEntry);
boolean isOutputEntry = tableEntry instanceof OutputColumnTableEntry;
boolean isIntputEntry = tableEntry instanceof InputColumnTableEntry;
boolean checked = false;
for (int i = 0; i < tableItems.length; i++) {
if (tableItems[i].getData() == tableEntry) {
itemIndex = i;
break;
}
}
boolean allIsNull = false;
if (tableItem == null && (isIntputEntry || isOutputEntry)) {
if (tableItems.length > 0) {
tableItem = tableItems[0];
checked = true;
} else {
allIsNull = true;
}
}
if (!allIsNull) {
Table table = tableItem.getParent();
// FIX for issue 1225 ("1" parameter added)
Rectangle boundsTableItem = tableItem.getBounds(1);
y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
if (isOutputEntry || isIntputEntry) {
if (entriesSize != tableItems.length) {
y = boundsTableItem.y + table.getItemHeight() / 2 + dataMapTableView.getBorderWidth();
}
}
if (checked) {
y = boundsTableItem.y + dataMapTableView.getBorderWidth();
checked = false;
}
int x = 0;
if (y < 0) {
y = 0;
}
Point point = new Point(x, y);
pointFromTableViewOrigin = display.map(tableItem.getParent(), dataMapTableView, point);
} else {
Text columnFilterText = dataMapTableView.getColumnNameFilterText();
Point point = new Point(-dataMapTableView.getBorderWidth() - 19, minHeight);
pointFromTableViewOrigin = display.map(columnFilterText, dataMapTableView, point);
}
}
} else if (tableEntry instanceof ExpressionFilterEntry) {
StyledText expressionFilterText = dataMapTableView.getExpressionFilterText();
// dataMapTableView.getex
Point point = new Point(-dataMapTableView.getBorderWidth() - 19, 16);
pointFromTableViewOrigin = display.map(expressionFilterText, dataMapTableView, point);
} else {
//$NON-NLS-1$
throw new IllegalStateException("Case not found");
}
if (pointFromTableViewOrigin.y > tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION) {
pointFromTableViewOrigin.y = tableViewBounds.height - TableEntriesManager.HEIGHT_REACTION;
}
returnedPoint = convertPointToReferenceOrigin(getReferenceComposite(), pointFromTableViewOrigin, dataMapTableView);
if (tableEntryProperties != null) {
tableEntryProperties.position = returnedPoint;
}
return returnedPoint;
}
use of org.talend.designer.mapper.model.tableentry.GlobalMapEntry in project tdi-studio-se by Talend.
the class TableEntriesManager method remove.
public void remove(ITableEntry dataMapTableEntry) {
if (dataMapTableEntry != null) {
mapperManager.removeLinksOf(dataMapTableEntry);
tableEntries.remove(TableEntriesManager.buildLocation(dataMapTableEntry));
dataMapTableEntryToProperties.remove(dataMapTableEntry);
IDataMapTable dataMapTable = dataMapTableEntry.getParent();
if (dataMapTableEntry instanceof IColumnEntry) {
dataMapTableEntry.getParent().removeColumnEntry((IColumnEntry) dataMapTableEntry);
} else if (dataMapTableEntry instanceof GlobalMapEntry) {
if (dataMapTable instanceof OutputTable) {
((InputTable) dataMapTable).removeGlobalMapEntry((GlobalMapEntry) dataMapTableEntry);
}
} else if (dataMapTableEntry instanceof FilterTableEntry) {
if (dataMapTable instanceof OutputTable) {
((OutputTable) dataMapTable).removeFilterEntry((FilterTableEntry) dataMapTableEntry);
}
} else if (dataMapTableEntry instanceof ExpressionFilterEntry) {
// nothing
} else {
String exceptionMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
throw new IllegalArgumentException(exceptionMessage);
}
}
}
Aggregations