Search in sources :

Example 1 with RecycleBinRepNode

use of org.talend.dq.nodes.RecycleBinRepNode in project tdq-studio-se by Talend.

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 2 with RecycleBinRepNode

use of org.talend.dq.nodes.RecycleBinRepNode in project tdq-studio-se by Talend.

the class DQRepositoryViewLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    Image image = super.getImage(element);
    if (element instanceof IRepositoryNode) {
        IRepositoryNode node = (IRepositoryNode) element;
        if (node instanceof ReportAnalysisRepNode) {
            image = ImageLib.getImage(ImageLib.ANALYSIS_OBJECT);
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            image = ImageLib.getImage(ImageLib.EXCHANGE);
        } else if (node instanceof RecycleBinRepNode) {
            image = ImageLib.getImage(ImageLib.RECYCLEBIN_EMPTY);
        } else {
            IRepositoryViewObject viewObject = node.getObject();
            ENodeType type = node.getType();
            if (type.equals(ENodeType.SYSTEM_FOLDER)) {
                if (EResourceConstant.REFERENCED_PROJECT.getName().equals(node.getProperties(EProperties.LABEL))) {
                    image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
                } else {
                    String label = viewObject.getLabel();
                    if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
                        image = ImageLib.getImage(ImageLib.DATA_PROFILING);
                    } else if (label.equals(EResourceConstant.METADATA.getName())) {
                        image = ImageLib.getImage(ImageLib.METADATA);
                    } else if (node instanceof DBConnectionFolderRepNode) {
                        image = ImageLib.getImage(ImageLib.CONNECTION);
                    } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
                        image = ImageLib.getImage(ImageLib.FILE_DELIMITED);
                    } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
                        image = ImageLib.getImage(ImageLib.LIBRARIES);
                    } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
                        image = ImageLib.getImage(ImageLib.EXCHANGE);
                    } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
                        image = ImageLib.getImage(ImageLib.HADOOP_CLUSTER);
                    } else if (label.equals(EResourceConstant.CONTEXT.getName())) {
                        image = ImageLib.getImage(ImageLib.CONTEXT);
                    } else {
                        image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                    }
                }
            } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
                image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
            } else if (type.equals(ENodeType.REFERENCED_PROJECT)) {
                image = ImageLib.getImage(ImageLib.REFERENCED_PROJECT);
            } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
                // TDQ-7560 when the image is a overlay image,use originalImageName to get the corresponding one.
                String originalImageName = null;
                if (node instanceof DBConnectionRepNode) {
                    originalImageName = ImageLib.TD_DATAPROVIDER;
                    if (!RepositoryNodeHelper.isSupportedConnection(node) || isNeedAddDriverConnection(node)) {
                        image = ImageLib.createErrorIcon(originalImageName);
                    } else if (isInvalidJDBCConnection(node)) {
                        image = ImageLib.createInvalidIcon(originalImageName);
                    } else {
                        image = ImageLib.getImage(originalImageName);
                    }
                } else if (node instanceof DFConnectionRepNode) {
                    originalImageName = ImageLib.FILE_DELIMITED;
                } else if (node instanceof AnalysisRepNode) {
                    originalImageName = ImageLib.ANALYSIS_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof ReportRepNode) {
                    originalImageName = ImageLib.REPORT_OBJECT;
                    image = addWarnIconIfNeeded(node, originalImageName);
                } else if (node instanceof SysIndicatorDefinitionRepNode) {
                    originalImageName = ImageLib.IND_DEFINITION;
                } else if (node instanceof PatternRepNode) {
                    originalImageName = ImageLib.PATTERN_REG;
                } else if (node instanceof RuleRepNode) {
                    if (((RuleRepNode) node).getRule() instanceof MatchRuleDefinition) {
                        originalImageName = ImageLib.MATCH_RULE_ICON;
                    } else {
                        originalImageName = ImageLib.DQ_RULE;
                    }
                } else if (node instanceof SourceFileRepNode) {
                    originalImageName = ImageLib.SOURCE_FILE;
                } else if (node instanceof HadoopClusterConnectionRepNode) {
                    originalImageName = ImageLib.HADOOP_CLUSTER;
                } else if (node instanceof HDFSOfHCConnectionNode) {
                    originalImageName = ImageLib.HDFS;
                } else if (node instanceof HiveOfHCConnectionNode) {
                    originalImageName = ImageLib.HIVE_LINK;
                } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
                    originalImageName = ImageLib.EXCHANGE;
                } else if (node instanceof ContextRepNode) {
                    originalImageName = ImageLib.CONTEXT;
                } else if (node instanceof RepositoryNode) {
                    // MOD qiongli 2011-1-18 get image for nodes in recycle bin
                    Image imageNode = getImageByContentType((RepositoryNode) node);
                    if (image != null) {
                        image = imageNode;
                    }
                }
                if (originalImageName != null && !(node instanceof DBConnectionRepNode || node instanceof AnalysisRepNode || node instanceof ReportRepNode)) {
                    image = ImageLib.getImage(originalImageName);
                }
                // exchange folder did not contain viewObject.
                if (viewObject != null) {
                    // MOD yyi 2011-04-07 19696: "Lock element"
                    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(viewObject);
                    Context ctx = CoreRuntimePlugin.getInstance().getContext();
                    RepositoryContext rc = (RepositoryContext) ctx.getProperty(Context.REPOSITORY_CONTEXT_KEY);
                    // will be enhanced later by TDI-29265.
                    if (rc.isEditableAsReadOnly()) {
                        if (status == ERepositoryStatus.LOCK_BY_USER) {
                            status = ERepositoryStatus.DEFAULT;
                        }
                    }
                    if (ERepositoryStatus.DEFAULT != status && originalImageName != null) {
                        if (ERepositoryStatus.LOCK_BY_USER == status) {
                            image = ImageLib.createLockedByOwnIcon(originalImageName);
                        } else if (ERepositoryStatus.LOCK_BY_OTHER == status) {
                            image = ImageLib.createLockedByOtherIcon(originalImageName);
                        }
                    }
                }
            } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
                if (node instanceof DBCatalogRepNode) {
                    image = ImageLib.getImage(ImageLib.CATALOG);
                } else if (node instanceof DBSchemaRepNode) {
                    image = ImageLib.getImage(ImageLib.SCHEMA);
                } else if (node instanceof DBTableFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBViewFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
                    image = ImageLib.getImage(ImageLib.TABLE);
                } else if (node instanceof DBViewRepNode) {
                    image = ImageLib.getImage(ImageLib.VIEW);
                } else if (node instanceof DBColumnRepNode) {
                    if (((DBColumnRepNode) node).isKey()) {
                        image = ImageLib.getImage(ImageLib.PK_COLUMN);
                    } else {
                        image = ImageLib.getImage(ImageLib.TD_COLUMN);
                    }
                } else if (node instanceof DFColumnRepNode) {
                    image = ImageLib.getImage(ImageLib.TD_COLUMN);
                } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
                    image = ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
                } else if (node instanceof JrxmlTempleteRepNode) {
                    image = ImageLib.getImage(ImageLib.JRXML_ICON);
                }
            }
        }
    }
    return image;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryContext(org.talend.core.context.RepositoryContext) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) Image(org.eclipse.swt.graphics.Image) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Context(org.talend.core.context.Context) RepositoryContext(org.talend.core.context.RepositoryContext) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) HiveOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HiveOfHCConnectionNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Example 3 with RecycleBinRepNode

use of org.talend.dq.nodes.RecycleBinRepNode in project tdq-studio-se by Talend.

the class DQRepositoryViewLabelProvider method getForeground.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider#getForeground(java.lang.Object)
     */
@Override
public Color getForeground(Object element) {
    RepositoryNode node = (RepositoryNode) element;
    if (node instanceof RecycleBinRepNode) {
        return super.getForeground(element);
    }
    if (node.getObject() != null) {
        switch(node.getType()) {
            case REFERENCED_PROJECT:
                return STABLE_PRIMARY_ENTRY_COLOR;
            case STABLE_SYSTEM_FOLDER:
            case SYSTEM_FOLDER:
                if (node.getContentType() == ERepositoryObjectType.TDQ_DATA_PROFILING || node.getContentType() == ERepositoryObjectType.METADATA || node.getContentType() == ERepositoryObjectType.TDQ_SYSTEM_INDICATORS || node.getContentType() == ERepositoryObjectType.TDQ_PATTERN_REGEX) {
                    return STABLE_PRIMARY_ENTRY_COLOR;
                }
                return STABLE_SECONDARY_ENTRY_COLOR;
            default:
                ERepositoryStatus repositoryStatus = node.getObject().getRepositoryStatus();
                if (repositoryStatus == ERepositoryStatus.LOCK_BY_OTHER) {
                    return LOCKED_ENTRY;
                }
                if (org.talend.core.PluginChecker.isRefProjectLoaded()) {
                    IReferencedProjectService service = (IReferencedProjectService) GlobalServiceRegister.getDefault().getService(IReferencedProjectService.class);
                    if (service != null && service.isMergeRefProject()) {
                        IRepositoryViewObject object = node.getObject();
                        if (object != null) {
                            org.talend.core.model.properties.Project mainProject = ProjectManager.getInstance().getCurrentProject().getEmfProject();
                            String projectLabel = object.getProjectLabel();
                            if (!mainProject.getLabel().equals(projectLabel)) {
                                return MERGED_REFERENCED_ITEMS_COLOR;
                            }
                        }
                    }
                }
        }
    }
    return super.getForeground(element);
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IReferencedProjectService(org.talend.core.ui.IReferencedProjectService) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode)

Example 4 with RecycleBinRepNode

use of org.talend.dq.nodes.RecycleBinRepNode in project tdq-studio-se by Talend.

the class ResourceViewContentProvider method createWorkspaceRootChildren.

/**
 * DOC talend Comment method "getWorkspaceRootChildren".
 *
 * @param element
 * @return
 * @throws CoreException
 */
private Object[] createWorkspaceRootChildren(Object element, String projectTechnicalLabel) throws CoreException {
    Project inWhichProject = ProxyRepositoryManager.getInstance().getProjectFromProjectTechnicalLabel(projectTechnicalLabel);
    Object currentOpenProject = null;
    for (Object child : super.getChildren(element)) {
        if (child instanceof IProject) {
            if (((IProject) child).getName().equals(projectTechnicalLabel)) {
                currentOpenProject = child;
                break;
            }
        }
    }
    List<Object> folders = new ArrayList<Object>();
    Object[] rootFolders = new Object[0];
    if (currentOpenProject != null) {
        rootFolders = ((IProject) currentOpenProject).members(false);
        for (Object folder : rootFolders) {
            IRepositoryNode node = null;
            // TDQ_XXX node on the DQRepository view
            if (folder instanceof IFolder && ((IFolder) folder).getName().startsWith(RepositoryNodeHelper.PREFIX_TDQ)) {
                IFolder iFolder = (IFolder) folder;
                if (((IFolder) folder).getName().trim().equals("TDQ_reporting_db")) {
                    // $NON-NLS-1$
                    continue;
                }
                IPath relativePath = iFolder.getFullPath().makeRelativeTo(((IProject) currentOpenProject).getFullPath());
                ERepositoryObjectType respositoryObjectType = RepositoryNodeBuilder.getInstance().retrieveRepObjectTypeByPath(relativePath.toOSString());
                node = createNewRepNode(respositoryObjectType, inWhichProject);
            }
            // MOD mzhao for metadata folder
            if (folder instanceof IFolder) {
                String folderName = ((IFolder) folder).getName();
                if (EResourceConstant.METADATA.getName().equals(folderName)) {
                    node = createNewRepNode(ERepositoryObjectType.METADATA, inWhichProject);
                } else if (PluginChecker.isTDQLoaded() && EResourceConstant.CONTEXT.getName().equals(folderName)) {
                    node = createNewRepNode(ERepositoryObjectType.CONTEXT, inWhichProject);
                }
            }
            if (node != null) {
                folders.add(node);
            }
        }
    }
    // add msjian TDQ-10386: Recycle Bin should remove form Referenced project
    if (inWhichProject.isMainProject()) {
        // add RecycleBinRepNode
        RecycleBinRepNode recycleBin = new RecycleBinRepNode(DefaultMessagesImpl.getString("RecycleBin.resBinName"), // $NON-NLS-1$
        inWhichProject);
        folders.add(recycleBin);
    }
    // Reference Projects
    if (org.talend.core.PluginChecker.isRefProjectLoaded() && inWhichProject.getEmfProject() != null && inWhichProject.getEmfProject().getReferencedProjects().size() > 0) {
        if (!ProxyRepositoryManager.getInstance().isMergeRefProject()) {
            DQRepositoryNode refProjectNode = createNewRepNode(ERepositoryObjectType.REFERENCED_PROJECTS, inWhichProject);
            refProjectNode.setProperties(EProperties.LABEL, ERepositoryObjectType.REFERENCED_PROJECTS.getLabel());
            refProjectNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.REFERENCED_PROJECTS);
            folders.add(refProjectNode);
            // create children for referenced project node
            handleReferenced(refProjectNode);
        }
    }
    return folders.toArray();
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with RecycleBinRepNode

use of org.talend.dq.nodes.RecycleBinRepNode in project tdq-studio-se by Talend.

the class OpenItemEditorAction method computeEditorInput.

/**
 * get the ItemEditorInput according to the repNode, if there no ItemEditorInput return null.
 *
 * @param repNode
 * @param isOpenItemEditorAction
 * @return IEditorInput
 * @throws PersistenceException
 */
public IEditorInput computeEditorInput(IRepositoryNode repNode, boolean isOpenItemEditorAction) throws BusinessException {
    // TDQ-12499 msjian add : when click the node under recyclebin, no need to find a EditorInput
    if (repNode != null && !isOpenItemEditorAction) {
        IRepositoryNode currentNode = repNode;
        do {
            RepositoryNode parentNode = currentNode.getParent();
            if (parentNode != null && parentNode instanceof RecycleBinRepNode) {
                return null;
            }
            currentNode = parentNode;
        } while (currentNode != null);
    }
    // TDQ-12499~
    IEditorInput result = null;
    IRepositoryViewObject repViewObj = repNode.getObject();
    if (repViewObj != null) {
        // Connection editor
        String key = repViewObj.getRepositoryObjectType().getKey();
        Item item = repViewObj.getProperty().getItem();
        if (item instanceof TDQItem && !(item instanceof TDQFileItem)) {
            ModelElement modelElement = PropertyHelper.getModelElement(repViewObj.getProperty());
            if (modelElement.eIsProxy() && repNode != null) {
                modelElement = (ModelElement) EObjectHelper.resolveObject(modelElement);
                item = repViewObj.getProperty().getItem();
            }
            if (modelElement == null || modelElement.eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(((TDQItem) item).getFilename());
            }
        }
        if (ERepositoryObjectType.METADATA_CONNECTIONS.getKey().equals(key) || ConnectionUtils.isTcompJdbc(key)) {
            result = new ConnectionItemEditorInput(repNode);
            Connection connection = ((ConnectionItem) item).getConnection();
            if (connection == null || connection.getDataPackage().size() == 0) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            editorID = ConnectionEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT.getKey().equals(key)) {
            result = new AnalysisItemEditorInput(repNode);
            Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
            if (analysis == null || analysis.getContext() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            EList<ModelElement> analysedElements = analysis.getContext().getAnalysedElements();
            RepositoryNode connectionRepositoryNode = null;
            if (!analysedElements.isEmpty()) {
                Connection connection = null;
                ModelElement modelElement = analysedElements.get(0);
                if (modelElement instanceof Connection) {
                    connection = (Connection) modelElement;
                } else if (modelElement instanceof Catalog) {
                    Catalog catalog = SwitchHelpers.CATALOG_SWITCH.caseCatalog((Catalog) modelElement);
                    connection = ConnectionHelper.getConnection(catalog);
                } else if (modelElement instanceof Schema) {
                    Schema schema = SwitchHelpers.SCHEMA_SWITCH.caseSchema((Schema) modelElement);
                    if (schema != null) {
                        connection = ConnectionHelper.getConnection(schema);
                    }
                } else if (modelElement instanceof TdTable) {
                    TdTable tdTable = SwitchHelpers.TABLE_SWITCH.caseTdTable((TdTable) modelElement);
                    connection = ConnectionHelper.getConnection(tdTable);
                } else if (modelElement instanceof TdView) {
                    TdView tdView = SwitchHelpers.VIEW_SWITCH.caseTdView((TdView) modelElement);
                    connection = ConnectionHelper.getConnection(tdView);
                } else if (modelElement instanceof TdColumn) {
                    TdColumn tdColumn = SwitchHelpers.COLUMN_SWITCH.caseTdColumn((TdColumn) modelElement);
                    connection = ConnectionHelper.getConnection(tdColumn);
                } else if (modelElement instanceof MetadataColumn) {
                    MetadataColumn mColumn = SwitchHelpers.METADATA_COLUMN_SWITCH.doSwitch(modelElement);
                    connection = ConnectionHelper.getTdDataProvider(mColumn);
                }
                connectionRepositoryNode = RepositoryNodeHelper.recursiveFind(connection);
            }
            ((AnalysisItemEditorInput) result).setConnectionNode(connectionRepositoryNode);
            if (analysis.getParameters() != null && analysis.getParameters().getAnalysisType().equals(AnalysisType.MATCH_ANALYSIS)) {
                editorID = MatchAnalysisEditor.class.getName();
            } else {
                editorID = AnalysisEditor.class.getName();
            }
        } else if (ERepositoryObjectType.TDQ_INDICATOR_ELEMENT.getKey().equals(key)) {
            result = new IndicatorDefinitionItemEditorInput(repNode);
            TDQIndicatorDefinitionItem definitionItem = (TDQIndicatorDefinitionItem) item;
            if (definitionItem.getIndicatorDefinition().eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
            }
            if (UDIHelper.getUDICategory(definitionItem.getIndicatorDefinition()) == null) {
                throw ExceptionFactory.getInstance().createBusinessException(definitionItem.getFilename());
            }
            editorID = IndicatorEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_RULES_SQL.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_PARSER.getKey().equals(key) || ERepositoryObjectType.TDQ_RULES_MATCHER.getKey().equals(key)) {
            result = new BusinessRuleItemEditorInput(repNode);
            editorID = DQRuleEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_PATTERN_ELEMENT.getKey().equals(key)) {
            result = new PatternItemEditorInput(repNode);
            TDQPatternItem patternItem = (TDQPatternItem) item;
            if (patternItem.getPattern() == null || patternItem.getPattern().eResource() == null) {
                throw ExceptionFactory.getInstance().createBusinessException(patternItem.getFilename());
            }
            editorID = PatternEditor.class.getName();
        } else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT.getKey().equals(key)) {
            result = new ReportItemEditorInput(repNode);
            TDQReportItem reportItem = (TDQReportItem) item;
            if (!(reportItem.getReport() instanceof TdReport)) {
                throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
            }
            for (AnalysisMap anaMap : ((TdReport) reportItem.getReport()).getAnalysisMap()) {
                Analysis analysis = anaMap.getAnalysis();
                if (analysis.eResource() == null) {
                    throw ExceptionFactory.getInstance().createBusinessException(reportItem.getFilename());
                }
            }
            // $NON-NLS-1$
            editorID = "org.talend.dataprofiler.core.tdq.ui.editor.report.ReportEditror";
        } else if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key)) {
            IPath append = WorkbenchUtils.getFilePath(repViewObj.getRepositoryNode());
            DQRepositoryNode node = (DQRepositoryNode) repViewObj.getRepositoryNode();
            file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
            if (!file.exists()) {
                throw ExceptionFactory.getInstance().createBusinessException(repViewObj);
            }
            if (ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
                editorID = SqlExplorerUtils.SQLEDITOR_ID;
            } else {
                editorID = TDQFileEditorInput.DEFAULT_EDITOR_ID;
            }
            result = new TDQFileEditorInput(file);
            // Added TDQ-7143 yyin 20130531
            ((TDQFileEditorInput) result).setFileItem(item);
            CorePlugin.getDefault().refreshDQView(repNode);
        // ~
        }
        // ADD msjian TDQ-4209 2012-2-7 : return the editorInput of *.jrxml and *.sql files
        if (!isOpenItemEditorAction) {
            if (ERepositoryObjectType.TDQ_JRAXML_ELEMENT.getKey().equals(key) || ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT.getKey().equals(key)) {
                // if there don't found the correct ItemEditorInput, try to open it as a File
                result = new FileEditorInput(file);
                editorID = FileEditorInput.class.getName();
            }
        }
    // TDQ-4209~
    }
    return result;
}
Also used : TDQFileItem(org.talend.dataquality.properties.TDQFileItem) ConnectionEditor(org.talend.dataprofiler.core.ui.editor.connection.ConnectionEditor) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) BusinessRuleItemEditorInput(org.talend.dataprofiler.core.ui.editor.dqrules.BusinessRuleItemEditorInput) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQItem(org.talend.core.model.properties.TDQItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQFileItem(org.talend.dataquality.properties.TDQFileItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) MetadataColumn(org.talend.core.model.metadata.builder.connection.MetadataColumn) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) TdView(org.talend.cwm.relational.TdView) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) TDQFileEditorInput(org.talend.dataprofiler.core.ui.editor.TDQFileEditorInput) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ReportItemEditorInput(org.talend.dataprofiler.core.ui.editor.report.ReportItemEditorInput) ConnectionItemEditorInput(org.talend.dataprofiler.core.ui.editor.connection.ConnectionItemEditorInput) TdTable(org.talend.cwm.relational.TdTable) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IPath(org.eclipse.core.runtime.IPath) TdReport(org.talend.dataquality.reports.TdReport) Connection(org.talend.core.model.metadata.builder.connection.Connection) PatternItemEditorInput(org.talend.dataprofiler.core.ui.editor.pattern.PatternItemEditorInput) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) Catalog(orgomg.cwm.resource.relational.Catalog) EList(org.eclipse.emf.common.util.EList) TdColumn(org.talend.cwm.relational.TdColumn) PatternEditor(org.talend.dataprofiler.core.ui.editor.pattern.PatternEditor) Analysis(org.talend.dataquality.analysis.Analysis) IndicatorEditor(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorEditor) TDQFileEditorInput(org.talend.dataprofiler.core.ui.editor.TDQFileEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TDQItem(org.talend.core.model.properties.TDQItem) IndicatorDefinitionItemEditorInput(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorDefinitionItemEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Aggregations

IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 RecycleBinRepNode (org.talend.dq.nodes.RecycleBinRepNode)5 IRepositoryNode (org.talend.repository.model.IRepositoryNode)4 RepositoryNode (org.talend.repository.model.RepositoryNode)3 IPath (org.eclipse.core.runtime.IPath)2 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)2 ExchangeCategoryRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode)2 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)2 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)2 ArrayList (java.util.ArrayList)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 EList (org.eclipse.emf.common.util.EList)1 Image (org.eclipse.swt.graphics.Image)1 IEditorInput (org.eclipse.ui.IEditorInput)1 FileEditorInput (org.eclipse.ui.part.FileEditorInput)1 Context (org.talend.core.context.Context)1 RepositoryContext (org.talend.core.context.RepositoryContext)1 Project (org.talend.core.model.general.Project)1 Connection (org.talend.core.model.metadata.builder.connection.Connection)1