Search in sources :

Example 1 with ReportRepNode

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

the class OpenItemEditorProvider method fillContextMenu.

@Override
public void fillContextMenu(IMenuManager menu) {
    if (!isSelectionSameType()) {
        return;
    }
    Object[] array = ((TreeSelection) this.getContext().getSelection()).toArray();
    List<IRepositoryNode> selectedItemsList = new ArrayList<IRepositoryNode>();
    for (Object obj : array) {
        if (obj instanceof IRepositoryNode) {
            IRepositoryNode node = (IRepositoryNode) obj;
            if (RepositoryNodeHelper.canOpenEditor(node) && !(node instanceof ReportRepNode)) {
                selectedItemsList.add((IRepositoryNode) obj);
            }
        }
    }
    if (!selectedItemsList.isEmpty()) {
        menu.add(new OpenItemEditorAction(selectedItemsList.toArray(new IRepositoryNode[selectedItemsList.size()])));
    }
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ArrayList(java.util.ArrayList) OpenItemEditorAction(org.talend.dataprofiler.core.ui.action.actions.OpenItemEditorAction)

Example 2 with ReportRepNode

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

the class UnitTestBuildHelper method createRealReportNode.

/**
 * create a real ReportRepNode.
 *
 * @param name report name
 * @param folder report's parent folder
 * @param isDelete delete flag
 * @return
 */
public static ReportRepNode createRealReportNode(String name, RepositoryNode parentNode, IPath createPath, Boolean isDelete) {
    ReportRepNode reportRepNode = null;
    Report report = ReportHelper.createReport(name);
    TDQReportItem reportItem = PropertiesFactoryImpl.eINSTANCE.createTDQReportItem();
    org.talend.core.model.properties.Property reportProperty = PropertiesFactory.eINSTANCE.createProperty();
    reportProperty.setId(EcoreUtil.generateUUID());
    reportProperty.setItem(reportItem);
    reportProperty.setLabel(report.getName());
    reportItem.setProperty(reportProperty);
    reportItem.setReport(report);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    reportItem.setState(itemState);
    try {
        ProxyRepositoryFactory.getInstance().create(reportItem, createPath, false);
        IRepositoryViewObject reportViewObject = new RepositoryViewObject(reportProperty);
        reportRepNode = new ReportRepNode(reportViewObject, parentNode, ENodeType.REPOSITORY_ELEMENT, null);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return reportRepNode;
}
Also used : ReportRepNode(org.talend.dq.nodes.ReportRepNode) Report(orgomg.cwmx.analysis.informationreporting.Report) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject)

Example 3 with ReportRepNode

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

the class RepNodeUtilsTest method setUp.

/**
 * can not use the real project to test, because the method RepositoryNodeHelper.getDataProfilingFolderNode will use
 * the UI view to fetch the node. so , can only mock for this test. The report and its analysismap with jrxml is
 * real created, not mocked object.
 *
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    // create a report with user defined jrxml
    // $NON-NLS-1$
    realReport = ReportHelper.createReport("report20130124");
    AnalysisMap analysisMap = ReportsFactory.eINSTANCE.createAnalysisMap();
    analysisMap.setReportType(ReportHelper.ReportType.USER_MADE.getLabel());
    // $NON-NLS-1$
    analysisMap.setAnalysis(AnalysisHelper.createAnalysis("analysis20130124"));
    analysisMap.setJrxmlSource(oldJrxmlPath);
    realReport.getAnalysisMap().add(analysisMap);
    List<ReportRepNode> repNodes = new ArrayList<ReportRepNode>();
    ReportRepNode repNode = mock(ReportRepNode.class);
    repNodes.add(repNode);
    IRepositoryViewObject view = mock(IRepositoryViewObject.class);
    Property prop = mock(Property.class);
    Item item = mock(Item.class);
    when(prop.getItem()).thenReturn(item);
    when(view.getProperty()).thenReturn(prop);
    when(repNode.getObject()).thenReturn(view);
    when(repNode.getReport()).thenReturn(realReport);
    ProjectManager manager = mock(ProjectManager.class);
    // $NON-NLS-1$
    stub(method(ProjectManager.class, "getInstance")).toReturn(manager);
    Project project = mock(Project.class);
    when(manager.getCurrentProject()).thenReturn(project);
    PowerMockito.mock(ResourceManager.class);
    IProject iproject = mock(IProject.class);
    // $NON-NLS-1$
    when(iproject.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/"));
    // $NON-NLS-1$
    stub(method(ResourceManager.class, "getRootProject")).toReturn(iproject);
    IFile ifile = mock(IFile.class);
    when(iproject.getFile(newJrxmlPath)).thenReturn(ifile);
    // $NON-NLS-1$
    when(ifile.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/" + newJrxmlPath));
    PowerMockito.mockStatic(ModelElementHelper.class);
    IFile ifile2 = mock(IFile.class);
    when(ModelElementHelper.getIFile(realReport)).thenReturn(ifile2);
    when(ifile2.getLocation()).thenReturn(// $NON-NLS-1$
    new Path("/opt/runtime/tdqee/a1/TDQ_Data Profiling/Reports/report20130124_0.1.rep"));
    IFile ifile3 = mock(IFile.class);
    when(iproject.getFile(moveJrxmlPath)).thenReturn(ifile3);
    // $NON-NLS-1$
    when(ifile3.getLocation()).thenReturn(new Path("/opt/runtime/tdqee/a1/" + moveJrxmlPath));
    PowerMockito.mock(RepositoryNodeHelper.class);
    IRepositoryNode ReportRootFolderNode = mock(IRepositoryNode.class);
    // $NON-NLS-1$
    stub(method(RepositoryNodeHelper.class, "getDataProfilingFolderNode", EResourceConstant.class)).toReturn(ReportRootFolderNode);
    // $NON-NLS-1$
    stub(method(RepositoryNodeHelper.class, "getReportRepNodes", IRepositoryNode.class, boolean.class, boolean.class)).toReturn(repNodes);
    ProxyRepositoryFactory repFactory = mock(ProxyRepositoryFactory.class);
    PowerMockito.mockStatic(ProxyRepositoryFactory.class);
    when(ProxyRepositoryFactory.getInstance()).thenReturn(repFactory);
    // $NON-NLS-1$
    stub(method(ProxyRepositoryFactory.class, "save", Project.class, Item.class, boolean.class));
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) ProjectManager(org.talend.repository.ProjectManager) Item(org.talend.core.model.properties.Item) IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) ReportRepNode(org.talend.dq.nodes.ReportRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) Property(org.talend.core.model.properties.Property) Before(org.junit.Before)

Example 4 with ReportRepNode

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

the class RepNodeUtils method updateJrxmlRelatedReport.

/**
 * when the report's user defined template(Jrxml file) changed its name, or be moved, the path info in the report's
 * anaMap: jrxml source should also be updated. This method is used to update the related reports when the jrxml
 * name or path is changed.
 *
 * @param jrxmlFileNames : the whole path with whole name of the jrxml, e.g./TDQ_Libraries/JRXML
 * Template/columnset/column_set_basic_0.1.jrxml
 * @param jrxmlFileNamesAfterMove
 */
public static void updateJrxmlRelatedReport(List<String> jrxmlFileNames, List<String> jrxmlFileNamesAfterMove) {
    if (jrxmlFileNames.size() == 0 || jrxmlFileNamesAfterMove.size() == 0 || jrxmlFileNamesAfterMove.size() < jrxmlFileNames.size()) {
        return;
    }
    Project project = ProjectManager.getInstance().getCurrentProject();
    // get all reports
    IRepositoryNode ReportRootFolderNode = RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.REPORTS);
    List<ReportRepNode> repNodes = RepositoryNodeHelper.getReportRepNodes(ReportRootFolderNode, true, true);
    // go through every report to :if any one used current jrxml-->modify its jrxml resource name
    for (ReportRepNode report : repNodes) {
        boolean isUpdated = false;
        EList<AnalysisMap> analysisMap = ((TdReport) report.getReport()).getAnalysisMap();
        for (AnalysisMap anaMap : analysisMap) {
            for (int i = 0; i < jrxmlFileNames.size(); i++) {
                String oldPath = jrxmlFileNames.get(i);
                if (isUsedByJrxml(new Path(oldPath), anaMap)) {
                    // like: ../../../TDQ_Libraries/JRXML Template/column1/b01_column_basic_0.1.jrxml
                    String newPath = getRelativeJrxmlPath(report.getReport(), jrxmlFileNamesAfterMove.get(i));
                    // Added 20130128, using event/listener to refresh the page if opening
                    EventManager.getInstance().publish(report, EventEnum.DQ_JRXML_RENAME, newPath);
                    // save the new jrxml path.
                    anaMap.setJrxmlSource(newPath);
                    isUpdated = true;
                }
            }
        }
        if (isUpdated) {
            try {
                ProxyRepositoryFactory.getInstance().save(project, report.getObject().getProperty().getItem());
            } catch (PersistenceException e) {
                // $NON-NLS-1$
                MessageUI.openError(DefaultMessagesImpl.getString("RepNodeUtils.updateReport.fail", report.getLabel()));
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.general.Project) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) TdReport(org.talend.dataquality.reports.TdReport) PersistenceException(org.talend.commons.exception.PersistenceException) AnalysisMap(org.talend.dataquality.reports.AnalysisMap)

Example 5 with ReportRepNode

use of org.talend.dq.nodes.ReportRepNode 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)

Aggregations

ReportRepNode (org.talend.dq.nodes.ReportRepNode)13 IRepositoryNode (org.talend.repository.model.IRepositoryNode)9 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)7 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 PatternRepNode (org.talend.dq.nodes.PatternRepNode)5 IPath (org.eclipse.core.runtime.IPath)4 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)4 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 RuleRepNode (org.talend.dq.nodes.RuleRepNode)4 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)4 ArrayList (java.util.ArrayList)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)3 DBConnectionRepNode (org.talend.dq.nodes.DBConnectionRepNode)3 DBSchemaRepNode (org.talend.dq.nodes.DBSchemaRepNode)3 DFTableRepNode (org.talend.dq.nodes.DFTableRepNode)3 DQRepositoryNode (org.talend.dq.nodes.DQRepositoryNode)3 JrxmlTempleteRepNode (org.talend.dq.nodes.JrxmlTempleteRepNode)3