Search in sources :

Example 16 with PersistenceException

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

the class MainComposite method getStatusMap.

protected Map<String, String> getStatusMap() {
    statusHelper = new StatusHelper(CoreRuntimePlugin.getInstance().getProxyRepositoryFactory());
    Map<String, String> statusMap = new HashMap();
    try {
        if (statusHelper != null) {
            List<org.talend.core.model.properties.Status> statusList = statusHelper.getStatusList(repositoryObject.getProperty());
            if (statusList != null) {
                for (org.talend.core.model.properties.Status s : statusList) {
                    statusMap.put(s.getCode(), s.getLabel());
                }
            }
        }
    } catch (PersistenceException e) {
        CommonExceptionHandler.process(e);
    }
    return statusMap;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.talend.core.repository.utils.ConvertJobsUtil.Status) StatusHelper(org.talend.repository.ui.properties.StatusHelper) HashMap(java.util.HashMap) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 17 with PersistenceException

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

the class FTPWizard method performFinish.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.wizard.IWizard#performFinish()
     */
@Override
public boolean performFinish() {
    final IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        if (creation) {
            String nextId = factory.getNextId();
            connectionProperty.setId(nextId);
            factory.create(connectionItem, propertiesWizardPage.getDestinationPath());
        } else {
            RepositoryUpdateManager.updateFileConnection(connectionItem);
            boolean isModified = propertiesWizardPage.isNameModifiedByUser();
            if (isModified) {
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                    IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                    if (service != null) {
                        service.refreshComponentView(connectionItem);
                    }
                }
            }
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            IWorkspaceRunnable operation = new IWorkspaceRunnable() {

                public void run(IProgressMonitor monitor) throws CoreException {
                    try {
                        factory.save(connectionItem);
                        closeLockStrategy();
                    } catch (PersistenceException e) {
                        throw new CoreException(new Status(IStatus.ERROR, "", "", e));
                    }
                }
            };
            workspace.run(operation, null);
        }
    } catch (Exception e) {
        String detailError = e.toString();
        new //$NON-NLS-1$
        ErrorDialogWidthDetailArea(//$NON-NLS-1$
        getShell(), //$NON-NLS-1$
        PID, //$NON-NLS-1$
        "", detailError);
        return false;
    }
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) IWorkspace(org.eclipse.core.resources.IWorkspace) PersistenceException(org.talend.commons.exception.PersistenceException) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 18 with PersistenceException

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

the class GenericConnPropertiesWizard method performFinish.

@Override
public boolean performFinish() {
    boolean done = super.performFinish();
    if (done) {
        Property property = object.getProperty();
        GenericConnectionItem gcItem = (GenericConnectionItem) property.getItem();
        boolean itemChanged = GenericConnectionUtil.synNamePropertyWithItem(gcItem);
        if (itemChanged) {
            try {
                ProxyRepositoryFactory.getInstance().save(gcItem);
            } catch (PersistenceException e) {
                done = false;
                ExceptionHandler.process(e);
            }
        }
    }
    return done;
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) Property(org.talend.core.model.properties.Property)

Example 19 with PersistenceException

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

the class AddContextCommentValueMigrationTask method execute.

@SuppressWarnings("unchecked")
@Override
public ExecutionResult execute(Item item) {
    EList<ContextType> contexts = null;
    if (item instanceof ProcessItem) {
        // process, process_mr, process_storm, route, routelet.
        ProcessItem processItem = (ProcessItem) item;
        contexts = processItem.getProcess().getContext();
    } else if (item instanceof JobletProcessItem) {
        JobletProcessItem jobletItem = (JobletProcessItem) item;
        contexts = jobletItem.getJobletProcess().getContext();
    } else if (item instanceof ContextItem) {
        ContextItem contextItem = (ContextItem) item;
        contexts = contextItem.getContext();
    }
    // 2 kinds of situation should be excluded before doing migration to the old context:
    // 1.has null, 2.all same comment values;
    // 1 is from 6.1.0 release and 5.6.2 patched TPS-1109, all null comment value will set to "".
    // for repository context in job, won't change anything because the repository context has been fixed
    // the update action will execute when opening job.
    boolean hasNull = false, isSame = true;
    if (contexts != null && contexts.size() > 1) {
        List<String> firstComments = new ArrayList<String>();
        for (int x = 0; x < contexts.size(); x++) {
            List<ContextParameterType> contextParams = contexts.get(x).getContextParameter();
            for (int y = 0; y < contextParams.size(); y++) {
                ContextParameterType param = contextParams.get(y);
                boolean isBuiltin = param.getRepositoryContextId() == null;
                String comment = param.getComment();
                if (comment == null) {
                    if (isBuiltin) {
                        //$NON-NLS-1$
                        param.setComment("");
                        hasNull = true;
                    }
                    continue;
                }
                // comments to show in old item before 5.6.1 are always in the first group.
                if (x == 0) {
                    if (!isBuiltin) {
                        //$NON-NLS-1$
                        firstComments.add("NOT_BUILTIN");
                    } else {
                        firstComments.add(comment);
                    }
                    continue;
                }
                if (isBuiltin && !comment.equals(firstComments.get(y))) {
                    isSame = false;
                }
            }
        }
        try {
            if (hasNull) {
                ProxyRepositoryFactory.getInstance().save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            }
            if (!isSame) {
                for (int x = 1; x < contexts.size(); x++) {
                    List<ContextParameterType> contextParams = contexts.get(x).getContextParameter();
                    for (int y = 0; y < contextParams.size(); y++) {
                        ContextParameterType param = contextParams.get(y);
                        String comment = param.getComment();
                        if (param.getRepositoryContextId() == null && !firstComments.get(y).equals(comment)) {
                            if (!firstComments.get(y).equals("NOT_BUILTIN")) {
                                //$NON-NLS-1$
                                param.setComment(firstComments.get(y));
                            }
                        }
                    }
                }
                ProxyRepositoryFactory.getInstance().save(item, true);
                return ExecutionResult.SUCCESS_NO_ALERT;
            }
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
            return ExecutionResult.FAILURE;
        }
    }
    return ExecutionResult.NOTHING_TO_DO;
}
Also used : ContextType(org.talend.designer.core.model.utils.emf.talendfile.ContextType) ContextItem(org.talend.core.model.properties.ContextItem) ArrayList(java.util.ArrayList) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) PersistenceException(org.talend.commons.exception.PersistenceException) ContextParameterType(org.talend.designer.core.model.utils.emf.talendfile.ContextParameterType)

Example 20 with PersistenceException

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

the class AddCopyBookXc2jFileMigrationTask method getReferenceXc2jFile.

public static IFile getReferenceXc2jFile(ConnectionItem connectionItem) {
    IFile x2cjFile = null;
    try {
        IProject currentProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
        String label = connectionItem.getProperty().getLabel();
        String version = connectionItem.getProperty().getVersion();
        String xc2jFileName = label + "_" + version + ".xc2j";
        String folderPath = "";
        String folder = "";
        if (connectionItem.getState() != null) {
            folderPath = connectionItem.getState().getPath();
        }
        if (!folderPath.equals("")) {
            folder = "/" + folderPath;
        }
        x2cjFile = currentProject.getFolder("metadata/fileEBCDIC" + folder).getFile(xc2jFileName);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return x2cjFile;
}
Also used : IFile(org.eclipse.core.resources.IFile) PersistenceException(org.talend.commons.exception.PersistenceException) IProject(org.eclipse.core.resources.IProject)

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