use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ItemRecord method getSystemIndicaotrOfAnalysis.
/**
* get Analysis Dependency (for indicator only).
*
* @return get the list of indicator which in use by the analysis
*/
private List<File> getSystemIndicaotrOfAnalysis(ModelElement mElement) {
List<File> listFile = new ArrayList<File>();
if (mElement instanceof Analysis) {
Analysis anaElement = (Analysis) mElement;
List<Indicator> indicators = IndicatorHelper.getIndicators(anaElement.getResults());
for (Indicator indicator : indicators) {
if (indicator instanceof UserDefIndicator) {
// whereRuleIndicator or UDIIndicator
continue;
}
boolean isContain = false;
IndicatorDefinition newIndicatorDefinition = indicator.getIndicatorDefinition();
// MOD qiongli 2012-5-11 TDQ-5256
if (newIndicatorDefinition == null) {
continue;
}
for (File lf : listFile) {
ModelElement me = getElement(lf);
if (me != null && me instanceof IndicatorDefinition) {
IndicatorDefinition oldIndicatorDefinition = (IndicatorDefinition) me;
if (ModelElementHelper.compareUUID(oldIndicatorDefinition, newIndicatorDefinition)) {
isContain = true;
break;
}
}
}
if (!isContain) {
File depFile = EObjectHelper.modelElement2File(newIndicatorDefinition);
if (depFile != null) {
FILE_ELEMENT_MAP.put(depFile, newIndicatorDefinition);
listFile.add(depFile);
}
}
}
}
return listFile;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ImportWizardPage method checkforErrors.
/**
* check that directory exist and issue an error message if not. <br>
* check that the folder is a data quality repository or issue an error.<br>
* check that anything is check in the tree or issue an error.<br>
*/
protected void checkforErrors() {
List<String> dErrors = new ArrayList<String>();
if (repositoryTree.getTree().getItems().length == 0) {
// $NON-NLS-1$
dErrors.add(Messages.getString("ImportWizardPage.0"));
}
if (repositoryTree.getCheckedElements().length == 0) {
// $NON-NLS-1$
dErrors.add(Messages.getString("ImportWizardPage.1"));
}
dErrors.addAll(writer.check());
ItemRecord[] elements = getElements();
for (ItemRecord record : elements) {
dErrors.addAll(record.getErrors());
for (File depFile : record.getDependencySet()) {
ItemRecord findRecord = ItemRecord.findRecord(depFile);
if (findRecord == null || !repositoryTree.getChecked(findRecord)) {
// TDQ-12410: if the dependency comes from reference project, we ingore it.
if (!DqFileUtils.isFileUnderBasePath(depFile, writer.getBasePath())) {
continue;
}
ModelElement element = ItemRecord.getElement(depFile);
// Indicator, don't add it into errors even if it is not exist
if (element instanceof IndicatorDefinition) {
String uuid = ResourceHelper.getUUID(element);
if (IndicatorDefinitionFileHelper.isTechnialIndicator(uuid)) {
continue;
}
}
// MOD qiongli 2012-12-13 TDQ-5356 use itself file name for jrxml
boolean isJrxmlDepFile = depFile.getName().endsWith(FactoriesUtil.JRXML);
// MOD msjian TDQ-5909: modify to displayName
String dptLabel = element != null && !isJrxmlDepFile && PropertyHelper.getProperty(element) != null ? PropertyHelper.getProperty(element).getDisplayName() : depFile.getName();
// TDQ-5909~
// $NON-NLS-1$ //$NON-NLS-2$
dErrors.add("\"" + record.getName() + "\" miss dependency :" + dptLabel);
}
}
}
if (!dErrors.isEmpty()) {
setErrorMessage(dErrors.get(0));
} else {
setErrorMessage(null);
}
updatePageStatus();
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class FileSystemImportWriter method updateAnalysisClientDependence.
/**
* remove the old client dependency add a new one in Anlaysis.
*
* @param supplierItem
* @param modelElement
* @throws PersistenceException
*/
private void updateAnalysisClientDependence(TDQItem supplierItem, Property property) throws PersistenceException {
ModelElement anaModelElement = PropertyHelper.getModelElement(property);
if (anaModelElement != null) {
Analysis analysis = (Analysis) anaModelElement;
EList<Dependency> clientDependency = anaModelElement.getClientDependency();
Iterator<Dependency> it = clientDependency.iterator();
ModelElement supplierModelElement = RepositoryNodeHelper.getResourceModelElement(supplierItem);
Resource supModeResource = supplierModelElement.eResource();
while (it.hasNext()) {
Dependency clientDep = it.next();
// systemSupplyModelElement,remove it.
if (clientDep.eResource() == null) {
URI clientDepURI = ((InternalEObject) clientDep).eProxyURI();
boolean isUDI = clientDepURI.path().contains(ResourceManager.getUDIFolder().getProjectRelativePath().toString());
boolean isPattern = clientDepURI.path().contains(ResourceManager.getPatternFolder().getProjectRelativePath().toString());
if (supModeResource != null && (isUDI || isPattern) && clientDepURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
it.remove();
break;
}
}
}
DependenciesHandler.getInstance().setUsageDependencyOn(anaModelElement, supplierModelElement);
// TDQ-8436 remove the old pattern and add the new pattern in analysis Indicator Parameters.
if (isPattern(supplierModelElement)) {
updatePatternInAnaParams(supplierModelElement, analysis);
ElementWriterFactory.getInstance().createPatternWriter().save(supplierItem, true);
}
// remove old udi and set a new one in the analysis indicators.
if (supplierModelElement instanceof UDIndicatorDefinition) {
if (analysis.getResults() != null) {
EList<Indicator> indicators = analysis.getResults().getIndicators();
Iterator<Indicator> itIndicators = indicators.iterator();
while (itIndicators.hasNext()) {
Indicator indicator = itIndicators.next();
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
if (indicatorDefinition.eResource() == null) {
URI indicatorDefURI = ((InternalEObject) indicatorDefinition).eProxyURI();
if (supModeResource != null && UDIHelper.isUDI(indicator) && indicatorDefURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
indicator.setIndicatorDefinition((UDIndicatorDefinition) supplierModelElement);
break;
}
}
}
ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(supplierItem, true);
}
}
// only save analysis item at here.
ProxyRepositoryFactory.getInstance().save(property.getItem(), true);
}
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ColumnAnalysisSqlExecutor method getIndicatorDefinition.
/**
* DOC talend Comment method "getIndicatorDefinition".
*
* @param indicator
* @return
*/
private TypedReturnCode<IndicatorDefinition> getIndicatorDefinition(Indicator indicator) {
TypedReturnCode<IndicatorDefinition> rt = new TypedReturnCode<IndicatorDefinition>(true);
IndicatorDefinition indicatorDefinition;
String label = indicator.getIndicatorDefinition().getLabel();
if (label == null || PluginConstant.EMPTY_STRING.equals(label)) {
indicatorDefinition = indicator.getIndicatorDefinition();
} else {
indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(label);
}
// TDQ-10559: when the indicator is in reference project, the above can get NOTHING
if (indicatorDefinition == null) {
indicatorDefinition = indicator.getIndicatorDefinition();
if (indicatorDefinition.eIsProxy()) {
indicatorDefinition = (IndicatorDefinition) EObjectHelper.resolveObject(indicatorDefinition);
}
}
if (indicatorDefinition == null) {
traceError(Messages.getString("ColumnAnalysisSqlExecutor.INTERNALERROR", // $NON-NLS-1$
AnalysisExecutorHelper.getIndicatorName(indicator)));
rt.setOk(false);
}
rt.setObject(indicatorDefinition);
return rt;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class MultiColumnAnalysisExecutor method initializeNumericFunctions.
/**
* DOC scorreia Comment method "initializeNumericFunctions".
*
* @param indicator
* @return
*/
private EList<String> initializeNumericFunctions(ColumnSetMultiValueIndicator indicator) {
final EList<String> numericFunctions = indicator.getNumericFunctions();
if (!numericFunctions.isEmpty()) {
// could be already set
return numericFunctions;
}
final IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
final List<String> aggregate1argFunctions = dbms().getAggregate1argFunctions(indicatorDefinition);
numericFunctions.addAll(aggregate1argFunctions);
return numericFunctions;
}
Aggregations