Search in sources :

Example 6 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class AbstractVersionManagementProjectSettingPage method checkAllVerSionLatest.

protected void checkAllVerSionLatest(List<ItemVersionObject> tableList, ItemVersionObject object) {
    if (object.getRepositoryNode() != null) {
        List<Relation> relations = builder.getItemsJobRelatedTo(object.getRepositoryNode().getId(), object.getItem().getProperty().getVersion(), RelationshipItemBuilder.JOB_RELATION);
        for (Relation relation : relations) {
            try {
                IRepositoryViewObject obj = FACTORY.getLastVersion(relation.getId());
                if (obj != null) {
                    for (ItemVersionObject obj2 : versionObjects) {
                        if (obj2.getItem() == obj.getProperty().getItem()) {
                            ItemVersionObject relat = obj2;
                            if (!tableList.contains(relat)) {
                                tableList.add(relat);
                                checkAllVerSionLatest(tableList, relat);
                            }
                            break;
                        }
                    }
                }
            } catch (PersistenceException et) {
                ExceptionHandler.process(et);
            }
        }
    }
}
Also used : Relation(org.talend.core.model.relationship.Relation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ItemVersionObject(org.talend.repository.model.ItemVersionObject)

Example 7 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class AutoConversionTypesEditor method applyChange.

private void applyChange() {
    try {
        IProject project = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        IFolder prefsSettingFolder = ResourceUtils.getFolder(project, RepositoryConstants.SETTING_DIRECTORY, false);
        AutoConvertTypesUtils.save(typeModel.getBeansList(), AutoConvertTypesUtils.getTypeFile());
        prefsSettingFolder.refreshLocal(IResource.DEPTH_ONE, null);
    } catch (CoreException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class PaletteSettingPage method getComponentsUsedInProject.

public Set<IComponent> getComponentsUsedInProject(Project project) {
    if (componentsUsed != null) {
        return componentsUsed;
    }
    componentsUsed = new HashSet<IComponent>();
    IProxyRepositoryFactory repositoryFactory = CoreUIPlugin.getDefault().getProxyRepositoryFactory();
    try {
        ERepositoryObjectType jobType = ERepositoryObjectType.PROCESS;
        if (jobType != null) {
            List<IRepositoryViewObject> allProcess = repositoryFactory.getAll(project, jobType, true);
            addUsedComponents(componentsUsed, allProcess, ComponentCategory.CATEGORY_4_DI);
        }
        ERepositoryObjectType jobletType = ERepositoryObjectType.JOBLET;
        if (jobletType != null) {
            List<IRepositoryViewObject> allJoblet = repositoryFactory.getAll(project, jobletType, true);
            addUsedComponents(componentsUsed, allJoblet, ComponentCategory.CATEGORY_4_DI);
        }
        ERepositoryObjectType routeType = ERepositoryObjectType.PROCESS_ROUTE;
        if (routeType != null) {
            List<IRepositoryViewObject> allRoutes = repositoryFactory.getAll(project, routeType, true);
            addUsedComponents(componentsUsed, allRoutes, ComponentCategory.CATEGORY_4_CAMEL);
        }
        //$NON-NLS-1$
        ERepositoryObjectType mrType = ERepositoryObjectType.valueOf("PROCESS_MR");
        if (mrType != null) {
            List<IRepositoryViewObject> allMr = repositoryFactory.getAll(project, mrType, true);
            addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_MAPREDUCE);
            addUsedComponents(componentsUsed, allMr, ComponentCategory.CATEGORY_4_SPARK);
        }
        //$NON-NLS-1$
        ERepositoryObjectType stormType = ERepositoryObjectType.valueOf("PROCESS_STORM");
        if (stormType != null) {
            List<IRepositoryViewObject> allStorm = repositoryFactory.getAll(project, stormType, true);
            addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_STORM);
            addUsedComponents(componentsUsed, allStorm, ComponentCategory.CATEGORY_4_SPARKSTREAMING);
        }
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ITestContainerProviderService.class)) {
            ITestContainerProviderService testContainerService = (ITestContainerProviderService) GlobalServiceRegister.getDefault().getService(ITestContainerProviderService.class);
            if (testContainerService != null) {
                ERepositoryObjectType testCaseType = testContainerService.getTestCaseObjectType();
                if (testCaseType != null) {
                    List<IRepositoryViewObject> allTestCase = repositoryFactory.getAll(project, testCaseType, true);
                    addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_SPARK);
                    addUsedComponents(componentsUsed, allTestCase, ComponentCategory.CATEGORY_4_DI);
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return componentsUsed;
}
Also used : IComponent(org.talend.core.model.components.IComponent) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ITestContainerProviderService(org.talend.core.ui.ITestContainerProviderService)

Example 9 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class CustomComponentSettingPage method finish.

private void finish(IProgressMonitor... monitorWrap) {
    IProgressMonitor monitor = null;
    if (monitorWrap != null && monitorWrap.length == 1) {
        monitor = monitorWrap[0];
    }
    final IProxyRepositoryFactory prf = CorePlugin.getDefault().getProxyRepositoryFactory();
    if (PluginChecker.isSVNProviderPluginLoaded() && (!sharedAdded.isEmpty() || !backAdded.isEmpty())) {
        RepositoryWorkUnit repositoryWorkUnit = new RepositoryWorkUnit("Update custom components") {

            @Override
            public void run() throws PersistenceException {
                final IWorkspaceRunnable op = new IWorkspaceRunnable() {

                    @Override
                    public void run(IProgressMonitor subMonitor) throws CoreException {
                        ISVNProviderService service = (ISVNProviderService) GlobalServiceRegister.getDefault().getService(ISVNProviderService.class);
                        String projectLabel = pro.getTechnicalLabel();
                        IWorkspace workspace = ResourcesPlugin.getWorkspace();
                        IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
                        String targetRoot = eclipseProject.getLocation().toString() + "/" + ERepositoryObjectType.getFolderName(ERepositoryObjectType.COMPONENTS);
                        File componentFolder = new File(targetRoot);
                        URL url = null;
                        try {
                            if (!componentFolder.exists()) {
                                FilesUtils.createFoldersIfNotExists(targetRoot, false);
                            }
                            Bundle b = Platform.getBundle(IComponentsFactory.COMPONENTS_LOCATION);
                            url = FileLocator.toFileURL(FileLocator.find(b, new Path(""), null));
                            String sourceRoot = url.getFile();
                            // delete share
                            for (IComponent component : backAdded.keySet()) {
                                String componentFullPath = targetRoot + File.separator + component.getName();
                                if (service.isSVNProject(pro)) {
                                    service.svnEclipseHandlerDelete(eclipseProject, pro, componentFullPath);
                                    if (subMonitor != null) {
                                        subMonitor.worked(10);
                                    }
                                } else {
                                    File file = new File(componentFullPath);
                                    if (file != null && file.exists()) {
                                        org.talend.utils.io.FilesUtils.deleteFolder(file, true);
                                    }
                                }
                            }
                            if (!backAdded.isEmpty()) {
                                getCustomComponentSettings().removeAll(backAdded.values());
                            }
                            FileFilter ff = new FileFilter() {

                                @Override
                                public boolean accept(File pathname) {
                                    if (FilesUtils.isSVNFolder(pathname)) {
                                        return false;
                                    }
                                    return true;
                                }
                            };
                            // share
                            for (IComponent component : sharedAdded.keySet()) {
                                String sourcePath = sourceRoot + component.getPathSource() + File.separator + component.getName();
                                File sourceFile = new File(sourcePath);
                                String targetPath = targetRoot + File.separatorChar + component.getName();
                                File targetFile = new File(targetPath);
                                FilesUtils.copyFolder(sourceFile, targetFile, true, ff, null, true, false);
                                if (subMonitor != null) {
                                    subMonitor.worked(10);
                                }
                            }
                        } catch (Exception e) {
                            resetCustomComponentSetting();
                            ExceptionHandler.process(e);
                        }
                        try {
                            prf.saveProject(pro);
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                        try {
                            eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, subMonitor);
                        } catch (CoreException e1) {
                            ExceptionHandler.process(e1);
                        }
                    }
                };
                IWorkspace workspace = ResourcesPlugin.getWorkspace();
                try {
                    ISchedulingRule schedulingRule = workspace.getRoot();
                    // the update the project files need to be done in the workspace runnable to avoid all
                    // notification
                    // of changes before the end of the modifications.
                    workspace.run(op, schedulingRule, IWorkspace.AVOID_UPDATE, new NullProgressMonitor());
                } catch (CoreException e) {
                    throw new PersistenceException(e.getCause());
                }
            }
        };
        repositoryWorkUnit.setRefreshRepository(false);
        repositoryWorkUnit.setForceTransaction(true);
        prf.executeRepositoryWorkUnit(repositoryWorkUnit);
        try {
            repositoryWorkUnit.throwPersistenceExceptionIfAny();
        } catch (PersistenceException e) {
            e.printStackTrace();
        }
    }
    if (monitor != null) {
        monitor.done();
    }
    // refresh again after the gui closed .
    try {
        String projectLabel = pro.getTechnicalLabel();
        IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IProject eclipseProject = workspace.getRoot().getProject(projectLabel);
        eclipseProject.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
    } catch (CoreException e1) {
        ExceptionHandler.process(e1);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Bundle(org.osgi.framework.Bundle) IComponent(org.talend.core.model.components.IComponent) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) ISVNProviderService(org.talend.core.services.ISVNProviderService) IProject(org.eclipse.core.resources.IProject) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) FileFilter(java.io.FileFilter) File(java.io.File) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 10 with PersistenceException

use of org.talend.commons.exception.PersistenceException in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method updateItemsVersion.

private void updateItemsVersion() {
    IRunnableWithProgress runnable = new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            //$NON-NLS-1$
            monitor.beginTask("", getModifiedVersionItems().size() * 100);
            Set<ERepositoryObjectType> types = new HashSet<ERepositoryObjectType>();
            for (RepositoryObject object : getModifiedVersionItems()) {
                // IRepositoryViewObject repositoryObject = object.getRepositoryNode().getObject();
                if (object != null && object.getProperty() != null) {
                    if (object.getStatusCode().equals(object.getProperty().getStatusCode())) {
                        final Item item = object.getProperty().getItem();
                        item.getProperty().setOldStatusCode(object.getStatusCode());
                        // types.add(object.getRepositoryNode().getObjectType());
                        try {
                            // }
                            if (object != null) {
                                // obj.setVersion(object.getNewVersion());
                                FACTORY.save(project, object.getProperty());
                            } else {
                            // FACTORY.save(project, item.getProperty());
                            }
                        } catch (PersistenceException e) {
                            ExceptionHandler.process(e);
                        }
                    }
                }
                monitor.worked(100);
            }
            // RepositoryManager.refresh(types);
            monitor.done();
        }
    };
    // final ProgressMonitorJobsDialog dialog = new ProgressMonitorJobsDialog(null);
    final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
    try {
        dialog.run(false, false, runnable);
    } catch (InvocationTargetException e) {
        ExceptionHandler.process(e);
    } catch (InterruptedException e) {
        ExceptionHandler.process(e);
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) HashSet(java.util.HashSet)

Aggregations

PersistenceException (org.talend.commons.exception.PersistenceException)571 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)202 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)151 Property (org.talend.core.model.properties.Property)106 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)106 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)91 Item (org.talend.core.model.properties.Item)90 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)85 ArrayList (java.util.ArrayList)80 IComponentConversion (org.talend.core.model.components.conversions.IComponentConversion)78 IComponentFilter (org.talend.core.model.components.filters.IComponentFilter)78 NameComponentFilter (org.talend.core.model.components.filters.NameComponentFilter)77 Project (org.talend.core.model.general.Project)68 ConnectionItem (org.talend.core.model.properties.ConnectionItem)61 ProcessItem (org.talend.core.model.properties.ProcessItem)60 IPath (org.eclipse.core.runtime.IPath)58 IProject (org.eclipse.core.resources.IProject)54 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)52 CoreException (org.eclipse.core.runtime.CoreException)50 Path (org.eclipse.core.runtime.Path)50