use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.
the class AElementPersistance method createItem.
/**
* DOC bZhou Comment method "createItem".
*
* @param element
* @return
*/
public Item createItem(ModelElement element) {
Item item = null;
// MOD mzhao feature 13114, 2010-05-19 distinguish tdq items.
if (ModelElementIdentifier.isAnalysis(element)) {
item = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
((TDQAnalysisItem) item).setAnalysis((Analysis) element);
} else if (ModelElementIdentifier.isDQRule(element)) {
item = PropertiesFactory.eINSTANCE.createTDQBusinessRuleItem();
((TDQBusinessRuleItem) item).setDqrule((DQRule) element);
} else if (ModelElementIdentifier.isDataProvider(element)) {
if (element instanceof DatabaseConnection) {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createDatabaseConnectionItem();
((ConnectionItem) item).setConnection((DatabaseConnection) element);
}
((ConnectionItem) item).setConnection((Connection) element);
} else if (ModelElementIdentifier.isMatchRule(element)) {
// this Condition must before the IndicatorDefinition one because MatchRule instance of it.
item = PropertiesFactory.eINSTANCE.createTDQMatchRuleItem();
((TDQMatchRuleItem) item).setMatchRule((MatchRuleDefinition) element);
} else if (ModelElementIdentifier.isID(element)) {
item = PropertiesFactory.eINSTANCE.createTDQIndicatorDefinitionItem();
((TDQIndicatorDefinitionItem) item).setIndicatorDefinition((IndicatorDefinition) element);
} else if (ModelElementIdentifier.isPattern(element)) {
item = PropertiesFactory.eINSTANCE.createTDQPatternItem();
((TDQPatternItem) item).setPattern((Pattern) element);
} else if (ModelElementIdentifier.isReport(element)) {
item = PropertiesFactory.eINSTANCE.createTDQReportItem();
((TDQReportItem) item).setReport((Report) element);
} else {
item = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createTDQItem();
}
ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
itemState.setDeleted(false);
item.setState(itemState);
if (item instanceof TDQItem) {
setTDQItemFileName(element, item);
}
Resource eResource = element.eResource();
if (eResource != null) {
URI uri = eResource.getURI();
if (uri.isPlatform()) {
IPath elementPath = new Path(uri.toPlatformString(true)).removeLastSegments(1);
IPath typedPath = ResourceManager.getRootProject().getFullPath().append(PropertyHelper.getItemTypedPath(item));
IPath statePath = elementPath.makeRelativeTo(typedPath);
itemState.setPath(statePath.toString());
}
}
return item;
}
use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.
the class MatchRuleDefinitionWriter method save.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#save(org.talend.core.model.properties.Item, boolean)
*/
@Override
public ReturnCode save(final Item item, final boolean careDependency) {
ReturnCode rc = new ReturnCode();
RepositoryWorkUnit<Object> repositoryWorkUnit = new // $NON-NLS-1$
RepositoryWorkUnit<Object>(// $NON-NLS-1$
"save MatchRule Definition item") {
@Override
protected void run() throws LoginException, PersistenceException {
TDQMatchRuleItem matchRuleItem = (TDQMatchRuleItem) item;
MatchRuleDefinition matchRuleDefinition = matchRuleItem.getMatchRule();
if (careDependency) {
saveWithDependencies(matchRuleItem, matchRuleDefinition);
} else {
saveWithoutDependencies(matchRuleItem, matchRuleDefinition);
}
}
};
repositoryWorkUnit.setAvoidUnloadResources(true);
ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(repositoryWorkUnit);
try {
repositoryWorkUnit.throwPersistenceExceptionIfAny();
} catch (PersistenceException e) {
log.error(e, e);
rc.setOk(Boolean.FALSE);
rc.setMessage(e.getMessage());
}
return rc;
}
use of org.talend.dataquality.rules.MatchRuleDefinition in project tdq-studio-se by Talend.
the class AnaMatchSurvivorSection method checkAndRemoveEmptyMatchRule.
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.record.linkage.ui.section.MatchingKeySection#checkAndRemoveEmptyMatchRule(org.eclipse.
* swt.custom.CTabItem)
*/
@Override
protected void checkAndRemoveEmptyMatchRule(CTabItem theTab) {
MatchRule matchRule = getMatchRule(theTab);
List<MatchKeyAndSurvivorDefinition> matchAndSurvDefList = matchRuleWithSurvMap.get(matchRule);
if (matchAndSurvDefList.size() <= 0) {
MatchRuleDefinition matchRuleDefinition = getMatchRuleDefinition();
matchRuleDefinition.getMatchRules().remove(matchRule);
for (MatchKeyAndSurvivorDefinition matchAndSurvDef : matchAndSurvDefList) {
matchRuleDefinition.getSurvivorshipKeys().remove(matchAndSurvDef.getSurvivorShipKey());
}
}
}
use of org.talend.dataquality.rules.MatchRuleDefinition 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.dataquality.rules.MatchRuleDefinition 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;
}
Aggregations