Search in sources :

Example 16 with ServiceItem

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

the class ServiceMetadataAction method doRun.

@Override
protected void doRun() {
    final IRepositoryNode node = getNode();
    final ServiceItem serviceItem = (ServiceItem) node.getObject().getProperty().getItem();
    final boolean isLocked = isLocked(node.getObject());
    new ServiceMetadataDialog(getWorkbenchWindow(), serviceItem, (ServiceConnection) serviceItem.getConnection()).open();
    if (!isLocked) {
        // restore lock state.
        try {
            ProxyRepositoryFactory.getInstance().unlock(node.getObject());
        } catch (PersistenceException | LoginException e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryNode(org.talend.repository.model.IRepositoryNode) ServiceMetadataDialog(org.talend.repository.services.ui.ServiceMetadataDialog) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 17 with ServiceItem

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

the class OpenJobAction method getReferenceJobId.

protected static String getReferenceJobId(IRepositoryNode node) {
    String parentPortName = node.getParent().getObject().getLabel();
    ServiceItem serviceItem = (ServiceItem) node.getParent().getParent().getObject().getProperty().getItem();
    List<ServicePort> listPort = ((ServiceConnection) serviceItem.getConnection()).getServicePort();
    for (ServicePort port : listPort) {
        if (port.getName().equals(parentPortName)) {
            List<ServiceOperation> listOperation = port.getServiceOperation();
            for (ServiceOperation operation : listOperation) {
                if (operation.getLabel().equals(node.getObject().getLabel())) {
                    return operation.getReferenceJobId();
                }
            }
            break;
        }
    }
    return null;
}
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)

Example 18 with ServiceItem

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

the class ESBService method getWsdlFilePath.

@Override
public String getWsdlFilePath(Item item) {
    if (item != null && item instanceof ServiceItem) {
        ServiceItem si = (ServiceItem) item;
        IFile wsdlFile = WSDLUtils.getWsdlFile(si);
        if (wsdlFile != null) {
            return wsdlFile.getLocation().toPortableString();
        }
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 19 with ServiceItem

use of org.talend.repository.services.model.services.ServiceItem 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 20 with ServiceItem

use of org.talend.repository.services.model.services.ServiceItem 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)

Aggregations

ServiceItem (org.talend.repository.services.model.services.ServiceItem)22 ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)18 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)17 ServicePort (org.talend.repository.services.model.services.ServicePort)17 PersistenceException (org.talend.commons.exception.PersistenceException)13 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)9 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)9 IRepositoryNode (org.talend.repository.model.IRepositoryNode)6 IFile (org.eclipse.core.resources.IFile)5 Item (org.talend.core.model.properties.Item)5 ConnectionItem (org.talend.core.model.properties.ConnectionItem)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 INode (org.talend.core.model.process.INode)3 IProcess2 (org.talend.core.model.process.IProcess2)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 IEditorReference (org.eclipse.ui.IEditorReference)2 IProcess (org.talend.core.model.process.IProcess)2