use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.
the class AnalysisTableTreeViewer method hasIndicatorParameters.
/**
* DOC msjian Comment method "hasIndicatorParameters".
*
* @param indicatorUnit
* @return
*/
private boolean hasIndicatorParameters(TableIndicatorUnit indicatorUnit) {
IndicatorParameters parameters = indicatorUnit.getIndicator().getParameters();
if (parameters == null) {
return false;
}
if (indicatorUnit.getIndicator() instanceof FrequencyIndicator) {
return true;
}
TextParameters tParameter = parameters.getTextParameter();
if (tParameter != null) {
return true;
}
DateParameters dParameters = parameters.getDateParameters();
if (dParameters != null) {
return true;
}
Domain dataValidDomain = parameters.getDataValidDomain();
if (dataValidDomain != null) {
return true;
}
Domain indicatorValidDomain = parameters.getIndicatorValidDomain();
if (indicatorValidDomain != null) {
return true;
}
Domain bins = parameters.getBins();
if (bins != null) {
return true;
}
return false;
}
use of org.talend.dataquality.domain.Domain in project tdq-studio-se by Talend.
the class CreateDuplicatesAnalysisAction method run.
@Override
public void run() {
ReturnCode success = new ReturnCode(true);
if (this.getColumnsMap() == null || this.getColumnsMap().isEmpty() || this.getConnection() == null) {
return;
}
try {
Set<ColumnSet> keySet = this.getColumnsMap().keySet();
for (ColumnSet cs : keySet) {
List<TdColumn> columns = this.getColumnsMap().get(cs);
// create the analysis
Analysis analysis = null;
AnalysisBuilder analysisBuilder = new AnalysisBuilder();
boolean analysisInitialized = analysisBuilder.initializeAnalysis(getAnalysisName(cs), AnalysisType.MULTIPLE_COLUMN);
if (analysisInitialized) {
analysis = analysisBuilder.getAnalysis();
}
fillMetadataToAnalysis(analysis, createDefaultAnalysisParameter(cs));
// add Connection into the Analysis Context
analysis.getContext().setConnection(this.getConnection());
for (TdColumn theColumn : columns) {
// add TdColumn into the Analysis Context
analysis.getContext().getAnalysedElements().add(theColumn);
// create Row Count Indicator
RowCountIndicator rcIndicator = IndicatorsFactory.eINSTANCE.createRowCountIndicator();
rcIndicator.setAnalyzedElement(theColumn);
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(rcIndicator);
analysis.getResults().getIndicators().add(rcIndicator);
// create Duplicate Count Indicator
DuplicateCountIndicator dcIndicator = IndicatorsFactory.eINSTANCE.createDuplicateCountIndicator();
dcIndicator.setAnalyzedElement(theColumn);
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(dcIndicator);
analysis.getResults().getIndicators().add(dcIndicator);
}
// create dependencies
DependenciesHandler.getInstance().setDependencyOn(analysis, this.getConnection());
// set the domain
for (Domain domain : analysis.getParameters().getDataFilter()) {
domain.setName(analysis.getName());
}
// set execution language
analysis.getParameters().setExecutionLanguage(ExecutionLanguage.SQL);
// save the analysis
RepositoryNode analysisRepNode = (RepositoryNode) RepositoryNodeHelper.getDataProfilingFolderNode(EResourceConstant.ANALYSIS);
IFolder folder = WorkbenchUtils.getFolder(analysisRepNode);
AnalysisWriter analysisWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
TypedReturnCode<Object> create = analysisWriter.create(analysis, folder);
if (create.isOk()) {
// refresh the RepositoryView
CorePlugin.getDefault().refreshDQView(analysisRepNode);
// open the editor
AnalysisRepNode anaRepNode = RepositoryNodeHelper.recursiveFindAnalysis(analysis);
AnalysisItemEditorInput analysisEditorInput = new AnalysisItemEditorInput(anaRepNode);
IRepositoryNode connectionRepNode = RepositoryNodeHelper.recursiveFind(this.getConnection());
analysisEditorInput.setConnectionNode(connectionRepNode);
CorePlugin.getDefault().openEditor(analysisEditorInput, AnalysisEditor.class.getName());
} else {
success.setOk(false);
success.setMessage(create.getMessage());
}
}
// for
} catch (Exception e) {
success.setOk(false);
success.setMessage(e.getMessage());
}
if (!success.isOk()) {
MessageUI.openError(success.getMessage());
}
}
use of org.talend.dataquality.domain.Domain 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.Domain 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.Domain 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