Search in sources :

Example 21 with ServiceOperation

use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.

the class ESBRepositoryContentHandler method addNode.

//    public RepositoryNode createRepositoryNode(RepositoryNode node) {
//        RepositoryNode serviceNode = new RepositoryNode(null, node, ENodeType.SYSTEM_FOLDER);
//        serviceNode.setProperties(EProperties.LABEL, ESBRepositoryNodeType.SERVICES);
//        serviceNode.setProperties(EProperties.CONTENT_TYPE, ESBRepositoryNodeType.SERVICES);
//        return serviceNode;
//    }
@Override
public void addNode(ERepositoryObjectType type, RepositoryNode recBinNode, IRepositoryViewObject repositoryObject, RepositoryNode node) {
    if (type == ESBRepositoryNodeType.SERVICES) {
        ServiceConnection serviceConnection = (ServiceConnection) ((ServiceItem) repositoryObject.getProperty().getItem()).getConnection();
        List<ServicePort> listPort = serviceConnection.getServicePort();
        for (ServicePort port : listPort) {
            PortRepositoryObject portRepositoryObject = new PortRepositoryObject(repositoryObject, port);
            RepositoryNode portNode = new RepositoryNode(portRepositoryObject, node, ENodeType.REPOSITORY_ELEMENT);
            portNode.setProperties(EProperties.LABEL, port.getName());
            portNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SERVICESPORT);
            node.getChildren().add(portNode);
            //
            List<ServiceOperation> listOperation = port.getServiceOperation();
            for (ServiceOperation operation : listOperation) {
                OperationRepositoryObject operationRepositoryObject = new OperationRepositoryObject(repositoryObject, operation);
                RepositoryNode operationNode = new RepositoryNode(operationRepositoryObject, portNode, ENodeType.REPOSITORY_ELEMENT);
                operationNode.setProperties(EProperties.LABEL, operation.getLabel());
                operationNode.setProperties(EProperties.CONTENT_TYPE, ERepositoryObjectType.SERVICESOPERATION);
                if (!operation.isInBinding()) {
                    operationRepositoryObject.setInformationStatus(ERepositoryStatus.ERROR);
                    operationRepositoryObject.setDescription(Messages.LocalWSDLEditor_refreshBindingMessage);
                } else {
                    operationRepositoryObject.setInformationStatus(null);
                    operationRepositoryObject.setDescription(null);
                }
                portNode.getChildren().add(operationNode);
            }
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode)

Example 22 with ServiceOperation

use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.

the class WSDLUtils method isValidService.

public static boolean isValidService(ServiceItem serviceItem) {
    boolean isValid = false;
    List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    for (ServicePort port : listPort) {
        List<ServiceOperation> listOperation = port.getServiceOperation();
        for (ServiceOperation operation : listOperation) {
            if (operation.getReferenceJobId() != null) {
                isValid = true;
                break;
            }
        }
    }
    return isValid;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Example 23 with ServiceOperation

use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.

the class ESBService method getValue.

@Override
public Object getValue(Item connItem, String value, INode node) {
    if (connItem instanceof ServiceItem) {
        ServiceItem serviceItem = ((ServiceItem) connItem);
        if (WSDLUtils.ENDPOINT_URI.equals(value) || WSDLUtils.OPERATION_NAME.equals(value) || WSDLUtils.OPERATION_NS.equals(value) || WSDLUtils.PORT_NAME.equals(value) || WSDLUtils.PORT_NS.equals(value) || WSDLUtils.SERVICE_NAME.equals(value) || WSDLUtils.SERVICE_NS.equals(value) || WSDLUtils.WSDL_LOCATION.equals(value)) {
            String wsdlPortTypeName = null;
            String wsdlOperationName = null;
            // find operation that job is bind to
            String processId = node.getProcess().getId();
            ServiceConnection connection = (ServiceConnection) serviceItem.getConnection();
            for (ServicePort port : connection.getServicePort()) {
                for (ServiceOperation operation : port.getServiceOperation()) {
                    if (processId.equals(operation.getReferenceJobId())) {
                        wsdlOperationName = operation.getName();
                        wsdlPortTypeName = port.getName();
                        break;
                    }
                }
                if (null != wsdlOperationName) {
                    break;
                }
            }
            if (null == wsdlOperationName) {
                // job is not bind to any data service operation -> no need any updates
                return null;
            }
            if (WSDLUtils.OPERATION_NAME.equals(value)) {
                return wsdlOperationName;
            }
            IFile wsdl = WSDLUtils.getWsdlFile(serviceItem);
            if (WSDLUtils.WSDL_LOCATION.equals(value)) {
                return wsdl.getLocation().toPortableString();
            }
            try {
                return WSDLUtils.getServiceOperationParameters(wsdl, wsdlOperationName, wsdlPortTypeName).get(value);
            } catch (CoreException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    return null;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Example 24 with ServiceOperation

use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.

the class AssignJobAction method changeOldJob.

public void changeOldJob() {
    String operationName = repositoryNode.getObject().getLabel();
    String portName = repositoryNode.getParent().getObject().getLabel();
    ServiceItem serviceItem = (ServiceItem) repositoryNode.getParent().getParent().getObject().getProperty().getItem();
    List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    String oldJobID = null;
    for (ServicePort port : listPort) {
        if (port.getName().equals(portName)) {
            List<ServiceOperation> listOperation = port.getServiceOperation();
            for (ServiceOperation operation : listOperation) {
                if (operation.getLabel().equals(operationName)) {
                    oldJobID = operation.getReferenceJobId();
                    break;
                }
            }
            break;
        }
    }
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        if (oldJobID != null) {
            IRepositoryViewObject object = factory.getLastVersion(oldJobID);
            Item item = object.getProperty().getItem();
            ProcessItem processItem = (ProcessItem) item;
            //
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            IProcess2 process = null;
            IEditorReference[] reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
            List<IProcess2> processes = RepositoryPlugin.getDefault().getDesignerCoreService().getOpenedProcess(reference);
            for (IProcess2 processOpen : processes) {
                if (processOpen.getProperty().getItem() == processItem) {
                    process = processOpen;
                    break;
                }
            }
            if (process == null) {
                IProcess proc = service.getProcessFromProcessItem(processItem);
                if (proc instanceof IProcess2) {
                    process = (IProcess2) proc;
                }
            }
            if (process != null) {
                List<? extends INode> nodelist = process.getGraphicalNodes();
                for (INode node : nodelist) {
                    if (node.getComponent().getName().equals("tESBProviderRequest")) {
                        repositoryChangeToBuildIn(repositoryNode, node);
                    }
                }
                processItem.setProcess(process.saveXmlFile());
                factory.save(processItem);
            }
        }
    } catch (PersistenceException | IOException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) INode(org.talend.core.model.process.INode) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IOException(java.io.IOException) Item(org.talend.core.model.properties.Item) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ProcessItem(org.talend.core.model.properties.ProcessItem) IEditorReference(org.eclipse.ui.IEditorReference) ProcessItem(org.talend.core.model.properties.ProcessItem) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 25 with ServiceOperation

use of org.talend.repository.services.model.services.ServiceOperation in project tesb-studio-se by Talend.

the class ESBService method getServiceLabel.

@Override
public String getServiceLabel(Item item, String linkedRepository) {
    String serviceName = item.getProperty().getLabel();
    if (item instanceof ServiceItem) {
        String[] ids = linkedRepository.split(" - ");
        ServiceConnection serConn = (ServiceConnection) ((ServiceItem) item).getConnection();
        if (ids.length == 3) {
            String portName = "";
            String operationName = "";
            EList<ServicePort> portList = serConn.getServicePort();
            out: for (ServicePort port : portList) {
                if (port.getId().equals(ids[1])) {
                    portName = port.getName();
                    EList<ServiceOperation> opeList = port.getServiceOperation();
                    for (ServiceOperation ope : opeList) {
                        if (ope.getId().equals(ids[2])) {
                            operationName = ope.getName();
                            return serviceName + " - " + portName + " - " + operationName;
                        }
                    }
                }
            }
        }
    }
    return serviceName;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) EList(org.eclipse.emf.common.util.EList) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation)

Aggregations

ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)26 ServicePort (org.talend.repository.services.model.services.ServicePort)26 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)25 ServiceItem (org.talend.repository.services.model.services.ServiceItem)17 PersistenceException (org.talend.commons.exception.PersistenceException)15 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)12 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ProcessItem (org.talend.core.model.properties.ProcessItem)5 IFile (org.eclipse.core.resources.IFile)4 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 Item (org.talend.core.model.properties.Item)4 RepositoryNode (org.talend.repository.model.RepositoryNode)4 ArrayList (java.util.ArrayList)3 CoreException (org.eclipse.core.runtime.CoreException)3 INode (org.talend.core.model.process.INode)3 IProcess2 (org.talend.core.model.process.IProcess2)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Operation (javax.wsdl.Operation)2