use of org.talend.dataquality.properties.TDQMatchRuleItem in project tmdm-studio-se by Talend.
the class RepositoryResourceUtil method getItemFile.
public static IFile getItemFile(IRepositoryViewObject viewObj) {
Item item = viewObj.getProperty().getItem();
// $NON-NLS-1$
String extName = "item";
if (item instanceof TDQMatchRuleItem) {
// $NON-NLS-1$
extName = "rules";
}
return findReferenceFile(viewObj.getRepositoryObjectType(), item, extName);
}
use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.
the class PropertyHelper method getModelElement.
/**
* DOC bZhou Comment method "getModelElement".
*
* Get model element from property recognized by current system.
*
* @param property
* @return
*/
public static ModelElement getModelElement(Property property) {
Item item = property.getItem();
assert item != null;
ModelElement element = (ModelElement) new org.talend.core.model.properties.util.PropertiesSwitch() {
@Override
public Object caseDatabaseConnectionItem(DatabaseConnectionItem object) {
return object.getConnection();
}
@Override
public Object caseMDMConnectionItem(MDMConnectionItem object) {
return object.getConnection();
}
@Override
public Object caseDelimitedFileConnectionItem(DelimitedFileConnectionItem object) {
return object.getConnection();
}
}.doSwitch(item);
if (element == null) {
element = new org.talend.dataquality.properties.util.PropertiesSwitch<ModelElement>() {
@Override
public ModelElement caseTDQReportItem(TDQReportItem object) {
return object.getReport();
}
@Override
public ModelElement caseTDQAnalysisItem(TDQAnalysisItem object) {
return object.getAnalysis();
}
@Override
public ModelElement caseTDQBusinessRuleItem(TDQBusinessRuleItem object) {
return object.getDqrule();
}
/*
* (non-Javadoc)
*
* @see
* org.talend.dataquality.properties.util.PropertiesSwitch#caseTDQMatchRuleItem(org.talend.dataquality
* .properties.TDQMatchRuleItem)
*/
@Override
public ModelElement caseTDQMatchRuleItem(TDQMatchRuleItem object) {
return object.getMatchRule();
}
@Override
public ModelElement caseTDQIndicatorDefinitionItem(TDQIndicatorDefinitionItem object) {
return object.getIndicatorDefinition();
}
@Override
public ModelElement caseTDQPatternItem(TDQPatternItem object) {
return object.getPattern();
}
}.doSwitch(item);
}
return element;
}
use of org.talend.dataquality.properties.TDQMatchRuleItem in project tdq-studio-se by Talend.
the class AbstractWizard method performFinish.
@Override
public boolean performFinish() {
// wizard. TODO: consider other better solution.
if (isDoingPerformFinish) {
return true;
}
isDoingPerformFinish = true;
// MOD mzhao feature 15750 Use repository object represent ModelElement.
modelElement = initCWMResourceBuilder();
if (modelElement != null) {
fillMetadataToCWMResource(modelElement);
// Save the repository objects.
TypedReturnCode<Object> csResult = createAndSaveCWMFile(modelElement);
if (csResult.isOk()) {
Object savedObj = csResult.getObject();
if (savedObj instanceof Item) {
if (!RepositoryNodeHelper.isOpenDQCommonViewer() && savedObj instanceof TDQMatchRuleItem) {
openEditor((TDQMatchRuleItem) savedObj);
} else {
RepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(((Item) savedObj).getProperty());
openEditor(recursiveFind);
}
}
CorePlugin.getDefault().refresh(modelElement);
isDoingPerformFinish = false;
return true;
} else {
MessageUI.openError(csResult.getMessage());
}
}
isDoingPerformFinish = false;
return false;
}
use of org.talend.dataquality.properties.TDQMatchRuleItem 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.properties.TDQMatchRuleItem 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;
}
Aggregations