Search in sources :

Example 1 with AssignJobAction

use of org.talend.repository.services.action.AssignJobAction in project tesb-studio-se by Talend.

the class LocalWSDLEditor method save.

private void save() {
    try {
        saveModel();
        // update
        RepositoryUpdateManager.updateServices(serviceItem);
        ProxyRepositoryFactory.getInstance().save(serviceItem);
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IESBService.class)) {
            IESBService service = (IESBService) GlobalServiceRegister.getDefault().getService(IESBService.class);
            if (service != null) {
                service.refreshComponentView(serviceItem);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    // ////////// TODO: remove this ugly patch! do correct changeset
    EList<ServicePort> servicePorts = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    for (ServicePort servicePort : servicePorts) {
        List<IRepositoryNode> portNodes = repositoryNode.getChildren();
        IRepositoryNode portNode = null;
        for (IRepositoryNode node : portNodes) {
            if (node.getObject().getLabel().equals(servicePort.getName())) {
                portNode = node;
            }
        }
        if (portNode == null) {
            // for now, if the port has been renamed, we just lose all links (avoid an NPE for nothing)
            continue;
        }
        EList<ServiceOperation> operations = servicePort.getServiceOperation();
        for (ServiceOperation operation : operations) {
            String referenceJobId = operation.getReferenceJobId();
            if (referenceJobId != null) {
                for (IRepositoryNode operationNode : portNode.getChildren()) {
                    if (operationNode.getObject().getLabel().startsWith(operation.getName() + '-')) {
                        IRepositoryNode jobNode = org.talend.core.repository.seeker.RepositorySeekerManager.getInstance().searchRepoViewNode(referenceJobId, false);
                        AssignJobAction action = new AssignJobAction((RepositoryNode) operationNode);
                        action.assign(jobNode);
                        break;
                    }
                }
            }
        }
    }
}
Also used : AssignJobAction(org.talend.repository.services.action.AssignJobAction) ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) IESBService(org.talend.core.IESBService) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)1 PartInitException (org.eclipse.ui.PartInitException)1 LoginException (org.talend.commons.exception.LoginException)1 PersistenceException (org.talend.commons.exception.PersistenceException)1 IESBService (org.talend.core.IESBService)1 IRepositoryNode (org.talend.repository.model.IRepositoryNode)1 AssignJobAction (org.talend.repository.services.action.AssignJobAction)1 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)1 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)1 ServicePort (org.talend.repository.services.model.services.ServicePort)1