Search in sources :

Example 6 with ImportItem

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

the class BigDataEeImportTest method importEeDemo.

@Before
public void importEeDemo() throws Exception {
    initDemo(BIG_DATA_EE_DEMO_PLUGIN_ID);
    Assert.assertNotNull(currentDemo);
    initTestPaths();
    initTempPro();
    eeResManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(eeResManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(eeResManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), eeResManager, 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 ImportItem

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

the class BigdataCeImportTest method importCeDemo.

@Before
public void importCeDemo() throws Exception {
    initDemo(BIG_DATA_CE_DEMO_PLUGIN_ID);
    if (currentDemo == null) {
        // maybe license problem, the demo plugin is not loaded.
        return;
    }
    initTestPaths();
    initTempPro();
    Assert.assertNotNull(currentDemo);
    ceResManager = DemoImportTestUtil.getResourceManager(currentDemo);
    Assert.assertNotNull(ceResManager);
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    List<ImportItem> projectRecords = importManager.populateImportingItems(ceResManager, true, new NullProgressMonitor());
    Assert.assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), ceResManager, 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 ImportItem

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

the class BuildJobHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    // Fix the NPE for org.talend.designer.core.ui.editor.process.Process.createMainParameters(Process.java:401)
    bridgeProject = ReponsitoryContextBridge.getProject();
    ReponsitoryContextBridge.setProject(ProjectManager.getInstance().getCurrentProject().getEmfProject());
    ImportExportHandlersManager importManager = new ImportExportHandlersManager();
    // job with tdm and tdq component.
    URL testJobURL = FileLocator.find(Platform.getBundle("org.talend.repository.test"), new Path("/resources/testBuildJob.zip"), null);
    if (testJobURL != null) {
        testJobURL = FileLocator.toFileURL(testJobURL);
    }
    File srcFile = new File(testJobURL.getFile());
    FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
    ResourcesManager resManager = fileUnityManager.doUnify();
    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, new NullProgressMonitor());
    assertTrue(projectRecords.size() > 0);
    importManager.importItemRecords(new NullProgressMonitor(), resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
    IRepositoryViewObject obj = ProxyRepositoryFactory.getInstance().getLastVersion("_bWyBUAYbEeapTZ0aKwL_YA");
    Item item = obj.getProperty().getItem();
    assertTrue(item instanceof ProcessItem);
    processItem = (ProcessItem) item;
}
Also used : ImportExportHandlersManager(org.talend.repository.items.importexport.handlers.ImportExportHandlersManager) Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) FileResourcesUnityManager(org.talend.repository.items.importexport.ui.managers.FileResourcesUnityManager) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) ZipFile(java.util.zip.ZipFile) File(java.io.File) URL(java.net.URL) Before(org.junit.Before)

Example 9 with ImportItem

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

the class ImportDemoProjectItemsPage method performFinish.

public boolean performFinish() {
    List<DemoProjectBean> checkedElements = getCheckedElements();
    final List<ResourcesManager> finalCheckManagers = getResourceManagers(checkedElements);
    String warnMessage = populateExistItemRecords(finalCheckManagers);
    if (!warnMessage.equals("")) {
        MessageDialog dialog = new MessageDialog(getShell(), Messages.getString("ImportDemoProjectPage.overwrite"), null, warnMessage, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL }, 0);
        dialog.open();
        int result = dialog.getReturnCode();
        if (result != MessageDialog.OK) {
            return false;
        }
    }
    ProgressDialog progressDialog = new ProgressDialog(getShell()) {

        private IProgressMonitor monitorWrap;

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            monitorWrap = new EventLoopProgressMonitor(monitor);
            try {
                for (ResourcesManager resManager : finalCheckManagers) {
                    List<ImportItem> projectRecords = importManager.populateImportingItems(resManager, true, monitorWrap);
                    // clearOverWriteErrorMessages(projectRecords, overwrite);
                    importManager.importItemRecords(monitorWrap, resManager, projectRecords, true, projectRecords.toArray(new ImportItem[0]), null);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
            monitorWrap.done();
            if (monitor.isCanceled()) {
                MessageDialog.openInformation(getShell(), Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProjectCancel"), Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedIncompletely"));
                return;
            } else {
                MessageDialog.openInformation(getShell(), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogTitle.demoProject"), //$NON-NLS-1$
                Messages.getString("ImportDemoProjectAction.messageDialogContent.demoProjectImportedSuccessfully"));
            }
        }
    };
    try {
        progressDialog.executeProcess();
    } catch (InvocationTargetException e) {
        MessageBoxExceptionHandler.process(e.getTargetException(), getShell());
    } catch (InterruptedException e) {
    // Nothing to do
    }
    return true;
}
Also used : ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem) EventLoopProgressMonitor(org.talend.commons.ui.swt.dialogs.EventLoopProgressMonitor) ProgressDialog(org.talend.commons.ui.swt.dialogs.ProgressDialog) ZipException(java.util.zip.ZipException) FileNotFoundException(java.io.FileNotFoundException) InvocationTargetException(java.lang.reflect.InvocationTargetException) TarException(org.eclipse.ui.internal.wizards.datatransfer.TarException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResourcesManager(org.talend.repository.items.importexport.manager.ResourcesManager) MessageDialog(org.eclipse.jface.dialogs.MessageDialog)

Example 10 with ImportItem

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

the class RoutineImportHandler method isValidSystemItem.

@Override
public boolean isValidSystemItem(ImportItem importItem) {
    boolean valid = super.valid(importItem);
    if (!valid) {
        return false;
    }
    Item item = importItem.getItem();
    if (isBuiltIn(item)) {
        return true;
    }
    return false;
}
Also used : RoutineItem(org.talend.core.model.properties.RoutineItem) Item(org.talend.core.model.properties.Item) ImportItem(org.talend.repository.items.importexport.handlers.model.ImportItem)

Aggregations

ImportItem (org.talend.repository.items.importexport.handlers.model.ImportItem)16 ImportExportHandlersManager (org.talend.repository.items.importexport.handlers.ImportExportHandlersManager)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)7 Before (org.junit.Before)7 Item (org.talend.core.model.properties.Item)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 ResourcesManager (org.talend.repository.items.importexport.manager.ResourcesManager)4 ProcessItem (org.talend.core.model.properties.ProcessItem)3 FileNotFoundException (java.io.FileNotFoundException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ZipException (java.util.zip.ZipException)2 ZipFile (java.util.zip.ZipFile)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 TarException (org.eclipse.ui.internal.wizards.datatransfer.TarException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 RoutineItem (org.talend.core.model.properties.RoutineItem)2 File (java.io.File)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1