Search in sources :

Example 66 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory 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 67 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.

the class DBTreeProvider method addNode.

private void addNode(RepositoryNode parent, IRepositoryViewObject repositoryObject, boolean isBuildIn, Integer index) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    DatabaseConnection connection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
    String sid = connection.getSID();
    MetadataConnectionRepositoryObject connectionRepositoryObject = new MetadataConnectionRepositoryObject(repositoryObject);
    if (isBuildIn) {
        connectionRepositoryObject.setRepositoryName(BUILT_IN);
    } else {
        connectionRepositoryObject.setRepositoryName(repositoryObject.getLabel());
    }
    //$NON-NLS-1$
    connectionRepositoryObject.setSourceName((sid == null || sid.trim().equals("")) ? connection.getDatasourceName() : sid);
    if (!isBuildIn) {
        connectionRepositoryObject.setImage(IMAGES_CONNECTION_ICON);
    } else {
        connectionRepositoryObject.setImage(IMAGES_DATABASE_ICON);
    }
    connectionRepositoryObject.setBuildIn(isBuildIn);
    RepositoryNode node = new RepositoryNodeExt(connectionRepositoryObject, parent, ENodeType.REPOSITORY_ELEMENT);
    node.setProperties(EProperties.CONTENT_TYPE, RepositoryNodeType.DATABASE);
    node.setProperties(EProperties.LABEL, repositoryObject.getLabel());
    boolean[] isDiffs = repositoryNodeManager.isDiff(node);
    if (isDiffs[0]) {
        connectionRepositoryObject.setDiffImage(IMAGES_GRAY_ICON);
    }
    if (isDiffs[1]) {
        connectionRepositoryObject.setDiffImage(IMAGES_RED_ICON);
    }
    if (isDiffs[2]) {
        connectionRepositoryObject.setDiffImage(IMAGES_REFRESH_ICON);
    }
    if (factory.getStatus(repositoryObject) == ERepositoryStatus.DELETED) {
    // ignore recycle node
    } else {
        if (index == null) {
            parent.getChildren().add(node);
        } else {
            parent.getChildren().add(index.intValue(), node);
        }
        repositoryNodeManager.addRepositoryNode(node);
        DatabaseConnection metadataConnection = (DatabaseConnection) ((ConnectionItem) repositoryObject.getProperty().getItem()).getConnection();
        createTables(node, repositoryObject, metadataConnection, isBuildIn);
        createQueries(node, repositoryObject, metadataConnection, isBuildIn);
    }
}
Also used : ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) RepositoryNode(org.talend.repository.model.RepositoryNode) RepositoryNodeExt(org.talend.sqlbuilder.RepositoryNodeExt)

Example 68 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.

the class MigrateDeprecatedHadoopDistribution1 method changeMRConfiguration.

private void changeMRConfiguration(ProcessType processType, Item item) throws PersistenceException {
    boolean modified = false;
    final ParametersType parameters = processType.getParameters();
    if (parameters != null) {
        EList elementParameters = parameters.getElementParameter();
        for (int i = 0; i < elementParameters.size(); i++) {
            ElementParameterType param = (ElementParameterType) elementParameters.get(i);
            if ("MR_VERSION".equals(param.getName())) {
                //$NON-NLS-1$ 
                if (values.containsKey(param.getValue())) {
                    param.setValue(values.get(param.getValue()));
                    modified = true;
                }
                break;
            }
        }
    }
    if (modified) {
        ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.save(item, true);
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) EList(org.eclipse.emf.common.util.EList) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Example 69 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.

the class RenameDbMacroMigrationTask method convertItem.

private boolean convertItem(Item item, ProcessType processType) throws PersistenceException {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    EList node = processType.getNode();
    for (Object n : node) {
        NodeType type = (NodeType) n;
        EList elementParameterList = type.getElementParameter();
        for (Object elem : elementParameterList) {
            ElementParameterType elemType = (ElementParameterType) elem;
            if (elemType.getName().equals("DBTABLE")) {
                //$NON-NLS-1$
                //$NON-NLS-1$
                elemType.setName("TABLE");
                modified = true;
            }
        }
    }
    if (modified) {
        factory.save(item, true);
    }
    return modified;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) EList(org.eclipse.emf.common.util.EList) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType)

Example 70 with ProxyRepositoryFactory

use of org.talend.core.repository.model.ProxyRepositoryFactory in project tdi-studio-se by Talend.

the class RenameModeParaForPigMigrationTask method renameModeName.

private void renameModeName(Item item) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    boolean modified = false;
    ProcessType processType = getProcessType(item);
    for (Object object : processType.getNode()) {
        if (object instanceof NodeType) {
            NodeType currentNode = (NodeType) object;
            if (currentNode.getComponentName().startsWith("tPigLoad")) {
                //$NON-NLS-1$
                for (Object o : currentNode.getElementParameter()) {
                    ElementParameterType para = (ElementParameterType) o;
                    if ("MODE".equals(para.getName())) {
                        //$NON-NLS-1$
                        //$NON-NLS-1$
                        para.setName("DB_VERSION");
                        if ("local".equals(para.getValue()))
                            para.setValue("pig.jar");
                        if ("mapreduce".equals(para.getValue()))
                            para.setValue("pig-withouthadoop.jar;hadoop-conf.jar;hadoop-0.20.2-core.jar");
                        modified = true;
                        break;
                    }
                }
            }
        }
    }
    if (modified) {
        try {
            factory.save(item, true);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)74 PersistenceException (org.talend.commons.exception.PersistenceException)32 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)25 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)22 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)18 EList (org.eclipse.emf.common.util.EList)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 ConnectionType (org.talend.designer.core.model.utils.emf.talendfile.ConnectionType)11 Project (org.talend.core.model.general.Project)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 BusinessException (org.talend.commons.exception.BusinessException)8 ParametersType (org.talend.designer.core.model.utils.emf.talendfile.ParametersType)8 ArrayList (java.util.ArrayList)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 Path (org.eclipse.core.runtime.Path)6 EConnectionType (org.talend.core.model.process.EConnectionType)6 ConnectionItem (org.talend.core.model.properties.ConnectionItem)6 List (java.util.List)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)5