Search in sources :

Example 31 with PersistenceException

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

the class ImportProjectsUtilities method afterImportAs.

/**
     * DOC smallet Comment method "afterImportAs".
     * 
     * @param newName
     * @param technicalName
     * @throws InvocationTargetException
     */
private static Project afterImportAs(String newName, String technicalName) throws InvocationTargetException {
    // Rename in ".project" and "talendProject" or "talend.project"
    // TODO SML Optimize
    final IWorkspace workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace();
    IContainer containers = (IProject) workspace.getRoot().findMember(new Path(technicalName));
    IResource file2 = containers.findMember(IProjectDescription.DESCRIPTION_FILE_NAME);
    try {
        //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        replaceInFile("<name>.*</name>", file2.getLocation().toOSString(), "<name>" + technicalName + "</name>");
        // TDI-19269
        final IProject project = workspace.getRoot().getProject(technicalName);
        XmiResourceManager xmiManager = new XmiResourceManager();
        try {
            final Project loadProject = xmiManager.loadProject(project);
            loadProject.setTechnicalLabel(technicalName);
            loadProject.setLabel(newName);
            loadProject.setLocal(true);
            loadProject.setId(0);
            loadProject.setUrl(null);
            loadProject.setCreationDate(null);
            loadProject.setDescription("");
            loadProject.setType(null);
            // ADD xqliu 2012-03-12 TDQ-4771 clear the list of Folders
            if (loadProject.getFolders() != null) {
                loadProject.getFolders().clear();
            }
            // ~ TDQ-4771
            xmiManager.saveResource(loadProject.eResource());
            return loadProject;
        } catch (PersistenceException e) {
        //
        }
    } catch (IOException e) {
        throw new InvocationTargetException(e);
    }
    return null;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) Project(org.talend.core.model.properties.Project) IProject(org.eclipse.core.resources.IProject) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) XmiResourceManager(org.talend.core.repository.utils.XmiResourceManager) IOException(java.io.IOException) IContainer(org.eclipse.core.resources.IContainer) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 32 with PersistenceException

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

the class ExportProjectsAsAction method getRoutineFromProject.

/**
     * DOC bqian Comment method "getRouineFromProject".
     * 
     * @param project
     */
private RootContainer<String, IRepositoryViewObject> getRoutineFromProject(Project project) {
    ProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    RootContainer<String, IRepositoryViewObject> routines = null;
    try {
        routines = factory.getRoutineFromProject(project);
    } catch (PersistenceException e) {
        // TODO Auto-generated catch block
        // e.printStackTrace();
        ExceptionHandler.process(e);
    }
    return routines;
}
Also used : IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 33 with PersistenceException

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

the class ReadRoutineAction method doRun.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.action.Action#run()
     */
protected void doRun() {
    if (repositoryNode == null && getSelection() != null) {
        repositoryNode = (RepositoryNode) ((IStructuredSelection) getSelection()).getFirstElement();
    }
    RoutineItem routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    Property updatedProperty = null;
    try {
        updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(routineItem)), routineItem.getProperty().getId()).getProperty();
    // repositoryNode.getObject().setProperty(updatedProperty);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    routineItem = (RoutineItem) repositoryNode.getObject().getProperty().getItem();
    try {
        openRoutineEditor(routineItem, true);
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : Project(org.talend.core.model.general.Project) SystemException(org.talend.commons.exception.SystemException) PersistenceException(org.talend.commons.exception.PersistenceException) RoutineItem(org.talend.core.model.properties.RoutineItem) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) Property(org.talend.core.model.properties.Property)

Example 34 with PersistenceException

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

the class TOSLoginComposite method readProject.

public Project[] readProject() {
    ProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    Project[] projects = null;
    try {
        projects = repositoryFactory.readProject();
    } catch (PersistenceException e1) {
        e1.printStackTrace();
    } catch (BusinessException e1) {
        e1.printStackTrace();
    }
    return projects;
}
Also used : Project(org.talend.core.model.general.Project) IProject(org.eclipse.core.resources.IProject) BusinessException(org.talend.commons.exception.BusinessException) ProxyRepositoryFactory(org.talend.core.repository.model.ProxyRepositoryFactory) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 35 with PersistenceException

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

the class NameSection method beforeSave.

@Override
protected void beforeSave() {
    IStatus status = evaluateTextField();
    if (status.getSeverity() != IStatus.ERROR) {
        String text = nameText.getText();
        if (!text.equals(getObject().getLabel())) {
            if (getType() == ERepositoryObjectType.FOLDER) {
                IPath path = RepositoryNodeUtilities.getPath(getNode());
                try {
                    ERepositoryObjectType type = getNode().getContentType();
                    getRepositoryFactory().renameFolder(type, path, text);
                // TDI-21143 : Studio repository view : remove all refresh call to repo view
                // IRepositoryView view = RepositoryManagerHelper.findRepositoryView();
                // if (view != null) {
                // view.refresh();
                // }
                } catch (PersistenceException e) {
                    // e.printStackTrace();
                    ExceptionHandler.process(e);
                    return;
                }
            }
        // getObject().setLabel(text);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) PersistenceException(org.talend.commons.exception.PersistenceException) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

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