Search in sources :

Example 1 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class AnalysisTableTreeViewer method removeUncheckedWhereRuleIndicator.

/**
 * DOC xqliu Comment method "removeUncheckedWhereRuleIndicator". ADD xqliu 2009-04-30 bug 6808
 *
 * @param ownedWhereRuleNodes
 * @param results
 * @param tableIndicator
 */
private void removeUncheckedWhereRuleIndicator(Object[] ownedWhereRuleNodes, Object[] results, TableIndicator tableIndicator) {
    ArrayList<Object> removeList = new ArrayList<Object>();
    for (Object node : ownedWhereRuleNodes) {
        boolean remove = true;
        for (Object result : results) {
            if (node.equals(result)) {
                remove = false;
                break;
            }
        }
        if (remove) {
            removeList.add(node);
        }
    }
    TableIndicatorUnit[] indicatorUnits = tableIndicator.getIndicatorUnits();
    for (TableIndicatorUnit unit : indicatorUnits) {
        IndicatorDefinition indicatorDefinition = unit.getIndicator().getIndicatorDefinition();
        if (indicatorDefinition instanceof WhereRule) {
            WhereRule wr = (WhereRule) indicatorDefinition;
            RuleRepNode recursiveFindNode = RepositoryNodeHelper.recursiveFindRuleSql(wr);
            for (Object obj : removeList) {
                RuleRepNode node = (RuleRepNode) obj;
                if (recursiveFindNode.equals(node)) {
                    // the order can not be changed
                    removeItemBranch(this.indicatorTreeItemMap.get(unit));
                    deleteIndicatorItems(tableIndicator, unit);
                    // ~the order can not be changed
                    break;
                }
            }
        }
    }
}
Also used : WhereRule(org.talend.dataquality.rules.WhereRule) ArrayList(java.util.ArrayList) TableIndicatorUnit(org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit) RuleRepNode(org.talend.dq.nodes.RuleRepNode) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition)

Example 2 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method recursiveFindRuleParser.

/**
 * DOC klliu Comment method "recursiveFindRuleParser".
 *
 * @param modelElement
 * @return
 */
public static RuleRepNode recursiveFindRuleParser(ParserRule rule) {
    if (rule == null) {
        return null;
    }
    String uuid = getUUID(rule);
    if (uuid == null) {
        return null;
    }
    IRepositoryNode librariesFolderNode = getParserRuleFolderNode(rule);
    List<RuleRepNode> ruleRepNodes = getRuleRepNodes(librariesFolderNode, true, true);
    if (ruleRepNodes.size() > 0) {
        for (RuleRepNode childNode : ruleRepNodes) {
            if (uuid.equals(getUUID(childNode.getRule()))) {
                return childNode;
            }
        }
    }
    return null;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode)

Example 3 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class RepositoryNodeHelper method recursiveFindMatcherRule.

/**
 * recursiveFind MatcherRule
 *
 * @param modelElement
 * @return
 */
public static RuleRepNode recursiveFindMatcherRule(MatchRuleDefinition rule) {
    if (rule == null) {
        return null;
    }
    String uuid = getUUID(rule);
    if (uuid == null) {
        return null;
    }
    IRepositoryNode librariesFolderNode = getMatchRuleFolderNode(rule);
    List<RuleRepNode> ruleRepNodes = getRuleRepNodes(librariesFolderNode, true, true);
    if (ruleRepNodes.size() > 0) {
        for (RuleRepNode childNode : ruleRepNodes) {
            if (uuid.equals(getUUID(childNode.getRule()))) {
                return childNode;
            }
        }
    }
    return null;
}
Also used : IRepositoryNode(org.talend.repository.model.IRepositoryNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode)

Example 4 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class ImageLib method getImageNameByRepositoryNode.

public static String getImageNameByRepositoryNode(IRepositoryNode node) {
    String imageName = null;
    IRepositoryViewObject viewObject = node.getObject();
    ENodeType type = node.getType();
    if (node instanceof ReportAnalysisRepNode) {
        imageName = ImageLib.ANALYSIS_OBJECT;
    } else if (node instanceof RecycleBinRepNode) {
        imageName = ImageLib.RECYCLEBIN_EMPTY;
    } else if (type.equals(ENodeType.SYSTEM_FOLDER)) {
        String label = viewObject.getLabel();
        if (label.equals(EResourceConstant.DATA_PROFILING.getName())) {
            imageName = ImageLib.DATA_PROFILING;
        } else if (label.equals(EResourceConstant.METADATA.getName())) {
            imageName = ImageLib.METADATA;
        } else if (node instanceof DBConnectionFolderRepNode) {
            imageName = ImageLib.CONNECTION;
        } else if (label.equals(EResourceConstant.FILEDELIMITED.getName())) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (label.equals(EResourceConstant.HADOOP_CLUSTER.getName())) {
            imageName = ImageLib.HADOOP_CLUSTER;
        } else if (label.equals(EResourceConstant.LIBRARIES.getName())) {
            imageName = ImageLib.LIBRARIES;
        } else if (label.equals(EResourceConstant.EXCHANGE.getName())) {
            imageName = ImageLib.EXCHANGE;
        } else {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    } else if (type.equals(ENodeType.SIMPLE_FOLDER)) {
        imageName = ImageLib.FOLDERNODE_IMAGE;
    } else if (type.equals(ENodeType.REPOSITORY_ELEMENT)) {
        if (node instanceof DBConnectionRepNode) {
            imageName = ImageLib.TD_DATAPROVIDER;
        } else if (node instanceof DFConnectionRepNode) {
            imageName = ImageLib.FILE_DELIMITED;
        } else if (node instanceof AnalysisRepNode) {
            imageName = ImageLib.ANALYSIS_OBJECT;
        } else if (node instanceof ReportRepNode) {
            imageName = ImageLib.REPORT_OBJECT;
        } else if (node instanceof SysIndicatorDefinitionRepNode) {
            imageName = ImageLib.IND_DEFINITION;
        } else if (node instanceof PatternRepNode) {
            imageName = ImageLib.PATTERN_REG;
        } else if (node instanceof RuleRepNode) {
            imageName = ImageLib.DQ_RULE;
        } else if (node instanceof SourceFileRepNode) {
            imageName = ImageLib.SOURCE_FILE;
        } else if (node instanceof ExchangeCategoryRepNode || node instanceof ExchangeComponentRepNode) {
            imageName = ImageLib.EXCHANGE;
        } else if (node instanceof JrxmlTempleteRepNode) {
            imageName = ImageLib.JRXML_ICON;
        }
    } else if (type.equals(ENodeType.TDQ_REPOSITORY_ELEMENT)) {
        if (node instanceof DBCatalogRepNode) {
            imageName = ImageLib.CATALOG;
        } else if (node instanceof DBSchemaRepNode) {
            imageName = ImageLib.SCHEMA;
        } else if (node instanceof DBTableFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBViewFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        } else if (node instanceof DBTableRepNode || node instanceof DFTableRepNode) {
            imageName = ImageLib.TABLE;
        } else if (node instanceof DBViewRepNode) {
            imageName = ImageLib.VIEW;
        } else if (node instanceof DBColumnRepNode) {
            if (((DBColumnRepNode) node).isKey()) {
                imageName = ImageLib.PK_COLUMN;
            } else {
                imageName = ImageLib.TD_COLUMN;
            }
        } else if (node instanceof DFColumnRepNode) {
            imageName = ImageLib.TD_COLUMN;
        } else if (node instanceof DBColumnFolderRepNode || node instanceof DFColumnFolderRepNode) {
            imageName = ImageLib.FOLDERNODE_IMAGE;
        }
    }
    return imageName;
}
Also used : DBConnectionRepNode(org.talend.dq.nodes.DBConnectionRepNode) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) SourceFileRepNode(org.talend.dq.nodes.SourceFileRepNode) DBViewFolderRepNode(org.talend.dq.nodes.DBViewFolderRepNode) DBCatalogRepNode(org.talend.dq.nodes.DBCatalogRepNode) ReportRepNode(org.talend.dq.nodes.ReportRepNode) ExchangeComponentRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode) SysIndicatorDefinitionRepNode(org.talend.dq.nodes.SysIndicatorDefinitionRepNode) DFTableRepNode(org.talend.dq.nodes.DFTableRepNode) DBConnectionFolderRepNode(org.talend.dq.nodes.DBConnectionFolderRepNode) DBViewRepNode(org.talend.dq.nodes.DBViewRepNode) PatternRepNode(org.talend.dq.nodes.PatternRepNode) DBTableFolderRepNode(org.talend.dq.nodes.DBTableFolderRepNode) DFColumnFolderRepNode(org.talend.dq.nodes.DFColumnFolderRepNode) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) RuleRepNode(org.talend.dq.nodes.RuleRepNode) JrxmlTempleteRepNode(org.talend.dq.nodes.JrxmlTempleteRepNode) RecycleBinRepNode(org.talend.dq.nodes.RecycleBinRepNode) DBColumnFolderRepNode(org.talend.dq.nodes.DBColumnFolderRepNode) DFColumnRepNode(org.talend.dq.nodes.DFColumnRepNode) DBTableRepNode(org.talend.dq.nodes.DBTableRepNode) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode) AnalysisRepNode(org.talend.dq.nodes.AnalysisRepNode) ExchangeCategoryRepNode(org.talend.dataprofiler.core.ui.exchange.ExchangeCategoryRepNode) DFConnectionRepNode(org.talend.dq.nodes.DFConnectionRepNode) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) ENodeType(org.talend.repository.model.IRepositoryNode.ENodeType) ReportAnalysisRepNode(org.talend.dq.nodes.ReportAnalysisRepNode)

Example 5 with RuleRepNode

use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.

the class ExportParserRuleWizard method performFinish.

@Override
public boolean performFinish() {
    String targetFile = page.getTargetFile();
    Object[] elements = page.getSelectedTree().getCheckedElements();
    List<ParserRule> parserRules = new ArrayList<ParserRule>();
    for (Object element : elements) {
        if (element instanceof RuleRepNode) {
            RuleRepNode ruleNode = (RuleRepNode) element;
            ParserRule parserRule = (ParserRule) ruleNode.getRule();
            parserRules.add(parserRule);
        }
    }
    if ("".equals(targetFile)) {
        // $NON-NLS-1$
        MessageDialog.openError(getShell(), DefaultMessagesImpl.getString("ExportParserRuleWizard.Error"), // $NON-NLS-1$ //$NON-NLS-2$
        DefaultMessagesImpl.getString("ExportParserRuleWizard.SpecifyValidResource"));
        return false;
    } else {
        File resource = new File(targetFile);
        if (isForExchange) {
            // export for exchange
            for (Iterator<ParserRule> iterator = parserRules.iterator(); iterator.hasNext(); ) {
                ParserRule parserRule = iterator.next();
                ExportFactory.export(resource, folder, parserRule);
                // $NON-NLS-1$
                File parserRuleFile = new File(resource, ExportFactory.toLocalFileName(parserRule.getName() + ".csv"));
                if (parserRuleFile.isFile() && parserRuleFile.exists()) {
                    try {
                        // $NON-NLS-1$
                        FilesUtils.zip(parserRuleFile, parserRuleFile.getPath() + ".zip");
                        parserRuleFile.delete();
                    } catch (Exception e) {
                        log.error(e.getMessage(), e);
                    }
                }
            }
        } else {
            // Export to local
            ExportFactory.export(resource, folder, parserRules.toArray(new ParserRule[parserRules.size()]));
        }
        CorePlugin.getDefault().refreshDQView(RepositoryNodeHelper.getLibrariesFolderNode(EResourceConstant.RULES_PARSER));
        CorePlugin.getDefault().refreshWorkSpace();
        return true;
    }
}
Also used : ParserRule(org.talend.dataquality.rules.ParserRule) ArrayList(java.util.ArrayList) RuleRepNode(org.talend.dq.nodes.RuleRepNode) File(java.io.File)

Aggregations

RuleRepNode (org.talend.dq.nodes.RuleRepNode)20 ArrayList (java.util.ArrayList)7 MatchRuleDefinition (org.talend.dataquality.rules.MatchRuleDefinition)6 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 AnalysisRepNode (org.talend.dq.nodes.AnalysisRepNode)5 DBTableRepNode (org.talend.dq.nodes.DBTableRepNode)5 DBViewRepNode (org.talend.dq.nodes.DBViewRepNode)5 HashMap (java.util.HashMap)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 DFConnectionRepNode (org.talend.dq.nodes.DFConnectionRepNode)4 PatternRepNode (org.talend.dq.nodes.PatternRepNode)4 ReportRepNode (org.talend.dq.nodes.ReportRepNode)4 SysIndicatorDefinitionRepNode (org.talend.dq.nodes.SysIndicatorDefinitionRepNode)4 Map (java.util.Map)3 TreeItem (org.eclipse.swt.widgets.TreeItem)3 TableIndicatorUnit (org.talend.dataprofiler.core.ui.editor.preview.TableIndicatorUnit)3 ExchangeComponentRepNode (org.talend.dataprofiler.core.ui.exchange.ExchangeComponentRepNode)3 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)3 DBCatalogRepNode (org.talend.dq.nodes.DBCatalogRepNode)3 DBColumnRepNode (org.talend.dq.nodes.DBColumnRepNode)3