use of org.talend.dataquality.domain.RangeRestriction in project tdq-studio-se by Talend.
the class ColumnAnalysisSqlExecutor method getBinsAsGenericString.
/**
* DOC scorreia Comment method "getBinsAsString".
*
* @param ranges
* @return
*/
private List<String> getBinsAsGenericString(EList<RangeRestriction> ranges, String colName) {
List<String> bins = new ArrayList<String>();
for (RangeRestriction rangeRestriction : ranges) {
String bin = colName + dbms().greaterOrEqual() + DomainHelper.getMinValue(rangeRestriction) + dbms().and() + colName + dbms().less() + DomainHelper.getMaxValue(rangeRestriction);
// set the name of the RangeRestriction here
// TODO range name should be set at the construction (in the bins designer wizard)
rangeRestriction.setName(this.unquote(bin));
bins.add(bin);
}
return bins;
}
use of org.talend.dataquality.domain.RangeRestriction in project tdq-studio-se by Talend.
the class FrequencyStatisticsExplorer method getFreqRowsStatement.
protected String getFreqRowsStatement() {
IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
if (indicatorDefinition instanceof UDIndicatorDefinition) {
return getQueryForUDIndicator(indicatorDefinition);
}
String clause = PluginConstant.EMPTY_STRING;
TdColumn column = (TdColumn) indicator.getAnalyzedElement();
int javaType = column.getSqlDataType().getJavaDataType();
if (Java2SqlType.isTextInSQL(javaType)) {
clause = getInstantiatedClause();
} else if (Java2SqlType.isDateInSQL(javaType)) {
// MOD scorreia 2009-09-22 first check whether the value is null
if (entity.isLabelNull()) {
clause = getInstantiatedClause();
} else {
IndicatorParameters parameters = indicator.getParameters();
if (parameters != null) {
DateParameters dateParameters = parameters.getDateParameters();
if (dateParameters != null) {
DateGrain dateGrain = dateParameters.getDateAggregationType();
clause = entity.isLabelNull() ? getInstantiatedClause() : getClauseWithDate(dateGrain, clause);
} else {
clause = getInstantiatedClause();
}
} else {
clause = getInstantiatedClause();
}
}
} else if (Java2SqlType.isNumbericInSQL(javaType)) {
IndicatorParameters parameters = indicator.getParameters();
if (parameters != null) {
// handle bins
Domain bins = parameters.getBins();
if (bins != null) {
// rangeStrings = getBinsAsGenericString(bins.getRanges());
final EList<RangeRestriction> ranges = bins.getRanges();
for (RangeRestriction rangeRestriction : ranges) {
// find the rangeLabel
if (entity.getLabel() != null && entity.getLabel().equals(rangeRestriction.getName())) {
clause = createWhereClause(rangeRestriction);
break;
}
}
} else {
// MOD hcheng 2009-05-18.Bug 7377,Frequency indicator,when bins is null,handle as textual data
clause = getInstantiatedClause();
}
} else {
// MOD scorreia 2009-05-13. Bug 7235
// no parameter set: handle as textual data
clause = getInstantiatedClause();
}
} else {
// no quote here
clause = getDefaultQuotedStatement(PluginConstant.EMPTY_STRING);
}
return // $NON-NLS-1$
"SELECT * FROM " + getFullyQualifiedTableName(column) + dbmsLanguage.where() + inBrackets(clause) + andDataFilterClause();
}
use of org.talend.dataquality.domain.RangeRestriction in project tdq-studio-se by Talend.
the class BinsDesignerForm method addFieldsListeners.
/*
* (non-Javadoc)
*
* @see org.talend.dataprofiler.core.ui.utils.AbstractForm#addFieldsListeners()
*/
@Override
protected void addFieldsListeners() {
// MOD hcheng for 7377,only when minValue,maxValue,numbOfBins are set, the wizard can finish
minValue.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String mintxt = minValue.getText();
String maxtxt = maxValue.getText();
String bintxt = numbOfBins.getText();
if (mintxt != "") {
// $NON-NLS-1$
if (!CheckValueUtils.isRealNumberValue(mintxt)) {
updateStatus(IStatus.ERROR, MSG_ONLY_REAL_NUMBER);
} else if (!maxtxt.equals("") && CheckValueUtils.isAoverB(mintxt, maxtxt)) {
// $NON-NLS-1$
updateStatus(IStatus.ERROR, UIMessages.MSG_LOWER_LESS_HIGHER);
} else if (!maxtxt.equals("") && !bintxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.OK, MSG_OK);
} else {
updateStatus(IStatus.ERROR, MSG_EMPTY);
}
} else {
if (!maxtxt.equals("") || !bintxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.ERROR, MSG_EMPTY);
} else {
updateStatus(IStatus.OK, UIMessages.MSG_INDICATOR_WIZARD);
}
}
}
});
maxValue.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String mintxt = minValue.getText();
String maxtxt = maxValue.getText();
String bintxt = numbOfBins.getText();
if (maxtxt != "") {
// $NON-NLS-1$
if (!CheckValueUtils.isRealNumberValue(maxtxt)) {
updateStatus(IStatus.ERROR, MSG_ONLY_REAL_NUMBER);
} else if (!mintxt.equals("") && CheckValueUtils.isAoverB(mintxt, maxtxt)) {
// $NON-NLS-1$
updateStatus(IStatus.ERROR, UIMessages.MSG_LOWER_LESS_HIGHER);
} else if (!mintxt.equals("") && !bintxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.OK, MSG_OK);
} else {
updateStatus(IStatus.ERROR, MSG_EMPTY);
}
} else {
if (!mintxt.equals("") || !bintxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.ERROR, MSG_EMPTY);
} else {
updateStatus(IStatus.OK, UIMessages.MSG_INDICATOR_WIZARD);
}
}
}
});
numbOfBins.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
String mintxt = minValue.getText();
String maxtxt = maxValue.getText();
String numbtxt = numbOfBins.getText();
if (numbtxt != "") {
// $NON-NLS-1$
if (!CheckValueUtils.isNumberValue(numbtxt)) {
updateStatus(IStatus.ERROR, MSG_ONLY_NUMBER);
} else if (!mintxt.equals("") && !maxtxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.OK, MSG_OK);
} else {
updateStatus(IStatus.ERROR, MSG_EMPTY);
}
} else {
if (!mintxt.equals("") || !maxtxt.equals("")) {
// $NON-NLS-1$ //$NON-NLS-2$
updateStatus(IStatus.ERROR, MSG_EMPTY);
} else {
updateStatus(IStatus.OK, UIMessages.MSG_INDICATOR_WIZARD);
}
}
}
});
isSetRange.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
boolean flag = ((Button) e.getSource()).getSelection();
boolean validSelect = !CheckValueUtils.isEmpty(numbOfBins.getText(), minValue.getText(), maxValue.getText());
if (flag && validSelect) {
addSlice.setEnabled(true);
delSlice.setEnabled(true);
minValue.setEnabled(false);
maxValue.setEnabled(false);
numbOfBins.setEnabled(false);
int numb = Integer.parseInt(numbOfBins.getText());
double min = Double.parseDouble(minValue.getText());
double max = Double.parseDouble(maxValue.getText());
// $NON-NLS-1$
Domain customerDomin = DomainHelper.createContiguousClosedBinsIntoDomain("", numb, min, max);
tableViewer.setInput(customerDomin.getRanges());
} else {
addSlice.setEnabled(false);
delSlice.setEnabled(false);
minValue.setEnabled(true);
maxValue.setEnabled(true);
numbOfBins.setEnabled(true);
// $NON-NLS-1$
tableViewer.setInput("");
}
}
});
addSlice.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
if (tableViewer.getInput() instanceof List) {
List<RangeRestriction> inputList = (List<RangeRestriction>) tableViewer.getInput();
// create a default range restriction, the min = 0, the max = 0
RangeRestriction newRange = DomainHelper.createRealRangeRestriction(0, 0);
inputList.add(newRange);
tableViewer.setInput(inputList);
}
}
});
delSlice.addSelectionListener(new SelectionAdapter() {
@SuppressWarnings("unchecked")
@Override
public void widgetSelected(SelectionEvent e) {
boolean flag = !tableViewer.getSelection().isEmpty();
if (flag) {
IStructuredSelection selection = (IStructuredSelection) tableViewer.getSelection();
RangeRestriction range = (RangeRestriction) selection.getFirstElement();
if (tableViewer.getInput() instanceof List) {
List<RangeRestriction> inputList = (List<RangeRestriction>) tableViewer.getInput();
inputList.remove(range);
tableViewer.setInput(inputList);
}
}
}
});
}
use of org.talend.dataquality.domain.RangeRestriction in project tdq-studio-se by Talend.
the class IndicatorHelper method getDataThreshold.
/**
* Method "getDataThreshold".
*
* @param parameters
* @return an array with two elements. returns null when no threshold has been found. One element of the array can
* be null but not both. In this case, it means that there is only one defined threshold, either the upper or the
* lower threshold.
*/
public static String[] getDataThreshold(IndicatorParameters parameters) {
Domain validDomain = parameters.getDataValidDomain();
if (validDomain == null) {
return null;
}
EList<RangeRestriction> ranges = validDomain.getRanges();
if (ranges.size() != 1) {
// log.warn("Data threshold contain too many ranges (or no range): " + ranges.size() + " range(s).");
return null;
}
RangeRestriction rangeRestriction = ranges.get(0);
if (rangeRestriction == null) {
return new String[] { null, null };
}
return new String[] { DomainHelper.getMinValue(rangeRestriction), DomainHelper.getMaxValue(rangeRestriction) };
}
use of org.talend.dataquality.domain.RangeRestriction in project tdq-studio-se by Talend.
the class IndicatorHelper method getIndicatorThreshold.
private static String[] getIndicatorThreshold(IndicatorParameters parameters, ThresholdType thresholdType) {
Domain validDomain = parameters.getIndicatorValidDomain();
if (validDomain == null) {
return null;
}
EList<RangeRestriction> ranges = validDomain.getRanges();
for (RangeRestriction rangeRestriction : ranges) {
if (thresholdType.getLabel().equals(rangeRestriction.getName())) {
return new String[] { DomainHelper.getMinValue(rangeRestriction), DomainHelper.getMaxValue(rangeRestriction) };
}
}
return null;
}
Aggregations