use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method updateAggregates.
/**
* Update aggregates for some indicators(Simple Statistic Indicator/Text Statistic Indicator...).make the path/name
* of indicator definition in agregate right and is not a proxy).
*/
public void updateAggregates() {
List<IndicatorDefinition> indicatorsDefinitions = getIndicatorsDefinitions();
String defFileExt = PluginConstant.DOT_STRING + FactoriesUtil.DEFINITION;
for (IndicatorDefinition indiDef : indicatorsDefinitions) {
EList<IndicatorDefinition> aggregatedDefinitions = indiDef.getAggregatedDefinitions();
List<IndicatorDefinition> updatedAggrDefinitions = new ArrayList<IndicatorDefinition>();
if (indiDef.eIsProxy() || aggregatedDefinitions == null || aggregatedDefinitions.isEmpty()) {
continue;
}
for (IndicatorDefinition aggrDef : aggregatedDefinitions) {
URI oldUri = EObjectHelper.getURI(aggrDef);
if (oldUri == null) {
continue;
}
String oldLabel = (oldUri.lastSegment());
oldLabel = oldLabel.replace(defFileExt, PluginConstant.EMPTY_STRING);
if (oldLabel.equalsIgnoreCase("Inter Quartile Range")) {
// $NON-NLS-1$
// $NON-NLS-1$
oldLabel = "IQR";
}
IndicatorDefinition find = getIndicatorDefinition(oldLabel);
if (find != null) {
updatedAggrDefinitions.add(find);
}
}
indiDef.getAggregatedDefinitions().clear();
indiDef.getAggregatedDefinitions().addAll(updatedAggrDefinitions);
EMFSharedResources.getInstance().saveResource(indiDef.eResource());
}
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method getIndicatorModelElement.
private final ModelElement getIndicatorModelElement(File file) {
DefinitionSwitch<IndicatorDefinition> definitionSwitch = new DefinitionSwitch<IndicatorDefinition>() {
@Override
public IndicatorDefinition caseIndicatorDefinition(IndicatorDefinition object) {
return object;
}
};
if (file != null) {
Resource resource = EmfFileResourceUtil.getInstance().getFileResource(file.getAbsolutePath());
EList<EObject> contents = resource.getContents();
if (contents.isEmpty()) {
// $NON-NLS-1$
log.error("no content in: " + resource);
}
for (EObject object : contents) {
ModelElement switchObject = definitionSwitch.doSwitch(object);
if (switchObject != null) {
return switchObject;
}
}
}
return null;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method reloadAllUDIs.
/**
* reload all user defined indicators, when some udi's name is changed, this method will be needed
*/
public void reloadAllUDIs() {
List<IndicatorDefinition> udis = new ArrayList<IndicatorDefinition>();
for (IndicatorDefinition indicatorDefinition : this.getIndicatorsDefinitions()) {
if (indicatorDefinition instanceof UDIndicatorDefinition) {
udis.add(indicatorDefinition);
}
}
// remove all udis
this.getIndicatorsDefinitions().removeAll(udis);
// reload all udis
this.getIndicatorsDefinitions().addAll(IndicatorResourceFileHelper.getInstance().getAllUDIs());
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method updateRegex.
public boolean updateRegex(String dbmsName, String regexpFunction) {
boolean ok = true;
boolean replaced = false;
IndicatorDefinition regexIndDef = this.getIndicatorDefinition(REGULAR_EXPRESSION_MATCHING);
EList<TdExpression> sqlGenericExpression = regexIndDef.getSqlGenericExpression();
for (Expression expression : sqlGenericExpression) {
// MOD qiongli 2011-4-18,bug 16723.data cleansing.
if (DbmsLanguageFactory.compareDbmsLanguage(dbmsName, expression.getLanguage())) {
replaced = replaceBodyWith(expression, regexpFunction);
}
}
if (!replaced) {
// add new expression
String genericSQL = getGenericSQL(dbmsName, regexpFunction);
TdExpression createdExpression = BooleanExpressionHelper.createTdExpression(dbmsName, genericSQL);
sqlGenericExpression.add(createdExpression);
}
return ok;
}
use of org.talend.dataquality.indicators.definition.IndicatorDefinition in project tdq-studio-se by Talend.
the class DefinitionHandler method getDefinitionById.
/**
* DOC mzhao Get indicator definition by definition id (xmi id).
*
* @param definitionId
* @return
*/
public IndicatorDefinition getDefinitionById(String definitionId) {
for (IndicatorDefinition indDef : this.getIndicatorsDefinitions()) {
CwmResource resource = (CwmResource) indDef.eResource();
if (resource == null) {
return null;
}
EObject object = resource.getEObject(definitionId);
if (object != null && DefinitionPackage.eINSTANCE.getIndicatorDefinition().equals(object.eClass())) {
return (IndicatorDefinition) object;
}
}
return null;
}
Aggregations