Search in sources :

Example 1 with Container

use of org.talend.commons.utils.data.container.Container in project tdi-studio-se by Talend.

the class DBTreeProvider method convert.

private void convert(Container fromModel, RepositoryNode parent, ERepositoryObjectType type) {
    if (fromModel.isEmpty()) {
        return;
    }
    for (Object obj : fromModel.getSubContainer()) {
        Container container = (Container) obj;
        Folder folderRepositoryObject = new Folder(container.getId(), container.getLabel());
        FolderRepositoryObject oFolder = new FolderRepositoryObject(folderRepositoryObject);
        oFolder.setImage(IMAGES_CLOSED_FOLDER);
        oFolder.setSourceName(oFolder.getLabel());
        oFolder.setRepositoryName(null);
        RepositoryNode folder = new RepositoryNodeExt(oFolder, parent, ENodeType.SIMPLE_FOLDER);
        folder.setProperties(EProperties.LABEL, container.getLabel());
        // ERepositoryObjectType.FOLDER);
        folder.setProperties(EProperties.CONTENT_TYPE, RepositoryNodeType.FOLDER);
        parent.getChildren().add(folder);
        convert(container, folder, type);
    }
    if (!isCleared) {
        maps.clear();
        isCleared = true;
    }
    for (Object obj : fromModel.getMembers()) {
        RepositoryObject obj2 = (RepositoryObject) obj;
        if (!connectionParameters.getRepositoryId().equals(obj2.getProperty().getId())) {
            continue;
        }
        RepositoryViewObject viewObject = new RepositoryViewObject(obj2.getProperty());
        maps.put((obj2).getId(), viewObject);
        addNode(parent, viewObject, false, null);
    }
}
Also used : Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) Folder(org.talend.core.model.repository.Folder) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryNodeExt(org.talend.sqlbuilder.RepositoryNodeExt) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 2 with Container

use of org.talend.commons.utils.data.container.Container in project tdi-studio-se by Talend.

the class DBTreeProvider method getMetadataConnection.

/**
     * @return MetadataConnection
     */
@SuppressWarnings("unchecked")
private Container getMetadataConnection() {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    ProjectManager pManager = ProjectManager.getInstance();
    Container container = null;
    try {
        container = factory.getMetadata(pManager.getCurrentProject(), ERepositoryObjectType.METADATA_CONNECTIONS);
        pManager.retrieveReferencedProjects();
        for (Project p : pManager.getAllReferencedProjects()) {
            RootContainer rContainer = factory.getMetadata(p, ERepositoryObjectType.METADATA_CONNECTIONS);
            if (container == null) {
                container = rContainer;
            } else if (rContainer != null) {
                Iterator iterator = rContainer.absoluteKeySet().iterator();
                while (iterator.hasNext()) {
                    Object id = iterator.next();
                    container.addMember(id, rContainer.getAbsoluteMember(id));
                }
            }
        }
    } catch (PersistenceException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    } catch (BusinessException e) {
        //$NON-NLS-1$
        SqlBuilderPlugin.log(Messages.getString("DBTreeProvider.logMessage"), e);
    }
    return container;
}
Also used : Project(org.talend.core.model.general.Project) Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) Iterator(java.util.Iterator) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) RootContainer(org.talend.commons.utils.data.container.RootContainer) ProjectManager(org.talend.repository.ProjectManager)

Example 3 with Container

use of org.talend.commons.utils.data.container.Container in project tdi-studio-se by Talend.

the class DBTreeProvider method initialize.

private void initialize(RepositoryNode treeRoot) {
    if (!connectionParameters.isRepository()) {
        addNode(treeRoot, repositoryNodeManager.getRepositoryNodeByBuildIn(treeRoot, connectionParameters).getObject(), true, null);
    } else {
        Container metadataConnection = getMetadataConnection();
        convert(metadataConnection, treeRoot, ERepositoryObjectType.METADATA_CONNECTIONS);
    }
}
Also used : Container(org.talend.commons.utils.data.container.Container) RootContainer(org.talend.commons.utils.data.container.RootContainer)

Aggregations

Container (org.talend.commons.utils.data.container.Container)3 RootContainer (org.talend.commons.utils.data.container.RootContainer)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 RepositoryViewObject (org.talend.core.model.repository.RepositoryViewObject)2 Iterator (java.util.Iterator)1 BusinessException (org.talend.commons.exception.BusinessException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Project (org.talend.core.model.general.Project)1 Folder (org.talend.core.model.repository.Folder)1 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)1 ProjectManager (org.talend.repository.ProjectManager)1 RepositoryNode (org.talend.repository.model.RepositoryNode)1 RepositoryNodeExt (org.talend.sqlbuilder.RepositoryNodeExt)1