use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.
the class TOPRepositoryService method createParserRuleItem.
public void createParserRuleItem(ArrayList<HashMap<String, Object>> values, String parserRuleName) {
ParserRule parserRule = null;
DqRuleBuilder ruleBuilder = new DqRuleBuilder();
boolean ruleInitialized = ruleBuilder.initializeParserRuleBuilder(parserRuleName);
if (ruleInitialized) {
parserRule = ruleBuilder.getParserRule();
}
TaggedValueHelper.setValidStatus(true, parserRule);
for (HashMap<String, Object> expression : values) {
parserRule.addExpression(expression.get(RULE_NAME).toString(), expression.get(RULE_TYPE) instanceof Integer ? Integer.toString((Integer) expression.get(RULE_TYPE)) : expression.get(RULE_TYPE).toString(), expression.get(RULE_VALUE).toString());
}
IndicatorCategory ruleIndicatorCategory = DefinitionHandler.getInstance().getDQRuleIndicatorCategory();
if (ruleIndicatorCategory != null && !parserRule.getCategories().contains(ruleIndicatorCategory)) {
parserRule.getCategories().add(ruleIndicatorCategory);
}
IFolder folder = ResourceManager.getRulesParserFolder();
TypedReturnCode<Object> returnObject = ElementWriterFactory.getInstance().createdRuleWriter().create(parserRule, folder);
Object object = returnObject.getObject();
RuleRepNode parserRuleNode = RepositoryNodeHelper.recursiveFindRuleParser(parserRule);
BusinessRuleItemEditorInput parserRuleEditorInput = new BusinessRuleItemEditorInput(parserRuleNode);
CorePlugin.getDefault().openEditor(parserRuleEditorInput, DQRuleEditor.class.getName());
refresh(object);
}
use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.
the class MatchRuleElementTreeSelectionDialog method getParticularRulesFromNodes.
/**
* Get particular rules from nodes
*
* @param nodes
* @param retrieveDisplayValue get the display value when this parameter is set to true, otherwise, get the
* component value.
* @return
*/
public List<Map<String, String>> getParticularRulesFromNodes(Object[] nodes, boolean retrieveDisplayValue) {
List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
for (Object rule : nodes) {
if (rule instanceof RuleRepNode) {
RuleRepNode node = (RuleRepNode) rule;
MatchRuleDefinition matchRuleDefinition = (MatchRuleDefinition) node.getRule();
ruleValues.addAll(getParticularSurvivorshipRulesFromRules(matchRuleDefinition, retrieveDisplayValue));
}
}
return ruleValues;
}
use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.
the class MatchRuleElementTreeSelectionDialog method createDialogArea.
@Override
protected Control createDialogArea(final Composite parent) {
final SashForm form = new SashForm(parent, SWT.SMOOTH | SWT.VERTICAL | SWT.FILL);
form.setSize(Math.min(Display.getCurrent().getActiveShell().getSize().x, 800), 580);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true, 0, 0);
form.setLayoutData(data);
Composite composite = (Composite) super.createDialogArea(form);
getTreeViewer().addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
if (dialogType != SUGGEST_TYPE) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
Object[] array = selection.toArray();
if (array.length == 1) {
if (array[0] != null) {
MatchRuleDefinition matchRuleDefinition = null;
if (array[0] instanceof RuleRepNode) {
RuleRepNode node = (RuleRepNode) array[0];
matchRuleDefinition = (MatchRuleDefinition) node.getRule();
}
if (matchRuleDefinition != null) {
// MatchAnalysis tmatchGroup tRecordMatching tGenKey will come here
algorithmValue.setText(RecordMatcherType.valueOf(matchRuleDefinition.getRecordLinkageAlgorithm()).getLabel());
if (blockingKeysTable != null) {
blockingKeysTable.setInput(getBlockingKeysFromNodes(array, true));
}
if (matchingRulesTable != null) {
matchRulesTableComposite.dispose();
if (StringUtils.equals(RecordMatcherType.T_SwooshAlgorithm.name(), matchRuleDefinition.getRecordLinkageAlgorithm())) {
if (particularSurvivRulesTableComposite != null) {
particularSurvivRulesTableComposite.dispose();
particularSurvivRulesTableComposite = null;
}
createSelectMatchRulesTableTswoosh(form);
if (dialogType == MATCHGROUP_TYPE) {
createParticularSurvivorshipRulesTableTswoosh(form);
form.setWeights(new int[] { 5, 3, 2 });
} else if (dialogType == MATCH_ANALYSIS_TYPE) {
createParticularSurvivorshipRulesTableTswoosh(form);
form.setWeights(new int[] { 4, 2, 2, 2 });
}
// MatchAnalysis tmatchGroup tRecordMatching will come here
if (particularSurvivRulesTable != null) {
// MatchAnalysis tmatchGroup will come here
particularSurvivRulesTable.setInput(getParticularRulesFromNodes(array, true));
}
} else {
createSelectMatchRulesTableVsr(form);
if (particularSurvivRulesTableComposite != null && dialogType == MATCHGROUP_TYPE) {
particularSurvivRulesTableComposite.dispose();
particularSurvivRulesTableComposite = null;
form.setWeights(new int[] { 3, 2 });
} else if (particularSurvivRulesTableComposite != null && dialogType == MATCH_ANALYSIS_TYPE) {
particularSurvivRulesTableComposite.dispose();
particularSurvivRulesTableComposite = null;
form.setWeights(new int[] { 5, 3, 2 });
}
}
matchingRulesTable.setInput(getMatchRulesFromNodes(array, true));
// refresh the dialog
matchRulesTableComposite.getParent().layout();
matchRulesTableComposite.getParent().redraw();
}
}
}
}
}
}
});
if (dialogType == GENKEY_TYPE) {
createSelectBlockingKeysTable(form);
form.setWeights(new int[] { 3, 2 });
} else if (dialogType == MATCHGROUP_TYPE) {
createSelectMatchRulesTableVsr(form);
createParticularSurvivorshipRulesTableTswoosh(form);
form.setWeights(new int[] { 5, 3, 2 });
} else if (dialogType == RECORD_MATCHING_TYPE) {
createSelectMatchRulesTableVsr(form);
form.setWeights(new int[] { 3, 2 });
} else if (dialogType == MATCH_ANALYSIS_TYPE) {
createSelectBlockingKeysTable(form);
createSelectMatchRulesTableVsr(form);
createParticularSurvivorshipRulesTableTswoosh(form);
form.setWeights(new int[] { 4, 2, 2, 2 });
} else if (dialogType == SUGGEST_TYPE) {
createSelectBlockingKeysTable(form);
createSelectMatchRulesTableVsr(form);
form.setWeights(new int[] { 5, 2, 3 });
if (blockingKeysTable != null) {
blockingKeysTable.setInput(getBlockingKeysFromRules(matchRuleDefinitionInput, true));
}
if (matchingRulesTable != null) {
matchingRulesTable.setInput(getMatchRulesFromRules(matchRuleDefinitionInput, true));
}
}
createCheckerArea(composite);
return composite;
}
use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.
the class MatchRuleElementTreeSelectionDialog method getMatchRulesFromNodes.
/**
* DOC sizhaoliu Comment method "getMatchRulesFromNodes".
*
* @param nodes
* @param retrieveDisplayValue get the display value when this parameter is set to true, otherwise, get the
* component value.
* @return
*/
public List<Map<String, String>> getMatchRulesFromNodes(Object[] nodes, boolean retrieveDisplayValue) {
List<Map<String, String>> ruleValues = new ArrayList<Map<String, String>>();
for (Object rule : nodes) {
if (rule instanceof RuleRepNode) {
RuleRepNode node = (RuleRepNode) rule;
MatchRuleDefinition matchRuleDefinition = (MatchRuleDefinition) node.getRule();
ruleValues.addAll(getMatchRulesFromRules(matchRuleDefinition, retrieveDisplayValue));
}
}
return ruleValues;
}
use of org.talend.dq.nodes.RuleRepNode in project tdq-studio-se by Talend.
the class RepositoryNodeHelper method recursiveFindRuleSql.
public static RuleRepNode recursiveFindRuleSql(DQRule rule) {
if (rule == null) {
return null;
}
String uuid = getUUID(rule);
if (uuid == null) {
return null;
}
IRepositoryNode ruleSQLFolderNode = getRuleSQLFolderNode(rule);
List<RuleRepNode> ruleRepNodes = getRuleRepNodes(ruleSQLFolderNode, true, true);
if (ruleRepNodes.size() > 0) {
for (RuleRepNode childNode : ruleRepNodes) {
if (uuid.equals(getUUID(childNode.getRule()))) {
return childNode;
}
}
}
return null;
}
Aggregations