Search in sources :

Example 6 with NoSQLConnection

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

the class NoSQLSchemaWizardPage method createControl.

@Override
public void createControl(final Composite parent) {
    String dbType = ((NoSQLConnection) connectionItem.getConnection()).getDbType();
    IWizardPageProvider wizPageProvider = NoSQLRepositoryFactory.getInstance().getWizardPageProvider(dbType);
    if (wizPageProvider == null) {
        return;
    }
    schemaForm = wizPageProvider.createSchemaForm(parent, connectionItem, metadataTable, creation, this);
    if (schemaForm == null) {
        return;
    }
    schemaForm.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);
                schemaForm.setButtonsVisibility(isRepositoryObjectEditable);
                setErrorMessage(null);
                setMessage(source.getStatus(), source.getStatusLevel());
            }
        }
    };
    schemaForm.setListener(listener);
    setControl(schemaForm);
}
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)

Example 7 with NoSQLConnection

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

the class NoSqlContextUpdateService method updateContextParameter.

@Override
public boolean updateContextParameter(Connection conn, String oldValue, String newValue) {
    boolean isModified = false;
    if (conn.isContextMode()) {
        if (conn instanceof NoSQLConnection) {
            NoSQLConnection connection = (NoSQLConnection) conn;
            EMap<String, String> connAttributes = (EMap<String, String>) connection.getAttributes();
            if (connAttributes == null) {
                return isModified;
            }
            for (Map.Entry<String, String> attr : connection.getAttributes()) {
                if (attr.equals(IMongoDBAttributes.REPLICA_SET)) {
                    String replicaSets = connAttributes.get(IMongoDBAttributes.REPLICA_SET);
                    try {
                        JSONArray jsa = new JSONArray(replicaSets);
                        for (int i = 0; i < jsa.length(); i++) {
                            JSONObject jso = jsa.getJSONObject(i);
                            String hostValue = jso.getString(IMongoConstants.REPLICA_HOST_KEY);
                            if (hostValue != null && hostValue.equals(oldValue)) {
                                jso.put(IMongoConstants.REPLICA_HOST_KEY, newValue);
                                connAttributes.put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
                                isModified = true;
                            }
                            String portValue = jso.getString(IMongoConstants.REPLICA_PORT_KEY);
                            if (portValue != null && portValue.equals(oldValue)) {
                                jso.put(IMongoConstants.REPLICA_PORT_KEY, newValue);
                                connAttributes.put(IMongoDBAttributes.REPLICA_SET, jsa.toString());
                                isModified = true;
                            }
                        }
                    } catch (JSONException e) {
                        ExceptionHandler.process(e);
                    }
                } else if (attr.getValue().equals(oldValue)) {
                    attr.setValue(newValue);
                    isModified = true;
                }
            }
        }
    }
    return isModified;
}
Also used : JSONObject(org.talend.utils.json.JSONObject) EMap(org.eclipse.emf.common.util.EMap) JSONArray(org.talend.utils.json.JSONArray) JSONException(org.talend.utils.json.JSONException) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) Map(java.util.Map) EMap(org.eclipse.emf.common.util.EMap)

Example 8 with NoSQLConnection

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

the class NoSQLDragAndDropHandler method getCorrespondingComponentName.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public IComponentName getCorrespondingComponentName(Item item, ERepositoryObjectType type) {
    RepositoryComponentSetting setting = null;
    if (item instanceof NoSQLConnectionItem) {
        NoSQLConnection connection = (NoSQLConnection) ((NoSQLConnectionItem) item).getConnection();
        String repType = getRepType(connection);
        setting = new RepositoryComponentSetting();
        setting.setName(repType);
        setting.setRepositoryType(repType);
        setting.setWithSchema(true);
        setting.setInputComponent(getInputComponentName(connection));
        setting.setOutputComponent(getOutputComponentName(connection));
        List<Class<Item>> list = new ArrayList<Class<Item>>();
        Class clazz = null;
        try {
            clazz = Class.forName(NoSQLConnectionItem.class.getName());
        } catch (ClassNotFoundException e) {
            ExceptionHandler.process(e);
        }
        list.add(clazz);
        setting.setClasses(list.toArray(new Class[0]));
    }
    return setting;
}
Also used : Item(org.talend.core.model.properties.Item) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem) RepositoryComponentSetting(org.talend.core.repository.RepositoryComponentSetting) ArrayList(java.util.ArrayList) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 9 with NoSQLConnection

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

the class NoSQLDragAndDropHandler method handleTableRelevantParameters.

@Override
public void handleTableRelevantParameters(Connection connection, IElement ele, IMetadataTable metadataTable) {
    if (canHandle(connection)) {
        NoSQLConnection conn = (NoSQLConnection) connection;
        String dbType = conn.getDbType();
        IDNDProvider dndProvider = NoSQLRepositoryFactory.getInstance().getDNDProvider(dbType);
        if (dndProvider != null) {
            dndProvider.handleTableRelevantParameters(conn, ele, metadataTable);
        }
    }
}
Also used : NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection)

Example 10 with NoSQLConnection

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

the class CreateNoSQLSchemaAction method doRun.

@Override
protected void doRun() {
    if (repositoryNode == null) {
        repositoryNode = getCurrentRepositoryNode();
    }
    NoSQLConnection connection = null;
    MetadataTable metadataTable = null;
    boolean creation = false;
    if (repositoryNode.getType() == ENodeType.REPOSITORY_ELEMENT) {
        ERepositoryObjectType nodeType = (ERepositoryObjectType) repositoryNode.getProperties(EProperties.CONTENT_TYPE);
        String metadataTableLabel = (String) repositoryNode.getProperties(EProperties.LABEL);
        NoSQLConnectionItem item = null;
        if (nodeType == ERepositoryObjectType.METADATA_CON_TABLE) {
            item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (NoSQLConnection) item.getConnection();
            metadataTable = TableHelper.findByLabel(connection, metadataTableLabel);
            creation = false;
        } else if (nodeType == NoSQLRepositoryNodeType.METADATA_NOSQL_CONNECTIONS) {
            item = (NoSQLConnectionItem) repositoryNode.getObject().getProperty().getItem();
            connection = (NoSQLConnection) item.getConnection();
            creation = true;
        } else {
            return;
        }
        boolean isOK = true;
        if (creation) {
            isOK = checkNoSQLConnection((NoSQLConnection) item.getConnection());
        }
        if (isOK) {
            openNoSQLSchemaWizard(item, metadataTable, false, creation);
        }
    }
}
Also used : MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

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