Search in sources :

Example 6 with ImportExportHandlersManager

use of org.talend.repository.items.importexport.handlers.ImportExportHandlersManager in project tdi-studio-se by Talend.

the class MdmEeDemoImportTest method importMdmEeDemo.

@Before
public void importMdmEeDemo() throws Exception {
    initDemo(MDM_EE_DEMO_PLUGIN_ID);
    Assert.assertNotNull(currentDemo);
    initTestPaths();
    initTempPro();
    mdmResEeManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(mdmResEeManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(mdmResEeManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), mdmResEeManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) Before(org.junit.Before)

Example 7 with ImportExportHandlersManager

use of org.talend.repository.items.importexport.handlers.ImportExportHandlersManager in project tdi-studio-se by Talend.

the class DiDemoImportTest method importDiDemo.

@Before
public void importDiDemo() throws Exception {
    initDemo(DI_DEMO_PLUGIN_ID);
    Assert.assertNotNull(currentDemo);
    initTestPaths();
    initTempPro();
    diResManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(diResManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(diResManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), diResManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) Before(org.junit.Before)

Example 8 with ImportExportHandlersManager

use of org.talend.repository.items.importexport.handlers.ImportExportHandlersManager in project tdi-studio-se by Talend.

the class TalendImportUtil method importItems.

public static boolean importItems(String zipPath, IProgressMonitor monitor, final boolean overwrite, final boolean openThem, boolean needMigrationTask) throws IOException {
    // File srcFile = new File(zipPath);
    ZipFile srcZipFile = new ZipFile(zipPath);
    final ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    final ResourcesManager resourcesManager = ResourcesManagerFactory.getInstance().createResourcesManager(srcZipFile);
    // resourcesManager.collectPath2Object(srcFile);
    resourcesManager.collectPath2Object(srcZipFile);
    final List<ImportItem> items = populateItems(importManager, resourcesManager, monitor, overwrite);
    final List<String> itemIds = new ArrayList<String>();
    try {
        for (ImportItem itemRecord : items) {
            Item item = itemRecord.getProperty().getItem();
            if (item instanceof ProcessItem) {
                // only select jobs
                itemIds.add(item.getProperty().getId());
            }
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            if (item.getState().isLocked()) {
                factory.unlock(item);
            }
            ERepositoryStatus status = factory.getStatus(item);
            if (status != null && status == ERepositoryStatus.LOCK_BY_USER) {
                factory.unlock(item);
            }
            if (!needMigrationTask) {
                itemRecord.setMigrationTasksToApply(null);
            }
        }
        // nodesBuilder.getAllImportItemRecords(), null);
        if (items != null && !items.isEmpty()) {
            importManager.importItemRecords(monitor, resourcesManager, items, overwrite, nodesBuilder.getAllImportItemRecords(), null);
        }
    } catch (Exception e) {
        CommonExceptionHandler.process(e);
    } finally {
        // clean
        if (resourcesManager != null) {
            resourcesManager.closeResource();
        }
        nodesBuilder.clear();
    }
    return true;
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) ArrayList(java.util.ArrayList) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ZipFile(java.util.zip.ZipFile) ProcessItem(org.talend.core.model.properties.ProcessItem) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

ImportExportHandlersManager (org.talend.repository.items.importexport.handlers.ImportExportHandlersManager)8 ImportItem (org.talend.repository.items.importexport.handlers.model.ImportItem)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 Before (org.junit.Before)7 ZipFile (java.util.zip.ZipFile)2 Item (org.talend.core.model.properties.Item)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 ResourcesManager (org.talend.repository.items.importexport.manager.ResourcesManager)2 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Path (org.eclipse.core.runtime.Path)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 FileResourcesUnityManager (org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager)1 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)1