Search in sources :

Example 1 with AnalysisWriter

use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.

the class AElementPersistanceRealTest method testCreateItemAnalysis.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#createItem(orgomg.cwm.objectmodel.core.ModelElement)}.
 */
@Test
public void testCreateItemAnalysis() {
    AnalysisWriter createAnalysisWrite = ElementWriterFactory.getInstance().createAnalysisWrite();
    // test normal name
    // $NON-NLS-1$
    String anaName = "ana1";
    // $NON-NLS-1$
    String exceptedFileName = anaName + "_0.1.ana";
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis.setName(anaName);
    Item createItem = createAnalysisWrite.createItem(createAnalysis);
    assertTrue(createItem instanceof TDQAnalysisItem);
    TDQAnalysisItem analysisItem = (TDQAnalysisItem) createItem;
    assertTrue(analysisItem.getFilename().equals(exceptedFileName));
    // test special name
    // $NON-NLS-1$
    String anaNameWithSpecialChar = "ana1~!`";
    // $NON-NLS-1$
    String exceptedFileName2 = "ana1____0.1.ana";
    Analysis createAnalysis2 = AnalysisFactory.eINSTANCE.createAnalysis();
    createAnalysis2.setName(anaNameWithSpecialChar);
    Item createItem2 = createAnalysisWrite.createItem(createAnalysis2);
    assertTrue(createItem2 instanceof TDQAnalysisItem);
    TDQAnalysisItem analysisItem2 = (TDQAnalysisItem) createItem2;
    assertTrue(analysisItem2.getFilename().equals(exceptedFileName2));
}
Also used : TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) Item(org.talend.core.model.properties.Item) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) Analysis(org.talend.dataquality.analysis.Analysis) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 2 with AnalysisWriter

use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.

the class AnalysisBuilder method saveAnalysis.

/**
 * Method "saveAnalysis". This method should be called when the creation of the analysis definition (analysis
 * context + parameters) is created. It is not safe to use it for saving the analysis after the evaluation of the
 * analysis result. The domain should be saved before calling this method.
 *
 * @param folder the folder where the analysis is saved.
 * @return true if saved without problem
 */
public boolean saveAnalysis(IFolder folder) {
    assert analysis != null;
    AnalysisWriter writer = ElementWriterFactory.getInstance().createAnalysisWrite();
    String filename = DqRepositoryViewService.createFilename(this.analysis.getName(), FactoriesUtil.ANA);
    IFile file = folder.getFile(filename);
    ReturnCode saved = writer.create(analysis, folder);
    if (saved.isOk()) {
        if (log.isDebugEnabled()) {
            // $NON-NLS-1$
            log.debug("Saved in  " + file.getFullPath());
        }
    }
    return saved.isOk();
}
Also used : IFile(org.eclipse.core.resources.IFile) ReturnCode(org.talend.utils.sugars.ReturnCode) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter)

Example 3 with AnalysisWriter

use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.

the class AnalysisExecutorSelector method executeAnalysis.

public static ReturnCode executeAnalysis(final TDQAnalysisItem analysisItem, final IProgressMonitor monitor) {
    IAnalysisExecutor analysisExecutor = getAnalysisExecutor(analysisItem.getAnalysis());
    if (analysisExecutor != null) {
        // MOD xqliu 2009-02-09 bug 6237
        analysisExecutor.setMonitor(monitor);
        ReturnCode execute = analysisExecutor.execute(analysisItem.getAnalysis());
        // save analysis.
        if (Platform.isRunning()) {
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    if (monitor != null && !monitor.isCanceled()) {
                        // $NON-NLS-1$
                        monitor.subTask(Messages.getString("AnalysisExecutorSelector.SavingAnalysisTask"));
                        AnalysisWriter writer = ElementWriterFactory.getInstance().createAnalysisWrite();
                        writer.save(analysisItem, Boolean.FALSE);
                        monitor.worked(10);
                    }
                }
            });
        }
        return execute;
    }
    // else
    return new ReturnCode(Messages.getString("AnalysisExecutorSelector.NotFindHowExecute", analysisItem.getAnalysis().getName()), // $NON-NLS-1$
    false);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter)

Example 4 with AnalysisWriter

use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.

the class AbstractAnalysisWizard method createAndSaveCWMFile.

public TypedReturnCode<Object> createAndSaveCWMFile(ModelElement cwmElement) {
    Analysis analysis = (Analysis) cwmElement;
    IFolder folder = parameter.getFolderProvider().getFolderResource();
    AnalysisWriter analysisWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
    return analysisWriter.create(analysis, folder);
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with AnalysisWriter

use of org.talend.dq.writer.impl.AnalysisWriter in project tdq-studio-se by Talend.

the class IndicatorSettingsPage method modifyAndSaveLimit.

/**
 * DOC zshen Comment method "modifyAndSaveLimit".
 *
 * @param anaNode
 * @param isLowCase
 */
private void modifyAndSaveLimit(AnalysisRepNode anaNode, boolean isLowCase) {
    Analysis analysis = anaNode.getAnalysis();
    for (Indicator indicator : analysis.getResults().getIndicators()) {
        if (isLowCase) {
            modifyLowFre(indicator);
        } else {
            // too many frequency type
            modifyFre(indicator);
        }
    }
    AnalysisWriter anaWriter = ElementWriterFactory.getInstance().createAnalysisWrite();
    anaWriter.save(anaNode.getObject().getProperty().getItem(), false);
    ((TDQAnalysisItem) anaNode.getObject().getProperty().getItem()).setAnalysis(analysis);
// Resource resource = analysis.eResource();
// EMFUtil.saveSingleResource(resource);
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) FrequencyIndicator(org.talend.dataquality.indicators.FrequencyIndicator) Indicator(org.talend.dataquality.indicators.Indicator) LowFrequencyIndicator(org.talend.dataquality.indicators.LowFrequencyIndicator) AnalysisWriter(org.talend.dq.writer.impl.AnalysisWriter) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Aggregations

AnalysisWriter (org.talend.dq.writer.impl.AnalysisWriter)8 Analysis (org.talend.dataquality.analysis.Analysis)6 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)4 ReturnCode (org.talend.utils.sugars.ReturnCode)4 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)3 IFolder (org.eclipse.core.resources.IFolder)2 Test (org.junit.Test)2 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)2 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)2 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)2 DQRule (org.talend.dataquality.rules.DQRule)2 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 Item (org.talend.core.model.properties.Item)1 Property (org.talend.core.model.properties.Property)1 TdColumn (org.talend.cwm.relational.TdColumn)1 AnalysisEditor (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisEditor)1 AnalysisItemEditorInput (org.talend.dataprofiler.core.ui.editor.analysis.AnalysisItemEditorInput)1