Search in sources :

Example 6 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class RespositoryDetailView method createTechnicalDetail.

private void createTechnicalDetail(IRepositoryViewObject reposViewObj) {
    // MOD klliu the DQRepositoryview unified with tos, so refactor as follow bug 19154 2011-02-28
    if (reposViewObj.getProperty() != null) {
        Item item = reposViewObj.getProperty().getItem();
        if (item instanceof ConnectionItem) {
            Connection conn = ((ConnectionItem) item).getConnection();
            createTechnicalDetail(conn);
        } else if (item instanceof TDQAnalysisItem) {
            Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
            createTechnicalDetail(analysis);
        } else if (item instanceof TDQPatternItem) {
            Pattern pattern = ((TDQPatternItem) item).getPattern();
            createTechnicalDetail(pattern);
        } else if (item instanceof TDQReportItem) {
            Report report = ((TDQReportItem) item).getReport();
            createTechnicalDetail(report);
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) Pattern(org.talend.dataquality.domain.pattern.Pattern) Report(orgomg.cwmx.analysis.informationreporting.Report) TdReport(org.talend.dataquality.reports.TdReport) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 7 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class AElementPersistance method createItem.

/**
 * DOC bZhou Comment method "createItem".
 *
 * @param element
 * @return
 */
public Item createItem(ModelElement element) {
    Item item = null;
    // MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
    if (ModelElementIdentifier.isAnalysis(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
        ((TDQAnalysisItem) item).setAnalysis((Analysis) element);
    } else if (ModelElementIdentifier.isDQRule(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
        ((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
    } else if (ModelElementIdentifier.isDataProvider(element)) {
        if (element instanceof DatabaseConnection) {
            item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
            ((ConnectionItem) item).setConnection((DatabaseConnection) element);
        }
        ((ConnectionItem) item).setConnection((Connection) element);
    } else if (ModelElementIdentifier.isMatchRule(element)) {
        // this Condition must before the IndicatorDefinition one because MatchRule instance of it.
        item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
        ((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
    } else if (ModelElementIdentifier.isID(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
        ((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
    } else if (ModelElementIdentifier.isPattern(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
        ((TDQPatternItem) item).setPattern((Pattern) element);
    } else if (ModelElementIdentifier.isReport(element)) {
        item = PropertiesFactory.eINSTANCE.createTDQReportItem();
        ((TDQReportItem) item).setReport((Report) element);
    } else {
        item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
    }
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    item.setState(itemState);
    if (item instanceof TDQItem) {
        setTDQItemFileName(element, item);
    }
    Resource eResource = element.eResource();
    if (eResource != null) {
        URI uri = eResource.getURI();
        if (uri.isPlatform()) {
            IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
            IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
            IPath statePath = elementPath.makeRelativeTo(typedPath);
            itemState.setPath(statePath.toString());
        }
    }
    return item;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Resource(org.eclipse.emf.ecore.resource.Resource) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) URI(org.eclipse.emf.common.util.URI) DQRule(org.talend.dataquality.rules.DQRule) 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) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) ItemState(org.talend.core.model.properties.ItemState) TDQItem(org.talend.core.model.properties.TDQItem) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 8 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class ReportWriter method removeDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#removeDependencies(org.talend.core.model.properties.Item)
     */
@Override
protected ReturnCode removeDependencies(Item item) {
    ReturnCode rc = new ReturnCode();
    TDQReportItem anaItem = (TDQReportItem) item;
    TdReport report = (TdReport) anaItem.getReport();
    List<Property> clintDependency = DependenciesHandler.getInstance().getClintDependency(anaItem.getProperty());
    EList<AnalysisMap> analysisMap = report.getAnalysisMap();
    for (Property currentClient : clintDependency) {
        ModelElement modelElement = PropertyHelper.getModelElement(currentClient);
        if (!analysisMap.contains(modelElement)) {
            boolean isSuccess = DependenciesHandler.getInstance().removeDependenciesBetweenModel(report, modelElement);
            if (isSuccess) {
                rc.setOk(EMFUtil.saveSingleResource(modelElement.eResource()));
            } else {
                rc.setOk(false);
                rc.setMessage(// $NON-NLS-1$
                Messages.getString(// $NON-NLS-1$
                "ReportWriter.CanNotFindDependencyElement", // $NON-NLS-1$
                report.getName(), modelElement.getName()));
            }
        }
    }
    return rc;
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) ReturnCode(org.talend.utils.sugars.ReturnCode) TdReport(org.talend.dataquality.reports.TdReport) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) Property(org.talend.core.model.properties.Property) TDQReportItem(org.talend.dataquality.properties.TDQReportItem)

Example 9 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class TDQResourceChangeHandler method moveReportGeneratedDocFolder.

@Override
public void moveReportGeneratedDocFolder(TDQItem tdqItem, File tarFolder) {
    if (tdqItem instanceof TDQReportItem && tarFolder.exists()) {
        TDQReportItem tdqReportItem = (TDQReportItem) tdqItem;
        Report report = tdqReportItem.getReport();
        IFile iFile = ModelElementHelper.getIFile(report);
        IFolder outputFolder = ReportFileHelper.getOutputFolder(iFile);
        File srcFolder = WorkspaceUtils.ifolderToFile(outputFolder);
        FilesUtils.copyDirectoryWithoutSvnFolder(srcFolder, tarFolder);
        File newFolder = new File(tarFolder.getAbsolutePath() + File.separator + srcFolder.getName());
        if (newFolder.exists()) {
            IFolder ifolder = WorkspaceUtils.fileToIFolder(newFolder);
            if (ifolder != null) {
                try {
                    ifolder.refreshLocal(IResource.DEPTH_INFINITE, null);
                } catch (CoreException e) {
                    log.info(e);
                }
            }
        }
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) Report(orgomg.cwmx.analysis.informationreporting.Report) IFile(org.eclipse.core.resources.IFile) File(java.io.File) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) IFolder(org.eclipse.core.resources.IFolder)

Example 10 with TDQReportItem

use of org.talend.dataquality.properties.TDQReportItem in project tdq-studio-se by Talend.

the class RemoveAnalysisAction method run.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
@Override
public void run() {
    DQRespositoryView findView = CorePlugin.getDefault().getRepositoryView();
    if (findView == null) {
        return;
    }
    TreeSelection treeSelection = (TreeSelection) findView.getCommonViewer().getSelection();
    TreePath[] paths = treeSelection.getPaths();
    List<Analysis> analysisList;
    Analysis analysisObj = null;
    Map<TDQReportItem, List<Analysis>> removeMap = new HashMap<TDQReportItem, List<Analysis>>();
    for (TreePath path : paths) {
        Object lastSegment = path.getLastSegment();
        if (!(lastSegment instanceof ReportAnalysisRepNode)) {
            return;
        }
        // MOD sizhaoliu 2012-06-12 TDQ-5051 "Remove Anaysis" menu item is not in the right place
        ReportAnalysisRepNode repNode = (ReportAnalysisRepNode) lastSegment;
        analysisObj = repNode.getAnalysis();
        TDQReportItem reportItem = repNode.getReportItem();
        analysisList = removeMap.get(reportItem);
        if (analysisList == null) {
            analysisList = new ArrayList<Analysis>();
            analysisList.add(analysisObj);
            removeMap.put(reportItem, analysisList);
        } else {
            analysisList.add(analysisObj);
        }
    }
    if (analysisObj == null) {
        return;
    }
    String message = paths.length > 1 ? DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement0", // $NON-NLS-1$
    paths.length) : // $NON-NLS-1$
    DefaultMessagesImpl.getString("RemoveAnalysisAction.areYouDeleteElement2", analysisObj.getName());
    boolean openConfirm = MessageDialog.openConfirm(null, DefaultMessagesImpl.getString("RemoveAnalysisAction.confirmResourceDelete"), // $NON-NLS-1$
    message);
    if (openConfirm) {
        Iterator<TDQReportItem> iterator = removeMap.keySet().iterator();
        while (iterator.hasNext()) {
            TDQReportItem reportItem = iterator.next();
            ReportHelper.removeAnalyses((TdReport) reportItem.getReport(), removeMap.get(reportItem));
            // save now modified resources (that contain the Dependency
            // objects)
            ElementWriterFactory.getInstance().createReportWriter().save(reportItem, true);
        }
        IFolder reportsFolder = ResourceManager.getReportsFolder();
        try {
            reportsFolder.refreshLocal(IResource.DEPTH_INFINITE, null);
        } catch (CoreException e) {
            log.error(e, e);
        }
        findView.getCommonViewer().refresh();
    }
}
Also used : HashMap(java.util.HashMap) TreePath(org.eclipse.jface.viewers.TreePath) CoreException(org.eclipse.core.runtime.CoreException) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Analysis(org.talend.dataquality.analysis.Analysis) ArrayList(java.util.ArrayList) List(java.util.List) DQRespositoryView(org.talend.dataprofiler.core.ui.views.DQRespositoryView) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

TDQReportItem (org.talend.dataquality.properties.TDQReportItem)17 Report (orgomg.cwmx.analysis.informationreporting.Report)9 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)8 Item (org.talend.core.model.properties.Item)7 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)7 TdReport (org.talend.dataquality.reports.TdReport)7 Analysis (org.talend.dataquality.analysis.Analysis)6 PersistenceException (org.talend.commons.exception.PersistenceException)5 Property (org.talend.core.model.properties.Property)5 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)5 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 ItemState (org.talend.core.model.properties.ItemState)4 Pattern (org.talend.dataquality.domain.pattern.Pattern)4 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)4 IPath (org.eclipse.core.runtime.IPath)3 Connection (org.talend.core.model.metadata.builder.connection.Connection)3 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)3 TDQItem (org.talend.core.model.properties.TDQItem)3 IFolder (org.eclipse.core.resources.IFolder)2 CoreException (org.eclipse.core.runtime.CoreException)2