Search in sources :

Example 16 with TDQIndicatorDefinitionItem

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

the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase2.

/**
 * Test method for
 * {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . 、
 * case2 supplier side is lost
 */
@Test
public void testSetUsageDependencyOnModelElementModelElementCase2() {
    // analysis init
    TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    // $NON-NLS-1$
    analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2Analysis");
    analysisItem.setAnalysis(analysis);
    Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyAna.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2Analysis");
    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);
    analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
    try {
        ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // UDI init
    TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
    UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // $NON-NLS-1$
    createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2UDI");
    createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
    createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
    Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyUDI.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase2UDI");
    createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
    try {
        ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // init UDI supplier Dependency
    analysisResult1.getIndicators().add(createUserDefIndicator);
    ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
    if (!createIndicatorDefinition.getSupplierDependency().isEmpty()) {
        createIndicatorDefinition.getSupplierDependency().get(0).getClient().clear();
    }
    Analysis analysisFromFile = AnalysisFactory.eINSTANCE.createAnalysis();
    try {
        analysis.eResource().unload();
        IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(propertyAna.getId());
        analysisFromFile = ((TDQAnalysisItem) lastVersion.getProperty().getItem()).getAnalysis();
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // call the test method
    TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysisFromFile, createIndicatorDefinition);
    // $NON-NLS-1$
    Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
    Assert.assertEquals(analysisFromFile, setUsageDependencyOn.getObject().getClient().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
    Assert.assertEquals(createIndicatorDefinition, setUsageDependencyOn.getObject().getSupplier().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
Also used : Path(org.eclipse.core.runtime.Path) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Dependency(orgomg.cwm.objectmodel.core.Dependency) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 17 with TDQIndicatorDefinitionItem

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

the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase1.

/**
 * Test method for
 * {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . case1
 * noraml case the dependency has been set between clint and supplier
 */
@Test
public void testSetUsageDependencyOnModelElementModelElementCase1() {
    // analysis init
    TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    // $NON-NLS-1$
    analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1Analysis");
    analysisItem.setAnalysis(analysis);
    Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyAna.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1Analysis");
    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);
    analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
    try {
        ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // UDI init
    TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
    UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // $NON-NLS-1$
    createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1UDI");
    createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
    createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
    Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyUDI.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase1UDI");
    createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
    try {
        ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // init UDI supplier Dependency
    analysisResult1.getIndicators().add(createUserDefIndicator);
    ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
    if (!createIndicatorDefinition.getSupplierDependency().isEmpty()) {
        createIndicatorDefinition.getSupplierDependency().get(0).getClient().clear();
    }
    // call the test method
    TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysis, createIndicatorDefinition);
    // $NON-NLS-1$
    Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
    Assert.assertEquals(analysis, setUsageDependencyOn.getObject().getClient().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
    Assert.assertEquals(createIndicatorDefinition, setUsageDependencyOn.getObject().getSupplier().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
Also used : Path(org.eclipse.core.runtime.Path) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) Dependency(orgomg.cwm.objectmodel.core.Dependency) Property(org.talend.core.model.properties.Property) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 18 with TDQIndicatorDefinitionItem

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

the class DependenciesHandlerTest method testSetUsageDependencyOnModelElementModelElementCase3.

/**
 * Test method for
 * {@link org.talend.cwm.dependencies.DependenciesHandler#setUsageDependencyOn(ModelElement, ModelElement)} . case3
 * client side is lost
 */
@Test
public void testSetUsageDependencyOnModelElementModelElementCase3() {
    // analysis init
    TDQAnalysisItem analysisItem = PropertiesFactoryImpl.eINSTANCE.createTDQAnalysisItem();
    Analysis analysis = AnalysisFactory.eINSTANCE.createAnalysis();
    // $NON-NLS-1$
    analysis.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3Analysis");
    analysisItem.setAnalysis(analysis);
    Property propertyAna = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyAna.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyAna.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3Analysis");
    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);
    analysis.setContext(AnalysisFactory.eINSTANCE.createAnalysisContext());
    try {
        ProxyRepositoryFactory.getInstance().create(analysisItem, Path.EMPTY, false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // UDI init
    TDQIndicatorDefinitionItem createTDQIndicatorDefinitionItem = PropertiesFactoryImpl.eINSTANCE.createTDQIndicatorDefinitionItem();
    UserDefIndicator createUserDefIndicator = IndicatorSqlFactory.eINSTANCE.createUserDefIndicator();
    IndicatorDefinition createIndicatorDefinition = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    // $NON-NLS-1$
    createIndicatorDefinition.setName("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3UDI");
    createTDQIndicatorDefinitionItem.setIndicatorDefinition(createIndicatorDefinition);
    createUserDefIndicator.setIndicatorDefinition(createIndicatorDefinition);
    Property propertyUDI = org.talend.core.model.properties.PropertiesFactory.eINSTANCE.createProperty();
    propertyUDI.setId(EcoreUtil.generateUUID());
    // $NON-NLS-1$
    propertyUDI.setLabel("DependenciesHandlerTest.testSetUsageDependencyOnModelElementModelElementCase3UDI");
    createTDQIndicatorDefinitionItem.setProperty(propertyUDI);
    try {
        ProxyRepositoryFactory.getInstance().create(createTDQIndicatorDefinitionItem, new Path(EResourceConstant.USER_DEFINED_INDICATORS.getName()), false);
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // init UDI supplier Dependency
    analysisResult1.getIndicators().add(createUserDefIndicator);
    ElementWriterFactory.getInstance().createAnalysisWrite().save(analysisItem, true);
    if (!analysis.getClientDependency().isEmpty()) {
        analysis.getClientDependency().get(0).getSupplier().clear();
    }
    IndicatorDefinition createIndicatorDefinitionFromFile = DefinitionFactory.eINSTANCE.createIndicatorDefinition();
    try {
        createIndicatorDefinition.eResource().unload();
        IRepositoryViewObject lastVersion = ProxyRepositoryFactory.getInstance().getLastVersion(propertyUDI.getId());
        createIndicatorDefinitionFromFile = ((TDQIndicatorDefinitionItem) lastVersion.getProperty().getItem()).getIndicatorDefinition();
    } catch (PersistenceException e) {
        Assert.fail(e.getMessage());
    }
    // call the test method
    TypedReturnCode<Dependency> setUsageDependencyOn = DependenciesHandler.getInstance().setUsageDependencyOn(analysis, createIndicatorDefinitionFromFile);
    // $NON-NLS-1$
    Assert.assertEquals("call setUsageDependencyOn method should return ok stauts", true, setUsageDependencyOn.isOk());
    Assert.assertEquals(analysis, setUsageDependencyOn.getObject().getClient().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getClient().size());
    Assert.assertEquals(createIndicatorDefinitionFromFile, setUsageDependencyOn.getObject().getSupplier().get(0));
    Assert.assertEquals(1, setUsageDependencyOn.getObject().getSupplier().size());
}
Also used : Path(org.eclipse.core.runtime.Path) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Dependency(orgomg.cwm.objectmodel.core.Dependency) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) AnalysisResult(org.talend.dataquality.analysis.AnalysisResult) Analysis(org.talend.dataquality.analysis.Analysis) ItemState(org.talend.core.model.properties.ItemState) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) Property(org.talend.core.model.properties.Property) UserDefIndicator(org.talend.dataquality.indicators.sql.UserDefIndicator) TDQAnalysisItem(org.talend.dataquality.properties.TDQAnalysisItem) Test(org.junit.Test)

Example 19 with TDQIndicatorDefinitionItem

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

the class AnalysisWriter method addDependencies.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dq.writer.AElementPersistance#addDependencies(orgomg.cwm.objectmodel.core.ModelElement)
     */
@Override
public void addDependencies(ModelElement element) {
    Analysis analysis = (Analysis) element;
    List<IndicatorDefinition> udis = AnalysisHelper.getUserDefinedIndicators(analysis);
    try {
        for (IndicatorDefinition udi : udis) {
            if (udi == null) {
                continue;
            }
            InternalEObject iudi = (InternalEObject) udi;
            if (!iudi.eIsProxy()) {
                DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(udi);
                // only do save when the dependency is not reference project node
                if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
                    TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, udi);
                    if (dependencyReturn.isOk()) {
                        Property property = PropertyHelper.getProperty(udi);
                        if (property != null) {
                            TDQItem udiItem = (TDQItem) property.getItem();
                            if (udiItem instanceof TDQIndicatorDefinitionItem) {
                                ((TDQIndicatorDefinitionItem) udiItem).setIndicatorDefinition(udi);
                            } else if (udiItem instanceof TDQBusinessRuleItem) {
                                ((TDQBusinessRuleItem) udiItem).setDqrule((DQRule) udi);
                            }
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(udi.eResource());
                    }
                }
            }
        }
        List<Pattern> patterns = AnalysisHelper.getPatterns(analysis);
        for (Pattern pattern : patterns) {
            InternalEObject iptn = (InternalEObject) pattern;
            if (!iptn.eIsProxy()) {
                DQRepositoryNode recursiveFind = RepositoryNodeHelper.recursiveFind(pattern);
                // only do save when the dependency is not reference project node
                if (recursiveFind != null && recursiveFind.getProject().isMainProject()) {
                    TypedReturnCode<Dependency> dependencyReturn = DependenciesHandler.getInstance().setDependencyOn(analysis, pattern);
                    if (dependencyReturn.isOk()) {
                        Property property = PropertyHelper.getProperty(pattern);
                        if (property != null && property.getItem() instanceof TDQPatternItem) {
                            TDQPatternItem patternItem = (TDQPatternItem) property.getItem();
                            patternItem.setPattern(pattern);
                        }
                        ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().saveResource(pattern.eResource());
                    // EMFUtil.saveSingleResource(pattern.eResource());
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        log.error(e, e);
    }
}
Also used : Pattern(org.talend.dataquality.domain.pattern.Pattern) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) Dependency(orgomg.cwm.objectmodel.core.Dependency) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) IndicatorDefinition(org.talend.dataquality.indicators.definition.IndicatorDefinition) DQRule(org.talend.dataquality.rules.DQRule) DQRepositoryNode(org.talend.dq.nodes.DQRepositoryNode) Analysis(org.talend.dataquality.analysis.Analysis) PersistenceException(org.talend.commons.exception.PersistenceException) TDQItem(org.talend.core.model.properties.TDQItem) TDQBusinessRuleItem(org.talend.dataquality.properties.TDQBusinessRuleItem) Property(org.talend.core.model.properties.Property) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 20 with TDQIndicatorDefinitionItem

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

the class FileSystemImportWriter method write.

/*
     * After check the conflicts of the imported object, calling this method (from ImportWizard) replace the conflicts
     * object in the records if the record is valid; then call the finish to do migrate. OR: merge the conflict system
     * indicators if valid.(overwrite)
     * 
     * @see
     * org.talend.dataprofiler.core.ui.imex.model.IImexWriter#write(org.talend.dataprofiler.core.ui.imex.model.ItemRecord
     * [], org.eclipse.core.runtime.IProgressMonitor)
     */
public void write(ItemRecord[] records, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    final ItemRecord[] fRecords = records;
    final IProgressMonitor fMonitor = monitor;
    need2MergeModelElementMap.clear();
    allImportItems.clear();
    RepositoryWorkUnit<Object> workUnit = new // $NON-NLS-1$
    RepositoryWorkUnit<Object>(// $NON-NLS-1$
    "Import TDQ Element") {

        @Override
        protected void run() {
            try {
                for (ItemRecord record : fRecords) {
                    if (fMonitor.isCanceled()) {
                        break;
                    }
                    Map<IPath, IPath> toImportMap = mapping(record);
                    // $NON-NLS-1$
                    fMonitor.subTask("Importing " + record.getName());
                    if (record.isValid()) {
                        boolean isDeleted = false;
                        // $NON-NLS-1$
                        log.info("Importing " + record.getFile().getAbsolutePath());
                        // Delete the conflict node before import.
                        IRepositoryViewObject object = record.getConflictObject();
                        boolean isDelete = true;
                        ModelElement modEle = record.getElement();
                        if (object != null) {
                            // is a system indicator definition, (using its UUid to find this SI not label)
                            if (isIndicatorDefinition(modEle)) {
                                if (isDQRule(modEle)) {
                                    if (isParserRule(modEle)) {
                                        mergeParserRule(record, (TDQBusinessRuleItem) object.getProperty().getItem());
                                        isDelete = false;
                                    } else if (isWhereRule(modEle)) {
                                    // do nothing here now
                                    }
                                } else if (isMatchRuleDefinition(modEle)) {
                                // do nothing here now
                                } else {
                                    // System Indicator and UDI need merge
                                    TDQIndicatorDefinitionItem indItem = (TDQIndicatorDefinitionItem) object.getProperty().getItem();
                                    mergeSystemIndicator(record, indItem);
                                    // only add it when it is UDIndicatorDefinition
                                    if (record.getElement() instanceof UDIndicatorDefinition) {
                                        need2MergeModelElementMap.put(indItem, record.getElement());
                                    }
                                    isDelete = false;
                                }
                            } else if (isPattern(modEle)) {
                                TDQPatternItem patternItem = (TDQPatternItem) object.getProperty().getItem();
                                mergePattern(record, patternItem);
                                need2MergeModelElementMap.put(patternItem, record.getElement());
                                isDelete = false;
                            } else {
                                // remove the dependency of the object
                                EObjectHelper.removeDependencys(PropertyHelper.getModelElement(object.getProperty()));
                                isDeleted = true;
                                // delete the object
                                ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
                            }
                        }
                        if (isDelete) {
                            updateFiles.clear();
                            updateFilesCoverd.clear();
                            for (IPath resPath : toImportMap.keySet()) {
                                IPath desPath = toImportMap.get(resPath);
                                ResourceSet resourceSet = ProxyRepositoryFactory.getInstance().getRepositoryFactoryFromProvider().getResourceManager().resourceSet;
                                synchronized (resourceSet) {
                                    write(resPath, desPath);
                                    allCopiedFiles.add(desPath.toFile());
                                }
                                allImportItems.add(desPath);
                                // TDQ-12180
                                if (isDeleted) {
                                    AbstractSvnRepositoryService svnReposService = GlobalServiceRegister.getDefault().getSvnRepositoryService(AbstractSvnRepositoryService.class);
                                    if (svnReposService != null) {
                                        svnReposService.addIfImportOverride(desPath);
                                    }
                                }
                            }
                            for (File file : updateFiles) {
                                update(file, false);
                            }
                            for (File file : updateFilesCoverd) {
                                update(file, true);
                            }
                        }
                    } else {
                        for (String error : record.getErrors()) {
                            log.error(error);
                        }
                    }
                    fMonitor.worked(1);
                }
                finish(fRecords, fMonitor);
            } catch (Exception e) {
                log.error(e, e);
            }
        }
    };
    workUnit.setAvoidUnloadResources(Boolean.TRUE);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnit);
    // after above workUnit executed, the imported items will worked, than can do merge/update about UDI and Pattern
    RepositoryWorkUnit<Object> workUnitFinish = new // $NON-NLS-1$
    RepositoryWorkUnit<Object>(// $NON-NLS-1$
    "Finish Import TDQ Element") {

        @Override
        protected void run() throws LoginException, PersistenceException {
            try {
                postFinish();
            } catch (IOException e) {
                log.error(e, e);
            }
        }
    };
    workUnitFinish.setAvoidUnloadResources(Boolean.TRUE);
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(workUnitFinish);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TDQIndicatorDefinitionItem(org.talend.dataquality.properties.TDQIndicatorDefinitionItem) IPath(org.eclipse.core.runtime.IPath) AbstractSvnRepositoryService(org.talend.dataprofiler.core.service.AbstractSvnRepositoryService) UDIndicatorDefinition(org.talend.dataquality.indicators.definition.userdefine.UDIndicatorDefinition) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) IOException(java.io.IOException) TDQPatternItem(org.talend.dataquality.properties.TDQPatternItem) CoreException(org.eclipse.core.runtime.CoreException) LoginException(org.talend.commons.exception.LoginException) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) ModelElement(orgomg.cwm.objectmodel.core.ModelElement) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) EObject(org.eclipse.emf.ecore.EObject) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

TDQIndicatorDefinitionItem (org.talend.dataquality.properties.TDQIndicatorDefinitionItem)28 PersistenceException (org.talend.commons.exception.PersistenceException)13 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 IndicatorDefinition (org.talend.dataquality.indicators.definition.IndicatorDefinition)13 Test (org.junit.Test)12 Item (org.talend.core.model.properties.Item)9 Property (org.talend.core.model.properties.Property)8 TDQAnalysisItem (org.talend.dataquality.properties.TDQAnalysisItem)8 Path (org.eclipse.core.runtime.Path)7 TDQPatternItem (org.talend.dataquality.properties.TDQPatternItem)7 Analysis (org.talend.dataquality.analysis.Analysis)6 RowCountIndicator (org.talend.dataquality.indicators.RowCountIndicator)6 TDQBusinessRuleItem (org.talend.dataquality.properties.TDQBusinessRuleItem)5 TDQReportItem (org.talend.dataquality.properties.TDQReportItem)5 File (java.io.File)4 IPath (org.eclipse.core.runtime.IPath)4 Resource (org.eclipse.emf.ecore.resource.Resource)4 ItemState (org.talend.core.model.properties.ItemState)4 TDQItem (org.talend.core.model.properties.TDQItem)4 ReturnCode (org.talend.utils.sugars.ReturnCode)4