Search in sources :

Example 1 with TDQAnalysisItem

use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.

the class MatchAnalysisDetailsPage method saveAnalysis.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.core.ui.editor.analysis.AbstractAnalysisMetadataPage#saveAnalysis()
     */
@Override
protected void saveAnalysis() throws DataprofilerCoreException {
    // save the default loaded row count
    if (this.isValidateRowCount()) {
        analysisHandler.changeDefaultRowLoaded(rowLoadedText.getText());
    } else {
        // $NON-NLS-1$
        MessageDialog.openWarning(// $NON-NLS-1$
        null, // $NON-NLS-1$
        DefaultMessagesImpl.getString("MatchMasterDetailsPage.NotValidate"), // $NON-NLS-1$
        DefaultMessagesImpl.getString("MatchMasterDetailsPage.LoadedRowCountError"));
        return;
    }
    analysisHandler.changeSampleDataShowWay(sampleDataShowWayCombo.getText());
    analysisHandler.saveSelectedAnalyzedElements();
    TDQAnalysisItem analysisItem = (TDQAnalysisItem) getCurrentRepNode().getObject().getProperty().getItem();
    analysisHandler.updateAnaConnRelationship(analysisItem);
    this.nameText.setText(analysisHandler.getName());
    ReturnCode saved = ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
    logSaved(saved);
}
Also used : ReturnCode(org.talend.utils.sugars.ReturnCode) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 2 with TDQAnalysisItem

use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.

the class RunAnalysisActionProvider method fillContextMenu.

/**
 * Adds a submenu to the given menu with the name "New Component".
 */
public void fillContextMenu(IMenuManager menu) {
    // MOD mzhao user readonly role on svn repository mode.
    if (!isShowMenu()) {
        return;
    }
    Object[] array = ((TreeSelection) this.getContext().getSelection()).toArray();
    ArrayList<TDQAnalysisItem> selectedItemsList = new ArrayList<TDQAnalysisItem>();
    for (Object obj : array) {
        RepositoryNode node = (RepositoryNode) obj;
        RepositoryNode parent = node.getParent();
        if (!(parent instanceof ReportSubFolderRepNode)) {
            // IPath append = WorkbenchUtils.getFilePath(node);
            Item item = node.getObject().getProperty().getItem();
            if (item instanceof TDQAnalysisItem) {
                selectedItemsList.add((TDQAnalysisItem) item);
            }
        }
    }
    if (!selectedItemsList.isEmpty()) {
        // IFile file = ResourceManager.getRootProject().getFile(append);
        RunAnalysisAction runAnalysisAction = new RunAnalysisAction();
        // runAnalysisAction.setSelectionFile(file);
        runAnalysisAction.setAnalysisItems(selectedItemsList.toArray(new TDQAnalysisItem[selectedItemsList.size()]));
        menu.add(runAnalysisAction);
    }
}
Also used : Item(org.talend.core.model.properties.Item) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) TreeSelection(org.eclipse.jface.viewers.TreeSelection) ArrayList(java.util.ArrayList) RepositoryNode(org.talend.repository.model.RepositoryNode) ReportSubFolderRepNode(org.talend.dq.nodes.ReportSubFolderRepNode) RunAnalysisAction(org.talend.dataprofiler.core.ui.action.actions.RunAnalysisAction) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem)

Example 3 with TDQAnalysisItem

use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.

the class DependenciesHandlerTest method testRemoveConnDependencyAndSave.

@Test
public void testRemoveConnDependencyAndSave() {
    TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    // $NON-NLS-1$
    analysis.setName("testDependAnalysis");
    analysisItem.setAnalysis(analysis);
    Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyAna.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyAna.setLabel("ana");
    analysisItem.setProperty(propertyAna);
    ItemState itemState = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createItemState();
    itemState.setDeleted(false);
    analysisItem.setState(itemState);
    AnalysisResult analysisResult1 = AnalysisFactory.eINSTANCE.createAnalysisResult();
    analysis.setResults(analysisResult1);
    AnalysisContext analysisContext = AnalysisFactory.eINSTANCE.createAnalysisContext();
    analysis.setContext(analysisContext);
    try {
        ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    DatabaseConnectionItem connectionItem = UnitTestBuildHelper.createDatabaseConnectionItem("testDependeceConnection", null, // $NON-NLS-1$
    false);
    DependenciesHandler.getInstance().setUsageDependencyOn(analysis, connectionItem.getConnection());
    analysisContext.setConnection(connectionItem.getConnection());
    ElementWriterFactory.getInstance().createDataProviderWriter().save(connectionItem, true);
    Assert.assertNotNull(analysis.getContext().getConnection());
    Assert.assertEquals(false, analysis.getClientDependency().isEmpty());
    DependenciesHandler.getInstance().removeConnDependencyAndSave(analysisItem);
    Assert.assertNull(analysis.getContext().getConnection());
    Assert.assertEquals(true, analysis.getClientDependency().isEmpty());
}
Also used : Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) AnalysisContext(org.talend.dataquality.analysis.AnalysisContext) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) DatabaseConnectionItem(org.talend.core.model.properties.DatabaseConnectionItem) Test(org.junit.Test)

Example 4 with TDQAnalysisItem

use of org.talend.dataquality.properties.TDQAnalysisItem 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 5 with TDQAnalysisItem

use of org.talend.dataquality.properties.TDQAnalysisItem in project tdq-studio-se by Talend.

the class AElementPersistanceRealTest method testSaveWithoutDependenciesReport.

/**
 * Test method for
 * {@link org.talend.dq.writer.AElementPersistance#saveWithoutDependencies(org.talend.core.model.properties.Item, orgomg.cwm.objectmodel.core.ModelElement)}
 * .
 *
 * @throws PersistenceException
 */
@Test
public void testSaveWithoutDependenciesReport() throws PersistenceException {
    ReportWriter createReportWriter = ElementWriterFactory.getInstance().createReportWriter();
    // create analysis
    Analysis createAnalysis = AnalysisFactory.eINSTANCE.createAnalysis();
    AnalysisResult createAnalysisResult = AnalysisFactory.eINSTANCE.createAnalysisResult();
    createAnalysis.setResults(createAnalysisResult);
    // $NON-NLS-1$
    createAnalysis.setName("AElementPersistanceRealTestanalysis6");
    // create analysis item
    TDQAnalysisItem createTDQAnalysisItem = PropertiesFactory.eINSTANCE.createTDQAnalysisItem();
    createTDQAnalysisItem.setAnalysis(createAnalysis);
    Property createAnalysisProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createAnalysisProperty.setLabel("AElementPersistanceRealTestanalysis6");
    createAnalysisProperty.setId(EcoreUtil.generateUUID());
    createTDQAnalysisItem.setProperty(createAnalysisProperty);
    ProxyRepositoryFactory.getInstance().create(createTDQAnalysisItem, Path.EMPTY, false);
    // create report
    TdReport createTdReport = ReportsFactory.eINSTANCE.createTdReport();
    TDQReportItem createTDQReportItem = PropertiesFactory.eINSTANCE.createTDQReportItem();
    createTDQReportItem.setReport(createTdReport);
    Property createReportProperty = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    // $NON-NLS-1$
    createReportProperty.setLabel("AElementPersistanceRealTestreport6");
    createTDQReportItem.setProperty(createReportProperty);
    createReportProperty.setId(EcoreUtil.generateUUID());
    ProxyRepositoryFactory.getInstance().create(createTDQReportItem, Path.EMPTY, false);
    createTdReport.addAnalysis(createAnalysis);
    // $NON-NLS-1$
    String repName = "rep61";
    // $NON-NLS-1$
    String exceptedFileName = repName + "_0.1.rep";
    createTdReport.setName(repName);
    ReturnCode create = createReportWriter.saveWithoutDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName, createTDQReportItem.getFilename());
    // $NON-NLS-1$
    String repName2 = "rep62";
    // $NON-NLS-1$
    String exceptedFileName2 = repName2 + "_0.1.rep";
    createTdReport.setName(repName2);
    create = createReportWriter.saveWithDependencies(createTDQReportItem, createTdReport);
    assertTrue(create.isOk());
    Assert.assertEquals(exceptedFileName2, createTDQReportItem.getFilename());
}
Also used : ReportWriter(org.talend.dq.writer.impl.ReportWriter) ReturnCode(org.talend.utils.sugars.ReturnCode) Analysis(org.talend.dataquality.analysis.Analysis) TdReport(org.talend.dataquality.reports.TdReport) Property(org.talend.core.model.properties.Property) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQReportItem(org.talend.dataquality.properties.TDQReportItem) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Aggregations

TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)33 Analysis (org.talend.dataquality.analysis.Analysis)26 PersistenceException (org.talend.commons.exception.PersistenceException)17 Property (org.talend.core.model.properties.Property)14 AnalysisResult (org.talend.dataquality.analysis.AnalysisResult)14 Item (org.talend.core.model.properties.Item)11 ItemState (org.talend.core.model.properties.ItemState)11 Path (org.eclipse.core.runtime.Path)9 Test (org.junit.Test)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)9 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)9 IPath (org.eclipse.core.runtime.IPath)7 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)7 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)7 AnalysisContext (org.talend.dataquality.analysis.AnalysisContext)6 ReturnCode (org.talend.utils.sugars.ReturnCode)6 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)6 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)5 TdReport (org.talend.dataquality.reports.TdReport)5