Search in sources :

Example 91 with Sequence

use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.

the class SequenceStep method getTagsForProperty.

@Override
public String[] getTagsForProperty(String propertyName) {
    if (propertyName.equals("sourceSequence")) {
        List<String> sequencesList = new ArrayList<String>();
        try {
            List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
            for (String projectName : projectNames) {
                Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                List<Sequence> sequences = project.getSequencesList();
                for (Sequence sequence : sequences) {
                    sequencesList.add(projectName + SOURCE_SEPARATOR + sequence.getName());
                }
            }
        } catch (EngineException e) {
        // Just ignore, should never happen
        }
        return sequencesList.toArray(new String[] {});
    }
    return super.getTagsForProperty(propertyName);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ArrayList(java.util.ArrayList) EngineException(com.twinsoft.convertigo.engine.EngineException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) GenericSequence(com.twinsoft.convertigo.beans.sequences.GenericSequence)

Example 92 with Sequence

use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.

the class Context method loadSequence.

public void loadSequence() throws EngineException {
    Sequence sequence = project.getSequenceByName(sequenceName);
    // clone sequence in studio, needed by #3188 - Order parallel step response
    if (sequence.isOriginal()) {
        try {
            sequence = sequence.cloneKeepParent();
        } catch (CloneNotSupportedException e) {
            Engine.logContext.error("Clone of sequence failed ! Use the original.", e);
        }
    }
    requestedObject = sequence;
    Engine.logContext.debug("Sequence loaded: " + requestedObject.getName());
    requestedObject.checkSymbols();
    setConnector(null);
    transaction = null;
    transactionName = null;
}
Also used : Sequence(com.twinsoft.convertigo.beans.core.Sequence)

Example 93 with Sequence

use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.

the class WebServiceServlet method generateWsdlForDocLiteral.

public static String generateWsdlForDocLiteral(String servletURI, String projectName) throws EngineException {
    Engine.logEngine.debug("(WebServiceServlet) Generating WSDL...");
    long timeStart = System.currentTimeMillis();
    String locationPath = servletURI.substring(0, servletURI.indexOf("/.w"));
    String targetNamespace = Project.CONVERTIGO_PROJECTS_NAMESPACEURI + projectName;
    Project project = null;
    // server mode
    if (Engine.isEngineMode()) {
        project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
        targetNamespace = project.getTargetNamespace();
    } else // studio mode
    {
        project = Engine.objectsProvider.getProject(projectName);
        targetNamespace = project.getTargetNamespace();
    }
    // Create WSDL definition
    Definition definition = new DefinitionImpl();
    definition.setExtensionRegistry(new PopulatedExtensionRegistry());
    definition.setTargetNamespace(targetNamespace);
    definition.setQName(new QName(targetNamespace, projectName));
    definition.addNamespace("soap", "http://schemas.xmlsoap.org/wsdl/soap/");
    definition.addNamespace("soapenc", "http://schemas.xmlsoap.org/soap/encoding/");
    definition.addNamespace("wsdl", "http://schemas.xmlsoap.org/wsdl/");
    definition.addNamespace("xsd", "http://www.w3.org/2001/XMLSchema");
    definition.addNamespace(projectName + "_ns", targetNamespace);
    // Add WSDL Types
    Types types = definition.createTypes();
    definition.setTypes(types);
    // Add WSDL service
    Service service = definition.createService();
    service.setQName(new QName(targetNamespace, projectName));
    definition.addService(service);
    // Add WSDL binding
    PortType portType = definition.createPortType();
    portType.setQName(new QName(targetNamespace, projectName + "PortType"));
    portType.setUndefined(false);
    definition.addPortType(portType);
    SOAPBindingImpl soapBinding = new SOAPBindingImpl();
    soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
    soapBinding.setStyle("document");
    Binding binding = definition.createBinding();
    binding.setQName(new QName(targetNamespace, projectName + "SOAPBinding"));
    binding.setUndefined(false);
    definition.addBinding(binding);
    binding.addExtensibilityElement(soapBinding);
    binding.setPortType(portType);
    // Add WSDL port
    SOAPAddress soapAddress = new SOAPAddressImpl();
    soapAddress.setLocationURI(locationPath + "/.wsl");
    Port port = definition.createPort();
    port.setName(projectName + "SOAP");
    port.addExtensibilityElement(soapAddress);
    port.setBinding(binding);
    service.addPort(port);
    // Add all WSDL operations
    // remember qnames for accessibility
    List<QName> partElementQNames = new ArrayList<QName>();
    if (project != null) {
        for (Connector connector : project.getConnectorsList()) {
            for (Transaction transaction : connector.getTransactionsList()) {
                if (transaction.isPublicAccessibility()) {
                    addWsdlOperation(definition, transaction, partElementQNames);
                }
            }
        }
        for (Sequence sequence : project.getSequencesList()) {
            if (sequence.isPublicAccessibility()) {
                addWsdlOperation(definition, sequence, partElementQNames);
            }
        }
    }
    // Add all schemas of project under WSDL Types
    try {
        // Retrieve the only needed schema objects map
        XmlSchemaCollection xmlSchemaCollection = Engine.theApp.schemaManager.getSchemasForProject(projectName);
        XmlSchema projectSchema = xmlSchemaCollection.getXmlSchema(targetNamespace)[0];
        LinkedHashMap<QName, XmlSchemaObject> map = new LinkedHashMap<QName, XmlSchemaObject>();
        XmlSchemaWalker dw = XmlSchemaWalker.newDependencyWalker(map, true, true);
        for (QName qname : partElementQNames) {
            dw.walkByElementRef(projectSchema, qname);
        }
        if (Engine.logEngine.isTraceEnabled()) {
            String message = "";
            for (QName qname : map.keySet()) {
                message += "\n\t" + qname.toString();
            }
            Engine.logEngine.trace("(WebServiceServlet) needed schema objects :" + message);
        }
        // Read schemas into a new Collection in order to modify them
        XmlSchemaCollection wsdlSchemaCollection = new XmlSchemaCollection();
        for (XmlSchema xmlSchema : xmlSchemaCollection.getXmlSchemas()) {
            String tns = xmlSchema.getTargetNamespace();
            if (tns.equals(Constants.URI_2001_SCHEMA_XSD))
                continue;
            if (tns.equals(SchemaUtils.URI_SOAP_ENC))
                continue;
            if (wsdlSchemaCollection.schemaForNamespace(tns) == null) {
                wsdlSchemaCollection.read(xmlSchema.getSchemaDocument(), xmlSchema.getSourceURI(), null);
            }
        }
        // Modify schemas and add them
        Map<String, Schema> schemaMap = new HashMap<String, Schema>();
        for (XmlSchema xmlSchema : wsdlSchemaCollection.getXmlSchemas()) {
            if (xmlSchema.getTargetNamespace().equals(Constants.URI_2001_SCHEMA_XSD))
                continue;
            if (xmlSchema.getTargetNamespace().equals(SchemaUtils.URI_SOAP_ENC))
                continue;
            String tns = xmlSchema.getTargetNamespace();
            // Reduce schema to needed objects
            reduceSchema(xmlSchema, map.keySet());
            // Retrieve schema Element
            Schema wsdlSchema = schemaMap.get(tns);
            if (wsdlSchema == null) {
                wsdlSchema = (Schema) definition.getExtensionRegistry().createExtension(Types.class, SchemaConstants.Q_ELEM_XSD_2001);
                Element schemaElt = xmlSchema.getSchemaDocument().getDocumentElement();
                // Remove 'schemaLocation' attribute on imports
                NodeList importList = schemaElt.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "import");
                if (importList.getLength() > 0) {
                    for (int i = 0; i < importList.getLength(); i++) {
                        Element importElt = (Element) importList.item(i);
                        importElt.removeAttribute("schemaLocation");
                    }
                }
                // Remove includes
                NodeList includeList = schemaElt.getElementsByTagNameNS(Constants.URI_2001_SCHEMA_XSD, "include");
                if (includeList.getLength() > 0) {
                    for (int i = 0; i < includeList.getLength(); i++) {
                        schemaElt.removeChild(includeList.item(i));
                    }
                }
                // Add schema Element
                schemaMap.put(tns, wsdlSchema);
                wsdlSchema.setElement(schemaElt);
                types.addExtensibilityElement(wsdlSchema);
            } else {
                // case of schema include (same targetNamespace) or same schema
                Element schemaElt = wsdlSchema.getElement();
                // Add missing attributes
                NamedNodeMap attributeMap = xmlSchema.getSchemaDocument().getDocumentElement().getAttributes();
                for (int i = 0; i < attributeMap.getLength(); i++) {
                    Node node = attributeMap.item(i);
                    if (schemaElt.getAttributes().getNamedItem(node.getNodeName()) == null) {
                        schemaElt.setAttribute(node.getNodeName(), node.getNodeValue());
                    }
                }
                // Add children
                NodeList children = xmlSchema.getSchemaDocument().getDocumentElement().getChildNodes();
                for (int i = 0; i < children.getLength(); i++) {
                    Node node = children.item(i);
                    // Special cases
                    if (node.getNodeType() == Node.ELEMENT_NODE) {
                        Element el = (Element) node;
                        // Do not add include
                        if (el.getTagName().endsWith("include"))
                            continue;
                        // Add import at first
                        if (el.getTagName().endsWith("import")) {
                            String ins = el.getAttribute("namespace");
                            if (!tns.equals(ins) && el.hasAttribute("schemaLocation")) {
                                if (!hasElement(schemaElt, el.getLocalName(), ins))
                                    schemaElt.insertBefore(schemaElt.getOwnerDocument().importNode(el, true), schemaElt.getFirstChild());
                                continue;
                            }
                        }
                        // Else
                        if (!hasElement(schemaElt, el.getLocalName(), el.getAttribute("name")))
                            schemaElt.appendChild(schemaElt.getOwnerDocument().importNode(el, true));
                    } else {
                        // Others
                        schemaElt.appendChild(schemaElt.getOwnerDocument().importNode(node, true));
                    }
                }
            }
        }
    } catch (Exception e1) {
        Engine.logEngine.error("An error occured while adding schemas for WSDL", e1);
    }
    // Write WSDL to string
    WSDLWriter wsdlWriter = new WSDLWriterImpl();
    StringWriter sw = new StringWriter();
    try {
        wsdlWriter.writeWSDL(definition, sw);
    } catch (WSDLException e) {
        Engine.logEngine.error("An error occured while generating WSDL", e);
    }
    String wsdl = sw.toString();
    long timeStop = System.currentTimeMillis();
    System.out.println("Wsdl for " + projectName + " | Times >> total : " + (timeStop - timeStart) + " ms");
    return wsdl;
}
Also used : SOAPAddressImpl(com.ibm.wsdl.extensions.soap.SOAPAddressImpl) Types(javax.wsdl.Types) Connector(com.twinsoft.convertigo.beans.core.Connector) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Port(javax.wsdl.Port) XmlSchema(org.apache.ws.commons.schema.XmlSchema) Schema(javax.wsdl.extensions.schema.Schema) WSDLElement(javax.wsdl.WSDLElement) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) SOAPElement(javax.xml.soap.SOAPElement) Element(org.w3c.dom.Element) OMNode(org.apache.axiom.om.OMNode) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) WSDLWriter(javax.wsdl.xml.WSDLWriter) LinkedHashMap(java.util.LinkedHashMap) DefinitionImpl(com.ibm.wsdl.DefinitionImpl) XmlSchemaWalker(com.twinsoft.convertigo.engine.util.XmlSchemaWalker) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) StringWriter(java.io.StringWriter) Binding(javax.wsdl.Binding) NamedNodeMap(org.w3c.dom.NamedNodeMap) WSDLException(javax.wsdl.WSDLException) QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) Definition(javax.wsdl.Definition) Service(javax.wsdl.Service) Sequence(com.twinsoft.convertigo.beans.core.Sequence) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) ServletException(javax.servlet.ServletException) SOAPException(javax.xml.soap.SOAPException) FileNotFoundException(java.io.FileNotFoundException) EngineException(com.twinsoft.convertigo.engine.EngineException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IOException(java.io.IOException) WSDLException(javax.wsdl.WSDLException) Project(com.twinsoft.convertigo.beans.core.Project) PopulatedExtensionRegistry(com.ibm.wsdl.extensions.PopulatedExtensionRegistry) Transaction(com.twinsoft.convertigo.beans.core.Transaction) XmlSchema(org.apache.ws.commons.schema.XmlSchema) SOAPAddress(javax.wsdl.extensions.soap.SOAPAddress) WSDLWriterImpl(com.ibm.wsdl.xml.WSDLWriterImpl) SOAPBindingImpl(com.ibm.wsdl.extensions.soap.SOAPBindingImpl) PortType(javax.wsdl.PortType)

Example 94 with Sequence

use of com.twinsoft.convertigo.beans.core.Sequence in project convertigo by convertigo.

the class AbstractSequenceCompositeWrap method checkEventSource.

protected boolean checkEventSource(EventObject event) {
    boolean isSourceFromSequence = false;
    Object source = event.getSource();
    if (event instanceof SequenceEvent) {
        if ((source instanceof Sequence) || (source instanceof Step)) {
            Sequence sequence = null;
            if (source instanceof Sequence)
                sequence = (Sequence) source;
            if (source instanceof Step)
                sequence = ((Step) source).getParentSequence();
            if ((sequence != null) && (sequence.equals(this.sequence) || sequence.getOriginal().equals(this.sequence)))
                isSourceFromSequence = true;
        }
    }
    return isSourceFromSequence;
}
Also used : SequenceEvent(com.twinsoft.convertigo.beans.core.SequenceEvent) EventObject(java.util.EventObject) Sequence(com.twinsoft.convertigo.beans.core.Sequence) Step(com.twinsoft.convertigo.beans.core.Step)

Aggregations

Sequence (com.twinsoft.convertigo.beans.core.Sequence)94 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)47 EngineException (com.twinsoft.convertigo.engine.EngineException)42 Step (com.twinsoft.convertigo.beans.core.Step)38 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)37 Project (com.twinsoft.convertigo.beans.core.Project)34 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)34 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)32 Transaction (com.twinsoft.convertigo.beans.core.Transaction)29 Cursor (org.eclipse.swt.graphics.Cursor)29 Display (org.eclipse.swt.widgets.Display)29 Shell (org.eclipse.swt.widgets.Shell)29 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)27 Connector (com.twinsoft.convertigo.beans.core.Connector)21 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)20 ThenStep (com.twinsoft.convertigo.beans.steps.ThenStep)19 TransactionStep (com.twinsoft.convertigo.beans.steps.TransactionStep)18 SequenceStep (com.twinsoft.convertigo.beans.steps.SequenceStep)17 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)17 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)16