use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class RespositoryDetailView method createTechnicalDetail.
private void createTechnicalDetail(IRepositoryViewObject reposViewObj) {
// MOD klliu the DQRepositoryview unified with tos, so refactor as follow bug 19154 2011-02-28
if (reposViewObj.getProperty() != null) {
Item item = reposViewObj.getProperty().getItem();
if (item instanceof ConnectionItem) {
Connection conn = ((ConnectionItem) item).getConnection();
createTechnicalDetail(conn);
} else if (item instanceof TDQAnalysisItem) {
Analysis analysis = ((TDQAnalysisItem) item).getAnalysis();
createTechnicalDetail(analysis);
} else if (item instanceof TDQPatternItem) {
Pattern pattern = ((TDQPatternItem) item).getPattern();
createTechnicalDetail(pattern);
} else if (item instanceof TDQReportItem) {
Report report = ((TDQReportItem) item).getReport();
createTechnicalDetail(report);
}
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class FileSystemImportWriter method updateAnalysisClientDependence.
/**
* remove the old client dependency add a new one in Anlaysis.
*
* @param supplierItem
* @param modelElement
* @throws PersistenceException
*/
private void updateAnalysisClientDependence(TDQItem supplierItem, Property property) throws PersistenceException {
ModelElement anaModelElement = PropertyHelper.getModelElement(property);
if (anaModelElement != null) {
Analysis analysis = (Analysis) anaModelElement;
EList<Dependency> clientDependency = anaModelElement.getClientDependency();
Iterator<Dependency> it = clientDependency.iterator();
ModelElement supplierModelElement = RepositoryNodeHelper.getResourceModelElement(supplierItem);
Resource supModeResource = supplierModelElement.eResource();
while (it.hasNext()) {
Dependency clientDep = it.next();
// systemSupplyModelElement,remove it.
if (clientDep.eResource() == null) {
URI clientDepURI = ((InternalEObject) clientDep).eProxyURI();
boolean isUDI = clientDepURI.path().contains(ResourceManager.getUDIFolder().getProjectRelativePath().toString());
boolean isPattern = clientDepURI.path().contains(ResourceManager.getPatternFolder().getProjectRelativePath().toString());
if (supModeResource != null && (isUDI || isPattern) && clientDepURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
it.remove();
break;
}
}
}
DependenciesHandler.getInstance().setUsageDependencyOn(anaModelElement, supplierModelElement);
// TDQ-8436 remove the old pattern and add the new pattern in analysis Indicator Parameters.
if (isPattern(supplierModelElement)) {
updatePatternInAnaParams(supplierModelElement, analysis);
ElementWriterFactory.getInstance().createPatternWriter().save(supplierItem, true);
}
// remove old udi and set a new one in the analysis indicators.
if (supplierModelElement instanceof UDIndicatorDefinition) {
if (analysis.getResults() != null) {
EList<Indicator> indicators = analysis.getResults().getIndicators();
Iterator<Indicator> itIndicators = indicators.iterator();
while (itIndicators.hasNext()) {
Indicator indicator = itIndicators.next();
IndicatorDefinition indicatorDefinition = indicator.getIndicatorDefinition();
if (indicatorDefinition.eResource() == null) {
URI indicatorDefURI = ((InternalEObject) indicatorDefinition).eProxyURI();
if (supModeResource != null && UDIHelper.isUDI(indicator) && indicatorDefURI.lastSegment().equals(supModeResource.getURI().lastSegment())) {
indicator.setIndicatorDefinition((UDIndicatorDefinition) supplierModelElement);
break;
}
}
}
ElementWriterFactory.getInstance().createIndicatorDefinitionWriter().save(supplierItem, true);
}
}
// only save analysis item at here.
ProxyRepositoryFactory.getInstance().save(property.getItem(), true);
}
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class DataFilterDND method installDND.
public static void installDND(final Text targetControl) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
DQRespositoryView findView = (DQRespositoryView) activePage.findView(DQRespositoryView.ID);
final CommonViewer commonViewer = findView.getCommonViewer();
final LocalSelectionTransfer transfer = LocalSelectionTransfer.getTransfer();
int operations = DND.DROP_COPY | DND.DROP_MOVE;
Transfer[] transfers = new Transfer[] { transfer };
DropTarget dropTarget = new DropTarget(targetControl, operations);
dropTarget.setTransfer(transfers);
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
Object obj = ((IStructuredSelection) commonViewer.getSelection()).getFirstElement();
if (!(obj instanceof DBColumnRepNode)) {
event.detail = DND.DROP_NONE;
} else {
event.detail = DND.DROP_MOVE;
event.feedback = DND.FEEDBACK_INSERT_AFTER;
}
}
@Override
public void dropAccept(DropTargetEvent event) {
// do nothing until now
}
@Override
public void drop(DropTargetEvent event) {
if (event.detail != DND.DROP_NONE) {
IStructuredSelection selection = (IStructuredSelection) commonViewer.getSelection();
if (!selection.isEmpty()) {
List list = selection.toList();
IEditorPart currentActiveEditor = CorePlugin.getDefault().getCurrentActiveEditor();
if (currentActiveEditor instanceof AnalysisEditor) {
AnalysisEditor editor = (AnalysisEditor) currentActiveEditor;
AnalysisItemEditorInput input = (AnalysisItemEditorInput) editor.getEditorInput();
for (Object object : list) {
DBColumnRepNode node = (DBColumnRepNode) object;
DbmsLanguage language = DbmsLanguageFactory.createDbmsLanguage((Analysis) input.getModel());
MetadataColumnRepositoryObject columnObject = (MetadataColumnRepositoryObject) node.getObject();
String name = columnObject.getTdColumn().getName();
targetControl.insert(language.quote(name));
// Focus text.
targetControl.forceFocus();
}
}
}
}
}
});
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class ReportExecutor method execute.
/*
* (non-Javadoc)
*
* @see org.talend.dq.analysis.IReportExecutor#execute(org.talend.dataquality.reports.TdReport)
*/
public ReturnCode execute(TdReport report, IProgressMonitor monitor) throws AnalysisExecutionException {
atLeastOneFailure = false;
long startTime = System.currentTimeMillis();
if (report.eIsProxy()) {
report = (TdReport) EObjectHelper.resolveObject(report);
}
EList<AnalysisMap> analysisMaps = report.getAnalysisMap();
StringBuilder strBuilder = new StringBuilder();
// loop on analysis maps is faster than loop on analyses
for (AnalysisMap analysisMap : analysisMaps) {
Analysis analysis = analysisMap.getAnalysis();
if (analysisMap.isMustRefresh()) {
if (analysis == null) {
return new ReturnCode(Messages.getString("ReportExecutor.CannotEvaluateNullAnalysis", report.getName()), // $NON-NLS-1$
false);
}
ReturnCode executeRc = AnalysisExecutorSelector.executeAnalysis(analysis, monitor);
if (executeRc.getMessage() != null && !StringUtils.EMPTY.equals(executeRc.getMessage().trim())) {
throw new AnalysisExecutionException(Messages.getString("ReportExecutor.failRunAnalysis", analysis.getName(), executeRc.getMessage()));
}
// ADD msjian TDQ-5952: we should close connections always
TdqAnalysisConnectionPool.closeConnectionPool(analysis);
// TDQ-5952~
if (!executeRc.isOk()) {
log.error("Failed to execute analysis " + analysis.getName() + ". Reason: " + executeRc.getMessage());
atLeastOneFailure = true;
}
if (log.isInfoEnabled()) {
strBuilder.append("Report " + report.getName() + ": Analysis " + analysis.getName() + " refreshed. State: " + executeRc.isOk() + "\n");
}
} else {
// skipped analysis
if (log.isInfoEnabled()) {
strBuilder.append("Report " + report.getName() + ": Analysis " + analysis.getName() + " skipped.\n");
}
}
}
// log execution
if (log.isInfoEnabled()) {
if (strBuilder.length() == 0) {
log.info("Generating reports for \"" + report.getName() + "\" without refreshing any analysis.");
} else {
log.info(strBuilder.toString());
}
}
long endTime = System.currentTimeMillis();
// fill in the execution informations
ExecutionInformations execInformations = ReportHelper.getExecutionInformations(report);
execInformations.setExecutionDate(new Date(startTime));
int duration = (int) (endTime - startTime);
execInformations.setExecutionDuration(duration);
execInformations.setExecutionNumber(execInformations.getExecutionNumber() + 1);
if (atLeastOneFailure) {
execInformations.setLastRunOk(false);
// $NON-NLS-1$
String err = Messages.getString("ReportExecutor.AnalysisExecutionFailed", report.getName());
execInformations.setMessage(err);
return new ReturnCode(err, false);
}
// else
execInformations.setLastRunOk(true);
execInformations.setLastExecutionNumberOk(execInformations.getExecutionNumber());
execInformations.setMessage(null);
return new ReturnCode();
}
use of org.talend.dataquality.analysis.Analysis in project tdq-studio-se by Talend.
the class SchemaAnalysisWizard method initCWMResourceBuilder.
@Override
public ModelElement initCWMResourceBuilder() {
Analysis analysis = (Analysis) super.initCWMResourceBuilder();
if (getAnalysisBuilder() != null) {
// MOD klliu 15750 2011-1-05 add the repnode on parameter
PackagesAnalyisParameter packageParameter = getParameter();
IRepositoryNode connectionRepNode = getParameter().getConnectionRepNode();
ConnectionItem item = (ConnectionItem) connectionRepNode.getObject().getProperty().getItem();
Connection tdProvider = item.getConnection();
// Connection tdProvider = packageParameter.getTdDataProvider();
getAnalysisBuilder().setAnalysisConnection(tdProvider);
Indicator[] indicators = new Indicator[packageParameter.getPackages().size()];
ModelElement[] modelElement = new ModelElement[packageParameter.getPackages().size()];
int i = 0;
for (IRepositoryNode node : packageParameter.getPackages()) {
SchemaIndicator createSchemaIndicator = SchemaFactory.eINSTANCE.createSchemaIndicator();
DBSchemaRepNode catalogNode = (DBSchemaRepNode) node;
Schema schema = ((MetadataSchemaRepositoryObject) catalogNode.getObject()).getSchema();
modelElement[i] = schema;
DefinitionHandler.getInstance().setDefaultIndicatorDefinition(createSchemaIndicator);
createSchemaIndicator.setAnalyzedElement(schema);
indicators[i] = createSchemaIndicator;
i++;
}
getAnalysisBuilder().addElementsToAnalyze(modelElement, indicators);
}
return analysis;
}
Aggregations