Search in sources :

Example 46 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class TableAnalysisWizard method createAndSaveCWMFile.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.wizard.analysis.AbstractAnalysisWizard#createAndSaveCWMFile(orgomg.cwm.objectmodel
     * .core.ModelElement)
     */
@Override
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
    Analysis analysis = (Analysis) cwmElement;
    DataManager connection = analysis.getContext().getConnection();
    if (connection != null) {
        DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
    }
    // MOD by hcheng for 7173:Broken dependency between analyses and connection
    TypedReturnCode<Object> saveCWMFile = super.createAndSaveCWMFile(analysis);
    if (saveCWMFile.isOk() && connection != null) {
        ElementWriterFactory.getInstance().createDataProviderWriter().save(connection);
    }
    return saveCWMFile;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager)

Example 47 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class ResourceViewLabelProvider method decorateImage.

@Override
protected ImageDescriptor decorateImage(ImageDescriptor input, Object element) {
    ImageDescriptor image = super.decorateImage(input, element);
    if (element instanceof IFile) {
        IFile file = (IFile) element;
        String fileExtension = file.getFileExtension();
        // MOD qiongli 2010-9-7,bug 14698,add 'try...catch'
        try {
            if (FactoriesUtil.isPatternFile(fileExtension)) {
                image = ImageLib.getImageDescriptor(ImageLib.PATTERN_REG);
                Pattern pattern = PatternResourceFileHelper.getInstance().findPattern(file);
                if (pattern != null) {
                    if (!TaggedValueHelper.getValidStatus(pattern)) {
                        image = ImageLib.createInvalidIconDes(ImageLib.PATTERN_REG);
                    }
                }
            } else if (FactoriesUtil.isReportFile(fileExtension)) {
                image = ImageLib.getImageDescriptor(ImageLib.REPORT_OBJECT);
            } else if (FactoriesUtil.isUDIFile(fileExtension)) {
                image = ImageLib.getImageDescriptor(ImageLib.IND_DEFINITION);
                IndicatorDefinition udi = IndicatorResourceFileHelper.getInstance().findIndDefinition(file);
                if (udi != null) {
                    boolean validStatus = TaggedValueHelper.getValidStatus(udi) | UDIHelper.isUDIValid(udi);
                    if (!validStatus) {
                        image = ImageLib.createInvalidIconDes(ImageLib.IND_DEFINITION);
                    }
                }
            } else if (FactoriesUtil.isAnalysisFile(fileExtension)) {
                // ADD qiongli 2010-8-9,feature 14252
                Analysis analysis = AnaResourceFileHelper.getInstance().findAnalysis(file);
                if (analysis != null) {
                    AnalysisHandler analysisHandler = new AnalysisHandler();
                    analysisHandler.setAnalysis(analysis);
                    if (analysisHandler.getResultMetadata().getExecutionNumber() != 0) {
                        if (!analysisHandler.getResultMetadata().isLastRunOk()) {
                            image = ImageLib.createErrorIcon(image);
                        } else if (analysisHandler.getResultMetadata().isOutThreshold()) {
                            image = ImageLib.createInvalidIcon(image);
                        }
                    }
                }
            }
        } catch (Exception exc) {
            log.error(exc, exc);
            image = ImageLib.getImageDescriptor(ImageLib.DELETE_ACTION);
        }
        if (FactoriesUtil.isEmfFile(fileExtension)) {
            Property property = PropertyHelper.getProperty(file);
            if (property != null) {
                Item item = property.getItem();
                Boolean lockByOthers = ProxyRepositoryManager.getInstance().isLockByOthers(item);
                Boolean lockByUserOwn = ProxyRepositoryManager.getInstance().isLockByUserOwn(item);
                if (lockByOthers || lockByUserOwn) {
                    // $NON-NLS-1$
                    log.info(property.getLabel() + " is locked");
                    image = ImageLib.createLockedIcon(image);
                }
            }
        }
    } else if (element instanceof IFolder) {
        IFolder folder = (IFolder) element;
        if (ResourceManager.isMetadataFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.METADATA);
        } else if (ResourceManager.isLibrariesFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.LIBRARIES);
        } else if (ResourceManager.isDataProfilingFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.DATA_PROFILING);
        } else if (ResourceManager.isDBConnectionFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.CONNECTION);
        } else if (ResourceManager.isExchangeFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.EXCHANGE);
        } else if (ResourceManager.isFileDelimitedFolder(folder)) {
            image = ImageLib.getImageDescriptor(ImageLib.FILE_DELIMITED);
        }
    }
    return image;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) AnalysisHandler(org.talend.dq.analysis.AnalysisHandler) IFile(org.eclipse.core.resources.IFile) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) CoreException(org.eclipse.core.runtime.CoreException) Item(org.talend.core.model.properties.Item) Analysis(org.talend.dataquality.analysis.Analysis) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 48 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class MatchWizard method initCWMResourceBuilder.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.wizard.analysis.column.ColumnSetWizard#initCWMResourceBuilder()
     */
@Override
public ModelElement initCWMResourceBuilder() {
    Analysis analysis = (Analysis) super.initCWMResourceBuilder();
    // New blocking key indicator.
    Indicator blockKeyIndicator = ColumnsetFactory.eINSTANCE.createBlockKeyIndicator();
    analysis.getResults().getIndicators().add(blockKeyIndicator);
    // Match rule indicator
    RecordMatchingIndicator matchRuleIndicator = ColumnsetFactory.eINSTANCE.createRecordMatchingIndicator();
    MatchRuleDefinition matchRuleDefinition = RulesFactory.eINSTANCE.createMatchRuleDefinition();
    matchRuleIndicator.setBuiltInMatchRuleDefinition(matchRuleDefinition);
    analysis.getResults().getIndicators().add(matchRuleIndicator);
    // default loaded row count
    IPreferenceStore preferenceStore = CorePlugin.getDefault().getPreferenceStore();
    int maxRows = preferenceStore.getInt(PluginConstant.MAX_NB_ROWS_ANALYSIS_EDITOR);
    TaggedValueHelper.setTaggedValue(analysis, TaggedValueHelper.PREVIEW_ROW_NUMBER, String.valueOf(maxRows));
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) RecordMatchingIndicator(org.talend.dataquality.indicators.columnset.RecordMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 49 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class AnalysisFilterWizard method createAndSaveCWMFile.

@Override
public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
    Analysis analysis = (Analysis) cwmElement;
    // MOD klliu feature 15750 connection property define
    // MOD qiongli 2011-2-24,bug 17588,add dependency.
    DataManager connection = analysis.getContext().getConnection();
    DependenciesHandler.getInstance().setDependencyOn(analysis, connection);
    ConnectionItem connectionItem = (ConnectionItem) getParameter().getConnectionRepNode().getObject().getProperty().getItem();
    TypedReturnCode<Object> saveCWMFile = super.createAndSaveCWMFile(analysis);
    // MOD by hcheng for 7173:Broken dependency between analyses and connection
    if (saveCWMFile.isOk()) {
        // ProxyRepositoryViewObject.fetchAllRepositoryViewObjects(Boolean.TRUE, Boolean.TRUE);
        // MOD yyi 2012-02-08 TDQ-4621:Explicitly set true for updating dependencies.
        ElementWriterFactory.getInstance().createDataProviderWriter().save(connectionItem, true);
    }
    return saveCWMFile;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) ConnectionItem(org.talend.core.model.properties.ConnectionItem) DataManager(orgomg.cwm.foundation.softwaredeployment.DataManager)

Example 50 with Analysis

use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.

the class AnalysisFilterWizard method initCWMResourceBuilder.

@Override
public ModelElement initCWMResourceBuilder() {
    Analysis analysis = (Analysis) super.initCWMResourceBuilder();
    EList<Domain> dataFilters = analysis.getParameters().getDataFilter();
    if ((getParameter().getTableFilter() != null) && (!getParameter().getTableFilter().equals(PluginConstant.EMPTY_STRING))) {
        DomainHelper.setDataFilterTablePattern(dataFilters, getParameter().getTableFilter());
    }
    if ((getParameter().getViewFilter() != null) && (!getParameter().getViewFilter().equals(PluginConstant.EMPTY_STRING))) {
        DomainHelper.setDataFilterViewPattern(dataFilters, getParameter().getViewFilter());
    }
    return analysis;
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) Domain(org.talend.dataquality.domain.Domain)

Aggregations

Analysis (org.talend.dataquality.analysis.Analysis)137 Test (org.junit.Test)36 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)36 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)30 ArrayList (java.util.ArrayList)28 Property (org.talend.core.model.properties.Property)28 Indicator (org.talend.dataquality.indicators.Indicator)27 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)27 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)26 PersistenceException (org.talend.commons.exception.PersistenceException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)18 ReturnCode (org.talend.utils.sugars.ReturnCode)18 Dependency (orgomg.cwm.objectmodel.core.Dependency)18 TdColumn (org.talend.cwm.relational.TdColumn)16 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)16 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 Pattern (org.talend.dataquality.domain.pattern.Pattern)15 IFile (org.eclipse.core.resources.IFile)14 File (java.io.File)12 IPath (org.eclipse.core.runtime.IPath)12