Search in sources :

Example 6 with NoSQLConnectionItem

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

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

the class NoSQLRepositoryTypeProcessor method selectRepositoryNode.

/*
     * (non-Javadoc)
     *
     * @see
     * org.talend.repository.ui.processor.SingleTypeProcessor#selectRepositoryNode(org.eclipse.jface.viewers.Viewer,
     * org.talend.repository.model.RepositoryNode, org.talend.repository.model.RepositoryNode)
     */
@Override
protected boolean selectRepositoryNode(Viewer viewer, RepositoryNode parentNode, RepositoryNode node) {
    final String repositoryType = getRepositoryType();
    if (node == null || repositoryType == null) {
        return false;
    }
    ERepositoryObjectType repObjType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (repObjType == ERepositoryObjectType.REFERENCED_PROJECTS) {
        return true;
    }
    if (node.getType() == ENodeType.SYSTEM_FOLDER) {
        return true;
    }
    IRepositoryViewObject object = node.getObject();
    if (object == null || object.getProperty().getItem() == null) {
        return false;
    }
    if (object instanceof MetadataTable) {
        return false;
    }
    Item item = object.getProperty().getItem();
    if (item instanceof FolderItem) {
        return true;
    }
    if (item instanceof NoSQLConnectionItem) {
        NoSQLConnectionItem connectionItem = (NoSQLConnectionItem) item;
        NoSQLConnection connection = (NoSQLConnection) connectionItem.getConnection();
        if (repositoryType.startsWith(INoSQLConstants.NOSQL_TYPE_PREFIX)) {
            // $NON-NLS-1$
            String realDbType = repositoryType.substring(repositoryType.indexOf(":") + 1);
            if (!StringUtils.equalsIgnoreCase(realDbType, connection.getDbType())) {
                return false;
            }
        }
    }
    return true;
}
Also used : Item(org.talend.core.model.properties.Item) FolderItem(org.talend.core.model.properties.FolderItem) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem) FolderItem(org.talend.core.model.properties.FolderItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataTable(org.talend.core.model.metadata.MetadataTable) NoSQLConnection(org.talend.repository.model.nosql.NoSQLConnection) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) NoSQLConnectionItem(org.talend.repository.model.nosql.NoSQLConnectionItem)

Example 8 with NoSQLConnectionItem

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

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