Search in sources :

Example 11 with DQRepositoryNode

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

the class RepositoryNodeHelper method getRootNode.

public static RepositoryNode getRootNode(ERepositoryObjectType nodeType, boolean open, org.talend.core.model.general.Project project) {
    DQRepositoryNode node = null;
    FolderItem folderItem = ProxyRepositoryFactory.getInstance().getFolderItem(project, nodeType, Path.EMPTY);
    CommonViewer commonViewer = getDQCommonViewer(open);
    if (commonViewer != null) {
        TreeItem[] items = commonViewer.getTree().getItems();
        for (TreeItem item : items) {
            node = (DQRepositoryNode) item.getData();
            DQRepositoryNode matchNode = getMatchNode(project, node, folderItem);
            if (matchNode != null) {
                return matchNode;
            }
        }
        // $NON-NLS-1$
        log.error(Messages.getString("RepositoryNodeHelper.canNotFindRootNode") + nodeType.getLabel());
    }
    return node;
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) FolderItem(org.talend.core.model.properties.FolderItem) CommonViewer(org.eclipse.ui.navigator.CommonViewer) TreeItem(org.eclipse.swt.widgets.TreeItem)

Example 12 with DQRepositoryNode

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

the class ExportWizardPage method createRepositoryTree.

/**
 * DOC bZhou Comment method "createRepositoryTree".
 *
 * @param top
 */
protected void createRepositoryTree(Composite top) {
    Composite treeComposite = new Composite(top, SWT.NONE);
    treeComposite.setLayout(new GridLayout(2, false));
    treeComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    repositoryTree = new ContainerCheckedTreeViewer(treeComposite);
    repositoryTree.setContentProvider(new FileTreeContentProvider());
    repositoryTree.setLabelProvider(new FileTreeLabelProvider());
    repositoryTree.setInput(writer.computeInput(specifiedPath));
    repositoryTree.expandAll();
    repositoryTree.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    // ADD msjian TDQ-14573: automatically checked the initial selected items.
    if (intCheckedElements != null) {
        List<ItemRecord> selectedItemRecords = new ArrayList<ItemRecord>();
        for (Object intCheckedElement : intCheckedElements) {
            getFileFromNode(selectedItemRecords, (IRepositoryNode) intCheckedElement);
        }
        repositoryTree.setCheckedElements(selectedItemRecords.toArray());
    }
    // show the same order with repository tree
    repositoryTree.setComparator(new ViewerComparator() {

        @Override
        public int compare(Viewer iviewer, Object o1, Object o2) {
            DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((ItemRecord) o1).getElement());
            DQRepositoryNode recursiveFind2 = RepositoryNodeHelper.recursiveFind(((ItemRecord) o2).getElement());
            return new RepositoryNodeComparator().compare(recursiveFind, recursiveFind2);
        }
    });
    // TDQ-14573~
    createUtilityButtons(treeComposite);
}
Also used : RepositoryNodeComparator(org.talend.dq.helper.RepositoryNodeComparator) Composite(org.eclipse.swt.widgets.Composite) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) ArrayList(java.util.ArrayList) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) GridData(org.eclipse.swt.layout.GridData) ItemRecord(org.talend.dataprofiler.core.ui.imex.model.ItemRecord) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer)

Example 13 with DQRepositoryNode

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

the class AnalysisWriter method addDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
     */
@Override
public void addDependencies(ModelElement element) {
    Analysis analysis = (Analysis) element;
    List<IndicatorDefinition> udis = AnalysisHelper.getUserDefinedIndicators(analysis);
    try {
        for (IndicatorDefinition udi : udis) {
            if (udi == null) {
                continue;
            }
            InternalEObject iudi = (InternalEObject) udi;
            if (!iudi.eIsProxy()) {
                DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(udi);
                // only do save when the dependency is not reference project node
                if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
                    TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, udi);
                    if (dependencyReturn.isOk()) {
                        Property property = PropertyHelper.getProperty(udi);
                        if (property != null) {
                            TDQItem udiItem = (TDQItem) property.getItem();
                            if (udiItem instanceof TDQIndicatorDefinitionItem) {
                                ((TDQIndicatorDefinitionItem) udiItem).setIndicatorDefinition(udi);
                            } else if (udiItem instanceof TDQBusinessRuleItem) {
                                ((TDQBusinessRuleItem) udiItem).setDqrule((DQRule) udi);
                            }
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
                    }
                }
            }
        }
        List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
        for (Pattern pattern : patterns) {
            InternalEObject iptn = (InternalEObject) pattern;
            if (!iptn.eIsProxy()) {
                DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
                // only do save when the dependency is not reference project node
                if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
                    TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
                    if (dependencyReturn.isOk()) {
                        Property property = PropertyHelper.getProperty(pattern);
                        if (property != null && property.getItem() instanceof TDQPatternItem) {
                            TDQPatternItem patternItem = (TDQPatternItem) property.getItem();
                            patternItem.setPattern(pattern);
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
                    // EMFUtil.saveSingleResource(pattern.eResource());
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        log.error(e, e);
    }
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Dependency(orgomg.cwm.objectmodel.core.Dependency) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) Analysis(org.talend.dataquality.analysis.Analysis) PersistenceException(org.talend.commons.exception.PersistenceException) TDQItem(org.talend.core.model.properties.TDQItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) Property(org.talend.core.model.properties.Property) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 14 with DQRepositoryNode

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

the class DQRespositoryView method createPartControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse .swt.widgets.Composite)
     */
@Override
public void createPartControl(Composite parent) {
    parent.setLayout(new BorderLayout());
    Composite topComp = new Composite(parent, SWT.NONE);
    topComp.setFont(parent.getFont());
    topComp.setLayoutData(BorderLayout.NORTH);
    Composite bottomComp = new Composite(parent, SWT.NONE);
    bottomComp.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    bottomComp.setFont(parent.getFont());
    bottomComp.setLayoutData(BorderLayout.CENTER);
    topComp.setLayout(new BorderLayout());
    FillLayout bottomLayout = new FillLayout(SWT.VERTICAL);
    bottomComp.setLayout(bottomLayout);
    createTreeFilter(topComp);
    super.createPartControl(bottomComp);
    // For removing the popup menu of DQRepositoryView.
    // $NON-NLS-1$
    MenuManager menuMgr = new MenuManager("org.talend.dataprofiler.core.ui.views.DQRespositoryView");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager menuManager) {
            ISelection selection = getCommonViewer().getSelection();
            getNavigatorActionService().setContext(new ActionContext(selection));
            getNavigatorActionService().fillContextMenu(menuManager);
        }
    });
    Menu menu = menuMgr.createContextMenu(getCommonViewer().getTree());
    getCommonViewer().getTree().setMenu(menu);
    this.addViewerFilter(EMFObjFilter.FILTER_ID);
    this.addViewerFilter(ReportingFilter.FILTER_ID);
    this.addViewerFilter(FolderObjFilter.FILTER_ID);
    adjustFilter();
    activateContext();
    getCommonViewer().setSorter(null);
    getCommonViewer().getTree().addTreeListener(new TreeAdapter() {

        @Override
        public void treeExpanded(TreeEvent e) {
            TreeItem item = (TreeItem) e.item;
            if (!item.getText().endsWith(")")) {
                // $NON-NLS-1$
                Object obj = item.getData();
                if (obj instanceof TableFolderNode || obj instanceof ViewFolderNode || obj instanceof ColumnFolderNode) {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    item.setText(item.getText() + "(" + item.getItemCount() + ")");
                }
            }
            super.treeExpanded(e);
        }
    });
    getCommonViewer().getTree().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(MouseEvent e) {
            boolean superDoubleClick = true;
            Tree tree = (Tree) e.getSource();
            Point point = new Point(e.x, e.y);
            final TreeItem item = tree.getItem(point);
            if (item != null) {
                Object obj = item.getData();
                if (obj instanceof AbstractFolderNode) {
                    AbstractFolderNode node = (AbstractFolderNode) obj;
                    node.loadChildren();
                    Object[] children = node.getChildren();
                    if (children != null) {
                        if (item.getText().indexOf("(") > 0) {
                            // $NON-NLS-1$
                            item.setText(// $NON-NLS-1$ //$NON-NLS-2$
                            item.getText().substring(0, item.getText().indexOf("(")) + "(" + children.length + // $NON-NLS-1$
                            ")");
                        } else {
                            // $NON-NLS-1$ //$NON-NLS-2$
                            item.setText(item.getText() + "(" + children.length + ")");
                        }
                    }
                }
                if (obj instanceof IndicatorDefinition) {
                    IndicatorDefinition indicatorDefinition = (IndicatorDefinition) obj;
                    // reload object
                    indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(indicatorDefinition.getLabel());
                    IndicatorEditorInput input = new IndicatorEditorInput(indicatorDefinition);
                    try {
                        CorePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, IndicatorEditor.class.getName());
                    } catch (PartInitException e1) {
                        log.error(e1, e1);
                    }
                }
                if (obj instanceof DQRepositoryNode) {
                    if (obj instanceof ReportFileRepNode) {
                        new OpenItemEditorAction(new IRepositoryNode[] { (IRepositoryNode) obj }).run();
                    } else if (obj instanceof DFConnectionRepNode) {
                        new EditFileDelimitedAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof HadoopClusterConnectionRepNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                        new EditHadoopClusterAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof HDFSOfHCConnectionNode && HadoopClusterUtils.getDefault().isServiceInstalled()) {
                        new EditHDFSConnectionAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof DFTableRepNode) {
                        new EditDFTableAction((IRepositoryNode) obj).run();
                    } else if (obj instanceof ContextRepNode) {
                        new DQEditContextAction((ContextRepNode) obj, false).run();
                    } else {
                        DQRepositoryNode repoNode = (DQRepositoryNode) obj;
                        if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
                            OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
                            openItemEditorAction.run();
                        }
                        if (repoNode instanceof AnalysisRepNode || repoNode instanceof ReportRepNode || repoNode instanceof SysIndicatorDefinitionRepNode || repoNode instanceof PatternRepNode || repoNode instanceof RuleRepNode) {
                            superDoubleClick = false;
                        }
                    }
                }
            }
            if (superDoubleClick) {
                super.mouseDoubleClick(e);
            }
        }
    });
    getCommonViewer().getTree().addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
                Tree tree = (Tree) e.getSource();
                TreeItem[] selection = tree.getSelection();
                for (TreeItem item : selection) {
                    Object data = item.getData();
                    DQRepositoryNode repoNode = (DQRepositoryNode) data;
                    if (RepositoryNodeHelper.canOpenEditor(repoNode)) {
                        OpenItemEditorAction openItemEditorAction = new OpenItemEditorAction(new IRepositoryNode[] { repoNode });
                        openItemEditorAction.run();
                    }
                }
            }
        }

        public void keyReleased(KeyEvent e) {
        // do nothing here until now
        }
    });
    // ~ADD mzhao for feature 6233 Load columns when selecting a table (or
    // view) in DQ Repository view
    getCommonViewer().addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            TreeSelection selection = (TreeSelection) event.getSelection();
            Iterator<?> iterator = selection.iterator();
            while (iterator.hasNext()) {
                Object selectedElement = iterator.next();
                if (selectedElement instanceof DBTableRepNode || selectedElement instanceof DBViewRepNode) {
                    ((RepositoryNode) selectedElement).getChildren().get(0).getChildren();
                }
            }
        }
    });
    // MOD mzhao 2011-03-10 bug 19147: filter MDM entries.
    getCommonViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (element instanceof IProject) {
                return false;
            }
            return true;
        }
    });
// ~
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) HDFSOfHCConnectionNode(org.talend.dq.nodes.hadoopcluster.HDFSOfHCConnectionNode) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ColumnViewer(org.eclipse.jface.viewers.ColumnViewer) Viewer(org.eclipse.jface.viewers.Viewer) TreeAdapter(org.eclipse.swt.events.TreeAdapter) TableFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.TableFolderNode) TreeEvent(org.eclipse.swt.events.TreeEvent) IndicatorEditorInput(org.talend.dataprofiler.core.ui.editor.indicator.IndicatorEditorInput) ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) BorderLayout(org.talend.dataprofiler.core.ui.views.layout.BorderLayout) ReportRepNode(org.talend.dq.nodes.ReportRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Tree(org.eclipse.swt.widgets.Tree) PatternRepNode(org.talend.dq.nodes.PatternRepNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FillLayout(org.eclipse.swt.layout.FillLayout) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction) ViewFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.ViewFolderNode) DQEditContextAction(org.talend.dataprofiler.core.ui.action.actions.DQEditContextAction) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) ColumnFolderNode(org.talend.dataprofiler.core.model.nodes.foldernode.ColumnFolderNode) EditDFTableAction(org.talend.dataprofiler.core.ui.action.actions.EditDFTableAction) AbstractViewerFilter(org.talend.dataprofiler.core.ui.filters.AbstractViewerFilter) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) AbstractFolderNode(org.talend.dq.nodes.foldernode.AbstractFolderNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) KeyEvent(org.eclipse.swt.events.KeyEvent) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ISelection(org.eclipse.jface.viewers.ISelection) EditHDFSConnectionAction(org.talend.dataprofiler.core.ui.action.actions.EditHDFSConnectionAction) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) Iterator(java.util.Iterator) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) Menu(org.eclipse.swt.widgets.Menu) PartInitException(org.eclipse.ui.PartInitException) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) MouseEvent(org.eclipse.swt.events.MouseEvent) Composite(org.eclipse.swt.widgets.Composite) IRepositoryNode(org.talend.repository.model.IRepositoryNode) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Point(org.eclipse.swt.graphics.Point) ActionContext(org.eclipse.ui.actions.ActionContext) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IMenuListener(org.eclipse.jface.action.IMenuListener) IProject(org.eclipse.core.resources.IProject) EditFileDelimitedAction(org.talend.dataprofiler.core.ui.action.actions.EditFileDelimitedAction) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) EditHadoopClusterAction(org.talend.dataprofiler.core.ui.action.actions.EditHadoopClusterAction) KeyListener(org.eclipse.swt.events.KeyListener) IMenuManager(org.eclipse.jface.action.IMenuManager) HadoopClusterConnectionRepNode(org.talend.dq.nodes.hadoopcluster.HadoopClusterConnectionRepNode) ContextRepNode(org.talend.dq.nodes.ContextRepNode)

Example 15 with DQRepositoryNode

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

the class ResourceViewContentProvider method handleReferenced.

@SuppressWarnings("unchecked")
private void handleReferenced(RepositoryNode parent) {
    Project currentProject = ((DQRepositoryNode) parent).getProject();
    if (parent.getType().equals(ENodeType.SYSTEM_FOLDER)) {
        for (ProjectReference refProject : (List<ProjectReference>) currentProject.getEmfProject().getReferencedProjects()) {
            String parentBranch = ProjectManager.getInstance().getMainProjectBranch(currentProject);
            // if not a DB ref project, modified by nma, order 12519
            org.talend.core.model.properties.Project emfProject = refProject.getReferencedProject();
            if (// $NON-NLS-1$
            emfProject.getUrl() != null && emfProject.getUrl().startsWith("teneo") || (refProject.getBranch() != null && refProject.getBranch().equals(parentBranch))) {
                DQRepositoryNode referencedProjectNode = new DQRepositoryNode(null, parent, ENodeType.REFERENCED_PROJECT, currentProject);
                referencedProjectNode.setProperties(EProperties.LABEL, emfProject.getLabel());
                referencedProjectNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.REFERENCED_PROJECTS);
                parent.getChildren().add(referencedProjectNode);
                try {
                    // org.talend.core.model.general.Project refGeneralProject = new
                    // org.talend.core.model.general.Project(
                    // emfProject, false);
                    Object[] createWorkspaceRootChildren = createWorkspaceRootChildren(ResourceManager.getRoot(), emfProject.getTechnicalLabel());
                    referencedProjectNode.getChildren().addAll((Collection<? extends IRepositoryNode>) Arrays.asList(createWorkspaceRootChildren));
                } catch (CoreException e) {
                    log.error(e, e);
                }
            }
        }
    }
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ProjectReference(org.talend.core.model.properties.ProjectReference) CoreException(org.eclipse.core.runtime.CoreException) List(java.util.List) ArrayList(java.util.ArrayList) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)24 IRepositoryNode (org.talend.repository.model.IRepositoryNode)11 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)8 ArrayList (java.util.ArrayList)7 Project (org.talend.core.model.general.Project)5 IPath (org.eclipse.core.runtime.IPath)4 Connection (org.talend.core.model.metadata.builder.connection.Connection)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 List (java.util.List)3 IProject (org.eclipse.core.resources.IProject)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 IEditorInput (org.eclipse.ui.IEditorInput)3 Item (org.talend.core.model.properties.Item)3 MetadataColumnRepositoryObject (org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject)3 TdTable (org.talend.cwm.relational.TdTable)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)3 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)3 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)3