Search in sources :

Example 41 with Analysis

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);
        }
    }
}
Also used : ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) Pattern(org.talend.dataquality.domain.pattern.Pattern) Report(orgomg.cwmx.analysis.informationreporting.Report) TdReport(org.talend.dataquality.reports.TdReport) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Analysis(org.talend.dataquality.analysis.Analysis) DatabaseConnection(org.talend.core.model.metadata.builder.connection.DatabaseConnection) DelimitedFileConnection(org.talend.core.model.metadata.builder.connection.DelimitedFileConnection) FileConnection(org.talend.core.model.metadata.builder.connection.FileConnection) Connection(org.talend.core.model.metadata.builder.connection.Connection) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 42 with Analysis

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);
    }
}
Also used : UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) Resource(org.eclipse.emf.ecore.resource.Resource) Dependency(orgomg.cwm.objectmodel.core.Dependency) URI(org.eclipse.emf.common.util.URI) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) Indicator(org.talend.dataquality.indicators.Indicator) RegexpMatchingIndicator(org.talend.dataquality.indicators.RegexpMatchingIndicator) AllMatchIndicator(org.talend.dataquality.indicators.columnset.AllMatchIndicator) PatternMatchingIndicator(org.talend.dataquality.indicators.PatternMatchingIndicator) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) Analysis(org.talend.dataquality.analysis.Analysis) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 43 with Analysis

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();
                        }
                    }
                }
            }
        }
    });
}
Also used : CommonViewer(org.eclipse.ui.navigator.CommonViewer) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) DBColumnRepNode(org.talend.dq.nodes.DBColumnRepNode) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) DbmsLanguage(org.talend.dq.dbms.DbmsLanguage) DropTargetAdapter(org.eclipse.swt.dnd.DropTargetAdapter) Analysis(org.talend.dataquality.analysis.Analysis) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer) Transfer(org.eclipse.swt.dnd.Transfer) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) List(java.util.List) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) DropTarget(org.eclipse.swt.dnd.DropTarget) AnalysisItemEditorInput(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput) AnalysisEditor(org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor) LocalSelectionTransfer(org.eclipse.jface.util.LocalSelectionTransfer)

Example 44 with Analysis

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();
}
Also used : ExecutionInformations(org.talend.dataquality.analysis.ExecutionInformations) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisExecutionException(org.talend.cwm.exception.AnalysisExecutionException) AnalysisMap(org.talend.dataquality.reports.AnalysisMap) Date(java.util.Date)

Example 45 with Analysis

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;
}
Also used : SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) DBSchemaRepNode(org.talend.dq.nodes.DBSchemaRepNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Schema(orgomg.cwm.resource.relational.Schema) Connection(org.talend.core.model.metadata.builder.connection.Connection) SchemaIndicator(org.talend.dataquality.indicators.schema.SchemaIndicator) Indicator(org.talend.dataquality.indicators.Indicator) MetadataSchemaRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataSchemaRepositoryObject) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) PackagesAnalyisParameter(org.talend.dq.analysis.parameters.PackagesAnalyisParameter) Analysis(org.talend.dataquality.analysis.Analysis)

Aggregations

Analysis (org.talend.dataquality.analysis.Analysis)137 Test (org.junit.Test)36 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)36 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)30 ArrayList (java.util.ArrayList)28 Property (org.talend.core.model.properties.Property)28 Indicator (org.talend.dataquality.indicators.Indicator)27 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)27 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)26 PersistenceException (org.talend.commons.exception.PersistenceException)19 Connection (org.talend.core.model.metadata.builder.connection.Connection)18 ReturnCode (org.talend.utils.sugars.ReturnCode)18 Dependency (orgomg.cwm.objectmodel.core.Dependency)18 TdColumn (org.talend.cwm.relational.TdColumn)16 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)16 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)15 Pattern (org.talend.dataquality.domain.pattern.Pattern)15 IFile (org.eclipse.core.resources.IFile)14 File (java.io.File)12 IPath (org.eclipse.core.runtime.IPath)12