use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class AnalysisHelper method getUserDefinedIndicators.
public static List<IndicatorDefinition> getUserDefinedIndicators(Analysis analysis) {
List<IndicatorDefinition> rets = new ArrayList<IndicatorDefinition>();
EList<Indicator> indicators = analysis.getResults().getIndicators();
for (Indicator indicator : indicators) {
if (indicator instanceof UserDefIndicator) {
rets.add(indicator.getIndicatorDefinition());
}
}
return rets;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class AnalysisExecutorHelper method checkIndicatorWithChild.
/**
* DOC zhao Comment method "checkIndicatorWithChild".
*
* @param indicator
* @return
*/
private static ReturnCode checkIndicatorWithChild(Indicator indicator) {
ReturnCode rc = new ReturnCode(Boolean.TRUE);
if (indicator.getBuiltInIndicatorDefinition() != null) {
return rc;
}
// Get indicator definition from dependent file
IndicatorDefinition dependentDefinition = indicator.getIndicatorDefinition();
if (isDependentFileExist(dependentDefinition)) {
IndicatorDefinition deepCopiedDefinition;
if (dependentDefinition instanceof WhereRule) {
deepCopiedDefinition = copyWhereRule((WhereRule) dependentDefinition);
} else {
deepCopiedDefinition = EObjectHelper.deepCopy(dependentDefinition);
}
// Hot copy to built-in definition.
deepCopiedDefinition.getSupplierDependency().clear();
// TDQ-10737 Because 'BuiltInIndicatorDefinition' is a containment reference, need to Clear these 3 non-containment
// reference list
deepCopiedDefinition.getCategories().clear();
deepCopiedDefinition.getAggregatedDefinitions().clear();
deepCopiedDefinition.getSubCategories().clear();
indicator.setBuiltInIndicatorDefinition(deepCopiedDefinition);
EMFUtil.saveResource(indicator.eResource());
} else {
IndicatorDefinition builtInDefinition = indicator.getBuiltInIndicatorDefinition();
if (builtInDefinition == null) {
// $NON-NLS-1$
rc.setMessage(Messages.getString("AnalysisExecutor.BuiltInNoIndicators"));
rc.setOk(false);
return rc;
} else {
indicator.setIndicatorDefinition(null);
}
}
return rc;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class AnalysisExecutorHelper method copyWhereRule.
/**
* When deep copy, if the where rule contains some joins, it will copy all related tables(extended in related db),
* but this is not what we want, so we use a temp list to store the joins, and then clear the joins before deep copy
* to avoid copy many useless things, and restore the joins after deep copy.
*
* @param dependentDefinition
*/
private static IndicatorDefinition copyWhereRule(WhereRule dependentDefinition) {
// firstly clear the dependency of the analysis
dependentDefinition.getSupplierDependency().clear();
// then , record the joins in a temp list
EList<JoinElement> joins = dependentDefinition.getJoins();
List<JoinElement> copyJoins = new ArrayList<JoinElement>();
if (!joins.isEmpty()) {
for (JoinElement element : joins) {
copyJoins.add(element);
}
dependentDefinition.getJoins().clear();
}
IndicatorDefinition deepCopiedDefinition = EObjectHelper.deepCopy(dependentDefinition);
// after deep copy, restore the joins.
if (!copyJoins.isEmpty()) {
((WhereRule) deepCopiedDefinition).getJoins().addAll(copyJoins);
dependentDefinition.getJoins().addAll(copyJoins);
}
return deepCopiedDefinition;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class IndcatorSwitchImp method setIndicatorDefinition.
private Boolean setIndicatorDefinition(Indicator indicator, String definitionLabel) {
if (definitionLabel == null) {
return false;
}
// get the definition
IndicatorDefinition indicatorDefinition = DefinitionHandler.getInstance().getIndicatorDefinition(definitionLabel);
if (indicatorDefinition == null) {
return false;
}
// else
indicator.setIndicatorDefinition(indicatorDefinition);
return true;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class ExportWizardPage method getElements.
/**
* DOC bZhou Comment method "getElements".
*
* @return
*/
public ItemRecord[] getElements() {
List<ItemRecord> itemRecords = new ArrayList<ItemRecord>();
boolean sumIndicatorAdded = false;
Object[] checkedElements = repositoryTree.getCheckedElements();
for (Object obj : checkedElements) {
if (obj instanceof ItemRecord) {
ItemRecord record = (ItemRecord) obj;
// MOD qiongli 2012-4-20,add related subreport jrxml/jasper file to elements.
File file = record.getFile();
if (file.isFile()) {
itemRecords.add(record);
if (file.getName().endsWith(FactoriesUtil.JRXML)) {
addSubRepToElements(record, itemRecords);
}
// if it is Mean Indicator, add it's dependency Sum Indicator
if (!sumIndicatorAdded) {
// $NON-NLS-1$
String meanIndicatorUuid = "_ccI48RF2Ed2PKb6nEJEvhw";
// $NON-NLS-1$
String sumIndicatorLabel = "Sum";
ModelElement element = record.getElement();
if (element != null && element instanceof IndicatorDefinition && meanIndicatorUuid.equals(ResourceHelper.getUUID(element))) {
IndicatorDefinition sumIndicator = DefinitionHandler.getInstance().getIndicatorDefinition(sumIndicatorLabel);
if (sumIndicator != null) {
IFile sumIndicatorIFile = IndicatorResourceFileHelper.findCorrespondingFile(sumIndicator);
if (sumIndicatorIFile != null) {
File sumIndicatorFile = WorkspaceUtils.ifileToFile(sumIndicatorIFile);
if (sumIndicatorFile != null) {
itemRecords.add(new ItemRecord(sumIndicatorFile));
sumIndicatorAdded = true;
}
}
}
}
}
}
}
}
return itemRecords.toArray(new ItemRecord[itemRecords.size()]);
}
Aggregations