Search in sources :

Example 51 with IProcess

use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.

the class MapperManager method addRejectOutput.

public void addRejectOutput() {
    String baseName = ERROR_REJECT;
    IProcess process = getAbstractMapComponent().getProcess();
    String tableName = baseName;
    if (!process.checkValidConnectionName(baseName) && process instanceof IProcess2) {
        final String uniqueName = ((IProcess2) process).generateUniqueConnectionName("row", baseName);
        tableName = uniqueName;
        ((IProcess2) process).addUniqueConnectionName(uniqueName);
    } else if (process instanceof IProcess2) {
        tableName = baseName;
        ((IProcess2) process).addUniqueConnectionName(baseName);
    }
    IMetadataTable metadataTable = getNewMetadataTable();
    metadataTable.setTableName(tableName);
    MetadataColumn errorMessageCol = new MetadataColumn();
    errorMessageCol.setLabel(ERROR_REJECT_MESSAGE);
    errorMessageCol.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorMessageCol.setNullable(true);
    errorMessageCol.setOriginalDbColumnName(ERROR_REJECT_MESSAGE);
    errorMessageCol.setReadOnly(true);
    errorMessageCol.setCustom(true);
    errorMessageCol.setCustomId(0);
    metadataTable.getListColumns().add(errorMessageCol);
    MetadataColumn errorStackTrace = new MetadataColumn();
    errorStackTrace.setLabel(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setTalendType(DesignerPlugin.getDefault().getPreferenceStore().getString(MetadataTypeLengthConstants.FIELD_DEFAULT_TYPE));
    errorStackTrace.setNullable(true);
    errorStackTrace.setOriginalDbColumnName(ERROR_REJECT_STACK_TRACE);
    errorStackTrace.setReadOnly(true);
    errorStackTrace.setCustom(true);
    errorStackTrace.setCustomId(1);
    metadataTable.getListColumns().add(errorStackTrace);
    OutputTable abstractDataMapTable = new OutputTable(this, metadataTable, tableName);
    abstractDataMapTable.setErrorRejectTable(true);
    abstractDataMapTable.initFromExternalData(null);
    TablesZoneView tablesZoneViewOutputs = uiManager.getTablesZoneViewOutputs();
    DataMapTableView rejectDataMapTableView = uiManager.createNewOutputTableView(null, abstractDataMapTable, tablesZoneViewOutputs);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    List<DataMapTableView> outputsTablesView = uiManager.getOutputsTablesView();
    int sizeList = outputsTablesView.size();
    for (int i = 0; i < sizeList; i++) {
        if (i + 1 < sizeList) {
            FormData formData = (FormData) outputsTablesView.get(i + 1).getLayoutData();
            formData.top = new FormAttachment(outputsTablesView.get(i));
        }
    }
    CustomTableManager.addCustomManagementToTable(uiManager.getOutputMetaEditorView(), true);
    tablesZoneViewOutputs.setSize(tablesZoneViewOutputs.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    tablesZoneViewOutputs.layout();
    uiManager.moveOutputScrollBarZoneToMax();
    uiManager.refreshBackground(true, false);
    uiManager.selectDataMapTableView(rejectDataMapTableView, true, false);
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) FormData(org.eclipse.swt.layout.FormData) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) MetadataColumn(org.talend.core.model.metadata.MetadataColumn) IProcess2(org.talend.core.model.process.IProcess2) 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) FormAttachment(org.eclipse.swt.layout.FormAttachment) OutputTable(org.talend.designer.mapper.model.table.OutputTable)

Example 52 with IProcess

use of org.talend.core.model.process.IProcess 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 53 with IProcess

use of org.talend.core.model.process.IProcess 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 54 with IProcess

use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.

the class JobErrorsChecker method checkExportErrors.

public static boolean checkExportErrors(IStructuredSelection selection, boolean isJob) {
    if (!selection.isEmpty()) {
        final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
        Set<String> jobIds = new HashSet<String>();
        List<RepositoryNode> nodes = selection.toList();
        if (nodes.size() > 1) {
            // in case it's a multiple export, only check the status of the latest job to export
            for (RepositoryNode node : nodes) {
                Item item = node.getObject().getProperty().getItem();
                try {
                    IFile sourceFile = synchronizer.getFile(item);
                    if (sourceFile == null) {
                        return false;
                    }
                    // check the item has compile error when export job
                    boolean ret = false;
                    String message = null;
                    IMarker[] markers = sourceFile.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_ONE);
                    for (IMarker marker : markers) {
                        Integer lineNr = (Integer) marker.getAttribute(IMarker.LINE_NUMBER);
                        message = (String) marker.getAttribute(IMarker.MESSAGE);
                        Integer severity = (Integer) marker.getAttribute(IMarker.SEVERITY);
                        Integer start = (Integer) marker.getAttribute(IMarker.CHAR_START);
                        Integer end = (Integer) marker.getAttribute(IMarker.CHAR_END);
                        if (lineNr != null && message != null && severity != null && start != null && end != null) {
                            switch(severity) {
                                case IMarker.SEVERITY_ERROR:
                                    ret = true;
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                    if (ret) {
                        if (isJob) {
                            throw new ProcessorException(//$NON-NLS-1$
                            Messages.getString("JobErrorsChecker_compile_errors") + '\n' + Messages.getString("JobErrorsChecker_compile_error_content", //$NON-NLS-1$
                            item.getProperty().getLabel()) + '\n' + message);
                        } else {
                            throw new ProcessorException(//$NON-NLS-1$
                            Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + Messages.getString("CamelJobErrorsChecker_compile_error_content", //$NON-NLS-1$
                            item.getProperty().getLabel()) + '\n' + message);
                        }
                    }
                    jobIds.add(item.getProperty().getId());
                    Problems.addRoutineFile(sourceFile, ProblemType.JOB, item.getProperty().getLabel(), item.getProperty().getVersion(), true);
                } catch (Exception e) {
                    MessageBoxExceptionHandler.process(e);
                    return true;
                }
            }
        } else {
            // if single export (normal case), check compilation status from latest generation.
            try {
                checkLastGenerationHasCompilationError(true);
            } catch (Exception e) {
                if (CommonsPlugin.isHeadless()) {
                    CommonExceptionHandler.process(e);
                    // trace in command status.
                    throw new RuntimeException(e);
                }
                MessageBoxExceptionHandler.process(e);
                return true;
            }
        }
        for (RepositoryNode node : nodes) {
            Item item = node.getObject().getProperty().getItem();
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            IProcess process = service.getProcessFromItem(item);
            if (process instanceof IProcess2) {
                ((IProcess2) process).checkProcess();
            }
        }
        Problems.refreshProblemTreeView();
        List<Problem> errors = Problems.getProblemList().getProblemsBySeverity(ProblemStatus.ERROR);
        ErrorDetailTreeBuilder builder = new ErrorDetailTreeBuilder();
        List<JobErrorEntry> input = builder.createTreeInput(errors, jobIds);
        try {
            if (input.size() > 0) {
                String label = input.get(0).getLabel();
                if (isJob) {
                    throw new ProcessorException(//$NON-NLS-1$
                    Messages.getString("JobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
                    Messages.getString("JobErrorsChecker_compile_error_content", label));
                } else {
                    throw new ProcessorException(//$NON-NLS-1$
                    Messages.getString("CamelJobErrorsChecker_compile_errors") + '\n' + //$NON-NLS-1$
                    Messages.getString("CamelJobErrorsChecker_compile_error_content", label));
                }
            }
        } catch (Exception e) {
            MessageBoxExceptionHandler.process(e);
            return true;
        }
    }
    return false;
}
Also used : ITalendSynchronizer(org.talend.designer.codegen.ITalendSynchronizer) IFile(org.eclipse.core.resources.IFile) RepositoryNode(org.talend.repository.model.RepositoryNode) CoreException(org.eclipse.core.runtime.CoreException) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) Item(org.talend.core.model.properties.Item) IProcess2(org.talend.core.model.process.IProcess2) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) IMarker(org.eclipse.core.resources.IMarker) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) JobErrorEntry(org.talend.designer.runprocess.ErrorDetailTreeBuilder.JobErrorEntry) HashSet(java.util.HashSet)

Example 55 with IProcess

use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.

the class MetadataToolbarEditorViewExt method createNumberRows.

private void createNumberRows() {
    numRowComposite = new Composite(toolbar, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.horizontalSpacing = 4;
    layout.marginBottom = 0;
    layout.marginHeight = 0;
    layout.marginLeft = 0;
    layout.marginRight = 0;
    layout.marginTop = 0;
    layout.marginWidth = 0;
    GridData gridData = new GridData();
    gridData.verticalAlignment = GridData.CENTER;
    numRowComposite.setLayout(layout);
    final Label numRowLabel = new Label(numRowComposite, SWT.NONE);
    //$NON-NLS-1$
    numRowLabel.setText(Messages.getString("MetadataToolbarEditorViewExt.RowNum.LabelText"));
    numRowText = new Text(numRowComposite, SWT.BORDER);
    GridDataFactory.swtDefaults().hint(rowNumberWidth(), SWT.DEFAULT).applyTo(numRowText);
    numRowText.setBackground(ColorConstants.white);
    IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    IProcess process = ((AbstractMultiPageTalendEditor) editor).getTalendEditor().getProcess();
    TalendProposalUtils.installOn(numRowText, process);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) IEditorPart(org.eclipse.ui.IEditorPart) IProcess(org.talend.core.model.process.IProcess)

Aggregations

IProcess (org.talend.core.model.process.IProcess)102 INode (org.talend.core.model.process.INode)33 ArrayList (java.util.ArrayList)28 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)24 IProcess2 (org.talend.core.model.process.IProcess2)22 ProcessItem (org.talend.core.model.properties.ProcessItem)21 Node (org.talend.designer.core.ui.editor.nodes.Node)20 List (java.util.List)17 Item (org.talend.core.model.properties.Item)16 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)16 IOException (java.io.IOException)15 PersistenceException (org.talend.commons.exception.PersistenceException)14 IElementParameter (org.talend.core.model.process.IElementParameter)14 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)13 IEditorPart (org.eclipse.ui.IEditorPart)11 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 File (java.io.File)9 Element (org.talend.core.model.process.Element)9 IConnection (org.talend.core.model.process.IConnection)9 IContext (org.talend.core.model.process.IContext)9