use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.
the class AbstractPredefinedAnalysisAction method composePredefinedColumnIndicator.
protected ModelElementIndicator[] composePredefinedColumnIndicator(IndicatorEnum[] allowedEnum) {
IRepositoryNode[] columns = getColumns();
ModelElementIndicator[] predefinedColumnIndicator = new ModelElementIndicator[columns.length];
ExecutionLanguage language = ExecutionLanguage.get(getMasterPage().getExecCombo().getText());
for (int i = 0; i < columns.length; i++) {
IRepositoryNode columnNode = columns[i];
ModelElementIndicator columnIndicator = ModelElementIndicatorHelper.createModelElementIndicator(columnNode);
for (IndicatorEnum oneEnum : allowedEnum) {
columnIndicator.addTempIndicatorEnum(oneEnum);
if (oneEnum.getChildren() != null) {
for (IndicatorEnum childEnum : oneEnum.getChildren()) {
// MOD by zshen:need language to decide DatePatternFrequencyIndicator whether can be choose by
// user.
IRepositoryViewObject object = columnNode.getObject();
ModelElement element = null;
if (object instanceof MetadataColumnRepositoryObject) {
element = ((MetadataColumnRepositoryObject) object).getTdColumn();
} else if (object instanceof MetadataXmlElementTypeRepositoryObject) {
element = ((MetadataXmlElementTypeRepositoryObject) object).getModelElement();
}
if (element != null && ModelElementIndicatorRule.patternRule(childEnum, element, language)) {
columnIndicator.addTempIndicatorEnum(childEnum);
}
}
}
}
columnIndicator.storeTempIndicator();
predefinedColumnIndicator[i] = columnIndicator;
}
return predefinedColumnIndicator;
}
use of org.talend.dq.nodes.indicator.type.IndicatorEnum 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.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.
the class TableIndicator method removeSpecialIndicatorUnit.
/**
* Remove the specialIndicatorUnit from specialIndicatorList, if there exist more than one special Indicator which
* has same IndicatorEnumn type, the type of IndicatorUnit will be not removed from flatIndicatorEnumList.
*
* @param indicatorUnit
*/
private void removeSpecialIndicatorUnit(TableIndicatorUnit indicatorUnit) {
IndicatorEnum indicatorEnumn = indicatorUnit.getType();
this.specialIndicatorUnitList.remove(indicatorUnit);
for (TableIndicatorUnit unit : specialIndicatorUnitList) {
if (unit.getType() == indicatorEnumn) {
return;
} else {
continue;
}
}
this.indicatorEnumList.remove(indicatorEnumn);
}
use of org.talend.dq.nodes.indicator.type.IndicatorEnum in project tdq-studio-se by Talend.
the class ModelElementIndicatorImpl method storeTempIndicator.
/**
* Store the tempory indicator to flatIndicatorEnumList.
*/
public void storeTempIndicator() {
for (IndicatorEnum indEnum : tempIndicatorEnums) {
if (!flatIndicatorEnumList.contains(indEnum)) {
this.flatIndicatorEnumList.add(indEnum);
}
}
// remove the deleted IndicatorEnum from current indicatorsEnums;
Iterator<IndicatorEnum> iterator = flatIndicatorEnumList.iterator();
while (iterator.hasNext()) {
IndicatorEnum next = iterator.next();
if (!tempIndicatorEnums.contains(next)) {
iterator.remove();
}
}
processCategoryIndicator();
StoreTempSpecialIndicator();
// specialIndicatorUnitList = createSpacialIndicatorUnits();
// clear tempIndicatorEnums
tempIndicatorEnums.clear();
tempSpecialIndicatorUnitList.clear();
}
use of org.talend.dq.nodes.indicator.type.IndicatorEnum 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