Search in sources :

Example 1 with ServiceItem

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

the class CreateNewJobAction method createNewProcess.

private boolean createNewProcess(RepositoryNode nodeOperation, final ProcessItem process) {
    if (process == null) {
        return false;
    }
    try {
        // Set readonly to false since created job will always be editable.
        ProcessEditorInput fileEditorInput = new ProcessEditorInput(process, false, true, false);
        IRepositoryNode repositoryNode = RepositorySeekerManager.getInstance().searchRepoViewNode(fileEditorInput.getItem().getProperty().getId());
        fileEditorInput.setRepositoryNode(repositoryNode);
        IEditorPart openEditor = getActivePage().openEditor(fileEditorInput, MultiPageTalendEditor.ID, true);
        CommandStack commandStack = (CommandStack) openEditor.getAdapter(CommandStack.class);
        final Node nodeProviderRequest = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_REQUEST, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
        final RepositoryNode portNode = nodeOperation.getParent();
        ServiceItem serviceItem = (ServiceItem) portNode.getParent().getObject().getProperty().getItem();
        IFile wsdlPath = WSDLUtils.getWsdlFile(serviceItem);
        Map<String, String> serviceParameters = WSDLUtils.getServiceOperationParameters(wsdlPath, ((OperationRepositoryObject) nodeOperation.getObject()).getName(), portNode.getObject().getLabel());
        setProviderRequestComponentConfiguration(nodeProviderRequest, serviceParameters);
        CreateNodeContainerCommand cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(nodeProviderRequest), new Point(3 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
        commandStack.execute(cNcc);
        if (!WSDLUtils.ONE_WAY.equals(serviceParameters.get(WSDLUtils.COMMUNICATION_STYLE))) {
            Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_RESPONSE, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
            cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(9 * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
            commandStack.execute(cNcc);
        }
        String faults = serviceParameters.get(WSDLUtils.FAULTS);
        if (null != faults) {
            int horMultiplier = 15;
            for (String fault : faults.split(",")) {
                Node node = new Node(ComponentsFactoryProvider.getInstance().get(T_ESB_PROVIDER_FAULT, ComponentCategory.CATEGORY_4_DI.getName()), fileEditorInput.getLoadedProcess());
                cNcc = new CreateNodeContainerCommand(fileEditorInput.getLoadedProcess(), new NodeContainer(node), new Point(horMultiplier * Node.DEFAULT_SIZE, 4 * Node.DEFAULT_SIZE));
                commandStack.execute(cNcc);
                //$NON-NLS-1$
                node.getElementParameter("ESB_FAULT_TITLE").setValue('\"' + fault + '\"');
                horMultiplier += 6;
            }
        }
        ServiceConnection serviceConnection = (ServiceConnection) serviceItem.getConnection();
        final String parentPortName = portNode.getObject().getLabel();
        for (ServicePort port : serviceConnection.getServicePort()) {
            if (port.getName().equals(parentPortName)) {
                for (ServiceOperation operation : port.getServiceOperation()) {
                    if (operation.getLabel().equals(nodeOperation.getObject().getLabel())) {
                        String jobName = process.getProperty().getLabel();
                        String jobID = process.getProperty().getId();
                        operation.setReferenceJobId(jobID);
                        operation.setLabel(operation.getName() + "-" + jobName);
                        break;
                    }
                }
                break;
            }
        }
        repositoryChange(nodeOperation, nodeProviderRequest);
        ProxyRepositoryFactory.getInstance().save(serviceItem);
        return true;
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    } catch (PersistenceException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return false;
}
Also used : CommandStack(org.eclipse.gef.commands.CommandStack) ServicePort(org.talend.repository.services.model.services.ServicePort) ServiceConnection(org.talend.repository.services.model.services.ServiceConnection) IFile(org.eclipse.core.resources.IFile) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NodeContainer(org.talend.designer.core.ui.editor.nodecontainer.NodeContainer) IEditorPart(org.eclipse.ui.IEditorPart) Point(org.eclipse.draw2d.geometry.Point) ServiceOperation(org.talend.repository.services.model.services.ServiceOperation) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Point(org.eclipse.draw2d.geometry.Point) PartInitException(org.eclipse.ui.PartInitException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput) CreateNodeContainerCommand(org.talend.designer.core.ui.editor.cmd.CreateNodeContainerCommand) PersistenceException(org.talend.commons.exception.PersistenceException) ServiceItem(org.talend.repository.services.model.services.ServiceItem) PartInitException(org.eclipse.ui.PartInitException)

Example 2 with ServiceItem

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

the class OpenWSDLWizard method addPages.

@Override
public void addPages() {
    super.addPages();
    IPath pathToSave;
    switch(repositoryNode.getType()) {
        case SIMPLE_FOLDER:
        case REPOSITORY_ELEMENT:
            pathToSave = RepositoryNodeUtilities.getPath(repositoryNode);
            break;
        //case SYSTEM_FOLDER:
        default:
            //$NON-NLS-1$
            pathToSave = new Path("");
            break;
    }
    wsdlPage = new OpenWSDLPage(repositoryNode, pathToSave, (ServiceItem) repositoryNode.getObject().getProperty().getItem(), false);
    addPage(wsdlPage);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 3 with ServiceItem

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

the class ServiceMetadataAction method isLocked.

private static boolean isLocked(IRepositoryViewObject object) {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
        ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
        boolean isOpened = coreService.isOpenedItemInEditor(object);
        if (isOpened) {
            return true;
        }
    }
    ServiceItem serviceItem = (ServiceItem) object.getProperty().getItem();
    return serviceItem.getState().isLocked();
}
Also used : ICoreService(org.talend.core.ICoreService) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

Example 4 with ServiceItem

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

the class OpenJobAction method removeReferenecJobId.

protected static void removeReferenecJobId(IRepositoryNode node) {
    IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
    try {
        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())) {
                        operation.setReferenceJobId(null);
                        operation.setLabel(operation.getName());
                        factory.save(node.getObject().getProperty().getItem());
                    }
                }
                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) 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 5 with ServiceItem

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

the class OpenWSDLEditorAction method init.

@Override
protected void init(RepositoryNode node) {
    // set to true for service node and service port node
    final boolean isServicesNode = ESBRepositoryNodeType.SERVICES == node.getObjectType() || ESBRepositoryNodeType.SERVICEPORT == node.getObjectType();
    setEnabled(isServicesNode);
    // anyway initialize for double-click
    if (isServicesNode && null != node.getObject()) {
        Item item = node.getObject().getProperty().getItem();
        if (item instanceof ServiceItem) {
            serviceItem = (ServiceItem) item;
        }
    }
}
Also used : ServiceItem(org.talend.repository.services.model.services.ServiceItem) Item(org.talend.core.model.properties.Item) ServiceItem(org.talend.repository.services.model.services.ServiceItem)

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