Search in sources :

Example 76 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class RepositoryHelper method createTalendItem.

public TalendItem createTalendItem(Repository repository, Object object) {
    TalendItem result = null;
    if (object instanceof RepositoryNode) {
        RepositoryNode repositoryNode = (RepositoryNode) object;
        if (repositoryNode.getType() == RepositoryNode.ENodeType.REPOSITORY_ELEMENT) {
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
            EClass class1 = getEClass(nodeType);
            if (class1 != null) {
                result = (TalendItem) BusinessFactory.eINSTANCE.create(class1);
                result.setRepository(repository);
                if (ERepositoryObjectType.METADATA_CON_TABLE.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((MetadataTableRepositoryObject) repositoryObject).getProperty();
                    Item item = property.getItem();
                    if (item instanceof SAPConnectionItem) {
                        if (repositoryNode.getParent() != null) {
                            result.setId(property.getId() + " - " + repositoryNode.getParent().getProperties(EProperties.LABEL) + " - " + repositoryObject.getLabel());
                        }
                    } else {
                        //$NON-NLS-1$
                        result.setId(property.getId() + " - " + repositoryObject.getLabel());
                    }
                } else if (ERepositoryObjectType.METADATA_CON_QUERY.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((QueryRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else if (ERepositoryObjectType.METADATA_SAP_FUNCTION.equals(repositoryObject.getRepositoryObjectType())) {
                    Property property = ((SAPFunctionRepositoryObject) repositoryObject).getProperty();
                    //$NON-NLS-1$
                    result.setId(property.getId() + " - " + repositoryObject.getLabel());
                } else {
                    result.setId(repositoryObject.getId());
                }
                result.setLabel(repositoryObject.getLabel());
            }
        }
    }
    return result;
}
Also used : Item(org.talend.core.model.properties.Item) TalendItem(org.talend.designer.business.model.business.TalendItem) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) EClass(org.eclipse.emf.ecore.EClass) SAPFunctionRepositoryObject(org.talend.core.repository.model.repositoryObject.SAPFunctionRepositoryObject) SAPConnectionItem(org.talend.core.model.properties.SAPConnectionItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendItem(org.talend.designer.business.model.business.TalendItem) RepositoryNode(org.talend.repository.model.RepositoryNode) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) Property(org.talend.core.model.properties.Property) MetadataTableRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataTableRepositoryObject)

Example 77 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class PropertyTypeController method createComboCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createComboCommand(org
     * .eclipse.swt.custom.CCombo)
     */
@Override
protected Command createComboCommand(CCombo combo) {
    Connection repositoryConnection = null;
    ConnectionItem repositoryConnectionItem = null;
    // hwang add
    FileItem repositoryFileItem = null;
    String paramName = (String) combo.getData(PARAMETER_NAME);
    IElementParameter param = elem.getElementParameter(paramName);
    String value = combo.getText();
    for (int j = 0; j < param.getListItemsValue().length; j++) {
        if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
            value = (String) param.getListItemsValue()[j];
        }
    }
    if (value.equals(param.getValue())) {
        return null;
    }
    // Map<String, ConnectionItem> repositoryConnectionItemMap = null;
    IElementParameter repositoryParam = null;
    // hywang add for feature 6484
    Map<String, FileItem> repositoryFileItemMap = null;
    if (value.equals(EmfComponent.REPOSITORY)) {
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        if (dynamicProperty instanceof MultipleThreadDynamicComposite) {
            repositoryFileItemMap = ((MultipleThreadDynamicComposite) dynamicProperty).getRepositoryFileItemMap();
        }
        repositoryParam = param.getParentParameter().getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
        String connectionSelected = (String) repositoryParam.getValue();
        // if (repositoryConnectionItemMap.containsKey(connectionSelected)) {
        try {
            Item item = null;
            if (!StringUtils.isEmpty(connectionSelected)) {
                IRepositoryViewObject repobj = factory.getLastVersion(connectionSelected);
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
                if (item != null && item instanceof ConnectionItem) {
                    repositoryConnectionItem = (ConnectionItem) factory.getLastVersion(connectionSelected).getProperty().getItem();
                    repositoryConnection = repositoryConnectionItem.getConnection();
                } else {
                    repositoryConnection = null;
                }
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
        // for ruleItem,hywang add
        if (repositoryFileItemMap.containsKey(connectionSelected)) {
            repositoryFileItem = repositoryFileItemMap.get(connectionSelected);
        } else {
            if (!repositoryFileItemMap.isEmpty()) {
                repositoryFileItem = repositoryFileItemMap.values().iterator().next();
            } else {
                repositoryFileItem = null;
            }
        }
    }
    CompoundCommand cc = new CompoundCommand();
    if (repositoryConnectionItem != null) {
        initCDC(cc, repositoryConnectionItem);
    }
    ChangeValuesFromRepository changeValuesFromRepository1 = new ChangeValuesFromRepository(elem, repositoryConnection, paramName, value);
    cc.add(changeValuesFromRepository1);
    if (repositoryConnection != null) {
        ChangeValuesFromRepository changeValuesFromRepository2 = new ChangeValuesFromRepository(elem, repositoryConnection, repositoryParam.getParentParameter().getName() + ":" + repositoryParam.getName(), //$NON-NLS-1$
        repositoryConnectionItem.getProperty().getId());
        cc.add(changeValuesFromRepository2);
    }
    // hywang add for feature 6484
    if (repositoryFileItem != null) {
        final String id = repositoryFileItem.getProperty().getId();
        cc.add(new Command() {

            @Override
            public void execute() {
                IElementParameter elementParameter = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
                if (elementParameter != null) {
                    elementParameter = elementParameter.getChildParameters().get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                    if (elementParameter != null) {
                        elementParameter.setValue(id);
                    }
                }
            }
        });
    }
    if (value.equals(EmfComponent.REPOSITORY)) {
        updateDBType(cc, repositoryConnection);
    }
    return cc;
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) CDCConnection(org.talend.core.model.metadata.builder.connection.CDCConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) Point(org.eclipse.swt.graphics.Point) MultipleThreadDynamicComposite(org.talend.designer.core.ui.views.properties.MultipleThreadDynamicComposite) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) FileItem(org.talend.core.model.properties.FileItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) LinkRulesItem(org.talend.core.model.properties.LinkRulesItem) FileItem(org.talend.core.model.properties.FileItem) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) Command(org.eclipse.gef.commands.Command) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 78 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class QueryTypeController method getGuessQueryCommand.

/**
     * DOC nrousseau Comment method "getGuessQueryCommand".
     * 
     * @return
     */
private QueryGuessCommand getGuessQueryCommand() {
    // Map<String, IMetadataTable> repositoryTableMap = null;
    IMetadataTable newRepositoryMetadata = null;
    String realTableName = null;
    String realTableId = null;
    String schemaName = "";
    // Only for getting the real table name.
    if (elem.getPropertyValue(EParameterName.SCHEMA_TYPE.getName()).equals(EmfComponent.REPOSITORY)) {
        IElementParameter repositorySchemaTypeParameter = elem.getElementParameter(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        if (repositorySchemaTypeParameter != null) {
            final Object value = repositorySchemaTypeParameter.getValue();
            if (elem instanceof Node) {
                /* value can be devided means the value like "connectionid - label" */
                String[] keySplitValues = value.toString().split(" - ");
                if (keySplitValues.length > 1) {
                    String connectionId = value.toString().split(" - ")[0];
                    String tableLabel = value.toString().split(" - ")[1];
                    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                    Item item = null;
                    try {
                        IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                        if (repobj != null) {
                            Property property = repobj.getProperty();
                            if (property != null) {
                                item = property.getItem();
                            }
                        }
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                    if (item != null && item instanceof ConnectionItem) {
                        Connection connection = ((ConnectionItem) item).getConnection();
                        for (org.talend.core.model.metadata.builder.connection.MetadataTable table : ConnectionHelper.getTables(connection)) {
                            // bug 20365
                            if (table.getLabel().equals(tableLabel)) {
                                IMetadataTable repositoryMetadata = ConvertionHelper.convert(table);
                                realTableName = repositoryMetadata.getTableName();
                                realTableId = repositoryMetadata.getId();
                                // }
                                break;
                            }
                        }
                    }
                }
            // if (repositoryTableMap.containsKey(value)) {
            // IMetadataTable repositoryMetadata = repositoryTableMap.get(value);
            // realTableName = repositoryMetadata.getTableName();
            // realTableId = repositoryMetadata.getId();
            // }
            }
        }
    // }
    // }
    }
    // Ends
    Connection repositoryConnection = null;
    boolean useExisting = false;
    IElementParameter elementParameter = elem.getElementParameter(EParameterName.USE_EXISTING_CONNECTION.name());
    if (elem instanceof Node) {
        IProcess process = ((Node) elem).getProcess();
        if (elementParameter != null && Boolean.valueOf(String.valueOf(elementParameter.getValue()))) {
            String connName = (String) elem.getPropertyValue("CONNECTION");
            for (INode node : process.getGraphicalNodes()) {
                if (node.getElementName().equals(connName)) {
                    useExisting = true;
                    final Object propertyValue = node.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                    if (propertyValue != null) {
                        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                        Item item = null;
                        try {
                            IRepositoryViewObject repobj = factory.getLastVersion(propertyValue.toString());
                            if (repobj != null) {
                                Property property = repobj.getProperty();
                                if (property != null) {
                                    item = property.getItem();
                                }
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                        if (item != null && item instanceof ConnectionItem) {
                            repositoryConnection = ((ConnectionItem) item).getConnection();
                        } else {
                            initConnectionParameters();
                            repositoryConnection = TracesConnectionUtils.createConnection(connParameters);
                        }
                    }
                    break;
                }
            }
        }
    }
    if (!useExisting && elem.getPropertyValue(EParameterName.PROPERTY_TYPE.getName()).equals(EmfComponent.REPOSITORY)) {
        final Object propertyValue = elem.getPropertyValue(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
        if (propertyValue != null) {
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            Item item = null;
            try {
                IRepositoryViewObject repobj = factory.getLastVersion(propertyValue.toString());
                if (repobj != null) {
                    Property property = repobj.getProperty();
                    if (property != null) {
                        item = property.getItem();
                    }
                }
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
            if (item != null && item instanceof ConnectionItem) {
                repositoryConnection = ((ConnectionItem) item).getConnection();
            }
        }
    } else {
        initConnectionParameters();
        repositoryConnection = TracesConnectionUtils.createConnection(connParameters);
    }
    QueryGuessCommand cmd = null;
    INode node = null;
    if (elem instanceof INode) {
        node = (INode) elem;
    } else {
        // else instanceof Connection
        node = ((IConnection) elem).getSource();
    }
    List<IMetadataTable> metadataList = node.getMetadataList();
    newRepositoryMetadata = metadataList.get(0);
    // for tInformixRow
    if (newRepositoryMetadata.getListColumns().size() == 0 && metadataList.size() > 1) {
        newRepositoryMetadata = metadataList.get(1);
    }
    if (newRepositoryMetadata == null) {
        String schemaSelected = (String) node.getPropertyValue(EParameterName.REPOSITORY_SCHEMA_TYPE.getName());
        if (schemaSelected != null) {
        // repositoryMetadata = repositoryTableMap.get(schemaSelected);
        } else if (newRepositoryMetadata == null) {
            MessageDialog.openWarning(new Shell(), Messages.getString("QueryTypeController.alert"), //$NON-NLS-1$ //$NON-NLS-2$
            Messages.getString("QueryTypeController.nothingToGuess"));
            return cmd;
        }
    }
    cmd = new QueryGuessCommand(node, newRepositoryMetadata, repositoryConnection);
    cmd.setMaps(dynamicProperty.getTableIdAndDbTypeMap(), dynamicProperty.getTableIdAndDbSchemaMap(), null);
    //$NON-NLS-1$
    String type = getValueFromRepositoryName("TYPE");
    if ("Oracle".equalsIgnoreCase(type)) {
        type = EDatabaseTypeName.ORACLEFORSID.getDisplayName();
    }
    cmd.setParameters(realTableId, realTableName, type);
    return cmd;
}
Also used : INode(org.talend.core.model.process.INode) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Shell(org.eclipse.swt.widgets.Shell) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 79 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class QueryTypeController method createComboCommand.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.designer.core.ui.editor.properties.controllers.AbstractRepositoryController#createComboCommand(org
     * .eclipse.swt.custom.CCombo)
     */
@Override
protected Command createComboCommand(CCombo combo) {
    String paramName = (String) combo.getData(PARAMETER_NAME);
    IElementParameter param = elem.getElementParameter(paramName);
    IElementParameter switchParam = elem.getElementParameter(EParameterName.REPOSITORY_ALLOW_AUTO_SWITCH.getName());
    String name = param.getName();
    String value = combo.getText();
    for (int j = 0; j < param.getListItemsValue().length; j++) {
        if (combo.getText().equals(param.getListItemsDisplayName()[j])) {
            value = (String) param.getListItemsValue()[j];
        }
    }
    if (name.equals(EParameterName.QUERYSTORE_TYPE.getName())) {
        if (elem instanceof Node) {
            String querySelected;
            Query repositoryQuery = null;
            // Map<String, Query> repositoryQueryStoreMap = this.dynamicProperty.getRepositoryQueryStoreMap();
            IElementParameter repositoryParam = param.getParentParameter().getChildParameters().get(EParameterName.REPOSITORY_QUERYSTORE_TYPE.getName());
            querySelected = (String) repositoryParam.getValue();
            /* value can be devided means the value like "connectionid - label" */
            String[] keySplitValues = querySelected.toString().split(" - ");
            if (keySplitValues.length > 1) {
                String connectionId = querySelected.split(" - ")[0];
                String queryLabel = querySelected.split(" - ")[1];
                IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                Item item = null;
                try {
                    IRepositoryViewObject repobj = factory.getLastVersion(connectionId);
                    if (repobj != null) {
                        Property property = repobj.getProperty();
                        if (property != null) {
                            item = property.getItem();
                        }
                    }
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
                if (item != null && item instanceof DatabaseConnectionItem) {
                    Connection conn = ((DatabaseConnectionItem) item).getConnection();
                    if (conn instanceof DatabaseConnection) {
                        DatabaseConnection dbconn = (DatabaseConnection) conn;
                        QueriesConnection queryConnection = dbconn.getQueries();
                        for (Query query : queryConnection.getQuery()) {
                            if (query.getLabel().equals(queryLabel)) {
                                repositoryQuery = query;
                                break;
                            }
                        }
                    }
                }
            }
            if (switchParam != null) {
                switchParam.setValue(Boolean.FALSE);
            }
            if (repositoryQuery != null) {
                return new RepositoryChangeQueryCommand(elem, repositoryQuery, name, value);
            } else {
                return new PropertyChangeCommand(elem, name, value);
            }
        }
    }
    return null;
}
Also used : QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) Query(org.talend.core.model.metadata.builder.connection.Query) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) QueriesConnection(org.talend.core.model.metadata.builder.connection.QueriesConnection) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Item(org.talend.core.model.properties.Item) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) RepositoryChangeQueryCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeQueryCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) IDynamicProperty(org.talend.core.ui.properties.tab.IDynamicProperty) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 80 with Property

use of org.talend.core.model.properties.Property in project tdi-studio-se by Talend.

the class AbstractPreferenceComposite method addButtonListeners.

private void addButtonListeners() {
    reloadBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            onReloadButtonClick();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    saveBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            onSaveButtonClick();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    if (hasRunJobNode(false) && needApplyToChildren()) {
        applyToChildrenJob.addSelectionListener(new SelectionListener() {

            /*
                 * (non-Javadoc)
                 * 
                 * @see
                 * org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
                 */
            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
            }

            /*
                 * (non-Javadoc)
                 * 
                 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
                 */
            @Override
            public void widgetSelected(SelectionEvent e) {
                // zli for bug 12335
                final ProgressDialog progress = new ProgressDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()) {

                    @Override
                    public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                        IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                        IEditorReference[] editorReferences = activePage.getEditorReferences();
                        CorePlugin defaultPlugin = CorePlugin.getDefault();
                        IDesignerCoreService designerCoreService = defaultPlugin.getDesignerCoreService();
                        List<IProcess2> openedProcessList = designerCoreService.getOpenedProcess(RepositoryUpdateManager.getEditors());
                        List<String> activeProcessId = new ArrayList<String>();
                        for (IProcess process : openedProcessList) {
                            activeProcessId.add(process.getId());
                        }
                        final int rate = 1 / openedProcessList.size() - activeProcessId.size();
                        for (INode runjobNode : tRunJobNodes) {
                            String id = (String) runjobNode.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName()).getValue();
                            String version = (String) runjobNode.getElementParameter(EParameterName.PROCESS_TYPE_VERSION.getName()).getValue();
                            if ("".equals(id) || id == null) {
                                //$NON-NLS-1$
                                MessageDialog.openWarning(getShell(), //$NON-NLS-1$
                                Messages.getString("AbstractPreferenceComposite.warning", runjobNode.getUniqueName()), Messages.getString("AbstractPreferenceComposite.jobAssigned", //$NON-NLS-1$
                                runjobNode.getUniqueName()));
                                return;
                            }
                            if (activeProcessId.contains(id)) {
                                IEditorPart activeEditorPart = activePage.getActiveEditor();
                                for (IEditorReference editorReference : editorReferences) {
                                    IEditorPart editorPart = editorReference.getEditor(false);
                                    if ((editorPart != activeEditorPart) && (editorPart instanceof MultiPageTalendEditor)) {
                                        IElement element = ((MultiPageTalendEditor) editorPart).getProcess();
                                        StatsAndLogsViewHelper.applySettings(elem, element, AbstractPreferenceComposite.this);
                                    }
                                }
                            } else {
                                try {
                                    SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * UpdatesConstants.SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
                                    subMonitor.beginTask(UpdatesConstants.EMPTY, 1 * rate);
                                    IRepositoryViewObject lastVersion = DesignerPlugin.getDefault().getProxyRepositoryFactory().getLastVersion(id);
                                    if (lastVersion != null) {
                                        Item item = lastVersion.getProperty().getItem();
                                        IProcess processFromItem = designerCoreService.getProcessFromItem(item);
                                        if (processFromItem instanceof Process) {
                                            Process process = (Process) processFromItem;
                                            StatsAndLogsViewHelper.applySettings(elem, process, AbstractPreferenceComposite.this);
                                            IProxyRepositoryFactory factory = defaultPlugin.getProxyRepositoryFactory();
                                            Property property = factory.getUptodateProperty(process.getProperty());
                                            process.setProperty(property);
                                            subMonitor.subTask(RepositoryUpdateManager.getUpdateJobInfor(process.getProperty()));
                                            ProcessType processType = process.saveXmlFile();
                                            Item item2 = process.getProperty().getItem();
                                            if (item2 instanceof JobletProcessItem) {
                                                ((JobletProcessItem) item2).setJobletProcess((JobletProcess) processType);
                                            } else {
                                                ((ProcessItem) item2).setProcess(processType);
                                            }
                                            factory.save(item2);
                                            subMonitor.done();
                                        }
                                    }
                                } catch (PersistenceException e1) {
                                    e1.printStackTrace();
                                } catch (IOException e2) {
                                    e2.printStackTrace();
                                }
                            }
                            applySettingsToSubJob(id, version);
                        }
                    }
                };
                try {
                    progress.executeProcess();
                } catch (InvocationTargetException e1) {
                    e1.printStackTrace();
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
            }

            /**
                 * yzhang Comment method "applySettingsToSubJob".
                 * 
                 * @param id
                 * @param version
                 */
            private void applySettingsToSubJob(String id, String version) {
                final ProcessItem processItem = ItemCacheManager.getProcessItem(id, version);
                if (processItem == null) {
                    return;
                }
                ProcessType processType = processItem.getProcess();
                EList<ElementParameterType> parameters = processType.getParameters().getElementParameter();
                StatsAndLogsViewHelper.applySettings(parameters, elem);
                List<NodeType> nodes = findRunJobNode(processType.getNode());
                for (NodeType nodeType : nodes) {
                    EList<ElementParameterType> list = nodeType.getElementParameter();
                    ElementParameterType idParam = getElementParameterType(list, //$NON-NLS-1$
                    PROCESS + ":" + EParameterName.PROCESS_TYPE_PROCESS.getName());
                    ElementParameterType versionParam = getElementParameterType(list, //$NON-NLS-1$
                    PROCESS + ":" + EParameterName.PROCESS_TYPE_VERSION.getName());
                    String subId = idParam.getValue();
                    String subVersion = versionParam.getValue();
                    applySettingsToSubJob(subId, subVersion);
                }
            }
        });
    }
}
Also used : INode(org.talend.core.model.process.INode) MultiPageTalendEditor(org.talend.designer.core.ui.MultiPageTalendEditor) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) JobletProcess(org.talend.designer.joblet.model.JobletProcess) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) JobletProcess(org.talend.designer.joblet.model.JobletProcess) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IEditorReference(org.eclipse.ui.IEditorReference) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) EList(org.eclipse.emf.common.util.EList) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IElement(org.talend.core.model.process.IElement) IEditorPart(org.eclipse.ui.IEditorPart) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) CorePlugin(org.talend.core.CorePlugin) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

Property (org.talend.core.model.properties.Property)147 PersistenceException (org.talend.commons.exception.PersistenceException)56 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)48 Item (org.talend.core.model.properties.Item)46 ProcessItem (org.talend.core.model.properties.ProcessItem)39 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)36 Node (org.talend.designer.core.ui.editor.nodes.Node)28 Process (org.talend.designer.core.ui.editor.process.Process)23 RepositoryNode (org.talend.repository.model.RepositoryNode)22 IElementParameter (org.talend.core.model.process.IElementParameter)21 ConnectionItem (org.talend.core.model.properties.ConnectionItem)21 IDynamicProperty (org.talend.core.ui.properties.tab.IDynamicProperty)21 ArrayList (java.util.ArrayList)20 Test (org.junit.Test)19 INode (org.talend.core.model.process.INode)19 IComponent (org.talend.core.model.components.IComponent)15 Connection (org.talend.core.model.metadata.builder.connection.Connection)14 IProcess2 (org.talend.core.model.process.IProcess2)14 List (java.util.List)12 IFile (org.eclipse.core.resources.IFile)12