use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class CompleteDropTargetListener method modifyExistingEntry.
/**
* DOC amaumont Comment method "modifyExistingEntry".
*
* @param uiManager
* @param analyzer
* @param currentLanguage
* @param currentEntryTarget
* @param columnIndicesToSelect
* @param tableViewerCreatorTarget
* @param lastEntryTarget
* @param tableEntrySource
* @param zoneSourceEntry
*/
private void modifyExistingEntry(UIManager uiManager, DropContextAnalyzer analyzer, IDbLanguage currentLanguage, ITableEntry currentEntryTarget, ArrayList<Integer> columnIndicesToSelect, TableViewerCreator tableViewerCreatorTarget, ITableEntry lastEntryTarget, ITableEntry tableEntrySource, Zone zoneSourceEntry) {
boolean overwrite = (lastEntryTarget != currentEntryTarget && analyzer.isOverwriteExpression());
modifyExistingExpression(currentLanguage, currentEntryTarget, tableEntrySource, overwrite, zoneSourceEntry);
uiManager.parseExpression(currentEntryTarget.getExpression(), currentEntryTarget, false, true, true);
if (currentEntryTarget instanceof InputColumnTableEntry) {
setDefaultOperator((InputColumnTableEntry) currentEntryTarget);
}
int indexOfEntry = tableViewerCreatorTarget.getInputList().indexOf(currentEntryTarget);
columnIndicesToSelect.add(indexOfEntry);
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class InputTable method initFromExternalData.
/*
* (non-Javadoc)
*
* @see
* org.talend.designer.dbmap.model.table.AbstractInOutTable#initFromExternalData(org.talend.designer.dbmap.external
* .data.ExternalMapperTable)
*/
@Override
public void initFromExternalData(ExternalDbMapTable externalMapperTable) {
boolean isAliasTable = externalMapperTable != null && externalMapperTable.getAlias() != null;
if (isAliasTable) {
// dbmap table is alias
setMetadataTable(connection.getTable().clone());
} else if (connection != null) {
// dbmap table references a physical table
setMetadataTable(connection.getTable());
}
super.initFromExternalData(externalMapperTable);
List<IMetadataColumn> columns = getMetadataTable().getListColumns();
Map<String, ExternalDbMapEntry> nameToPerTabEntry = new HashMap<String, ExternalDbMapEntry>();
if (externalMapperTable != null && externalMapperTable.getMetadataTableEntries() != null) {
for (ExternalDbMapEntry perTableEntry : externalMapperTable.getMetadataTableEntries()) {
nameToPerTabEntry.put(perTableEntry.getName(), perTableEntry);
}
}
ArrayList<IMetadataColumn> columnsToRemove = new ArrayList<IMetadataColumn>();
for (IMetadataColumn column : columns) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(inputEntry.getMetadataColumn().getLabel());
// Entry match with current column
if (externalMapperTableEntry != null) {
fillInputEntry(inputEntry, externalMapperTableEntry);
nameToPerTabEntry.remove(externalMapperTableEntry.getName());
}
if (externalMapperTableEntry != null || !isAliasTable) {
dataMapTableEntries.add(inputEntry);
} else {
columnsToRemove.add(column);
}
}
columns.removeAll(columnsToRemove);
// create unmatching entries
for (ExternalDbMapEntry perTableEntry : nameToPerTabEntry.values()) {
MetadataColumn column = new MetadataColumn();
column.setLabel(perTableEntry.getName());
InputColumnTableEntry inputEntry = (InputColumnTableEntry) getNewTableEntry(column);
ExternalDbMapEntry externalMapperTableEntry = nameToPerTabEntry.get(inputEntry.getMetadataColumn().getLabel());
fillInputEntry(inputEntry, externalMapperTableEntry);
dataMapTableEntries.add(inputEntry);
columns.add(column);
}
if (externalMapperTable != null) {
joinType = mapperManager.getCurrentLanguage().getJoin(externalMapperTable.getJoinType());
if (joinType == null) {
joinType = mapperManager.getCurrentLanguage().getAvailableJoins()[0];
}
alias = externalMapperTable.getAlias();
tableName = externalMapperTable.getTableName() != null ? externalMapperTable.getTableName() : connection.getName();
}
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class LinkManager method unregisterLevelForRemovedLink.
/**
* DOC amaumont Comment method "unregisterLevelForRemovedLink".
*
* @param link
* @param sourceGraphicalLinks
*/
protected void unregisterLevelForRemovedLink(IMapperLink link, Set<IMapperLink> sourceGraphicalLinks) {
ITableEntry targetEntry = link.getPointLinkDescriptor2().getTableEntry();
boolean hasSameZone = link.getPointLinkDescriptor1().getTableEntry().getClass() == targetEntry.getClass();
if (hasSameZone) {
boolean isInput = targetEntry instanceof InputColumnTableEntry;
boolean isOutput = targetEntry instanceof OutputColumnTableEntry;
List<List<IMapperLink>> leveledLinks = null;
if (isInput) {
leveledLinks = getInputLinksForLevels();
}
if (isOutput) {
leveledLinks = getOutputLinksForLevels();
}
boolean breakAll = false;
int lstSize = leveledLinks.size();
for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
List<IMapperLink> linksFromLevelsList = leveledLinks.get(indexOfLeveledLink);
if (linksFromLevelsList != null && linksFromLevelsList.size() > 0) {
int lstSizeInternal = linksFromLevelsList.size();
for (int i = 0; i < lstSizeInternal; i++) {
IMapperLink currentLink = linksFromLevelsList.get(i);
if (currentLink == link) {
linksFromLevelsList.remove(i);
if (linksFromLevelsList.size() == 0) {
leveledLinks.set(indexOfLeveledLink, null);
}
breakAll = true;
break;
}
}
// for (int i = 0; i < lstSizeInternal; i++) {
if (breakAll) {
break;
}
}
}
// for (int indexOfLeveledLink = 0; indexOfLeveledLink < lstSize; indexOfLeveledLink++) {
}
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class ProblemsManager method checkProblemsForTableEntry.
public void checkProblemsForTableEntry(ITableEntry tableEntry, boolean forceRefreshData) {
// if (forceRefreshData) {
// mapperManager.getComponent().refreshMapperConnectorData();
// checkProblems();
// }
List<Problem> problems = new ArrayList<Problem>(0);
String expression = tableEntry.getExpression();
if (tableEntry instanceof InputColumnTableEntry) {
InputColumnTableEntry inputEntry = (InputColumnTableEntry) tableEntry;
IDbOperatorManager operatorsManager = mapperManager.getCurrentLanguage().getOperatorsManager();
IDbOperator dbOperator = operatorsManager.getOperatorFromValue(inputEntry.getOperator());
boolean operatorIsSet = dbOperator != null;
boolean expressionIsSet = expression != null && expression.trim().length() > 0;
Problem problem = null;
String errorMessage = null;
String key = null;
if (!operatorIsSet && expressionIsSet) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.operatorNotSet", new Object[] { inputEntry.getName() });
key = KEY_OPERATOR_EMPTY;
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(key);
problems.add(problem);
}
if (operatorIsSet && !expressionIsSet && !dbOperator.isMonoOperand()) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.inputExpressionEmpty", new Object[] { inputEntry.getParentName(), inputEntry.getName() });
key = KEY_INPUT_EXPRESSION_EMPTY;
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(key);
problems.add(problem);
}
Problem warningProblem = null;
if (inputEntry.isUnmatchingEntry()) {
InputTable inputTable = (InputTable) inputEntry.getParent();
String message = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.entryDoesntMatch", new Object[] { inputEntry.getParentName(), inputEntry.getName(), inputTable.getTableName() });
warningProblem = new Problem(null, message, ProblemStatus.WARNING);
warningProblem.setKey(KEY_NO_MATCHING);
problems.add(warningProblem);
}
} else if (tableEntry instanceof OutputColumnTableEntry) {
String errorMessage = null;
Problem problem = null;
if (expression == null || EMPTY_STRING.equals(expression.trim())) {
errorMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"ProblemsManager.outputExpressionEmpty", new Object[] { tableEntry.getParentName(), tableEntry.getName() });
}
if (errorMessage != null) {
problem = new Problem(null, errorMessage, ProblemStatus.ERROR);
problem.setKey(KEY_OUTPUT_EXPRESSION_EMPTY);
problems.add(problem);
}
}
tableEntry.setProblems(problems.size() > 0 ? problems : null);
}
use of org.talend.designer.dbmap.model.tableentry.InputColumnTableEntry in project tdi-studio-se by Talend.
the class UIManager method parseExpression.
/**
*
*
* @param expression
* @param currentModifiedITableEntry
* @param linkMustHaveSelectedState
* @param checkInputKeyAutomatically TODO
* @param inputExpressionAppliedOrCanceled TODO
* @param newSelectedDataMapTableView
* @return true if a link has been added or removed, false else
*/
public ParseExpressionResult parseExpression(String expression, ITableEntry currentModifiedITableEntry, boolean linkMustHaveSelectedState, boolean checkInputKeyAutomatically, boolean inputExpressionAppliedOrCanceled) {
DataMapTableView dataMapTableView = mapperManager.retrieveDataMapTableView(currentModifiedITableEntry);
boolean linkHasBeenAdded = false;
boolean linkHasBeenRemoved = false;
DataMapExpressionParser dataMapExpressionParser = new DataMapExpressionParser(mapperManager.getCurrentLanguage());
TableEntryLocation[] tableEntriesLocationsSources = dataMapExpressionParser.parseTableEntryLocations(expression);
Set<TableEntryLocation> alreadyProcessed = new HashSet<TableEntryLocation>();
Set<ITableEntry> sourcesForTarget = mapperManager.getSourcesForTarget(currentModifiedITableEntry);
Set<ITableEntry> sourcesForTargetToDelete = new HashSet<ITableEntry>(sourcesForTarget);
boolean isInputEntry = currentModifiedITableEntry instanceof InputColumnTableEntry;
for (TableEntryLocation tableEntriesLocationsSource : tableEntriesLocationsSources) {
TableEntryLocation location = tableEntriesLocationsSource;
if (!alreadyProcessed.contains(location) && checkSourceLocationIsValid(location, currentModifiedITableEntry)) {
ITableEntry sourceTableEntry = mapperManager.retrieveTableEntry(location);
sourcesForTargetToDelete.remove(sourceTableEntry);
if (sourceTableEntry != null && !sourcesForTarget.contains(sourceTableEntry)) {
DataMapTableView sourceDataMapTableView = mapperManager.retrieveDataMapTableView(sourceTableEntry);
IMapperLink link = new Link(new PointLinkDescriptor(sourceTableEntry, sourceDataMapTableView.getZone()), new PointLinkDescriptor(currentModifiedITableEntry, dataMapTableView.getZone()), mapperManager);
link.setState(linkMustHaveSelectedState ? LinkState.SELECTED : LinkState.UNSELECTED);
mapperManager.addLink(link);
linkHasBeenAdded = true;
}
alreadyProcessed.add(location);
}
}
Set<IMapperLink> targets = mapperManager.getGraphicalLinksFromTarget(currentModifiedITableEntry);
Set<IMapperLink> linksFromTarget = new HashSet<IMapperLink>(targets);
for (IMapperLink link : linksFromTarget) {
if (sourcesForTargetToDelete.contains(link.getPointLinkDescriptor1().getTableEntry())) {
mapperManager.removeLink(link, link.getPointLinkDescriptor2().getTableEntry());
linkHasBeenRemoved = true;
}
}
mapperManager.orderLinks();
return new ParseExpressionResult(linkHasBeenAdded, linkHasBeenRemoved);
}
Aggregations