use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.
the class NewWizardSelectionPage method addListeners.
protected void addListeners() {
typeTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
AnalysisTypeNode node = (AnalysisTypeNode) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (node == null) {
return;
}
AnalysisTypeNode parent = (AnalysisTypeNode) node.getParent();
IContext context = HelpSystem.getContext(HelpPlugin.getDefault().getAnalysisHelpContextID());
IHelpResource[] relatedTopics = context.getRelatedTopics();
String href = null;
String currentLiteral = node.getLiteral();
if (AnalysisLabelParameter.FUNCTIONAL_DEPENDENCY_ANALYSIS.equals(currentLiteral)) {
currentLiteral = AnalysisType.TABLE_FUNCTIONAL_DEPENDENCY.getLiteral();
} else if (AnalysisLabelParameter.CONNECTION_OVERVIEW_ANALYSIS.equals(currentLiteral)) {
currentLiteral = AnalysisType.CONNECTION.getLiteral();
} else if (AnalysisLabelParameter.CATALOG_OVERVIEW_ANALYSIS.equals(currentLiteral)) {
currentLiteral = AnalysisType.CATALOG.getLiteral();
} else if (AnalysisLabelParameter.SCHEMA_OVERVIEW_ANALYSIS.equals(currentLiteral)) {
currentLiteral = AnalysisType.SCHEMA.getLiteral();
}
AnalysisType currentType = AnalysisType.get(currentLiteral);
if (parent == null) {
setPageComplete(false);
// MOD hcheng 2009-06-05 add help in analysis wizard
switch(currentType) {
case CONNECTION:
href = relatedTopics[0].getHref();
break;
case COLUMNS_COMPARISON:
href = relatedTopics[4].getHref();
break;
case TABLE:
href = relatedTopics[6].getHref();
break;
case MULTIPLE_COLUMN:
href = relatedTopics[11].getHref();
break;
case COLUMN_CORRELATION:
href = relatedTopics[18].getHref();
break;
default:
}
} else {
AnalysisParameter parameter = null;
AnalysisType parentType = AnalysisType.get(parent.getLiteral());
FolderProvider folderProvider = getCurrentFolderProvider() == null ? ((CreateNewAnalysisWizard) getWizard()).getCurrentFolderProvider() : getCurrentFolderProvider();
switch(parentType) {
case COLUMN_CORRELATION:
AnalysisParameter correlationColumnParam = new AnalysisLabelParameter();
((AnalysisLabelParameter) correlationColumnParam).setCategoryLabel(node.getName());
correlationColumnParam.setFolderProvider(folderProvider);
parameter = correlationColumnParam;
if (AnalysisLabelParameter.NUMBERIC_CORRELATION.equals(currentLiteral)) {
href = relatedTopics[19].getHref();
} else if (AnalysisLabelParameter.DATE_CORRELATION.equals(currentLiteral)) {
href = relatedTopics[20].getHref();
} else if (AnalysisLabelParameter.NOMINAL_CORRELATION.equals(currentLiteral)) {
href = relatedTopics[21].getHref();
} else {
href = relatedTopics[18].getHref();
}
break;
case MULTIPLE_COLUMN:
AnalysisParameter multipleColumnParam = new AnalysisLabelParameter();
((AnalysisLabelParameter) multipleColumnParam).setCategoryLabel(node.getName());
multipleColumnParam.setFolderProvider(folderProvider);
parameter = multipleColumnParam;
if (AnalysisLabelParameter.SEMANTIC_DISCOVERY_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[12].getHref();
} else if (AnalysisLabelParameter.BASIC_COLUMN_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[13].getHref();
} else if (AnalysisLabelParameter.NOMINAL_VALUES_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[14].getHref();
} else if (AnalysisLabelParameter.PATTERN_FREQUENCY_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[15].getHref();
} else if (AnalysisLabelParameter.DISCRETE_DATA_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[16].getHref();
} else if (AnalysisLabelParameter.SUMMARY_STATISTICS_ANALYSIS.equals(currentLiteral)) {
href = relatedTopics[17].getHref();
} else {
href = relatedTopics[13].getHref();
}
break;
case COLUMNS_COMPARISON:
AnalysisParameter anaParam = new AnalysisParameter();
anaParam.setFolderProvider(folderProvider);
parameter = anaParam;
href = relatedTopics[5].getHref();
break;
case CONNECTION:
switch(currentType) {
case CONNECTION:
default:
AnalysisFilterParameter connParam = new AnalysisFilterParameter();
connParam.setFolderProvider(folderProvider);
parameter = connParam;
href = relatedTopics[1].getHref();
parentType = currentType;
break;
case CATALOG:
PackagesAnalyisParameter catalogParam = new PackagesAnalyisParameter();
catalogParam.setFolderProvider(folderProvider);
parameter = catalogParam;
href = relatedTopics[2].getHref();
parentType = currentType;
break;
case SCHEMA:
PackagesAnalyisParameter schemaParam = new PackagesAnalyisParameter();
schemaParam.setFolderProvider(folderProvider);
parameter = schemaParam;
href = relatedTopics[3].getHref();
parentType = currentType;
break;
}
break;
case TABLE:
switch(currentType) {
case MATCH_ANALYSIS:
parameter = new AnalysisParameter();
parameter.setFolderProvider(folderProvider);
href = relatedTopics[8].getHref();
parentType = currentType;
break;
case COLUMN_SET:
AnalysisParameter corrParam = new AnalysisParameter();
corrParam.setFolderProvider(folderProvider);
parameter = corrParam;
href = relatedTopics[10].getHref();
parentType = currentType;
break;
case TABLE_FUNCTIONAL_DEPENDENCY:
FuncationDependencyParameter funcationDependency = new FuncationDependencyParameter();
funcationDependency.setFolderProvider(folderProvider);
parameter = funcationDependency;
href = relatedTopics[9].getHref();
parentType = currentType;
break;
default:
NamedColumnSetAnalysisParameter tableParam = new NamedColumnSetAnalysisParameter();
tableParam.setFolderProvider(folderProvider);
parameter = tableParam;
href = relatedTopics[7].getHref();
break;
}
break;
default:
parameter = new AnalysisParameter();
}
selectedWizard = WizardFactory.createAnalysisWizard(parentType, parameter);
setPageComplete(true);
}
// MOD by hcheng,0007483: Add help in analysis wizard
OpeningHelpWizardDialog dialog = (OpeningHelpWizardDialog) getWizard().getContainer();
dialog.setHref(href);
dialog.showHelp();
}
});
typeTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
AnalysisTypeNode node = (AnalysisTypeNode) ((IStructuredSelection) event.getSelection()).getFirstElement();
if (node.getParent() == null) {
typeTreeViewer.expandToLevel(node, 1);
} else {
advanceToNextPageOrFinish();
}
}
});
}
use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.
the class AnalysisParametersImpl method setAnalysisType.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setAnalysisType(AnalysisType newAnalysisType) {
AnalysisType oldAnalysisType = analysisType;
analysisType = newAnalysisType == null ? ANALYSIS_TYPE_EDEFAULT : newAnalysisType;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, AnalysisPackage.ANALYSIS_PARAMETERS__ANALYSIS_TYPE, oldAnalysisType, analysisType));
}
use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.
the class RunAnalysisAction method runAnalysisForItem.
/**
* DOC msjian Comment method "runAnalysisForItem".
*/
protected void runAnalysisForItem(final TDQAnalysisItem anaItem) {
try {
if (anaItem == null) {
// $NON-NLS-1$
log.error("Analysis item is null");
return;
}
if (ifLockByOthers(anaItem)) {
return;
}
// check if the analysis need to be saved or can run before real running by the event
if (!EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_ANALYSIS_CHECK_BEFORERUN, null)) {
// or the analysis can not run, return without continue
return;
}
// to do validate after save.
validateAnalysis(anaItem);
if (!isConnectedAvailable(anaItem)) {
return;
}
if (log.isInfoEnabled()) {
addTaggedVaLueIntoConnection(anaItem);
}
AnalysisType analysisType = anaItem.getAnalysis().getParameters().getAnalysisType();
if (AnalysisType.COLUMNS_COMPARISON.equals(analysisType)) {
// If the analysis type is column comparison, ask user to continue to run or not.
if (!isContinueRun()) {
return;
}
} else if (AnalysisType.CONNECTION.equals(analysisType)) {
// If the analysis type is overview analysis, reload the database.
// TODO check here the needed of reloading database
reloadConnection(anaItem);
}
// when the run comes from context menu, the listener is null
if (this.listener == null && !ProxyRepositoryManager.getInstance().isLocked(anaItem)) {
if (!ProxyRepositoryFactory.getInstance().isEditableAndLockIfPossible(anaItem)) {
// if the analysis is not editable , return without running.
isNeedUnlock = false;
return;
} else {
// it is locked here, means that it need the unlock too.
isNeedUnlock = true;
}
} else {
isNeedUnlock = false;
}
final WorkspaceJob job = new // $NON-NLS-1$
WorkspaceJob(// $NON-NLS-1$
"Run Analysis") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
final boolean isSupportDynamicChart = isSupportDynamicChart(anaItem);
monitor.beginTask(DefaultMessagesImpl.getString("RunAnalysisAction.running", anaItem.getAnalysis().getName()), // $NON-NLS-1$
100);
Display.getDefault().syncExec(new Runnable() {
public void run() {
if (listener != null) {
listener.fireRuningItemChanged(false, isSupportDynamicChart);
}
// register dynamic event for who supported dynamic chart
if (isSupportDynamicChart) {
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_DYNAMIC_REGISTER_DYNAMIC_CHART, null);
}
}
});
ReturnCode executed = null;
try {
monitor.worked(10);
executed = AnalysisExecutorSelector.executeAnalysis(anaItem, monitor);
if (monitor.isCanceled()) {
TdqAnalysisConnectionPool.closeConnectionPool(anaItem.getAnalysis());
// $NON-NLS-1$
executed = new ReturnCode(DefaultMessagesImpl.getString("RunAnalysisAction.TaskCancel"), false);
monitor.done();
if (isNeedUnlock) {
unlockAnalysis(anaItem);
}
return Status.CANCEL_STATUS;
}
if (isNeedUnlock) {
unlockAnalysis(anaItem);
}
// $NON-NLS-1$
monitor.subTask(DefaultMessagesImpl.getString("RunAnalysisAction.refresh.page"));
} finally {
// if any exception, still need to unregister dynamic events.
Display.getDefault().syncExec(new Runnable() {
public void run() {
// the analysis
if (isSupportDynamicChart) {
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_DYNAMIC_UNREGISTER_DYNAMIC_CHART, null);
}
if (listener != null) {
listener.fireRuningItemChanged(true);
} else {
// TODO yyin publish the event from listener.
EventManager.getInstance().publish(anaItem.getAnalysis(), EventEnum.DQ_ANALYSIS_RUN_FROM_MENU, null);
}
}
});
}
displayResultStatus(executed, anaItem);
// TODO move this code to the right place
addAnalysisToRef(anaItem.getAnalysis());
monitor.worked(20);
monitor.done();
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
// TDQ-11433: fix the job name still show after run analysis for remote project.(maybe this is not the best
// way to fix this issue)
job.addJobChangeListener(new JobChangeAdapter() {
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.runtime.jobs.JobChangeAdapter#done(org.eclipse.core.runtime.jobs.IJobChangeEvent)
*/
@Override
public void done(IJobChangeEvent event) {
// $NON-NLS-1$
job.setName("");
}
});
// TDQ-11433~
} catch (BusinessException e) {
ExceptionHandler.process(e, Level.FATAL);
}
}
use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.
the class DataExplorer method getComment.
/**
* get the comment of analysis, if analysis is null, return "".
*
* @param showing
* @return
*/
protected String getComment(String showing) {
if (!SHOW_COMMENT_BEFORE_STATEMENT) {
return PluginConstant.EMPTY_STRING;
}
StringBuffer sb = new StringBuffer();
if (this.analysis != null) {
String anaName = StringUtils.defaultString(this.analysis.getName());
AnalysisType analysisType = AnalysisHelper.getAnalysisType(this.analysis);
String anaType = analysisType == null ? PluginConstant.EMPTY_STRING : StringUtils.defaultString(analysisType.getLiteral());
String anaPurpose = AnalysisHelper.getPurpose(this.analysis);
String anaDescription = AnalysisHelper.getDescription(this.analysis);
String aeName = PluginConstant.EMPTY_STRING;
String indName = AnalysisExecutorHelper.getIndicatorName(indicator);
if (this.indicator != null) {
ModelElement analyzedElement = this.indicator.getAnalyzedElement();
if (analyzedElement != null) {
aeName = StringUtils.defaultString(analyzedElement.getName());
}
}
showing = StringUtils.defaultString(showing);
// sb.append("/*\n"); //$NON-NLS-1$
// sb.append("Analysis: " + anaName + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("Type of Analysis: " + anaType + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("Purpose: " + anaPurpose + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("Description: " + anaDescription + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("AnalyzedElement: " + aeName + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("Indicator: " + indName + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("Showing: " + showing + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
// sb.append("*/\n"); //$NON-NLS-1$
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.AnalysisLabel") + " " + anaName + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.TypeAnalysisLabel") + " " + anaType + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.PurposeLabel") + " " + anaPurpose + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
sb.append("-- " + Messages.getString("DataExplorer.DescriptionLabel") + " " + anaDescription.replace("\n", "\n-- ") + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.AnalyzedElementLabel") + " " + aeName + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.IndicatorLabel") + " " + indName + " ;\n");
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
sb.append("-- " + Messages.getString("DataExplorer.ShowingLabel") + " " + showing + " ;\n");
}
return sb.toString();
}
use of org.talend.dataquality.analysis.AnalysisType in project tdq-studio-se by Talend.
the class SimpleStatisticsExplorer method getSubClassQueryMap.
@Override
public Map<String, String> getSubClassQueryMap() {
Map<String, String> map = new HashMap<String, String>();
// MOD zshen feature 12919 adapt to pop-menu for Jave engin on result page
boolean isSqlEngine = ExecutionLanguage.SQL.equals(this.analysis.getParameters().getExecutionLanguage());
// MOD qiongli 2011-3-4,feature 19192:filter menue 'view rows' for columSet AnalysisType.
AnalysisType analysisType = this.analysis.getParameters().getAnalysisType();
// MOD qiongli 2012-8-29 hive don't support 'where in...'
boolean isHive = dbmsLanguage instanceof HiveDbmsLanguage;
switch(this.indicatorEnum) {
case RowCountIndicatorEnum:
// for columnset/column and jave engine, we didn't show the view rows menu
if (isSqlEngine) {
// when user define indicator
map.put(MENU_VIEW_ROWS, getComment(MENU_VIEW_ROWS) + getRowsStatement());
}
break;
case NullCountIndicatorEnum:
case BlankCountIndicatorEnum:
case DefValueCountIndicatorEnum:
case UserDefinedIndicatorEnum:
// when user define indicator
IndicatorDefinition indicatorDefinition = this.indicator.getIndicatorDefinition();
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + (indicatorDefinition instanceof UDIndicatorDefinition ? getQueryForViewRows(indicatorDefinition) : getRowsStatement()) : null);
break;
case UniqueIndicatorEnum:
case DuplicateCountIndicatorEnum:
if (analysisType != AnalysisType.COLUMN_SET) {
if (!isHive) {
map.put(MENU_VIEW_ROWS, isSqlEngine ? getComment(MENU_VIEW_ROWS) + getRowsStatementWithSubQuery() : null);
} else if (!isSqlEngine) {
map.put(MENU_VIEW_ROWS, null);
}
}
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getValuesStatement(this.columnName) : null);
break;
case DistinctCountIndicatorEnum:
map.put(MENU_VIEW_VALUES, isSqlEngine ? getComment(MENU_VIEW_VALUES) + getDistinctValuesStatement(this.columnName) : null);
break;
default:
}
return map;
}
Aggregations