Search in sources :

Example 6 with ChangeValuesFromRepository

use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.

the class ComponentChooseDialog method getPropertyPublicPart.

private Command getPropertyPublicPart(RepositoryNode selectedNode, IElementParameter param, Node node, ConnectionItem connectionItem) {
    param.getChildParameters().get(EParameterName.PROPERTY_TYPE.getName()).setValue(EmfComponent.REPOSITORY);
    ChangeValuesFromRepository command2 = new ChangeValuesFromRepository(node, connectionItem.getConnection(), param.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    selectedNode.getObject().getProperty().getId());
    if (selectedNode.getObject() instanceof IMetadataTable) {
        IMetadataTable metadataTable = (IMetadataTable) selectedNode.getObject();
        command2.setTable(metadataTable);
    }
    return command2;
}
Also used : IMetadataTable(org.talend.core.model.metadata.IMetadataTable) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)

Example 7 with ChangeValuesFromRepository

use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.

the class ConvertRepositoryNodeToProcessNode method convertToProcessNode.

public void convertToProcessNode(ConnectionItem connectionItem, String tableName) throws ProcessorException {
    EDatabaseComponentName name = EDatabaseComponentName.getCorrespondingComponentName(connectionItem, ERepositoryObjectType.METADATA_CONNECTIONS);
    String componentName = null;
    componentName = name.getDefaultComponentName();
    IComponent dbInputComponent = ComponentsFactoryProvider.getInstance().get(componentName, ComponentCategory.CATEGORY_4_DI.getName());
    Process process = new Process(GuessSchemaProcess.getNewmockProperty());
    node = new Node(dbInputComponent, process);
    selectedContext = node.getProcess().getContextManager().getDefaultContext();
    // TDI-20011
    IMetadataTable table = UpdateRepositoryUtils.getTableByName(connectionItem, tableName);
    if (table == null) {
        table = new MetadataTable();
        table.setTableName(tableName);
        table.setLabel(tableName);
    }
    IElementParameter propertyParam = ((Node) node).getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE);
    IElementParameter schemaParam = ((Node) node).getElementParameterFromField(EParameterFieldType.SCHEMA_TYPE);
    if (schemaParam == null) {
        schemaParam = ((Node) node).getElementParameterFromField(EParameterFieldType.SCHEMA_REFERENCE);
    }
    String propertyId = connectionItem.getProperty().getId();
    String schema = databaseConnection.getUiSchema();
    String dbType = databaseConnection.getDatabaseType();
    //$NON-NLS-1$
    String value = connectionItem.getProperty().getId() + " - " + table.getLabel();
    CompoundCommand cc = new CompoundCommand();
    // inital parameters command
    ChangeValuesFromRepository changeValueCommand = new ChangeValuesFromRepository(node, databaseConnection, propertyParam.getName() + ":" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName(), //$NON-NLS-1$
    propertyId);
    changeValueCommand.ignoreContextMode(true);
    cc.add(changeValueCommand);
    // change metadata command
    RepositoryChangeMetadataCommand changeMetadataCommand = new RepositoryChangeMetadataCommand((Node) node, //$NON-NLS-1$
    schemaParam.getName() + ":" + EParameterName.REPOSITORY_SCHEMA_TYPE.getName(), value, table, null, null);
    cc.add(changeMetadataCommand);
    // guess query command
    QueryGuessCommand queryGuessCommand = new QueryGuessCommand(node, node.getMetadataList().get(0), schema, dbType, databaseConnection);
    cc.add(queryGuessCommand);
    // execute the commands
    cc.execute();
    //$NON-NLS-1$
    IElementParameter query = node.getElementParameter("QUERY");
    //
    memoSQL = query.getValue().toString();
    String memoSQLTemp = TalendTextUtils.removeQuotesIfExist(memoSQL);
    if ((memoSQLTemp == null || memoSQLTemp.equals("")) && tableName != null && !tableName.equals("")) {
        //$NON-NLS-1$
        boolean check = !Pattern.matches("^\\w+$", tableName);
        boolean isJDBCForMysql = databaseConnection.getURL() == null ? false : databaseConnection.getURL().startsWith("jdbc:mysql");
        if ((dbType.equals(EDatabaseTypeName.MYSQL.getDisplayName()) || isJDBCForMysql) && check) {
            tableName = TalendQuoteUtils.addQuotes(tableName, TalendQuoteUtils.ANTI_QUOTE);
        }
        memoSQL = "select * from " + tableName;
        memoSQL = TalendTextUtils.addSQLQuotes(memoSQL);
    }
}
Also used : RepositoryChangeMetadataCommand(org.talend.designer.core.ui.editor.cmd.RepositoryChangeMetadataCommand) ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) QueryGuessCommand(org.talend.designer.core.ui.editor.cmd.QueryGuessCommand) GuessSchemaProcess(org.talend.designer.core.ui.editor.properties.controllers.GuessSchemaProcess) CompoundCommand(org.eclipse.gef.commands.CompoundCommand) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) MetadataTable(org.talend.core.model.metadata.MetadataTable) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 8 with ChangeValuesFromRepository

use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository in project tdi-studio-se by Talend.

the class ValidationRuleTypeController 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;
    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;
    }
    ChangeValuesFromRepository changeValuesFromRepository = new ChangeValuesFromRepository(elem, repositoryConnection, paramName, value);
    return changeValuesFromRepository;
}
Also used : ChangeValuesFromRepository(org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository) Connection(org.talend.core.model.metadata.builder.connection.Connection) IElementParameter(org.talend.core.model.process.IElementParameter)

Example 9 with ChangeValuesFromRepository

use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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 10 with ChangeValuesFromRepository

use of org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository 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)

Aggregations

ChangeValuesFromRepository (org.talend.designer.core.ui.editor.cmd.ChangeValuesFromRepository)24 IElementParameter (org.talend.core.model.process.IElementParameter)19 ConnectionItem (org.talend.core.model.properties.ConnectionItem)18 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)14 Connection (org.talend.core.model.metadata.builder.connection.Connection)13 PersistenceException (org.talend.commons.exception.PersistenceException)11 Item (org.talend.core.model.properties.Item)10 Property (org.talend.core.model.properties.Property)9 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)8 DatabaseConnectionItem (org.talend.core.model.properties.DatabaseConnectionItem)7 CompoundCommand (org.eclipse.gef.commands.CompoundCommand)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 AbstractMultiPageTalendEditor (org.talend.designer.core.ui.AbstractMultiPageTalendEditor)5 CommandStack (org.eclipse.gef.commands.CommandStack)4 CDCConnection (org.talend.core.model.metadata.builder.connection.CDCConnection)4 Element (org.talend.core.model.process.Element)4 FileItem (org.talend.core.model.properties.FileItem)4 LinkRulesItem (org.talend.core.model.properties.LinkRulesItem)4 Command (org.eclipse.gef.commands.Command)3