Search in sources :

Example 41 with ConnectionItem

use of org.talend.core.model.properties.ConnectionItem in project tesb-studio-se by Talend.

the class CreateNewJobAction method repositoryChange.

private void repositoryChange(RepositoryNode nodeOperation, Node nodeProviderRequest) {
    IElementParameter param = nodeProviderRequest.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    if (param != null) {
        param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
        ConnectionItem connectionItem = (ConnectionItem) nodeOperation.getObject().getProperty().getItem();
        String serviceId = connectionItem.getProperty().getId();
        String portId = ((PortRepositoryObject) nodeOperation.getParent().getObject()).getId();
        String operationId = ((OperationRepositoryObject) nodeOperation.getObject()).getId();
        ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(nodeProviderRequest, connectionItem.getConnection(), param.getName() + ':' + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
        serviceId + " - " + portId + " - " + operationId);
        command2.execute();
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IElementParameter(org.talend.core.model.process.IElementParameter) PortRepositoryObject(org.talend.repository.services.utils.PortRepositoryObject) OperationRepositoryObject(org.talend.repository.services.utils.OperationRepositoryObject)

Example 42 with ConnectionItem

use of org.talend.core.model.properties.ConnectionItem in project tesb-studio-se by Talend.

the class PublishMetadataRunnable method initFileConnection.

private Collection<XmlFileConnectionItem> initFileConnection() throws URISyntaxException, PersistenceException {
    Collection<String> paths = getAllPaths();
    Collection<XmlFileConnectionItem> connItems = new ArrayList<XmlFileConnectionItem>();
    for (ConnectionItem item : DesignerPlugin.getDefault().getProxyRepositoryFactory().getMetadataConnectionsItem()) {
        if (item instanceof XmlFileConnectionItem && paths.contains(item.getState().getPath()) && !ConnectionHelper.getTables(item.getConnection()).isEmpty()) {
            connItems.add((XmlFileConnectionItem) item);
        }
    }
    return connItems;
}
Also used : XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ArrayList(java.util.ArrayList) XmlFileConnectionItem(org.talend.core.model.properties.XmlFileConnectionItem)

Example 43 with ConnectionItem

use of org.talend.core.model.properties.ConnectionItem in project tesb-studio-se by Talend.

the class ESBService method copyJobForService.

private Item copyJobForService(final Item item, final IPath path, final String newName) {
    try {
        final Item newItem = ProxyRepositoryFactory.getInstance().copy(item, path, newName);
        if (newItem instanceof ConnectionItem) {
            Connection connection = ((ConnectionItem) newItem).getConnection();
            if (connection != null) {
                connection.setLabel(newName);
                connection.setName(newName);
                connection.getSupplierDependency().clear();
            }
        }
        ProxyRepositoryFactory.getInstance().save(newItem);
        return newItem;
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (BusinessException e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessException(org.talend.commons.exception.BusinessException) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Connection(org.talend.core.model.metadata.builder.connection.Connection) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 44 with ConnectionItem

use of org.talend.core.model.properties.ConnectionItem in project tesb-studio-se by Talend.

the class AssignJobAction method repositoryChangeToBuildIn.

private void repositoryChangeToBuildIn(RepositoryNode repNode, INode node) {
    IElementParameter param = node.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    ConnectionItem connectionItem = (ConnectionItem) repNode.getObject().getProperty().getItem();
    if (param != null) {
        param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.BUILTIN);
        ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.PROPERTY_TYPE.getName(), //$NON-NLS-1$
        EmfComponent.BUILTIN);
        command2.execute();
        command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
        "");
        command2.execute();
    }
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) ConnectionItem(org.talend.core.model.properties.ConnectionItem) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 45 with ConnectionItem

use of org.talend.core.model.properties.ConnectionItem 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)

Aggregations

ConnectionItem (org.talend.core.model.properties.ConnectionItem)79 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)44 PersistenceException (org.talend.commons.exception.PersistenceException)38 Connection (org.talend.core.model.metadata.builder.connection.Connection)38 IElementParameter (org.talend.core.model.process.IElementParameter)38 Item (org.talend.core.model.properties.Item)34 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)31 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)27 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)20 ArrayList (java.util.ArrayList)19 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)19 Property (org.talend.core.model.properties.Property)17 ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)17 RepositoryNode (org.talend.repository.model.RepositoryNode)17 INode (org.talend.core.model.process.INode)15 Node (org.talend.designer.core.ui.editor.nodes.Node)15 List (java.util.List)14 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)14 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)13 ProcessItem (org.talend.core.model.properties.ProcessItem)12