use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class AnalysisWriter method addDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
*/
@Override
public void addDependencies(ModelElement element) {
Analysis analysis = (Analysis) element;
List<IndicatorDefinition> udis = AnalysisHelper.getUserDefinedIndicators(analysis);
try {
for (IndicatorDefinition udi : udis) {
if (udi == null) {
continue;
}
InternalEObject iudi = (InternalEObject) udi;
if (!iudi.eIsProxy()) {
DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(udi);
// only do save when the dependency is not reference project node
if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, udi);
if (dependencyReturn.isOk()) {
Property property = PropertyHelper.getProperty(udi);
if (property != null) {
TDQItem udiItem = (TDQItem) property.getItem();
if (udiItem instanceof TDQIndicatorDefinitionItem) {
((TDQIndicatorDefinitionItem) udiItem).setIndicatorDefinition(udi);
} else if (udiItem instanceof TDQBusinessRuleItem) {
((TDQBusinessRuleItem) udiItem).setDqrule((DQRule) udi);
}
}
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
}
}
}
}
List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
for (Pattern pattern : patterns) {
InternalEObject iptn = (InternalEObject) pattern;
if (!iptn.eIsProxy()) {
DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
// only do save when the dependency is not reference project node
if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
if (dependencyReturn.isOk()) {
Property property = PropertyHelper.getProperty(pattern);
if (property != null && property.getItem() instanceof TDQPatternItem) {
TDQPatternItem patternItem = (TDQPatternItem) property.getItem();
patternItem.setPattern(pattern);
}
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
// EMFUtil.saveSingleResource(pattern.eResource());
}
}
}
}
} catch (PersistenceException e) {
log.error(e, e);
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ReportWriter method addDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
*/
@Override
public void addDependencies(ModelElement element) {
TdReport report = (TdReport) element;
List<Analysis> analyses = ReportHelper.getAnalyses(report);
for (Analysis ana : analyses) {
// TDQ-7999,filter the proxy.
if (!ana.eIsProxy()) {
AnalysisRepNode recursiveFindAnalysis = RepositoryNodeHelper.recursiveFindAnalysis(ana);
// only do save when the dependency is not reference project node
if (recursiveFindAnalysis != null && recursiveFindAnalysis.getProject().isMainProject()) {
TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(report, ana);
if (dependencyReturn.isOk()) {
try {
Property property = PropertyHelper.getProperty(ana);
if (property != null) {
Item item = property.getItem();
if (item instanceof TDQAnalysisItem) {
TDQAnalysisItem anaItem = (TDQAnalysisItem) item;
anaItem.setAnalysis(ana);
}
}
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(ana.eResource());
} catch (PersistenceException e) {
log.error(e, e);
}
}
}
}
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class WorkbenchUtils method impactExistingAnalyses.
/**
* DOC qiongli TDQ-3317:move this method from ReloadDatabaseAction. to this class .
*
* @param oldDataProvider
* @throws PartInitException
*/
public static void impactExistingAnalyses(DataProvider oldDataProvider) throws PartInitException {
EList<Dependency> clientDependencies = oldDataProvider.getSupplierDependency();
List<Analysis> unsynedAnalyses = new ArrayList<Analysis>();
for (Dependency dep : clientDependencies) {
for (ModelElement mod : dep.getClient()) {
// MOD mzhao 2009-08-24 The dependencies include "Property" and "Analysis"
if (!(mod instanceof Analysis)) {
continue;
}
Analysis ana = (Analysis) mod;
unsynedAnalyses.add(ana);
}
for (Analysis analysis : unsynedAnalyses) {
// Reload.
IFile file = getTempAnalysisFile(analysis);
Analysis tempAnalysis = (Analysis) AnaResourceFileHelper.getInstance().getModelElement(file);
// MOD qiongli 2010-8-17,bug 14977
if (tempAnalysis != null) {
Resource eResource = tempAnalysis.eResource();
Map<EObject, Collection<Setting>> referenceMaps = EcoreUtil.UnresolvedProxyCrossReferencer.find(eResource);
Iterator<EObject> it = referenceMaps.keySet().iterator();
ModelElement eobj = null;
boolean isModified = false;
while (it.hasNext()) {
eobj = (ModelElement) it.next();
Collection<Setting> settings = referenceMaps.get(eobj);
for (Setting setting : settings) {
if (setting.getEObject() instanceof AnalysisContext) {
tempAnalysis.getContext().getAnalysedElements().remove(eobj);
isModified = true;
} else if (setting.getEObject() instanceof Indicator) {
// the only indicator in the column set analysis. (Added TDQ-8842 20140512 yyin)
if (AnalysisType.COLUMN_SET.equals(tempAnalysis.getParameters().getAnalysisType())) {
// ~
((SimpleStatIndicator) setting.getEObject()).getAnalyzedColumns().remove(eobj);
} else {
tempAnalysis.getResults().getIndicators().remove(setting.getEObject());
}
isModified = true;
}
}
}
if (isModified) {
saveTempAnalysis(file, tempAnalysis);
}
// Should reopen this analyis's editor if it is opened now. what ever it is modified or not.
EventManager.getInstance().publish(tempAnalysis.getName(), EventEnum.DQ_ANALYSIS_REOPEN_EDITOR, null);
}
}
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DQRepositoryViewLabelProvider method addWarnIconIfNeeded.
/**
* if it is needed,add a over warning icon..eg., it is empty analysis or report; imported a MDM analysis or report.
*
* @param image
* @param node
* @param originalImageName
* @return
*/
private Image addWarnIconIfNeeded(IRepositoryNode node, String originalImageName) {
ModelElement modEle = RepositoryNodeHelper.getResourceModelElement(node);
ERepositoryObjectType objectType = node.getObjectType();
if (modEle != null) {
if (ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT == objectType) {
Analysis analysis = (Analysis) modEle;
AnalysisContext context = analysis.getContext();
if (context == null) {
return ImageLib.createInvalidIcon(originalImageName);
}
EList<ModelElement> analysedElements = context.getAnalysedElements();
DataManager connection = context.getConnection();
if (analysedElements.isEmpty() || connection instanceof MDMConnection) {
return ImageLib.createInvalidIcon(originalImageName);
}
} else if (ERepositoryObjectType.TDQ_REPORT_ELEMENT == objectType) {
TdReport report = (TdReport) modEle;
EList<AnalysisMap> analysisMap = report.getAnalysisMap();
if (analysisMap.isEmpty()) {
return ImageLib.createInvalidIcon(originalImageName);
}
for (AnalysisMap anaMap : report.getAnalysisMap()) {
Analysis analysis = anaMap.getAnalysis();
if (analysis == null || analysis.getContext() == null) {
continue;
}
DataManager connection = analysis.getContext().getConnection();
if (connection instanceof MDMConnection) {
return ImageLib.createInvalidIcon(originalImageName);
}
}
}
}
return ImageLib.getImage(originalImageName);
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class WorkbenchUtils method nodifyDependedAnalysis.
public static void nodifyDependedAnalysis(ConnectionItem connectionItem) {
// Added TDQ-8360 20140410 yyin: notify each depended analysis
EList<Dependency> clientDependencies = connectionItem.getConnection().getSupplierDependency();
for (Dependency dep : clientDependencies) {
for (ModelElement mod : dep.getClient()) {
if (!(mod instanceof Analysis)) {
continue;
}
EventManager.getInstance().publish(mod, EventEnum.DQ_ANALYSIS_REFRESH_DATAPROVIDER_LIST, null);
EventManager.getInstance().publish(mod, EventEnum.DQ_MATCH_ANALYSIS_REFRESH_DATAPROVIDER_LABEL, null);
}
}
}
Aggregations