Search in sources :

Example 61 with Pattern

use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.

the class ColumnAnalysisSqlExecutor method getPatterns.

/**
 * DOC scorreia Comment method "getPatterns".
 *
 * @param indicator
 * @return the patterns or null if none has been found
 */
protected List<String> getPatterns(Indicator indicator) {
    List<String> patternStrings = new ArrayList<String>();
    Domain dataValidDomain = indicator.getParameters().getDataValidDomain();
    if (dataValidDomain == null) {
        return patternStrings;
    }
    EList<Pattern> patterns = dataValidDomain.getPatterns();
    for (Pattern pattern : patterns) {
        Expression expression = this.dbms().getRegexp(pattern);
        String regexp = expression == null ? null : expression.getBody();
        if (regexp != null) {
            patternStrings.add(regexp);
        }
    }
    return patternStrings;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) TdExpression(org.talend.cwm.relational.TdExpression) Expression(orgomg.cwm.objectmodel.core.Expression) ArrayList(java.util.ArrayList) Domain(org.talend.dataquality.domain.Domain)

Example 62 with Pattern

use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.

the class TDQResourceChangeHandler method create.

@Override
public Resource create(IProject project, Item item, int classID, IPath path) {
    String fileExtension = FileConstants.ITEM_EXTENSION;
    Resource itemResource = null;
    try {
        switch(classID) {
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_ANALYSIS_ITEM:
                fileExtension = FileConstants.ANA_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT, false, fileExtension);
                AnalysisWriter createAnalysisWrite = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createAnalysisWrite();
                Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
                createAnalysisWrite.addResourceContent(itemResource, analysis);
                createAnalysisWrite.addDependencies(analysis);
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_REPORT_ITEM:
                fileExtension = FileConstants.REP_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_REPORT_ELEMENT, false, fileExtension);
                ReportWriter createReportWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createReportWriter();
                Report report = ((TDQReportItem) item).getReport();
                createReportWriter.addResourceContent(itemResource, report);
                createReportWriter.addDependencies(report);
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_INDICATOR_DEFINITION_ITEM:
                fileExtension = FileConstants.DEF_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_INDICATOR_ELEMENT, false, fileExtension);
                IndicatorDefinition indicatorDefinition = ((TDQIndicatorDefinitionItem) item).getIndicatorDefinition();
                IndicatorDefinitionWriter createIndicatorDefinitionWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createIndicatorDefinitionWriter();
                createIndicatorDefinitionWriter.addResourceContent(itemResource, indicatorDefinition);
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_PATTERN_ITEM:
                fileExtension = FileConstants.PAT_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_PATTERN_ELEMENT, false, fileExtension);
                Pattern pattern = ((TDQPatternItem) item).getPattern();
                PatternWriter createPatternWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createPatternWriter();
                createPatternWriter.addResourceContent(itemResource, pattern);
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_BUSINESS_RULE_ITEM:
                fileExtension = FileConstants.RULE_EXTENSION;
                // MOD gdbu 2011-6-10 bug : 21823 2011-06-27 revert the error type code by klliu
                DQRule dqrule = ((TDQBusinessRuleItem) item).getDqrule();
                if (dqrule instanceof WhereRule) {
                    itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_SQL, false, fileExtension);
                } else {
                    itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_PARSER, false, fileExtension);
                }
                // ~21823
                DQRuleWriter createdRuleWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createdRuleWriter();
                createdRuleWriter.addResourceContent(itemResource, dqrule);
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_JRXML_ITEM:
                fileExtension = FileConstants.JRXML_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_JRAXML_ELEMENT, true, fileExtension);
                itemResource.getContents().add(((TDQFileItem) item).getContent());
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_SOURCE_FILE_ITEM:
                fileExtension = FileConstants.SQL_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_SOURCE_FILE_ELEMENT, true, fileExtension);
                itemResource.getContents().add(((TDQFileItem) item).getContent());
                break;
            case org.talend.dataquality.properties.PropertiesPackage.TDQ_MATCH_RULE_ITEM:
                fileExtension = FileConstants.RULE_EXTENSION;
                itemResource = xmiResourceManager.createItemResourceWithExtension(project, item, path, ERepositoryObjectType.TDQ_RULES_MATCHER, false, fileExtension);
                MatchRuleDefinition matchRuleDefinition = ((TDQMatchRuleItem) item).getMatchRule();
                MatchRuleDefinitionWriter matchRuleDefinitionWriter = org.talend.dq.writer.impl.ElementWriterFactory.getInstance().createdMatchRuleWriter();
                matchRuleDefinitionWriter.addResourceContent(itemResource, matchRuleDefinition);
                break;
            default:
        }
    } catch (PersistenceException e) {
        log.error(e, e);
    }
    return itemResource;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Report(orgomg.cwmx.analysis.informationreporting.Report) TDQMatchRuleItem(org.talend.dataquality.properties.TDQMatchRuleItem) DQRuleWriter(org.talend.dq.writer.impl.DQRuleWriter) Resource(org.eclipse.emf.ecore.resource.Resource) IResource(org.eclipse.core.resources.IResource) PatternWriter(org.talend.dq.writer.impl.PatternWriter) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) ReportWriter(org.talend.dq.writer.impl.ReportWriter) WhereRule(org.talend.dataquality.rules.WhereRule) Analysis(org.talend.dataquality.analysis.Analysis) IndicatorDefinitionWriter(org.talend.dq.writer.impl.IndicatorDefinitionWriter) PersistenceException(org.talend.commons.exception.PersistenceException) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) MatchRuleDefinitionWriter(org.talend.dq.writer.impl.MatchRuleDefinitionWriter) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 63 with Pattern

use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.

the class CreatePatternWizard method createAndSaveCWMFile.

public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
    Pattern pattern = (Pattern) cwmElement;
    IFolder folder = parameter.getFolderProvider().getFolderResource();
    return ElementWriterFactory.getInstance().createPatternWriter().create(pattern, folder);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) IFolder(org.eclipse.core.resources.IFolder)

Example 64 with Pattern

use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.

the class PatternLabelProvider method getPatternFileByIndicator.

/**
 * @param clmIndicator
 * @return
 * @deprecated since repository nodes are used instead of IFiles
 */
@Deprecated
public static IFile[] getPatternFileByIndicator(ColumnIndicator clmIndicator) {
    Indicator[] patternIndicators = clmIndicator.getPatternIndicators();
    List<IFile> existedPatternFiles = new ArrayList<IFile>();
    if (patternIndicators.length != 0) {
        for (Indicator patternIndicator : patternIndicators) {
            PatternMatchingIndicator ptnIndicaotr = (PatternMatchingIndicator) patternIndicator;
            List<Pattern> patterns = ptnIndicaotr.getParameters().getDataValidDomain().getPatterns();
            for (Pattern pattern : patterns) {
                for (IFile file : getAllPatternFiles()) {
                    Pattern fpattern = PatternResourceFileHelper.getInstance().findPattern(file);
                    if (pattern.getName().equals(fpattern.getName())) {
                        existedPatternFiles.add(file);
                    }
                }
            }
        }
    }
    return existedPatternFiles.toArray(new IFile[existedPatternFiles.size()]);
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) IFile(org.eclipse.core.resources.IFile) ArrayList(java.util.ArrayList) ColumnIndicator(org.talend.dataprofiler.core.model.ColumnIndicator) ModelElementIndicator(org.talend.dataprofiler.core.model.ModelElementIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) Indicator(org.talend.dataquality.indicators.Indicator)

Example 65 with Pattern

use of org.talend.dataquality.domain.pattern.Pattern in project tdq-studio-se by Talend.

the class PatternLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof IFolder) {
        return ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
    }
    if (element instanceof IFile) {
        Pattern findPattern = PatternResourceFileHelper.getInstance().findPattern((IFile) element);
        boolean validStatus = TaggedValueHelper.getValidStatus(findPattern);
        ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.PATTERN_REG);
        if (!validStatus) {
            ImageDescriptor warnImg = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK);
            DecorationOverlayIcon icon = new DecorationOverlayIcon(imageDescriptor.createImage(), warnImg, IDecoration.BOTTOM_RIGHT);
            imageDescriptor = icon;
        }
        return imageDescriptor.createImage();
    }
    return null;
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) IFile(org.eclipse.core.resources.IFile) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

Pattern (org.talend.dataquality.domain.pattern.Pattern)75 RegularExpression (org.talend.dataquality.domain.pattern.RegularExpression)27 Test (org.junit.Test)19 TdExpression (org.talend.cwm.relational.TdExpression)18 Domain (org.talend.dataquality.domain.Domain)16 Analysis (org.talend.dataquality.analysis.Analysis)15 PatternComponent (org.talend.dataquality.domain.pattern.PatternComponent)15 IndicatorParameters (org.talend.dataquality.indicators.IndicatorParameters)14 ArrayList (java.util.ArrayList)13 PatternMatchingIndicator (org.talend.dataquality.indicators.PatternMatchingIndicator)13 IFile (org.eclipse.core.resources.IFile)11 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)10 Expression (orgomg.cwm.objectmodel.core.Expression)10 IFolder (org.eclipse.core.resources.IFolder)9 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)9 Indicator (org.talend.dataquality.indicators.Indicator)9 Item (org.talend.core.model.properties.Item)7 TdColumn (org.talend.cwm.relational.TdColumn)7 RegexpMatchingIndicator (org.talend.dataquality.indicators.RegexpMatchingIndicator)6 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)6