Search in sources :

Example 11 with ServicePort

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

the class ESBService method updateOperation.

@Override
public void updateOperation(INode node, String linkedRepository, RepositoryNode selectNode) {
    String[] ids = linkedRepository.split(" - ");
    if (ids.length == 3) {
        try {
            IRepositoryViewObject reViewObject = ProxyRepositoryFactory.getInstance().getLastVersion(ids[0]);
            ServiceItem servicesItem = (ServiceItem) reViewObject.getProperty().getItem();
            ServiceConnection serConn = (ServiceConnection) servicesItem.getConnection();
            String portName = "";
            EList<ServicePort> portList = serConn.getServicePort();
            ServiceOperation operation = null;
            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])) {
                            operation = ope;
                            break;
                        }
                    }
                    break;
                }
            }
            if (operation == null) {
                return;
            }
            RepositoryNode topParent = getServicesTopNode(selectNode);
            changeOldOperationLabel(topParent, node, operation);
            IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
            IProcess2 process = (IProcess2) RepositoryPlugin.getDefault().getDesignerCoreService().getCurrentProcess();
            Item jobItem = process.getProperty().getItem();
            String jobID = jobItem.getProperty().getId();
            String jobName = jobItem.getProperty().getLabel();
            if (operation.getReferenceJobId() != null && !operation.getReferenceJobId().equals(jobID)) {
                changeOtherJobSchemaValue(factory, operation, /* serConn, */
                selectNode);
                MessageDialog.openWarning(new Shell(), Messages.ESBService_DisconnectWarningTitle, Messages.ESBService_DisconnectWarningMsg);
            }
            operation.setReferenceJobId(jobID);
            operation.setLabel(operation.getName() + '-' + jobName);
            IFile wsdlPath = WSDLUtils.getWsdlFile(selectNode);
            Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, operation.getName(), portName);
            CreateNewJobAction.setProviderRequestComponentConfiguration(node, serviceParameters);
            factory.save(servicesItem);
        } catch (PersistenceException e) {
            ExceptionHandler.process(e);
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) 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) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) 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) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 12 with ServicePort

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

the class ESBService method changeOldOperationLabel.

// public AbstractMetadataObject getServicesOperation(Connection connection, String operationName) {
// List<ServiceOperation> list = new ArrayList<ServiceOperation>();
// if (connection instanceof ServiceConnection) {
// ServiceConnection serConnection = (ServiceConnection) connection;
// EList<ServicePort> serPort = serConnection.getServicePort();
// for (ServicePort port : serPort) {
// list.addAll(port.getServiceOperation());
// }
// }
// for (ServiceOperation ope : list) {
// if (ope.getLabel().equals(operationName)) {
// return ope;
// }
// }
// return null;
// }
// public void changeOperationLabel(RepositoryNode newNode, INode node, Connection connection) {
// if (!(connection instanceof ServiceConnection)) {
// return;
// }
// ServiceConnection serConn = (ServiceConnection) connection;
// changeOldOperationLabel(serConn, node);
// changenewOperationLabel(newNode, node, serConn);
// }
private void changeOldOperationLabel(RepositoryNode topParent, INode node, ServiceOperation newOperation) {
    // here should be all the ports, not just ports of one connection
    List<IRepositoryNode> nodeList = topParent.getChildren();
    IElementParameter elePara = node.getElementParameter("PROPERTY:" + EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    if (elePara == null) {
        return;
    }
    ServiceConnection serConn = null;
    ServiceItem servicesItem = null;
    String paraValue = (String) elePara.getValue();
    if (paraValue == null || "".equals(paraValue)) {
        return;
    }
    String connID = null;
    if (paraValue.contains(" - ")) {
        connID = paraValue.split(" - ")[0];
    } else {
        connID = paraValue;
    }
    for (IRepositoryNode repNode : nodeList) {
        String id = repNode.getObject().getProperty().getId();
        if (id.equals(connID)) {
            servicesItem = (ServiceItem) repNode.getObject().getProperty().getItem();
            serConn = (ServiceConnection) servicesItem.getConnection();
            break;
        }
    }
    if (serConn == null) {
        return;
    }
    EList<ServicePort> portList = serConn.getServicePort();
    IElementParameter portPara = node.getElementParameter(WSDLUtils.PORT_NAME);
    IElementParameter opePara = node.getElementParameter(WSDLUtils.OPERATION_NAME);
    if (portPara != null && opePara != null) {
        String portValue = (String) portPara.getValue();
        String opeValue = (String) opePara.getValue();
        if (portValue != null && !"".equals(portValue) && opeValue != null && !"".equals(opeValue)) {
            out: for (ServicePort port : portList) {
                if (port.getName().equals(portValue)) {
                    for (ServiceOperation ope : port.getServiceOperation()) {
                        if (ope.getName().equals(opeValue) && newOperation != null && !ope.getId().equals(newOperation.getId())) {
                            ope.setLabel(opeValue);
                            ope.setReferenceJobId(null);
                            if (servicesItem != null) {
                                IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                                try {
                                    factory.save(servicesItem);
                                } catch (PersistenceException e) {
                                    ExceptionHandler.process(e);
                                }
                            }
                            break out;
                        }
                    }
                }
            }
        }
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) PersistenceException(org.talend.commons.exception.PersistenceException) IElementParameter(org.talend.core.model.process.IElementParameter) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 13 with ServicePort

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

the class ESBService method getAllTheJObNames.

@Override
public StringBuffer getAllTheJObNames(IRepositoryNode jobObject) {
    StringBuffer jobNames = null;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    List<IRepositoryNode> jobList = new ArrayList<IRepositoryNode>();
    if (jobObject.getObjectType() == ERepositoryObjectType.PROCESS) {
        jobList.add(jobObject);
    } else if (jobObject.getObjectType() == ERepositoryObjectType.FOLDER) {
        jobList = getJobObject(jobObject);
    }
    try {
        List<IRepositoryViewObject> repList = factory.getAll(getServicesType());
        for (IRepositoryNode node : jobList) {
            ERepositoryObjectType repositoryObjectType = node.getObjectType();
            if (repositoryObjectType != ERepositoryObjectType.PROCESS) {
                continue;
            }
            String jobID = node.getObject().getProperty().getId();
            for (IRepositoryViewObject obj : repList) {
                ServiceItem item = (ServiceItem) obj.getProperty().getItem();
                ServiceConnection conn = (ServiceConnection) item.getConnection();
                middle: for (ServicePort port : conn.getServicePort()) {
                    for (ServiceOperation operation : port.getServiceOperation()) {
                        if (operation.getReferenceJobId() != null && operation.getReferenceJobId().endsWith(jobID)) {
                            if (jobNames == null) {
                                jobNames = new StringBuffer(node.getObject().getProperty().getLabel());
                            } else {
                                jobNames.append(",");
                                jobNames.append(node.getObject().getProperty().getLabel());
                            }
                            break middle;
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    return jobNames;
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ArrayList(java.util.ArrayList) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 14 with ServicePort

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

the class AssignJobAction method assign.

public boolean assign(IRepositoryNode jobNode) {
    if (jobNode == null) {
        return false;
    }
    IRepositoryViewObject repositoryObject = jobNode.getObject();
    final Item item = repositoryObject.getProperty().getItem();
    // judge the job whether had T_ESB_PROVIDER_REQUEST
    ProcessItem processItem = (ProcessItem) item;
    NodeType providerNode = null;
    for (Object obj : processItem.getProcess().getNode()) {
        NodeType node = (NodeType) obj;
        if (CreateNewJobAction.T_ESB_PROVIDER_REQUEST.equals(node.getComponentName())) {
            providerNode = node;
            break;
        }
    }
    if (null == providerNode) {
        MessageDialog.openWarning(Display.getCurrent().getActiveShell(), Messages.AssignJobAction_WarningTitle, Messages.AssignJobAction_WarningMessage);
        return false;
    }
    try {
        String jobID = item.getProperty().getId();
        String jobName = item.getProperty().getLabel();
        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();
        for (ServicePort port : listPort) {
            if (port.getName().equals(portName)) {
                List<ServiceOperation> listOperation = port.getServiceOperation();
                for (ServiceOperation operation : listOperation) {
                    if (operation.getLabel().equals(operationName)) {
                        // should not change the job name
                        // String jobNewName = port.getName() + "_" + operation.getName();
                        // if (resetJobname(item, jobNewName)) {
                        // jobName = jobNewName;
                        // }
                        operation.setReferenceJobId(jobID);
                        operation.setLabel(operation.getName() + "-" + jobName);
                        break;
                    }
                }
                break;
            }
        }
        IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
        Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) repositoryNode.getObject()).getName(), portName);
        for (Object paramObj : providerNode.getElementParameter()) {
            ElementParameterType param = (ElementParameterType) paramObj;
            String name = param.getName();
            if (serviceParameters.containsKey(name)) {
                param.setValue(serviceParameters.get(name));
            }
        }
        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) {
            IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
            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")) {
                    repositoryChange(repositoryNode, node);
                }
            }
            processItem.setProcess(process.saveXmlFile());
        }
        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
        factory.save(processItem);
        factory.save(serviceItem);
        return true;
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return false;
}
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) IFile(org.eclipse.core.resources.IFile) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) 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) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) IOException(java.io.IOException) PersistenceException(org.talend.commons.exception.PersistenceException) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessItem(org.talend.core.model.properties.ProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IProcess2(org.talend.core.model.process.IProcess2) PortRepositoryObject(org.talend.repository.services.utils.PortRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) OperationRepositoryObject(org.talend.repository.services.utils.OperationRepositoryObject) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 15 with ServicePort

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

the class CreateNewJobAction method init.

@Override
protected void init(RepositoryNode node) {
    ERepositoryObjectType nodeType = (ERepositoryObjectType) node.getProperties(EProperties.CONTENT_TYPE);
    if (!ERepositoryObjectType.SERVICESOPERATION.equals(nodeType)) {
        return;
    }
    boolean flag = true;
    ServiceItem serviceItem = (ServiceItem) node.getParent().getParent().getObject().getProperty().getItem();
    for (ServicePort port : ((ServiceConnection) serviceItem.getConnection()).getServicePort()) {
        for (ServiceOperation operation : port.getServiceOperation()) {
            if (operation.getLabel().equals(node.getLabel()) && operation.getReferenceJobId() != null && !operation.getReferenceJobId().equals("")) {
                flag = false;
            }
        }
    }
    setEnabled(flag);
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

Aggregations

ServicePort (org.talend.repository.services.model.services.ServicePort)28 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)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)14 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 ProcessItem (org.talend.core.model.properties.ProcessItem)5 HashMap (java.util.HashMap)4 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 Definition (javax.wsdl.Definition)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