use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.
the class MapperManager method removeSelectedOutput.
public void removeSelectedOutput() {
DataMapTableView currentSelectedDataMapTableView = uiManager.getCurrentSelectedOutputTableView();
String append = "";
OutputTable outputTable = ((OutputTable) currentSelectedDataMapTableView.getDataMapTable());
List<DataMapTableView> relatedOutputsTableView = null;
if (outputTable.getIsJoinTableOf() == null) {
relatedOutputsTableView = uiManager.getRelatedOutputsTableView(currentSelectedDataMapTableView);
if (relatedOutputsTableView != null && !relatedOutputsTableView.isEmpty()) {
append = " and it's join table ";
for (DataMapTableView tableView : relatedOutputsTableView) {
IDataMapTable retrieveAbstractDataMapTable = this.retrieveAbstractDataMapTable(tableView);
if (retrieveAbstractDataMapTable != null) {
append = append + "'" + retrieveAbstractDataMapTable.getName() + " ' ,";
}
}
append = append.substring(0, append.length() - 1);
}
}
if (currentSelectedDataMapTableView != null) {
String tableName = currentSelectedDataMapTableView.getDataMapTable().getName();
if (MessageDialog.openConfirm(currentSelectedDataMapTableView.getShell(), //$NON-NLS-1$
Messages.getString("MapperManager.removeOutputTableTitle"), Messages.getString("MapperManager.removeOutputTableTitleMessage") + tableName + " '" + append + "?")) {
//$NON-NLS-1$ //$NON-NLS-2$
IProcess process = getAbstractMapComponent().getProcess();
uiManager.removeOutputTableView(currentSelectedDataMapTableView);
// remove join table
if (outputTable.getIsJoinTableOf() == null && relatedOutputsTableView != null) {
for (DataMapTableView view : relatedOutputsTableView) {
uiManager.removeOutputTableView(view);
process.removeUniqueConnectionName(view.getDataMapTable().getName());
}
}
uiManager.updateToolbarButtonsStates(Zone.OUTPUTS);
process.removeUniqueConnectionName(currentSelectedDataMapTableView.getDataMapTable().getName());
}
}
}
use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.
the class MapperManager method addOutput.
/**
* DOC amaumont Comment method "addOutput".
*/
public void addOutput() {
String joinTableName = null;
OutputTable abstractDataMapTable = null;
String name = uiManager.openNewOutputCreationDialog();
if (name == null) {
return;
}
String[] split = name.split(uiManager.NAME_SEPARATOR);
String tableName = split[0];
boolean isCreatingJoinTable = split.length == 2;
if (isCreatingJoinTable) {
joinTableName = split[1];
}
IProcess process = getAbstractMapComponent().getProcess();
OutputTable orignalOutputTable = null;
if (isCreatingJoinTable) {
orignalOutputTable = getOutputTableByName(tableName);
if (orignalOutputTable != null) {
IMetadataTable metadataTable = orignalOutputTable.getMetadataTable();
if (metadataTable != null) {
process.addUniqueConnectionName(joinTableName);
abstractDataMapTable = new OutputTable(this, metadataTable, joinTableName);
abstractDataMapTable.setIsJoinTableOf(tableName);
}
}
} else {
process.addUniqueConnectionName(tableName);
IMetadataTable metadataTable = getNewMetadataTable();
metadataTable.setTableName(tableName);
abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
}
if (abstractDataMapTable == null) {
return;
}
abstractDataMapTable.initFromExternalData(null);
List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
int sizeOutputsView = outputsTablesView.size();
Control lastChild = null;
if (sizeOutputsView - 1 >= 0) {
lastChild = outputsTablesView.get(sizeOutputsView - 1);
}
TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
DataMapTableView dataMapTableView = uiManager.createNewOutputTableView(lastChild, abstractDataMapTable, tablesZoneViewOutputs);
tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
tablesZoneViewOutputs.layout();
uiManager.moveOutputScrollBarZoneToMax();
uiManager.refreshBackground(true, false);
tablesZoneViewOutputs.layout();
uiManager.selectDataMapTableView(dataMapTableView, true, false);
}
use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.
the class MapperMain method getMetadataListOut.
/**
* DOC amaumont Comment method "getMetadataListOut".
*
* @return
*/
public List<IMetadataTable> getMetadataListOut() {
List<OutputTable> tables = mapperManager.getOutputTables();
List<IMetadataTable> metadataTables = new ArrayList<IMetadataTable>(tables.size());
for (OutputTable table : tables) {
if (table.getIsJoinTableOf() == null) {
metadataTables.add(table.getMetadataTable());
}
}
return metadataTables;
}
use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkDropIsValid.
/**
* DOC amaumont Comment method "checkDropHasValidTarget".
*/
private boolean checkDropIsValid() {
isInputToInput = false;
mapOneToOneAuthorized = true;
if (targetIsExpressionFilterText() || (targetTableIsFiltersTable() || targetTableIsGlobalMapTable() || draggedData.getTransferableEntryList().size() <= 1)) {
mapOneToOneAuthorized = false;
}
if (invalidKeyPressed) {
return false;
}
/*
* INPUT => INPUT
*/
if (zoneSource == Zone.INPUTS && zoneTarget == Zone.INPUTS) {
isInputToInput = true;
mapOneToOneAuthorized = false;
List<InputTable> inputTables = mapperManager.getInputTables();
int indexTableSource = inputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTableTarget = inputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (currentTableTarget != null) {
if (indexTableSource >= indexTableTarget) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
return true;
}
} else if (currentStyledTextTarget != null) {
if (indexTableSource > indexTableTarget) {
/*
* INPUT => INPUT && index of table source > index of table target
*/
return false;
} else {
return true;
}
} else {
//$NON-NLS-1$
throw new IllegalStateException(Messages.getString("DropContextAnalyzer.notFound"));
}
}
/*
* OUTPUT => OUTPUT
*/
if (zoneSource == Zone.OUTPUTS && zoneTarget == Zone.OUTPUTS) {
isOutputToOutput = true;
mapOneToOneAuthorized = true;
List<OutputTable> outputTables = mapperManager.getOutputTables();
int indexSourceOutputTable = outputTables.indexOf(dataMapTableViewSource.getDataMapTable());
int indexTargetOutputTable = outputTables.indexOf(dataMapTableViewTarget.getDataMapTable());
if (indexSourceOutputTable == indexTargetOutputTable) {
/*
* INPUT => INPUT && index of table source >= index of table target
*/
return false;
} else {
// OUTPUT => OUTPUT
return checkZoonTarget();
}
}
if (currentTableTarget != null) {
TableItem tableItemTarget = getTableItemFromPosition(new Point(event.x, event.y));
if (zoneSource == Zone.VARS && zoneTarget == Zone.VARS && tableItemTarget != null) {
if (tableItemSource == tableItemTarget || !dropVarsEntryIsValid(tableItemTarget)) {
/*
* VAR => VAR && (item source == item target || item target is invalid)
*/
return false;
}
}
}
if (zoneSource == Zone.VARS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.INPUTS || zoneSource == Zone.OUTPUTS && zoneTarget == Zone.VARS) {
/*
* VAR => INPUT OUTPUT => OUTPUT OUTPUT => INPUT OUTPUT => VAR
*/
return false;
}
return checkZoonTarget();
}
use of org.talend.designer.mapper.model.table.OutputTable in project tdi-studio-se by Talend.
the class DropContextAnalyzer method checkZoonTarget.
private boolean checkZoonTarget() {
IDataMapTable dataMapTable = dataMapTableViewTarget.getDataMapTable();
if (zoneTarget == Zone.OUTPUTS) {
OutputTable outputTable = (OutputTable) dataMapTable;
if (outputTable.isErrorRejectTable()) {
if (currentTableTarget != null && event != null) {
if (event.item instanceof TableItem) {
Object data = event.item.getData();
if (data instanceof OutputColumnTableEntry) {
String label = ((OutputColumnTableEntry) data).getName();
if (mapperManager.ERROR_REJECT_MESSAGE.equals(label) || mapperManager.ERROR_REJECT_STACK_TRACE.equals(label)) {
return false;
}
}
}
}
}
boolean useRepositoryMeta = (outputTable.isRepository()) || (outputTable.getId() != null && !"".equals(outputTable.getId()));
// for join table if main table use repository metadata
if (!useRepositoryMeta && outputTable.getIsJoinTableOf() != null && !"".equals(outputTable.getIsJoinTableOf())) {
OutputTable mainTable = mapperManager.getOutputTableByName(outputTable.getIsJoinTableOf());
if (mainTable != null) {
useRepositoryMeta = mainTable.getId() != null && !"".equals(mainTable.getId());
}
}
if (useRepositoryMeta && currentStyledTextTarget != null) {
return true;
}
if (useRepositoryMeta && isCursorOverHeader || useRepositoryMeta && !isCursorOverExpressionCell) {
return false;
}
}
return true;
}
Aggregations