Search in sources :

Example 21 with TDQAnalysisItem

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

the class ReportWriter method addDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
     */
@Override
public void addDependencies(ModelElement element) {
    TdReport report = (TdReport) element;
    List<Analysis> analyses = ReportHelper.getAnalyses(report);
    for (Analysis ana : analyses) {
        // TDQ-7999,filter the proxy.
        if (!ana.eIsProxy()) {
            AnalysisRepNode recursiveFindAnalysis = RepositoryNodeHelper.recursiveFindAnalysis(ana);
            // only do save when the dependency is not reference project node
            if (recursiveFindAnalysis != null && recursiveFindAnalysis.getProject().isMainProject()) {
                TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(report, ana);
                if (dependencyReturn.isOk()) {
                    try {
                        Property property = PropertyHelper.getProperty(ana);
                        if (property != null) {
                            Item item = property.getItem();
                            if (item instanceof TDQAnalysisItem) {
                                TDQAnalysisItem anaItem = (TDQAnalysisItem) item;
                                anaItem.setAnalysis(ana);
                            }
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(ana.eResource());
                    } catch (PersistenceException e) {
                        log.error(e, e);
                    }
                }
            }
        }
    }
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Item(org.talend.core.model.properties.Item) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) PersistenceException(org.talend.commons.exception.PersistenceException) Dependency(orgomg.cwm.objectmodel.core.Dependency) Property(org.talend.core.model.properties.Property) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 22 with TDQAnalysisItem

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

the class RespositoryDetailView method createFileDetail.

private boolean createFileDetail(boolean is, IRepositoryViewObject reposViewObj) {
    // MOD klliu 2001-02-28 bug 19154
    if (reposViewObj.getProperty() != null) {
        Item item = reposViewObj.getProperty().getItem();
        if (item instanceof ConnectionItem) {
            Connection conn = ((ConnectionItem) item).getConnection();
            createDataProviderDetail(conn);
            is = false;
        }
        if (item instanceof TDQAnalysisItem) {
            Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
            createAnaysisDetail(analysis);
            is = false;
        }
        if (item instanceof TDQPatternItem) {
            Pattern pattern = ((TDQPatternItem) item).getPattern();
            createPatternDetail(pattern);
            is = false;
        }
        if (item instanceof TDQReportItem) {
            Report report = ((TDQReportItem) item).getReport();
            createReportDetail(report);
            is = false;
        }
    }
    return is;
}
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 23 with TDQAnalysisItem

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

the class IndicatorSettingsPage method modifyAndSaveLimit.

/**
 * DOC zshen Comment method "modifyAndSaveLimit".
 *
 * @param anaNode
 * @param isLowCase
 */
private void modifyAndSaveLimit(AnalysisRepNode anaNode, boolean isLowCase) {
    Analysis analysis = anaNode.getAnalysis();
    for (Indicator indicator : analysis.getResults().getIndicators()) {
        if (isLowCase) {
            modifyLowFre(indicator);
        } else {
            // too many frequency type
            modifyFre(indicator);
        }
    }
    AnalysisWriter anaWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
    anaWriter.save(anaNode.getObject().getProperty().getItem(), false);
    ((TDQAnalysisItem) anaNode.getObject().getProperty().getItem()).setAnalysis(analysis);
// Resource resource = analysis.eResource();
// EMFUtil.saveSingleResource(resource);
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) Indicator(org.talend.dataquality.indicators.Indicator) LowFrequencyIndicator(org.talend.dataquality.indicators.LowFrequencyIndicator) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 24 with TDQAnalysisItem

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

the class UnitTestBuildHelper method createRealAnalysis.

public static Analysis createRealAnalysis(String name, IFolder folder, Boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    Analysis analysis1 = AnalysisHelper.createAnalysis(name);
    TDQAnalysisItem item1 = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property property1 = PropertiesFactory.eINSTANCE.createProperty();
    property1.setId(EcoreUtil.generateUUID());
    property1.setItem(item1);
    property1.setLabel(analysis1.getName());
    item1.setProperty(property1);
    item1.setAnalysis(analysis1);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(isDelete);
    item1.setState(itemState);
    AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis1.setResults(analysisResult1);
    try {
        ProxyRepositoryFactory.getInstance().create(item1, createPath, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    return analysis1;
}
Also used : Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) IPath(org.eclipse.core.runtime.IPath) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 25 with TDQAnalysisItem

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

the class AbstractCommonActionProviderTest method createAnalysisNode.

private RepositoryNode createAnalysisNode(String name, IFolder folder, boolean isDelete) {
    IPath createPath = Path.EMPTY;
    if (folder != null) {
        createPath = new Path(folder.getFullPath().lastSegment());
    }
    // connection
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis.setName(name);
    // ~connection
    TDQAnalysisItem createAnalysisItem = org.talend.dataquality.properties.PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    org.talend.core.model.properties.Property createAnaProperty = PropertiesFactory.eINSTANCE.createProperty();
    createAnaProperty.setId(EcoreUtil.generateUUID());
    createAnaProperty.setItem(createAnalysisItem);
    createAnaProperty.setLabel(createAnalysis.getName());
    createAnalysisItem.setProperty(createAnaProperty);
    createAnalysisItem.setAnalysis(createAnalysis);
    ItemState createItemState = PropertiesFactory.eINSTANCE.createItemState();
    createItemState.setDeleted(isDelete);
    createAnalysisItem.setState(createItemState);
    // Indicator
    CountsIndicator createCountsIndicator = IndicatorsFactory.eINSTANCE.createCountsIndicator();
    List<IRepositoryViewObject> all = null;
    IndicatorDefinition createIndicatorDefinition = null;
    try {
        all = factory.getAll(ERepositoryObjectType.TDQ_SYSTEM_INDICATORS);
        for (IRepositoryViewObject indicatorViewObject : all) {
            if (indicatorViewObject.getLabel().equalsIgnoreCase("ROW COUNT")) {
                // $NON-NLS-1$
                createIndicatorDefinition = (IndicatorDefinition) PropertyHelper.getModelElement(indicatorViewObject.getProperty());
                break;
            }
        }
    } catch (PersistenceException e1) {
        e1.printStackTrace();
        Assert.fail(e1.getMessage());
    }
    createCountsIndicator.setIndicatorDefinition(createIndicatorDefinition);
    AnalysisParameters createAnalysisParameters = AnalysisFactory.eINSTANCE.createAnalysisParameters();
    AnalysisContext createAnalysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    createAnalysis.setContext(createAnalysisContext);
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    ExecutionInformations createExecutionInformations = AnalysisFactory.eINSTANCE.createExecutionInformations();
    createAnalysisResult.setResultMetadata(createExecutionInformations);
    createAnalysisResult.getIndicators().add(createCountsIndicator);
    createAnalysis.setResults(createAnalysisResult);
    createAnalysis.setParameters(createAnalysisParameters);
    IRepositoryViewObject repViewObject = null;
    try {
        factory.create(createAnalysisItem, createPath, false);
        repViewObject = factory.getLastVersion(createAnaProperty.getId());
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    RepositoryNode anaRepNode = new AnalysisRepNode(repViewObject, null, ENodeType.TDQ_REPOSITORY_ELEMENT, null);
    // set the contentType for anaRepNode from its parentNode
    setParentNode(anaRepNode, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT);
    // ~
    return anaRepNode;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) CountsIndicator(org.talend.dataquality.indicators.CountsIndicator) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) RepositoryNode(org.talend.repository.model.RepositoryNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisParameters(org.talend.dataquality.analysis.AnalysisParameters) ItemState(org.talend.core.model.properties.ItemState) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Aggregations

TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)33 Analysis (org.talend.dataquality.analysis.Analysis)26 PersistenceException (org.talend.commons.exception.PersistenceException)17 Property (org.talend.core.model.properties.Property)14 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)14 Item (org.talend.core.model.properties.Item)11 ItemState (org.talend.core.model.properties.ItemState)11 Path (org.eclipse.core.runtime.Path)9 Test (org.junit.Test)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)9 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)9 IPath (org.eclipse.core.runtime.IPath)7 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)7 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)7 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 ReturnCode (org.talend.utils.sugars.ReturnCode)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)5 TdReport (org.talend.dataquality.reports.TdReport)5