Search in sources :

Example 16 with ServiceConnection

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

the class AssignJobAction method getAllReferenceJobId.

private List<String> getAllReferenceJobId(RepositoryNode repositoryNode) {
    repositoryNode = getTopParent(repositoryNode);
    List<IRepositoryNode> nodeList = repositoryNode.getChildren();
    List<ServiceOperation> operaList = new ArrayList<ServiceOperation>();
    List<String> jobIDList = new ArrayList<String>();
    for (IRepositoryNode node : nodeList) {
        if (node.getObject().getProperty().getItem() instanceof ServiceItem) {
            ServiceItem item = (ServiceItem) node.getObject().getProperty().getItem();
            ServiceConnection conn = (ServiceConnection) item.getConnection();
            EList<ServicePort> portList = conn.getServicePort();
            for (ServicePort port : portList) {
                operaList.addAll(port.getServiceOperation());
            }
        }
    }
    for (ServiceOperation operation : operaList) {
        String jobID = operation.getReferenceJobId();
        if (jobID != null) {
            jobIDList.add(jobID);
        }
    }
    return jobIDList;
}
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) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 17 with ServiceConnection

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

the class ESBService method refreshOperationLabel.

@Override
public void refreshOperationLabel(String jobID) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        List<IRepositoryViewObject> repList = factory.getAll(getServicesType());
        for (IRepositoryViewObject obj : repList) {
            ServiceItem item = (ServiceItem) obj.getProperty().getItem();
            ServiceConnection conn = (ServiceConnection) item.getConnection();
            for (ServicePort port : conn.getServicePort()) {
                for (ServiceOperation operation : port.getServiceOperation()) {
                    if (operation.getReferenceJobId() != null && operation.getReferenceJobId().endsWith(jobID)) {
                        operation.setLabel(operation.getName());
                        operation.setReferenceJobId(null);
                        factory.save(item);
                        return;
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 18 with ServiceConnection

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

the class ESBService method editJobName.

@Override
public void editJobName(String originaleObjectLabel, String newLabel) {
    IProxyRepositoryFactory proxyRepositoryFactory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
    Project project = ProjectManager.getInstance().getCurrentProject();
    List<IRepositoryViewObject> service = null;
    try {
        service = proxyRepositoryFactory.getAll(project, ESBRepositoryNodeType.SERVICES, true);
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
    if (service != null && service.size() > 0) {
        for (IRepositoryViewObject Object : service) {
            boolean flag = false;
            ServiceItem item = (ServiceItem) Object.getProperty().getItem();
            ServiceConnection serviceConnection = (ServiceConnection) item.getConnection();
            List<ServicePort> servicePorts = serviceConnection.getServicePort();
            for (ServicePort port : servicePorts) {
                List<ServiceOperation> serviceOperations = port.getServiceOperation();
                for (ServiceOperation operation : serviceOperations) {
                    String originaleItemLabel = operation.getLabel();
                    if (originaleItemLabel.contains("-")) {
                        String[] array = originaleItemLabel.split("-");
                        if (originaleObjectLabel.equals(array[1])) {
                            operation.setLabel(array[0] + "-" + newLabel);
                            flag = true;
                        }
                    }
                }
            }
            if (flag) {
                try {
                    proxyRepositoryFactory.save(item);
                } catch (PersistenceException e) {
                    ExceptionHandler.process(e);
                }
            }
        }
    }
// RepositoryManager.refresh(ESBRepositoryNodeType.SERVICES);
}
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) Project(org.talend.core.model.general.Project) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 19 with ServiceConnection

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

the class ESBService method deleteOldRelation.

@Override
public void deleteOldRelation(String jobID) {
    boolean portBreak = false;
    boolean serviceBreak = false;
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        for (IRepositoryViewObject viewObject : factory.getAll(ERepositoryObjectType.SERVICESOPERATION)) {
            ServiceItem serviceItem = (ServiceItem) viewObject.getProperty().getItem();
            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 (jobID.equals(referenceJobId)) {
                        operation.setLabel(operation.getName());
                        operation.setReferenceJobId(null);
                        portBreak = true;
                        break;
                    }
                }
                if (portBreak) {
                    serviceBreak = true;
                    break;
                }
            }
            if (serviceBreak) {
                factory.save(serviceItem, null);
                break;
            }
        }
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 20 with ServiceConnection

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

Aggregations

ServiceConnection (org.talend.repository.services.model.services.ServiceConnection)28 ServiceOperation (org.talend.repository.services.model.services.ServiceOperation)25 ServicePort (org.talend.repository.services.model.services.ServicePort)25 ServiceItem (org.talend.repository.services.model.services.ServiceItem)18 PersistenceException (org.talend.commons.exception.PersistenceException)17 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)13 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)11 IRepositoryNode (org.talend.repository.model.IRepositoryNode)7 ProcessItem (org.talend.core.model.properties.ProcessItem)6 IFile (org.eclipse.core.resources.IFile)5 CoreException (org.eclipse.core.runtime.CoreException)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 INode (org.talend.core.model.process.INode)3 IProcess2 (org.talend.core.model.process.IProcess2)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 HashMap (java.util.HashMap)2