use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class SummaryStatisticsState method getCustomerDataset.
public ICustomerDataset getCustomerDataset() {
Map<IndicatorEnum, Double> map = new HashMap<IndicatorEnum, Double>();
CustomerDefaultCategoryDataset customerdataset = new CustomerDefaultCategoryDataset();
for (IndicatorUnit unit : units) {
// MOD xqliu 2009-06-29 bug 7068
String value = null;
if (indicators2ValueMap.containsKey(unit)) {
value = indicators2ValueMap.get(unit);
} else {
value = summaryUtil.getUnitValue(unit);
}
if (Java2SqlType.isNumbericInSQL(sqltype)) {
try {
map.put(unit.getType(), Double.parseDouble(value));
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
ChartDataEntity entity = summaryUtil.createDataEntity(unit, value);
customerdataset.addDataEntity(entity);
}
if (isIntact() && !isSupportDynamicChart) {
CustomerDefaultBAWDataset dataset = new CustomerDefaultBAWDataset(map.get(IndicatorEnum.MeanIndicatorEnum), map.get(IndicatorEnum.MedianIndicatorEnum), map.get(IndicatorEnum.LowerQuartileIndicatorEnum), map.get(IndicatorEnum.UpperQuartileIndicatorEnum), map.get(IndicatorEnum.MinValueIndicatorEnum), map.get(IndicatorEnum.MaxValueIndicatorEnum), customerdataset);
dataset.addDataEntity(customerdataset.getDataEntities());
return dataset;
} else {
// MOD hcheng,Range indicator value should not appear in bar chart
if (!isIntact()) {
map.remove(IndicatorEnum.RangeIndicatorEnum);
map.remove(IndicatorEnum.IQRIndicatorEnum);
}
for (IndicatorEnum indicatorEnum : map.keySet()) {
customerdataset.addValue(map.get(indicatorEnum), indicatorEnum.getLabel(), indicatorEnum.getLabel());
}
return customerdataset;
}
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class PatternLabelProvider method createIndicatorUnit.
/**
* DOC xqliu Comment method "createIndicatorUnit".
*
* @param pfile
* @param modelElementIndicator
* @param analysis
* @param indicatorDefinition
* @return
*/
public static TypedReturnCode<IndicatorUnit> createIndicatorUnit(Pattern pattern, ModelElementIndicator modelElementIndicator, Analysis analysis, IndicatorDefinition indicatorDefinition) {
TypedReturnCode<IndicatorUnit> result = new TypedReturnCode<IndicatorUnit>();
for (Indicator indicator : modelElementIndicator.getIndicators()) {
// MOD xwang 2011-08-01 bug TDQ-2730
if (UDIHelper.getMatchingIndicatorName(indicatorDefinition, pattern).equals(indicator.getName()) && indicator instanceof PatternMatchingIndicator) {
result.setOk(false);
// $NON-NLS-1$
result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.Selected"));
return result;
}
// ~
}
// MOD scorreia 2009-01-06: when expression type is not set (version
// TOP-1.1.x), then it's supposed to be a
// regexp pattern. This could be false because expression type was not
// set into SQL pattern neither in TOP-1.1.
// This means that there could exist the need for a migration task to
// set the expression type depending on the
// folder where the pattern is stored. The method
// DomainHelper.getExpressionType(pattern) tries to find the type
// of pattern.
Indicator patternMatchingIndicator = null;
String expressionType = DomainHelper.getExpressionType(pattern);
boolean isSQLPattern = (ExpressionType.SQL_LIKE.getLiteral().equals(expressionType));
if (indicatorDefinition != null) {
patternMatchingIndicator = UDIFactory.createUserDefIndicator(indicatorDefinition, pattern);
} else {
patternMatchingIndicator = isSQLPattern ? PatternIndicatorFactory.createSqlPatternMatchingIndicator(pattern) : PatternIndicatorFactory.createRegexpMatchingIndicator(pattern);
}
IEditorPart theEdit = CorePlugin.getDefault().getCurrentActiveEditor();
if (theEdit != null && theEdit instanceof AnalysisEditor && analysis.getContext().getConnection() == null) {
theEdit.doSave(null);
}
ExecutionLanguage executionLanguage = analysis.getParameters().getExecutionLanguage();
DbmsLanguage dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(analysis);
if (dbmsLanguage.isSql()) {
// $NON-NLS-1$
MessageUI.openWarning(DefaultMessagesImpl.getString("PatternUtilities.ConnectionError"));
result.setOk(false);
return result;
}
boolean isJavaEngin = ExecutionLanguage.JAVA.equals(executionLanguage);
Expression returnExpression = dbmsLanguage.getRegexp(pattern);
// MOD gdbu 2011-8-26 bug : TDQ-2169
if ((ExpressionType.REGEXP.getLiteral().equals(expressionType) || ExpressionType.SQL_LIKE.getLiteral().equals(expressionType)) && returnExpression == null) {
// ~TDQ-2169
String executeType = isJavaEngin ? executionLanguage.getName() : dbmsLanguage.getDbmsName();
boolean openPattern = MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), DefaultMessagesImpl.getString("PatternUtilities.Warning"), // $NON-NLS-1$ //$NON-NLS-2$
DefaultMessagesImpl.getString("PatternUtilities.NoExpression", executeType, pattern.getName()));
if (openPattern) {
RepositoryNode node = RepositoryNodeHelper.recursiveFind(pattern);
if (RepositoryNodeHelper.canOpenEditor(node)) {
new OpenItemEditorAction(new IRepositoryNode[] { node }).run();
}
}
result.setOk(false);
return result;
}
// a regular expression for the analyzed
// database, but we probably test also whether the analyzed database
// support the regular expressions (=> check
// DB type, DB number version, existence of UDF)
DataManager dm = analysis.getContext().getConnection();
if (dm != null) {
TypedReturnCode<java.sql.Connection> trc = JavaSqlFactory.createConnection((Connection) dm);
// MOD qiongli 2011-1-10 feature 16796
boolean isDelimitedFileConnection = ConnectionUtils.isDelimitedFileConnection((DataProvider) dm);
if (trc != null) {
// SoftwareSystem softwareSystem = DatabaseContentRetriever.getSoftwareSystem(conn);
// MOD sizhaoliu TDQ-6316
dbmsLanguage = DbmsLanguageFactory.createDbmsLanguage(dm);
}
// MOD xqliu 2010-08-12 bug 14601
if (!(isSQLPattern || DefinitionHandler.getInstance().canRunRegularExpressionMatchingIndicator(dbmsLanguage, isJavaEngin, pattern) || isDelimitedFileConnection)) {
// MessageDialogWithToggle.openInformation(null,
// DefaultMessagesImpl.getString("PatternUtilities.Pattern"), DefaultMessagesImpl //$NON-NLS-1$
// .getString("PatternUtilities.couldnotSetIndicator")); //$NON-NLS-1$
result.setOk(false);
// $NON-NLS-1$
result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.couldnotSetIndicator"));
return result;
}
// ~ 14601
}
// when the indicator is created.
if (indicatorDefinition == null) {
if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(patternMatchingIndicator)) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("PatternUtilities.SetFailed", patternMatchingIndicator.getName()));
}
} else {
patternMatchingIndicator.setIndicatorDefinition(indicatorDefinition);
}
IndicatorEnum type = IndicatorEnum.findIndicatorEnum(patternMatchingIndicator.eClass());
IndicatorUnit addIndicatorUnit = modelElementIndicator.addSpecialIndicator(type, patternMatchingIndicator);
DependenciesHandler.getInstance().setUsageDependencyOn(analysis, pattern);
result.setOk(true);
// $NON-NLS-1$
result.setMessage(DefaultMessagesImpl.getString("PatternUtilities.OK"));
result.setObject(addIndicatorUnit);
return result;
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method createSpecialIndicatorUnit.
private IndicatorUnit createSpecialIndicatorUnit(IndicatorEnum indicatorEnum, Indicator indicator) {
Indicator tempIndicator = indicator;
if (tempIndicator == null) {
EFactoryImpl factory = (EFactoryImpl) indicatorEnum.getIndicatorType().getEPackage().getEFactoryInstance();
tempIndicator = (Indicator) factory.create(indicatorEnum.getIndicatorType());
// MOD scorreia 2008-09-18: bug 5131 fixed: set indicator's definition when the indicator is created.
if (!DefinitionHandler.getInstance().setDefaultIndicatorDefinition(tempIndicator)) {
// $NON-NLS-1$
log.error(DefaultMessagesImpl.getString("ModelElementIndicatorImpl_COULDNOTSETDEF_GIVEN_IND0") + tempIndicator.getName());
}
}
// }
if (this.specialIndicatorUnitList == null) {
this.specialIndicatorUnitList = new ArrayList<IndicatorUnit>();
}
IndicatorUnit indicatorUnit = new ColumnIndicatorUnit(indicatorEnum, tempIndicator, this);
specialIndicatorUnitList.add(indicatorUnit);
this.specialIndicatorUnitMap.put(tempIndicator.getName(), indicatorUnit);
return indicatorUnit;
}
use of org.talend.dataprofiler.core.ui.editor.preview.IndicatorUnit in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method createCategoryIndicatorUnits.
/**
* create indicatorMappings according category indicatorEnum.
*
* @param categoryEnums
* @return
*/
private IndicatorUnit[] createCategoryIndicatorUnits(IndicatorEnum[] categoryEnums) {
List<IndicatorUnit> indicatorUnitList = new ArrayList<IndicatorUnit>();
IndicatorUnit indicatorUnit;
for (IndicatorEnum categoryEnum : categoryEnums) {
if (null == categoryEnum) {
continue;
}
if (!IndicatorEnum.isPlainIndicatorEnum(categoryEnum)) {
// tempSpecialIndicatorEnumList.add(categoryEnum);
continue;
}
indicatorUnit = getPlainIndicatorUnit(categoryEnum);
switch(categoryEnum) {
case CountsIndicatorEnum:
CountsIndicator countsIndicator = (CountsIndicator) indicatorUnit.getIndicator();
countsIndicator.setBlankCountIndicator((BlankCountIndicator) getPlainIndicatorUnit(IndicatorEnum.BlankCountIndicatorEnum).getIndicator());
countsIndicator.setDistinctCountIndicator((DistinctCountIndicator) getPlainIndicatorUnit(IndicatorEnum.DistinctCountIndicatorEnum).getIndicator());
countsIndicator.setDuplicateCountIndicator((DuplicateCountIndicator) getPlainIndicatorUnit(IndicatorEnum.DuplicateCountIndicatorEnum).getIndicator());
countsIndicator.setRowCountIndicator((RowCountIndicator) getPlainIndicatorUnit(IndicatorEnum.RowCountIndicatorEnum).getIndicator());
countsIndicator.setNullCountIndicator((NullCountIndicator) getPlainIndicatorUnit(IndicatorEnum.NullCountIndicatorEnum).getIndicator());
countsIndicator.setUniqueCountIndicator((UniqueCountIndicator) getPlainIndicatorUnit(IndicatorEnum.UniqueIndicatorEnum).getIndicator());
// MOD klliu bug 13411 2010-06-03
countsIndicator.setDefaultValueIndicator((DefValueCountIndicator) getPlainIndicatorUnit(IndicatorEnum.DefValueCountIndicatorEnum).getIndicator());
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.CountsIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
case TextIndicatorEnum:
TextIndicator textIndicator = (TextIndicator) indicatorUnit.getIndicator();
textIndicator.setMinLengthIndicator((MinLengthIndicator) getPlainIndicatorUnit(IndicatorEnum.MinLengthIndicatorEnum).getIndicator());
textIndicator.setMaxLengthIndicator((MaxLengthIndicator) getPlainIndicatorUnit(IndicatorEnum.MaxLengthIndicatorEnum).getIndicator());
textIndicator.setAverageLengthIndicator((AverageLengthIndicator) getPlainIndicatorUnit(IndicatorEnum.AverageLengthIndicatorEnum).getIndicator());
// MOD yyi 2010-08-05
textIndicator.setAvgLengthWithBlankIndicator((AvgLengthWithBlankIndicator) getPlainIndicatorUnit(IndicatorEnum.AverageLengthWithBlankIndicatorEnum).getIndicator());
textIndicator.setAvgLengthWithNullIndicator((AvgLengthWithNullIndicator) getPlainIndicatorUnit(IndicatorEnum.AverageLengthWithNullIndicatorEnum).getIndicator());
textIndicator.setAvgLengthWithBlankNullIndicator((AvgLengthWithBlankNullIndicator) getPlainIndicatorUnit(IndicatorEnum.AverageLengthWithNullBlankIndicatorEnum).getIndicator());
textIndicator.setMinLengthWithBlankIndicator((MinLengthWithBlankIndicator) getPlainIndicatorUnit(IndicatorEnum.MinLengthWithBlankIndicatorEnum).getIndicator());
textIndicator.setMinLengthWithNullIndicator((MinLengthWithNullIndicator) getPlainIndicatorUnit(IndicatorEnum.MinLengthWithNullIndicatorEnum).getIndicator());
textIndicator.setMinLengthWithBlankNullIndicator((MinLengthWithBlankNullIndicator) getPlainIndicatorUnit(IndicatorEnum.MinLengthWithBlankNullIndicatorEnum).getIndicator());
textIndicator.setMaxLengthWithBlankIndicator((MaxLengthWithBlankIndicator) getPlainIndicatorUnit(IndicatorEnum.MaxLengthWithBlankIndicatorEnum).getIndicator());
textIndicator.setMaxLengthWithNullIndicator((MaxLengthWithNullIndicator) getPlainIndicatorUnit(IndicatorEnum.MaxLengthWithNullIndicatorEnum).getIndicator());
textIndicator.setMaxLengthWithBlankNullIndicator((MaxLengthWithBlankNullIndicator) getPlainIndicatorUnit(IndicatorEnum.MaxLengthWithBlankNullIndicatorEnum).getIndicator());
// ~
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.TextIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
case BoxIIndicatorEnum:
BoxIndicator boxtIndicator = (BoxIndicator) indicatorUnit.getIndicator();
boxtIndicator.setRangeIndicator((RangeIndicator) getPlainIndicatorUnit(IndicatorEnum.RangeIndicatorEnum).getIndicator());
boxtIndicator.setIQR((IQRIndicator) getPlainIndicatorUnit(IndicatorEnum.IQRIndicatorEnum).getIndicator());
boxtIndicator.setMeanIndicator((MeanIndicator) getPlainIndicatorUnit(IndicatorEnum.MeanIndicatorEnum).getIndicator());
boxtIndicator.setMedianIndicator((MedianIndicator) getPlainIndicatorUnit(IndicatorEnum.MedianIndicatorEnum).getIndicator());
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.BoxIIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
case IQRIndicatorEnum:
IQRIndicator iqrIndicator = (IQRIndicator) indicatorUnit.getIndicator();
iqrIndicator.setLowerValue((LowerQuartileIndicator) getPlainIndicatorUnit(IndicatorEnum.LowerQuartileIndicatorEnum).getIndicator());
iqrIndicator.setUpperValue((UpperQuartileIndicator) getPlainIndicatorUnit(IndicatorEnum.UpperQuartileIndicatorEnum).getIndicator());
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.IQRIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
case RangeIndicatorEnum:
RangeIndicator rangeIndicator = (RangeIndicator) indicatorUnit.getIndicator();
rangeIndicator.setLowerValue((MinValueIndicator) getPlainIndicatorUnit(IndicatorEnum.MinValueIndicatorEnum).getIndicator());
rangeIndicator.setUpperValue((MaxValueIndicator) getPlainIndicatorUnit(IndicatorEnum.MaxValueIndicatorEnum).getIndicator());
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.RangeIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
case PhoneNumbStatisticsIndicatorEnum:
PhoneNumbStatisticsIndicator phoneNumbIndicator = (PhoneNumbStatisticsIndicator) indicatorUnit.getIndicator();
phoneNumbIndicator.setValidPhoneCountIndicator((ValidPhoneCountIndicator) getPlainIndicatorUnit(IndicatorEnum.ValidPhoneCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setPossiblePhoneCountIndicator((PossiblePhoneCountIndicator) getPlainIndicatorUnit(IndicatorEnum.PossiblePhoneCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setValidRegCodeCountIndicator((ValidRegCodeCountIndicator) getPlainIndicatorUnit(IndicatorEnum.ValidRegCodeCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setInvalidRegCodeCountIndicator((InvalidRegCodeCountIndicator) getPlainIndicatorUnit(IndicatorEnum.InvalidRegCodeCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setWellFormE164PhoneCountIndicator((WellFormE164PhoneCountIndicator) getPlainIndicatorUnit(IndicatorEnum.WellFormE164PhoneCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setWellFormIntePhoneCountIndicator((WellFormIntePhoneCountIndicatorImpl) getPlainIndicatorUnit(IndicatorEnum.WellFormIntePhoneCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setWellFormNationalPhoneCountIndicator((WellFormNationalPhoneCountIndicatorImpl) getPlainIndicatorUnit(IndicatorEnum.WellFormNationalPhoneCountIndicatorEnum).getIndicator());
phoneNumbIndicator.setFormatFreqPieIndicator((FormatFreqPieIndicatorImpl) getPlainIndicatorUnit(IndicatorEnum.FormatFreqPieIndictorEnum).getIndicator());
indicatorUnit.setChildren(createCategoryIndicatorUnits(IndicatorEnum.PhoneNumbStatisticsIndicatorEnum.getChildren()));
indicatorUnitList.add(indicatorUnit);
break;
default:
indicatorUnitList.add(indicatorUnit);
break;
}
}
return indicatorUnitList.toArray(new IndicatorUnit[indicatorUnitList.size()]);
}
Aggregations