Search in sources :

Example 26 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class ChangeMongoDBConnectionMinimalVersionMigrationTask method execute.

/*
     * (non-Javadoc)
     *
     * @see org.talend.core.model.migration.AbstractItemMigrationTask#execute(org.talend.core.model.properties.Item)
     */
@Override
public ExecutionResult execute(Item item) {
    if (item instanceof NoSQLConnectionItem) {
        boolean modify = false;
        Connection connection = ((NoSQLConnectionItem) item).getConnection();
        if (connection instanceof NoSQLConnection) {
            NoSQLConnection noSqlConn = (NoSQLConnection) connection;
            try {
                if (!noSqlConn.isContextMode()) {
                    String version = noSqlConn.getAttributes().get(ICassandraAttributies.DB_VERSION);
                    if (version == null || Arrays.asList(unsupportedVersion).contains(version)) {
                        // 1,No DB version => add one.
                        // 2,Has DB version, check if we still use it, if not change to the "lastestVersion".
                        noSqlConn.getAttributes().put(ICassandraAttributies.DB_VERSION, latestMajor2X);
                        modify = true;
                    }
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
        if (modify) {
            try {
                ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                factory.save(item, true);
                return ExecutionResult.SUCCESS_WITH_ALERT;
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 27 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class NoSQLDragAndDropHandler method filterNeededComponents.

@Override
public List<IComponent> filterNeededComponents(Item item, RepositoryNode seletetedNode, ERepositoryObjectType type) {
    List<IComponent> neededComponents = new ArrayList<IComponent>();
    if (!(item instanceof NoSQLConnectionItem)) {
        return neededComponents;
    }
    NoSQLConnection connection = (NoSQLConnection) ((NoSQLConnectionItem) item).getConnection();
    IComponentsService service = (IComponentsService) GlobalServiceRegister.getDefault().getService(IComponentsService.class);
    Collection<IComponent> components = service.getComponentsFactory().readComponents();
    for (IComponent component : components) {
        if (isValid(item, type, seletetedNode, component, getRepType(connection)) && !neededComponents.contains(component)) {
            neededComponents.add(component);
        }
    }
    return neededComponents;
}
Also used : IComponentsService(org.talend.core.model.components.IComponentsService) IComponent(org.talend.core.model.components.IComponent) ArrayList(java.util.ArrayList) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 28 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class NoSQLConnWizardPage method init.

private void init() {
    if (!creation) {
        NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
        List<String> dbTypes = repFactory.getAllRegisteredDBTypes();
        for (int n = 0; n < dbTypes.size(); n++) {
            if (dbTypes.get(n).equals(connection.getDbType())) {
                dbTypeCombo.select(n);
            }
        }
    } else if (dbTypeCombo.getItemCount() > 0) {
        dbTypeCombo.select(0);
    }
// getForm().checkFieldsValue();
}
Also used : NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Example 29 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class NoSQLConnWizardPage method addFieldsListeners.

protected void addFieldsListeners() {
    final AbstractForm.ICheckListener formCheckListener = new AbstractForm.ICheckListener() {

        @Override
        public void checkPerformed(final AbstractForm source) {
            if (source.isStatusOnError()) {
                setPageComplete(false);
                setErrorMessage(source.getStatus());
            } else {
                setPageComplete(isRepositoryObjectEditable);
                setErrorMessage(null);
                setMessage(source.getStatus(), source.getStatusLevel());
            }
        }
    };
    dbTypeCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
            String originalDbType = connection.getDbType();
            String dbType = repositoryTranslator.getValue(dbTypeCombo.getText());
            if (!StringUtils.equals(originalDbType, dbType)) {
                connection.setDbType(dbType);
                connection.getAttributes().clear();
            } else if (connectionForm != null) {
                return;
            }
            wizPageProvider = repFactory.getWizardPageProvider(dbType);
            if (wizPageProvider == null) {
                return;
            }
            clearForm(connectionForm);
            connectionForm = getConnectionForm();
            if (connectionForm == null) {
                return;
            }
            connectionForm.setReadOnly(!isRepositoryObjectEditable);
            connectionForm.setListener(formCheckListener);
            if (StringUtils.isNotEmpty(connectionItem.getProperty().getLabel())) {
                connectionForm.checkFieldsValue();
            }
            parentComp.layout();
        }
    });
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) AbstractForm(org.talend.metadata.managment.ui.wizard.AbstractForm) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Example 30 with NoSQLConnection

use of org.talend.repository.model.nosql.NoSQLConnection in project tbd-studio-se by Talend.

the class NoSQLRetrieveSchemaWizardPage method createControl.

@Override
public void createControl(final Composite parent) {
    NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
    String dbType = connection.getDbType();
    IWizardPageProvider wizPageProvider = NoSQLRepositoryFactory.getInstance().getWizardPageProvider(dbType);
    if (wizPageProvider == null) {
        return;
    }
    retrieveSchemaForm = wizPageProvider.createRetrieveSchemaForm(parent, connectionItem, creation, this);
    if (retrieveSchemaForm == null) {
        return;
    }
    retrieveSchemaForm.setReadOnly(!isRepositoryObjectEditable);
    AbstractForm.ICheckListener listener = new AbstractForm.ICheckListener() {

        @Override
        public void checkPerformed(final AbstractForm source) {
            if (source.isStatusOnError()) {
                setPageComplete(false);
                setErrorMessage(source.getStatus());
            } else {
                setPageComplete(isRepositoryObjectEditable);
                setErrorMessage(null);
                setMessage(source.getStatus(), source.getStatusLevel());
            }
        }
    };
    retrieveSchemaForm.setListener(listener);
    setControl(retrieveSchemaForm);
    if (StringUtils.isNotEmpty(connectionItem.getProperty().getLabel())) {
        retrieveSchemaForm.checkFieldsValue();
    }
}
Also used : IWizardPageProvider(org.talend.repository.nosql.ui.provider.IWizardPageProvider) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) AbstractForm(org.talend.metadata.managment.ui.wizard.AbstractForm)

Aggregations

NoSQLConnection (org.talend.repository.model.nosql.NoSQLConnection)30 NoSQLConnectionItem (org.talend.repository.model.nosql.NoSQLConnectionItem)7 ArrayList (java.util.ArrayList)5 Map (java.util.Map)4 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)4 EHadoopParamName (org.talend.metadata.managment.ui.utils.ExtendedNodeConnectionContextUtils.EHadoopParamName)4 JSONArray (org.talend.utils.json.JSONArray)4 JSONException (org.talend.utils.json.JSONException)4 JSONObject (org.talend.utils.json.JSONObject)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)3 ModifyListener (org.eclipse.swt.events.ModifyListener)3 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)3 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 IConnParamName (org.talend.metadata.managment.ui.model.IConnParamName)3 AbstractForm (org.talend.metadata.managment.ui.wizard.AbstractForm)3 HashMap (java.util.HashMap)2 List (java.util.List)2 Connection (org.talend.core.model.metadata.builder.connection.Connection)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1