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);
}
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);
}
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;
}
Aggregations