use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class MapperUI method createInputZoneWithTables.
private void createInputZoneWithTables(MapperModel mapperModel, UIManager uiManager, final Display display) {
inputsZone = new InputsZone(datasFlowViewSashForm, SWT.NONE, mapperManager);
inputsZone.createHeaderZoneComponents();
sc1 = new ScrolledComposite(inputsZone, getBorder() | SWT.H_SCROLL | SWT.V_SCROLL);
// this.dropTargetOperationListener.addControl(sc1);
GridData sc1GridData = new GridData(GridData.FILL_BOTH);
sc1.setLayoutData(sc1GridData);
sc1.setBackgroundMode(SWT.INHERIT_DEFAULT);
sc1.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
// System.out.println("sc1 controlMoved");
}
public void controlResized(ControlEvent e) {
// System.out.println("sc1 controlResized");
onSashResized(display);
}
});
inputTablesZoneView = new InputTablesZoneView(sc1, getBorder(), mapperManager);
// this.dropTargetOperationListener.addControl(inputTablesZoneView);
inputTablesZoneView.setBackgroundMode(SWT.INHERIT_DEFAULT);
sc1.setExpandHorizontal(true);
sc1.setContent(inputTablesZoneView);
sc1MSListener = new MouseScrolledListener(mapperManager.getUiManager(), sc1);
inputTablesZoneView.initInsertionIndicator();
Control previousControl = null;
List<InputTable> tables = mapperModel.getInputDataMapTables();
Boolean minimizeStateOfTables = getMinimizedButtonState(tables);
if (minimizeStateOfTables != null) {
inputsZone.getToolbar().setMinimizeButtonState(minimizeStateOfTables.booleanValue());
}
for (InputTable inputTable : tables) {
InputDataMapTableView dataMapTableView = uiManager.createNewInputTableView(previousControl, inputTable, inputTablesZoneView);
if (previousControl == null) {
uiManager.updateDropDownJoinTypeForInputs();
}
previousControl = dataMapTableView;
}
inputTablesZoneView.setSize(inputTablesZoneView.computeSize(SWT.DEFAULT, SWT.DEFAULT));
}
use of org.talend.designer.dbmap.model.table.InputTable 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.table.InputTable in project tdi-studio-se by Talend.
the class TableEntriesManager method remove.
public void remove(ITableEntry dataMapTableEntry, boolean removingPhysicalInputTable) {
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);
InputTable inputTable = isPhysicalTable(dataMapTable);
if (inputTable != null && !removingPhysicalInputTable) {
removeMetadataColumnFromDbTable(inputTable.getTableName(), dataMapTableEntry.getName());
}
} else if (dataMapTableEntry instanceof FilterTableEntry) {
if (dataMapTable instanceof OutputTable) {
if (FilterTableEntry.WHERE_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
((OutputTable) dataMapTable).removeWhereFilterEntry((FilterTableEntry) dataMapTableEntry);
} else if (FilterTableEntry.OTHER_FILTER.equals(((FilterTableEntry) dataMapTableEntry).getFilterKind())) {
((OutputTable) dataMapTable).removeOtherFilterEntry((FilterTableEntry) dataMapTableEntry);
}
}
} else {
String exceptionMessage = //$NON-NLS-1$
Messages.getString(//$NON-NLS-1$
"TableEntriesManager.exceptionMessage.typeIsNotValid", dataMapTableEntry.getClass().toString());
throw new IllegalArgumentException(exceptionMessage);
}
}
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class UIManager method processColumnNameChanged.
/**
* DOC amaumont Comment method "processNewProcessColumnName".
*
* @param previousColumnName TODO
* @param dataMapTableView
* @param renamingDependentEntries TODO
* @param text
* @param entry
*/
public void processColumnNameChanged(final String previousColumnName, final String newColumnName, final DataMapTableView dataMapTableView, final ITableEntry currentModifiedITableEntry, boolean renamingDependentEntries) {
mapperManager.changeColumnName(currentModifiedITableEntry, previousColumnName, newColumnName);
Collection<DataMapTableView> tableViews = mapperManager.getTablesView();
boolean atLeastOneLinkHasBeenRemoved = false;
for (DataMapTableView view : tableViews) {
IDataMapTable dataMapTable = view.getDataMapTable();
List<IColumnEntry> metadataTableEntries = dataMapTable.getColumnEntries();
for (IColumnEntry entry : metadataTableEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
if (dataMapTable instanceof OutputTable) {
List<FilterTableEntry> constraintWhereEntries = ((OutputTable) dataMapTable).getWhereFilterEntries();
for (FilterTableEntry entry : constraintWhereEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
List<FilterTableEntry> constraintOtherEntries = ((OutputTable) dataMapTable).getOtherFilterEntries();
for (FilterTableEntry entry : constraintOtherEntries) {
if (parseExpression(entry.getExpression(), entry, true, true, false).isAtLeastOneLinkRemoved()) {
atLeastOneLinkHasBeenRemoved = true;
}
}
}
}
mapperManager.getUiManager().refreshBackground(false, false);
dataMapTableView.getTableViewerCreatorForColumns().getTableViewer().refresh(currentModifiedITableEntry);
TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), previousColumnName);
TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry.getParentName(), newColumnName);
mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
refreshSqlExpression();
if (!renamingDependentEntries) {
AbstractInOutTable currentTable = (AbstractInOutTable) currentModifiedITableEntry.getParent();
if (currentTable instanceof InputTable) {
InputTable currentInputTable = (InputTable) currentTable;
String physicalTableName = currentInputTable.getTableName();
String alias = currentInputTable.getAlias();
InputTable physicalInputTable = null;
List<InputTable> inputTables = mapperManager.getInputTables();
if (alias != null) {
for (InputTable table : inputTables) {
if (table.equals(physicalTableName)) {
physicalInputTable = table;
}
}
} else {
physicalInputTable = currentInputTable;
}
if (physicalInputTable == null) {
List<IOConnection> incomingConnections = mapperManager.getComponent().getMapperMain().getIoInputConnections();
IOConnection connectionFound = null;
for (IOConnection connection : incomingConnections) {
if (connection.getName().equals(physicalTableName)) {
connectionFound = connection;
}
}
IMetadataColumn metadataColumn = connectionFound.getTable().getColumn(previousColumnName);
if (metadataColumn != null) {
metadataColumn.setLabel(newColumnName);
}
}
for (InputTable table : inputTables) {
if ((// Physical table parent
alias != null && table.getAlias() == null && table.getName().equals(physicalTableName) || // Alias table
alias == null && table.getAlias() != null && table.getTableName().equals(physicalTableName))) {
TableEntryLocation location = new TableEntryLocation(table.getName(), previousColumnName);
DataMapTableView aliasTableView = mapperManager.retrieveDataMapTableView(location);
ITableEntry aliasTableEntry = mapperManager.retrieveTableEntry(location);
if (aliasTableEntry != null) {
processColumnNameChanged(previousColumnName, newColumnName, aliasTableView, aliasTableEntry, true);
}
}
}
}
}
// if (atLeastOneLinkHasBeenRemoved) {
// new AsynchronousThreading(20, false, dataMapTableView.getDisplay(), new Runnable() {
//
// public void run() {
// TableViewerCreator tableViewerCreatorForColumns = dataMapTableView
// .getTableViewerCreatorForColumns();
// boolean propagate = MessageDialog.openQuestion(tableViewerCreatorForColumns.getTable().getShell(),
// Messages.getString("UIManager.propagateTitle"), //$NON-NLS-1$
// Messages.getString("UIManager.propagateMessage")); //$NON-NLS-1$
// if (propagate) {
// TableEntryLocation previousLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), previousColumnName);
// TableEntryLocation newLocation = new TableEntryLocation(currentModifiedITableEntry
// .getParentName(), newColumnName);
// mapperManager.replacePreviousLocationInAllExpressions(previousLocation, newLocation);
// refreshSqlExpression();
// }
// }
// }).start();
// }
}
use of org.talend.designer.dbmap.model.table.InputTable in project tdi-studio-se by Talend.
the class TableManager method getVisibleTables.
/**
* DOC amaumont Comment method "getVisibleTables".
*/
public String[] getVisibleTables() {
List<InputTable> inputTables = getInputTables();
ArrayList<String> names = new ArrayList<String>();
for (InputTable table : inputTables) {
names.add(table.getName());
}
return names.toArray(new String[0]);
}
Aggregations