Search in sources :

Example 46 with BusinessException

use of org.talend.commons.exception.BusinessException in project tesb-studio-se by Talend.

the class ESBService method copyDataServiceRelateJob.

@Override
public void copyDataServiceRelateJob(Item newItem) {
    if (newItem instanceof ServiceItem) {
        ServiceItem serviceItem = (ServiceItem) newItem;
        ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
        List<ServicePort> ports = serviceConnection.getServicePort();
        for (ServicePort port : ports) {
            List<ServiceOperation> operations = port.getServiceOperation();
            for (ServiceOperation operation : operations) {
                String referenceJobId = operation.getReferenceJobId();
                if (referenceJobId != null && !referenceJobId.equals("")) {
                    IRepositoryViewObject jobObj = null;
                    try {
                        jobObj = ProxyRepositoryFactory.getInstance().getLastVersion(referenceJobId);
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                    if (jobObj == null) {
                        continue;
                    }
                    ProcessItem processItem = (ProcessItem) jobObj.getProperty().getItem();
                    String initNameValue = "Copy_of_" + processItem.getProperty().getLabel();
                    final IPath path = RepositoryNodeUtilities.getPath(processItem.getProperty().getId());
                    String jobNameValue = null;
                    try {
                        jobNameValue = getDuplicateName(RepositoryNodeUtilities.getRepositoryNode(jobObj), initNameValue);
                    } catch (BusinessException e) {
                        // $NON-NLS-1$
                        jobNameValue = "";
                    }
                    Item newProcessItem = copyJobForService(processItem, path, jobNameValue);
                    String operationLabel = operation.getLabel();
                    if (operationLabel.contains("-")) {
                        String[] array = operationLabel.split("-");
                        operation.setLabel(array[0] + "-" + jobNameValue);
                    }
                    // update nodes in newProcessItem
                    updateNodesInNewProcessItem(newProcessItem, serviceItem, port, operation);
                    operation.setReferenceJobId(newProcessItem.getProperty().getId());
                    try {
                        ProxyRepositoryFactory.getInstance().save(serviceItem);
                    } catch (PersistenceException e) {
                        ExceptionHandler.process(e);
                    }
                }
            }
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IPath(org.eclipse.core.runtime.IPath) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) RouteletProcessItem(org.talend.camel.core.model.camelProperties.RouteletProcessItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessException(org.talend.commons.exception.BusinessException) CamelProcessItem(org.talend.camel.core.model.camelProperties.CamelProcessItem) RouteletProcessItem(org.talend.camel.core.model.camelProperties.RouteletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Aggregations

BusinessException (org.talend.commons.exception.BusinessException)46 PersistenceException (org.talend.commons.exception.PersistenceException)21 IPath (org.eclipse.core.runtime.IPath)9 Path (org.eclipse.core.runtime.Path)9 Project (org.talend.core.model.general.Project)9 Item (org.talend.core.model.properties.Item)9 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 ArrayList (java.util.ArrayList)8 ProxyRepositoryFactory (org.talend.core.repository.model.ProxyRepositoryFactory)8 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)7 IFile (org.eclipse.core.resources.IFile)6 IProject (org.eclipse.core.resources.IProject)6 MDMServerObjectItem (org.talend.mdm.repository.model.mdmproperties.MDMServerObjectItem)5 File (java.io.File)4 HashMap (java.util.HashMap)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 ReturnCode (org.talend.utils.sugars.ReturnCode)4 IOException (java.io.IOException)3 IWorkspace (org.eclipse.core.resources.IWorkspace)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3