Search in sources :

Example 1 with NoSQLConnectionItem

use of org.talend.repository.model.nosql.NoSQLConnectionItem 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)

Example 2 with NoSQLConnectionItem

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

the class FixCassandraDataStaxDbtypesProblemMigrationTask 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;
            EMap<String, String> attributes = noSqlConn.getAttributes();
            String dbVersion = attributes.get(INoSQLCommonAttributes.DB_VERSION);
            if (!CASSANDRA_2_0_0.equals(dbVersion)) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            boolean isDatastaxApiType = ICassandraConstants.API_TYPE_DATASTAX.equals(attributes.get(INoSQLCommonAttributes.API_TYPE));
            if (!isDatastaxApiType) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            Set<MetadataTable> tables = ConnectionHelper.getTables(noSqlConn);
            if (tables == null || tables.isEmpty()) {
                return ExecutionResult.NOTHING_TO_DO;
            }
            MappingTypeRetriever mappingTypeRetriever = MetadataTalendType.getMappingTypeRetriever(ICassandraConstants.DBM_DATASTAX_ID);
            for (MetadataTable table : tables) {
                EList<MetadataColumn> columns = table.getColumns();
                if (columns == null || columns.isEmpty()) {
                    continue;
                }
                for (MetadataColumn column : columns) {
                    String sourceType = column.getSourceType();
                    if (sourceType == null || sourceType.isEmpty()) {
                        continue;
                    }
                    modify = true;
                    sourceType = sourceType.toLowerCase();
                    column.setSourceType(sourceType);
                    String talendType = mappingTypeRetriever.getDefaultSelectedTalendType(sourceType);
                    if (talendType == null) {
                        talendType = JavaTypesManager.STRING.getId();
                    }
                    column.setTalendType(talendType);
                }
            }
        }
        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 : MappingTypeRetriever(org.talend.core.model.metadata.MappingTypeRetriever) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) MetadataTable(org.talend.core.model.metadata.builder.connection.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 3 with NoSQLConnectionItem

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

the class UnifyPasswordEncryption4NoSQLConnectionMigrationTask 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) {
        Connection connection = ((NoSQLConnectionItem) item).getConnection();
        connection.setEncryptAndDecryptFuncPair(CryptoMigrationUtil.encryptFunc(), CryptoMigrationUtil.decryptFunc());
        if (connection instanceof NoSQLConnection) {
            NoSQLConnection noSqlConn = (NoSQLConnection) connection;
            try {
                if (!noSqlConn.isContextMode()) {
                    String pass = noSqlConn.getAttributes().get(ICassandraAttributies.PASSWORD);
                    pass = cleanPassword(pass);
                    noSqlConn.getAttributes().put(ICassandraAttributies.PASSWORD, noSqlConn.getValue(pass, true));
                    factory.save(item, true);
                    return ExecutionResult.SUCCESS_NO_ALERT;
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
                return ExecutionResult.FAILURE;
            }
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : Connection(org.talend.core.model.metadata.builder.connection.Connection) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 4 with NoSQLConnectionItem

use of org.talend.repository.model.nosql.NoSQLConnectionItem 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 5 with NoSQLConnectionItem

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

the class NoSQLRepositoryContentHandler method create.

@Override
public Resource create(IProject project, Item item, int classifierID, IPath path) throws PersistenceException {
    Resource itemResource = null;
    if (item.eClass() == NosqlPackage.Literals.NO_SQL_CONNECTION_ITEM) {
        ERepositoryObjectType type = NoSQLRepositoryNodeType.METADATA_NOSQL_CONNECTIONS;
        itemResource = create(project, (NoSQLConnectionItem) item, path, type);
    }
    return itemResource;
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Aggregations

NoSQLConnectionItem (org.talend.repository.model.nosql.NoSQLConnectionItem)8 NoSQLConnection (org.talend.repository.model.nosql.NoSQLConnection)7 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)3 ArrayList (java.util.ArrayList)2 MetadataTable (org.talend.core.model.metadata.builder.connection.MetadataTable)2 Item (org.talend.core.model.properties.Item)2 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)2 Resource (org.eclipse.emf.ecore.resource.Resource)1 IComponent (org.talend.core.model.components.IComponent)1 IComponentsService (org.talend.core.model.components.IComponentsService)1 MappingTypeRetriever (org.talend.core.model.metadata.MappingTypeRetriever)1 MetadataTable (org.talend.core.model.metadata.MetadataTable)1 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)1 FolderItem (org.talend.core.model.properties.FolderItem)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 RepositoryComponentSetting (org.talend.core.repository.RepositoryComponentSetting)1