Search in sources :

Example 6 with OutputTable

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());
        }
    }
}
Also used : IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 7 with OutputTable

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);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Control(org.eclipse.swt.widgets.Control) DataMapTableView(org.talend.designer.mapper.ui.visualmap.table.DataMapTableView) TablesZoneView(org.talend.designer.mapper.ui.visualmap.zone.scrollable.TablesZoneView) IProcess(org.talend.core.model.process.IProcess) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 8 with OutputTable

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;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ArrayList(java.util.ArrayList) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 9 with OutputTable

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();
}
Also used : InputTable(org.talend.designer.mapper.model.table.InputTable) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 10 with OutputTable

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;
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) IDataMapTable(org.talend.designer.abstractmap.model.table.IDataMapTable) OutputColumnTableEntry(org.talend.designer.mapper.model.tableentry.OutputColumnTableEntry) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Aggregations

OutputTable (org.talend.designer.mapper.model.table.OutputTable)30 IDataMapTable (org.talend.designer.abstractmap.model.table.IDataMapTable)11 DataMapTableView (org.talend.designer.mapper.ui.visualmap.table.DataMapTableView)10 AbstractInOutTable (org.talend.designer.mapper.model.table.AbstractInOutTable)8 IColumnEntry (org.talend.designer.abstractmap.model.tableentry.IColumnEntry)6 ArrayList (java.util.ArrayList)5 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)5 IProcess (org.talend.core.model.process.IProcess)5 InputTable (org.talend.designer.mapper.model.table.InputTable)5 FilterTableEntry (org.talend.designer.mapper.model.tableentry.FilterTableEntry)5 OutputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.OutputDataMapTableView)5 Point (org.eclipse.swt.graphics.Point)4 TableItem (org.eclipse.swt.widgets.TableItem)4 ExternalMapperTable (org.talend.designer.mapper.external.data.ExternalMapperTable)4 GlobalMapEntry (org.talend.designer.mapper.model.tableentry.GlobalMapEntry)4 InputDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.InputDataMapTableView)4 VarsDataMapTableView (org.talend.designer.mapper.ui.visualmap.table.VarsDataMapTableView)4 HashMap (java.util.HashMap)3 TableViewer (org.eclipse.jface.viewers.TableViewer)3 GridData (org.eclipse.swt.layout.GridData)3