Search in sources :

Example 6 with DQRepositoryNode

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

the class AnalysisUtils method getSelectDialogInputData.

/**
 * get Select Dialog Input Data.
 *
 * @param eResourceConstant: for select UDI dialog is EResourceConstant.USER_DEFINED_INDICATORS
 * @return DQRepositoryNode
 */
public static DQRepositoryNode getSelectDialogInputData(EResourceConstant eResourceConstant) {
    DQRepositoryNode node = new DQRepositoryNode(null, null, ENodeType.SYSTEM_FOLDER, ProjectManager.getInstance().getCurrentProject());
    node.getChildren().clear();
    if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
        IRepositoryNode librariesFolderNode = RepositoryNodeHelper.getLibrariesFolderNode(eResourceConstant);
        node.getChildren().add(librariesFolderNode);
    } else {
        java.util.Set<Project> allProjects = ProxyRepositoryManager.getInstance().getAllProjects();
        for (Project project : allProjects) {
            IRepositoryNode librariesFolderNode = RepositoryNodeHelper.getLibrariesFolderNode(eResourceConstant, project);
            node.getChildren().add(librariesFolderNode);
        }
    }
    return node;
}
Also used : Project(org.talend.core.model.general.Project) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 7 with DQRepositoryNode

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

the class AnalysisUtils method getAnalysisSelectDialogInputData.

/**
 * get Analysis Select Dialog Input Data.
 *
 * @param eResourceConstant
 * @return
 */
public static DQRepositoryNode getAnalysisSelectDialogInputData(EResourceConstant eResourceConstant) {
    DQRepositoryNode node = new DQRepositoryNode(null, null, ENodeType.SYSTEM_FOLDER, ProjectManager.getInstance().getCurrentProject());
    node.getChildren().clear();
    if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
        IRepositoryNode analysisFolderNode = RepositoryNodeHelper.getDataProfilingFolderNode(eResourceConstant);
        node.getChildren().add(analysisFolderNode);
    } else {
        java.util.Set<Project> allProjects = ProxyRepositoryManager.getInstance().getAllProjects();
        for (Project project : allProjects) {
            IRepositoryNode analysisFolderNode = RepositoryNodeHelper.getDataProfilingFolderNode(eResourceConstant, project);
            node.getChildren().add(analysisFolderNode);
        }
    }
    return node;
}
Also used : Project(org.talend.core.model.general.Project) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 8 with DQRepositoryNode

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

the class AnalysisUtils method getMetadataSelectDialogInputData.

/**
 * get Metadata Select Dialog Input Data.
 *
 * @param eResourceConstant
 * @return DQRepositoryNode
 */
public static DQRepositoryNode getMetadataSelectDialogInputData(EResourceConstant eResourceConstant) {
    DQRepositoryNode node = new DQRepositoryNode(null, null, ENodeType.SYSTEM_FOLDER, ProjectManager.getInstance().getCurrentProject());
    node.getChildren().clear();
    if (ProxyRepositoryManager.getInstance().isMergeRefProject()) {
        IRepositoryNode librariesFolderNode = RepositoryNodeHelper.getMetadataFolderNode(eResourceConstant);
        node.getChildren().add(librariesFolderNode);
    } else {
        java.util.Set<Project> allProjects = ProxyRepositoryManager.getInstance().getAllProjects();
        for (Project project : allProjects) {
            IRepositoryNode librariesFolderNode = RepositoryNodeHelper.getMetadataFolderNode(eResourceConstant, project);
            node.getChildren().add(librariesFolderNode);
        }
    }
    return node;
}
Also used : Project(org.talend.core.model.general.Project) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode)

Example 9 with DQRepositoryNode

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

the class NominalValuesDPSelectionPage method addListeners.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnAnalysisDOSelectionPage#addListeners()
     */
@Override
protected void addListeners() {
    addListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
            if (object instanceof ColumnRepNode) {
                RepositoryNode repositoryNode = (ColumnRepNode) object;
                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                // int javaSQLType = TalendTypeConvert.convertToJDBCType(column.getTalendType());
                if (Java2SqlType.isTextInSQL(javaSQLType)) {
                    advanceToNextPageOrFinish();
                } else {
                    List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                    tempList.add(columnNode);
                    setAddTextIndicator(false);
                    if (!tempList.isEmpty()) {
                        ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                        dialog.setElements(tempList.toArray());
                        // $NON-NLS-1$
                        dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                        // $NON-NLS-1$
                        dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                        dialog.setSize(80, 20);
                        dialog.create();
                        if (Window.OK == dialog.open()) {
                            // use MetadataHelper
                            for (DFColumnRepNode col : tempList) {
                                MetadataHelper.setDataminingType(DataminingType.NOMINAL, col.getMetadataColumn());
                            }
                            advanceToNextPageOrFinish();
                        }
                    }
                }
            }
        }
    });
    addListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            try {
                Object object = ((IStructuredSelection) event.getSelection()).getFirstElement();
                nodes = new ArrayList<IRepositoryNode>();
                if (object instanceof ColumnRepNode) {
                    List<IRepositoryNode> list = ((IStructuredSelection) event.getSelection()).toList();
                    nodes.addAll(list);
                    if (nodes.size() == 0 || RepNodeUtils.isValidSelectionFromSameTable(nodes)) {
                        List<DFColumnRepNode> tempList = new ArrayList<DFColumnRepNode>();
                        for (IRepositoryNode obj : nodes) {
                            if (object instanceof ColumnRepNode) {
                                RepositoryNode repositoryNode = (ColumnRepNode) obj;
                                DFColumnRepNode columnNode = new DFColumnRepNode(repositoryNode.getObject(), repositoryNode.getParent(), ENodeType.TDQ_REPOSITORY_ELEMENT, ((DQRepositoryNode) repositoryNode).getProject());
                                int javaSQLType = TalendTypeConvert.convertToJDBCType(columnNode.getMetadataColumn().getTalendType());
                                if (!Java2SqlType.isTextInSQL(javaSQLType)) {
                                    tempList.add(columnNode);
                                    setAddTextIndicator(false);
                                }
                            }
                        }
                        if (!tempList.isEmpty()) {
                            ElementListSelectionDialog dialog = new ElementListSelectionDialog(null, new DQRepositoryViewLabelProvider());
                            dialog.setElements(tempList.toArray());
                            // $NON-NLS-1$
                            dialog.setTitle(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.dataTypeWarning"));
                            // $NON-NLS-1$
                            dialog.setMessage(DefaultMessagesImpl.getString("CreateNominalAnalysisAction.string"));
                            dialog.setSize(80, 20);
                            dialog.create();
                            if (Window.OK == dialog.open()) {
                                // zqin get the column and change their datamining type to "Nominal"
                                for (DFColumnRepNode column : tempList) {
                                    MetadataHelper.setDataminingType(DataminingType.NOMINAL, column.getMetadataColumn());
                                }
                                setPageComplete(true);
                                setMessage(chooseConnStr);
                            }
                        } else {
                            setPageComplete(true);
                            setMessage(chooseConnStr);
                        }
                    } else {
                        setPageComplete(false);
                        // $NON-NLS-1$
                        setMessage(DefaultMessagesImpl.getString("ColumnAnalysisDOSelectionPage.selectColumnError1"), ERROR);
                    }
                } else {
                    setPageComplete(false);
                    setMessage(chooseConnStr);
                }
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    });
}
Also used : DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) ColumnRepNode(org.talend.dq.nodes.ColumnRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IRepositoryNode(org.talend.repository.model.IRepositoryNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ArrayList(java.util.ArrayList) List(java.util.List) DQRepositoryViewLabelProvider(org.talend.dataprofiler.core.ui.views.provider.DQRepositoryViewLabelProvider)

Example 10 with DQRepositoryNode

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

the class OpenItemEditorAction method duRun.

protected void duRun(IRepositoryNode repNode) throws BusinessException {
    // TDQ-12200: fix a NPE when the open item is unsynchronized status(for example is deleted by others).
    repositoryObjectCRUD.refreshDQViewForRemoteProject();
    // TDQ-13357: fix NPE, because for ReportFileRepNode, repNode.getObject() == null
    if (repNode.getObject() != null) {
        if (repNode.getObject().getProperty() == null) {
            repositoryObjectCRUD.showWarningDialog();
            return;
        }
        // TDQ-12771: for local, also can avoid error when the cache node is changed but not save it.
        try {
            ProxyRepositoryFactory.getInstance().reload(repNode.getObject().getProperty());
            IFile objFile = PropertyHelper.getItemFile(repNode.getObject().getProperty());
            objFile.refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (Exception e1) {
            log.error(e1, e1);
        }
    }
    // TDQ-12034~
    IEditorInput itemEditorInput = computeEditorInput(repNode, true);
    if (itemEditorInput != null) {
        // open ItemEditorInput
        CorePlugin.getDefault().openEditor(itemEditorInput, editorID);
    } else {
        // not find ItemEditorInput
        if (repNode.getObject() == null) {
            // open Report's genetated doc file
            if (repNode != null && repNode instanceof ReportFileRepNode) {
                ReportFileRepNode reportFileNode = (ReportFileRepNode) repNode;
                IPath location = Path.fromOSString(reportFileNode.getResource().getRawLocation().toOSString());
                // TDQ-5458 sizhaoliu 2012-07-17 add "." before the full name to make sure it is ignored by SVN.
                IFile latestRepIFile = ResourceManager.getRootProject().getFile(PluginConstant.DOT_STRING + location.lastSegment());
                try {
                    // TDQ-5458 sizhaoliu 2012-07-17 the link creation should be after report generation, but not at
                    // the openning.
                    // latestRepIFile.createLink(location, IResource.REPLACE, null);
                    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                    // MOD yyin 20121224 TDQ-5329, using the default editor setted by the user.
                    IDE.openEditor(page, latestRepIFile);
                } catch (PartInitException e) {
                    MessageDialog.openError(Display.getCurrent().getActiveShell(), // $NON-NLS-1$
                    Messages.getString("NewFolderWizard.failureTitle"), e.getMessage());
                    ExceptionHandler.process(e);
                }
            }
        } else {
            // if there don't found the correct ItemEditorInput and it is not Report's genetated doc file, try to
            // open it as a File, this code will not be execute when method computeEditorInput() work well
            IPath append = WorkbenchUtils.getFilePath(repNode.getObject().getRepositoryNode());
            DQRepositoryNode node = (DQRepositoryNode) repNode.getObject().getRepositoryNode();
            file = ResourceManager.getRoot().getProject(node.getProject().getTechnicalLabel()).getFile(append);
            if (!file.exists()) {
                throw ExceptionFactory.getInstance().createBusinessException(repNode.getObject());
            }
            try {
                IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), file, true);
            } catch (PartInitException e) {
                log.error(e, e);
            }
        }
    }
}
Also used : DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) IFile(org.eclipse.core.resources.IFile) ReportFileRepNode(org.talend.dq.nodes.ReportFileRepNode) IPath(org.eclipse.core.runtime.IPath) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) PartInitException(org.eclipse.ui.PartInitException) BusinessException(org.talend.commons.exception.BusinessException) PersistenceException(org.talend.commons.exception.PersistenceException) IEditorInput(org.eclipse.ui.IEditorInput)

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