use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.
the class DependenciesHandler method getIndicatorDependency.
/**
* get Indicator Dependency.
*
* @return get the list for analysis which use parameter to be a Indicator
*/
public List<IRepositoryViewObject> getIndicatorDependency(IRepositoryViewObject viewObject) {
Item item = viewObject.getProperty().getItem();
List<IRepositoryViewObject> listAnalysisViewObject = new ArrayList<IRepositoryViewObject>();
if (item instanceof TDQIndicatorDefinitionItemImpl) {
TDQIndicatorDefinitionItemImpl tdqIndicatorItem = (TDQIndicatorDefinitionItemImpl) item;
IndicatorDefinition newIndicatorDefinition = tdqIndicatorItem.getIndicatorDefinition();
List<IRepositoryViewObject> allAnaList = new ArrayList<IRepositoryViewObject>();
try {
allAnaList.addAll(ProxyRepositoryFactory.getInstance().getAll(ERepositoryObjectType.TDQ_ANALYSIS_ELEMENT, true));
} catch (PersistenceException e) {
log.error(e, e);
}
for (IRepositoryViewObject theAna : allAnaList) {
List<Indicator> indicators = IndicatorHelper.getIndicators(((TDQAnalysisItem) theAna.getProperty().getItem()).getAnalysis().getResults());
for (Indicator indicator : indicators) {
IndicatorDefinition oldIndicatorDefinition = indicator.getIndicatorDefinition();
if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
listAnalysisViewObject.add(theAna);
break;
}
}
}
}
return listAnalysisViewObject;
}
use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.
the class AnalysisSubFolderRepNode method getCount.
public String getCount() {
IRepositoryViewObject anaViewObject = this.getParent().getObject();
if (anaViewObject.getProperty() != null) {
TDQAnalysisItem item = (TDQAnalysisItem) anaViewObject.getProperty().getItem();
Analysis analysis = item.getAnalysis();
AnalysisContext context = analysis.getContext();
EList<ModelElement> analysedElements = context.getAnalysedElements();
if (analysedElements.size() == 1) {
ModelElement modelElement = analysedElements.get(0);
if (modelElement instanceof DatabaseConnection) {
EList<Package> dataPackage = ((DatabaseConnection) modelElement).getDataPackage();
// $NON-NLS-1$ //$NON-NLS-2$
return "(" + dataPackage.size() + ")";
}
}
// $NON-NLS-1$ //$NON-NLS-2$
return "(" + analysedElements.size() + ")";
}
// $NON-NLS-1$
return "(0)";
}
use of org.talend.dataquality.properties.TDQAnalysisItem 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.TDQAnalysisItem in project tdq-studio-se by Talend.
the class AnalysisWriter method removeDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#removeDependencies(org.talend.core.model.properties.Item)
*/
@Override
protected ReturnCode removeDependencies(Item item) {
ReturnCode rc = new ReturnCode();
TDQAnalysisItem anaItem = (TDQAnalysisItem) item;
Analysis analysis = anaItem.getAnalysis();
List<Property> clintDependency = DependenciesHandler.getInstance().getClintDependency(anaItem.getProperty());
List<ModelElement> clientDepListByResultList = DependenciesHandler.getInstance().getClientDepListByResult(analysis);
for (Property currentClient : clintDependency) {
ModelElement modelElement = PropertyHelper.getModelElement(currentClient);
if (!clientDepListByResultList.contains(modelElement)) {
boolean isSuccess = DependenciesHandler.getInstance().removeDependenciesBetweenModel(analysis, modelElement);
if (isSuccess) {
try {
ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(modelElement.eResource());
} catch (PersistenceException e) {
log.error(e, e);
rc.setOk(false);
rc.setMessage(e.getMessage());
}
} else {
rc.setOk(false);
rc.setMessage(// $NON-NLS-1$
Messages.getString(// $NON-NLS-1$
"AnalysisWriter.CanNotFindDependencyElement", // $NON-NLS-1$
analysis.getName(), modelElement.getName()));
}
}
}
return rc;
}
use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.
the class IndicatorDefinitionWriter method updateDependencies.
/*
* (non-Javadoc)
*
* @see org.talend.dq.writer.AElementPersistance#updateDependencies(orgomg.cwm.objectmodel.core.ModelElement)
*/
// @Override
protected void updateDependencies(ModelElement element) {
// update client dependency
// if IndicatorDefinition have client depencency, add codes here
IndicatorDefinition definition = (IndicatorDefinition) element;
Property property = PropertyHelper.getProperty(definition);
List<IRepositoryViewObject> listIndicatorDependency = DependenciesHandler.getInstance().getIndicatorDependency(new RepositoryViewObject(property));
for (IRepositoryViewObject viewObject : listIndicatorDependency) {
Item item = viewObject.getProperty().getItem();
if (item instanceof TDQAnalysisItem) {
try {
ProxyRepositoryFactory.getInstance().save(item);
} catch (PersistenceException e) {
log.error(e, e);
}
}
}
}
Aggregations