Search in sources :

Example 26 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition 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 27 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class AnaMatchSurvivorSection method deleteMatchRuleTab.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.talend.dataquality.record.linkage.ui.section.MatchingKeySection#deleteMatchRuleTab(org.eclipse.swt.custom
     * .CTabItem)
     */
@Override
protected void deleteMatchRuleTab(CTabItem tabItem) {
    MatchRule matchRule = getMatchRule(tabItem);
    List<MatchKeyAndSurvivorDefinition> matchAndSurvDefList = matchRuleWithSurvMap.get(matchRule);
    MatchRuleDefinition matchRuleDefinition = getMatchRuleDefinition();
    for (MatchKeyAndSurvivorDefinition matchAndSurvDef : matchAndSurvDefList) {
        matchRuleDefinition.getSurvivorshipKeys().remove(matchAndSurvDef.getSurvivorShipKey());
    }
    matchRuleWithSurvMap.remove(matchRule);
    super.deleteMatchRuleTab(tabItem);
}
Also used : MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) MatchRule(org.talend.dataquality.rules.MatchRule) MatchKeyAndSurvivorDefinition(org.talend.dataquality.record.linkage.ui.composite.tableviewer.definition.MatchKeyAndSurvivorDefinition)

Example 28 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class MatchingKeySection method createGroupQualityThreshold.

/**
 * DOC zhao Comment method "createGroupQualityThreshold".
 *
 * @param parent
 */
protected void createGroupQualityThreshold(Composite parent) {
    Composite groupQualityThresholdComposite = new Composite(parent, SWT.NONE);
    groupQualityThresholdComposite.setLayout(new GridLayout(2, Boolean.TRUE));
    Label groupQualityTresholdLabel = new Label(groupQualityThresholdComposite, SWT.NONE);
    // $NON-NLS-1$
    groupQualityTresholdLabel.setText(DefaultMessagesImpl.getString("MatchRuleTableComposite.GROUP_QUALITY_THRESHOLD"));
    final MatchRuleDefinition ruleDefinition = getMatchRuleDefinition();
    groupQualityThresholdText = new Text(groupQualityThresholdComposite, SWT.BORDER);
    GridData layoutData = new GridData();
    layoutData.widthHint = 80;
    groupQualityThresholdText.setLayoutData(layoutData);
    groupQualityThresholdText.setText(String.valueOf(ruleDefinition.getMatchGroupQualityThreshold()));
    groupQualityThresholdText.addModifyListener(new ModifyListener() {

        Double oldValue = ruleDefinition.getMatchGroupQualityThreshold();

        @Override
        public void modifyText(ModifyEvent e) {
            try {
                String newValue = groupQualityThresholdText.getText();
                Double value = Double.valueOf(newValue);
                if (value != oldValue) {
                    ruleDefinition.setMatchGroupQualityThreshold(value);
                    listeners.firePropertyChange(MatchAnalysisConstant.ISDIRTY_PROPERTY, oldValue, value);
                    oldValue = value;
                }
            } catch (Exception exc) {
            // Invalid input
            }
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) MatchRuleTableComposite(org.talend.dataquality.record.linkage.ui.composite.MatchRuleTableComposite) AbsMatchAnalysisTableComposite(org.talend.dataquality.record.linkage.ui.composite.AbsMatchAnalysisTableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) Text(org.eclipse.swt.widgets.Text)

Example 29 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class MatchKeyAndSurvivorshipTableViewer method removeElement.

@Override
public void removeElement(MatchKeyAndSurvivorDefinition msDedefinition, List<MatchKeyAndSurvivorDefinition> matchKeys) {
    Iterator<MatchKeyAndSurvivorDefinition> matchKeyIterator = matchKeys.iterator();
    while (matchKeyIterator.hasNext()) {
        MatchKeyAndSurvivorDefinition keyDef = matchKeyIterator.next();
        if (StringUtils.equals(keyDef.getMatchKey().getName(), msDedefinition.getMatchKey().getName())) {
            super.removeElement(keyDef, matchKeys);
            // link the added MatchKeyAndSurvivorDefinition's match and survivor key with matchRuleDef's matchkey
            // and
            // survivorkey list;
            SurvivorshipKeyDefinition survivorShipKey = msDedefinition.getSurvivorShipKey();
            MatchRuleDefinition matchRuleDef = (MatchRuleDefinition) survivorShipKey.eContainer();
            ((MatchRule) msDedefinition.getMatchKey().eContainer()).getMatchKeys().remove(msDedefinition.getMatchKey());
            matchRuleDef.getSurvivorshipKeys().remove(survivorShipKey);
            break;
        }
    }
}
Also used : SurvivorshipKeyDefinition(org.talend.dataquality.rules.SurvivorshipKeyDefinition) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition)

Example 30 with MatchRuleDefinition

use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.

the class DQRuleLabelProvider method getImage.

@Override
public Image getImage(Object element) {
    if (element instanceof IFolder) {
        return ImageLib.getImage(ImageLib.FOLDERNODE_IMAGE);
    }
    if (element instanceof IFile && FactoriesUtil.DQRULE.equals(((IFile) element).getFileExtension())) {
        IFile file = (IFile) element;
        ModelElement me = DQRuleResourceFileHelper.getInstance().getModelElement(file);
        // add support for match rule
        ModelElement modelElement = DQRuleResourceFileHelper.getInstance().getModelElement(file);
        ModelElement rule = DQRuleResourceFileHelper.getInstance().doSwitch(modelElement);
        if (rule != null && rule instanceof MatchRuleDefinition) {
            ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.MATCH_RULE_ICON);
            return imageDescriptor.createImage();
        }
        // ~
        ImageDescriptor imageDescriptor = ImageLib.getImageDescriptor(ImageLib.DQ_RULE);
        if (rule != null && rule instanceof WhereRule) {
            boolean validStatus = TaggedValueHelper.getValidStatus(rule);
            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 : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) DecorationOverlayIcon(org.eclipse.jface.viewers.DecorationOverlayIcon) IFile(org.eclipse.core.resources.IFile) WhereRule(org.talend.dataquality.rules.WhereRule) MatchRuleDefinition(org.talend.dataquality.rules.MatchRuleDefinition) ImageDescriptor(org.eclipse.jface.resource.ImageDescriptor) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)35 ArrayList (java.util.ArrayList)10 HashMap (java.util.HashMap)9 RecordMatchingIndicator (org.talend.dataquality.indicators.columnset.RecordMatchingIndicator)8 MatchRule (org.talend.dataquality.rules.MatchRule)8 MetadataColumn (org.talend.core.model.metadata.builder.connection.MetadataColumn)6 AlgorithmDefinition (org.talend.dataquality.rules.AlgorithmDefinition)6 MatchKeyDefinition (org.talend.dataquality.rules.MatchKeyDefinition)6 RuleRepNode (org.talend.dq.nodes.RuleRepNode)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 Test (org.junit.Test)5 Analysis (org.talend.dataquality.analysis.Analysis)5 MatchGroupResultConsumer (org.talend.dataquality.record.linkage.grouping.MatchGroupResultConsumer)5 Map (java.util.Map)4 IFile (org.eclipse.core.resources.IFile)4 BlockKeyIndicator (org.talend.dataquality.indicators.columnset.BlockKeyIndicator)4 TDQMatchRuleItem (org.talend.dataquality.properties.TDQMatchRuleItem)4 ExecuteMatchRuleHandler (org.talend.dq.analysis.match.ExecuteMatchRuleHandler)4 IFolder (org.eclipse.core.resources.IFolder)3 BlockKeyDefinition (org.talend.dataquality.rules.BlockKeyDefinition)3