Search in sources :

Example 6 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class AbstractCouchDbTransaction method getQueryVariableValues.

public Map<String, String> getQueryVariableValues() {
    Map<String, String> map = new HashMap<String, String>();
    try {
        for (Method method : getClass().getMethods()) {
            if (method.getName().startsWith("getQ_")) {
                String name = method.getName().substring(5);
                String value = (String) method.invoke(this);
                if (value != null && !value.isEmpty()) {
                    map.put(name, value);
                }
            }
        }
        for (RequestableVariable variable : getAllVariables()) {
            if (variable.getName().startsWith(CouchParam.prefix)) {
                String name = variable.getName().substring(CouchParam.prefix.length());
                try {
                    getClass().getMethod("getP_" + name);
                } catch (Throwable t) {
                    String value;
                    if (variable.isMultiValued()) {
                        Object o = getParameterValue(variable.getName());
                        if (o instanceof Collection) {
                            JSONArray array = new JSONArray();
                            for (Object i : ((Collection<?>) o)) {
                                array.put(i);
                            }
                            value = array.toString();
                        } else {
                            value = o == null ? "" : o.toString();
                        }
                    } else {
                        value = getParameterStringValue(variable.getName());
                    }
                    if (value != null && !value.isEmpty()) {
                        map.put(name, value);
                    }
                }
            }
        }
    } catch (Exception e) {
        // TODO: handle error
        e.printStackTrace();
    }
    return map;
}
Also used : HashMap(java.util.HashMap) JSONArray(org.codehaus.jettison.json.JSONArray) Collection(java.util.Collection) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) NativeObject(org.mozilla.javascript.NativeObject) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) JSONObject(org.codehaus.jettison.json.JSONObject) Method(java.lang.reflect.Method) JSONException(org.codehaus.jettison.json.JSONException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 7 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class WebServiceTranslator method buildInputDocument.

public void buildInputDocument(Context context, Object inputData) throws Exception {
    Engine.logBeans.debug("[WebServiceTranslator] Making input document");
    HttpServletRequest request = (HttpServletRequest) inputData;
    SOAPMessage requestMessage = (SOAPMessage) request.getAttribute(WebServiceServlet.REQUEST_MESSAGE_ATTRIBUTE);
    SOAPPart sp = requestMessage.getSOAPPart();
    SOAPEnvelope se = sp.getEnvelope();
    SOAPBody sb = se.getBody();
    Iterator<?> iterator = sb.getChildElements();
    SOAPElement method, parameter;
    String methodName;
    InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context);
    while (iterator.hasNext()) {
        // jmc 12/06/26
        List<RequestableVariable> variableList = null;
        Object element = iterator.next();
        if (element instanceof SOAPElement) {
            method = (SOAPElement) element;
            methodName = method.getElementName().getLocalName();
            Engine.logBeans.debug("[WebServiceTranslator] Requested web service name: " + methodName);
            int i = methodName.indexOf("__");
            // for statefull transaction, don't replace the project
            if (context.project == null || !context.project.getName().equals(context.projectName)) {
                context.project = Engine.theApp.databaseObjectsManager.getProjectByName(context.projectName);
            }
            String connectorName = null;
            if (i == -1) {
                context.connectorName = null;
                context.sequenceName = methodName;
            } else {
                connectorName = methodName.substring(0, i);
                context.transactionName = methodName.substring(i + 2);
            }
            if ((connectorName != null) && (!connectorName.equals(context.connectorName))) {
                Engine.logBeans.debug("Connector name differs from previous one; requiring new session");
                context.isNewSession = true;
                context.connectorName = connectorName;
                Engine.logBeans.debug("[WebServiceTranslator] The connector is overridden to \"" + context.connectorName + "\".");
            }
            Engine.logBeans.debug("[WebServiceTranslator] Connector: " + (context.connectorName == null ? "(default)" : context.connectorName));
            Engine.logBeans.debug("[WebServiceTranslator] Transaction: " + context.transactionName);
            // Connector connector = (context.connectorName == null ? context.project.getDefaultConnector() : context.project.getConnectorByName(context.connectorName));
            // Transaction transaction = (context.transactionName == null ? connector.getDefaultTransaction() : connector.getTransactionByName(context.transactionName));
            RequestableObject requestable = null;
            if (context.sequenceName != null) {
                requestable = context.project.getSequenceByName(context.sequenceName);
                variableList = ((Sequence) requestable).getVariablesList();
            } else if (context.connectorName != null) {
                if (context.transactionName != null) {
                    requestable = context.project.getConnectorByName(context.connectorName).getTransactionByName(context.transactionName);
                    if (requestable instanceof TransactionWithVariables) {
                        variableList = ((TransactionWithVariables) requestable).getVariablesList();
                    }
                }
            }
            Iterator<?> iterator2 = method.getChildElements();
            String parameterName, parameterValue;
            while (iterator2.hasNext()) {
                element = iterator2.next();
                if (element instanceof SOAPElement) {
                    parameter = (SOAPElement) element;
                    parameterName = parameter.getElementName().getLocalName();
                    parameterValue = parameter.getValue();
                    if (parameterValue == null) {
                        parameterValue = "";
                    }
                    if (variableList != null) {
                        // jmc 12/06/26 hide hidden variables in sequences
                        String str = (String) Visibility.Logs.replaceVariables(variableList, "" + parameterName + "=\"" + parameterValue + "\"");
                        Engine.logBeans.debug("   Parameter: " + str);
                    } else
                        Engine.logBeans.debug("   Parameter: " + parameterName + "=\"" + parameterValue + "\"");
                    // Handle convertigo parameters
                    if (parameterName.startsWith("__")) {
                        webServiceServletRequester.handleParameter(parameterName, parameterValue);
                    }
                    // Common parameter handling
                    if (inputDocumentBuilder.handleSpecialParameter(parameterName, parameterValue)) {
                    // handled
                    } else // Compatibility for Convertigo 2.x
                    if (parameterName.equals("context")) {
                    // Just ignore it
                    } else {
                        SOAPElement soapArrayElement = null;
                        Iterator<?> iterator3;
                        String href = parameter.getAttributeValue(se.createName("href"));
                        String arrayType = parameter.getAttributeValue(se.createName("soapenc:arrayType"));
                        if (arrayType == null) {
                            iterator3 = parameter.getAllAttributes();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof Name) {
                                    String s = ((Name) element).getQualifiedName();
                                    if (s.equals("soapenc:arrayType")) {
                                        arrayType = s;
                                        break;
                                    }
                                }
                            }
                        }
                        // Array (Microsoft .net)
                        if (href != null) {
                            Engine.logBeans.debug("Deserializing Microsoft .net array");
                            iterator3 = sb.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    String elementId = soapArrayElement.getAttributeValue(se.createName("id"));
                                    if (elementId != null) {
                                        if (href.equals("#" + elementId)) {
                                            iterator3 = soapArrayElement.getChildElements();
                                            while (iterator3.hasNext()) {
                                                element = iterator3.next();
                                                if (element instanceof SOAPElement) {
                                                    break;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            // Find the element with href id
                            iterator3 = sb.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    String elementId = soapArrayElement.getAttributeValue(se.createName("id"));
                                    if (elementId != null) {
                                        if (href.equals("#" + elementId)) {
                                            break;
                                        }
                                    }
                                }
                            }
                        } else // Array (Java/Axis)
                        if (arrayType != null) {
                            Engine.logBeans.debug("Deserializing Java/Axis array");
                            soapArrayElement = parameter;
                        } else // If the node has children nodes, we assume it is an array.
                        if (parameter.getChildElements().hasNext()) {
                            if (isSoapArray((IVariableContainer) requestable, parameterName)) {
                                Engine.logBeans.debug("Deserializing array");
                                soapArrayElement = parameter;
                            }
                        }
                        // Deserializing array
                        if (soapArrayElement != null) {
                            iterator3 = soapArrayElement.getChildElements();
                            while (iterator3.hasNext()) {
                                element = iterator3.next();
                                if (element instanceof SOAPElement) {
                                    soapArrayElement = (SOAPElement) element;
                                    parameterValue = soapArrayElement.getValue();
                                    if (parameterValue == null)
                                        parameterValue = "";
                                    handleSimpleVariable(context.inputDocument, soapArrayElement, parameterName, parameterValue, inputDocumentBuilder.transactionVariablesElement);
                                }
                            }
                        } else // Deserializing simple variable
                        {
                            handleSimpleVariable(context.inputDocument, parameter, parameterName, parameterValue, inputDocumentBuilder.transactionVariablesElement);
                        }
                    }
                }
            }
            if (Engine.logBeans.isDebugEnabled()) {
                String soapMessage = SOAPUtils.toString(requestMessage, request.getCharacterEncoding());
                if (requestable instanceof TransactionWithVariables)
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + Visibility.Logs.replaceVariables(((TransactionWithVariables) (requestable)).getVariablesList(), request));
                else if (requestable instanceof Sequence)
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + Visibility.Logs.replaceVariables(((Sequence) (requestable)).getVariablesList(), request));
                else
                    Engine.logBeans.debug("[WebServiceTranslator] SOAP message received:\n" + soapMessage);
            }
            break;
        }
    }
    Engine.logBeans.debug("[WebServiceTranslator] SOAP message analyzed");
    Engine.logBeans.debug("[WebServiceTranslator] Input document created");
}
Also used : RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) SOAPEnvelope(javax.xml.soap.SOAPEnvelope) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SOAPMessage(javax.xml.soap.SOAPMessage) Name(javax.xml.soap.Name) QName(javax.xml.namespace.QName) HttpServletRequest(javax.servlet.http.HttpServletRequest) SOAPBody(javax.xml.soap.SOAPBody) IVariableContainer(com.twinsoft.convertigo.beans.core.IVariableContainer) SOAPPart(javax.xml.soap.SOAPPart) SOAPElement(javax.xml.soap.SOAPElement) Iterator(java.util.Iterator) TransactionWithVariables(com.twinsoft.convertigo.beans.core.TransactionWithVariables) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject)

Example 8 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class TreeDropAdapter method pasteNgxComponent.

private boolean pasteNgxComponent(DatabaseObject parent, DatabaseObject databaseObject, Element element) throws EngineException {
    // NGX COMPONENTS
    if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.MobileComponent) {
        if (parent.priority == databaseObject.priority) {
            return true;
        }
        // Case dbo is a Sequence
        if (databaseObject instanceof Sequence) {
            Sequence sequence = (Sequence) databaseObject;
            // Add child components to fill the form
            if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIForm) {
                com.twinsoft.convertigo.beans.ngx.components.UIForm uiForm = GenericUtils.cast(parent);
                try {
                    String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                    // add an onSubmit event with a callSequence
                    com.twinsoft.convertigo.beans.ngx.components.UIControlEvent event = new com.twinsoft.convertigo.beans.ngx.components.UIControlEvent();
                    event.setEventName(com.twinsoft.convertigo.beans.ngx.components.UIControlEvent.AttrEvent.onSubmit.name());
                    event.bNew = true;
                    event.hasChanged = true;
                    DatabaseObject call = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("CallSequenceAction"));
                    if (call != null && call instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) {
                        com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                        com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                        if (ionBean != null && ionBean.hasProperty("requestable")) {
                            ionBean.setPropertyValue("requestable", new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(projectName + "." + sequence.getName()));
                        }
                    }
                    call.bNew = true;
                    call.hasChanged = true;
                    event.add(call);
                    // add a list of item with label & input for each variable
                    DatabaseObject dboList = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("List"));
                    for (RequestableVariable variable : sequence.getVariables()) {
                        DatabaseObject dboItem = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("ListItem"));
                        dboList.add(dboItem);
                        DatabaseObject dboLabel = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("Label"));
                        dboItem.add(dboLabel);
                        com.twinsoft.convertigo.beans.ngx.components.UIText uiText = new com.twinsoft.convertigo.beans.ngx.components.UIText();
                        uiText.bNew = true;
                        uiText.hasChanged = true;
                        uiText.setTextSmartType(new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(variable.getName() + ":"));
                        dboLabel.add(uiText);
                        DatabaseObject dboInput = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("Input"));
                        if (dboInput != null && dboInput instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement) {
                            com.twinsoft.convertigo.beans.ngx.components.UIDynamicElement dynElem = GenericUtils.cast(dboInput);
                            com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean ionBean = dynElem.getIonBean();
                            if (ionBean != null && ionBean.hasProperty("FormControlName")) {
                                ionBean.setPropertyValue("FormControlName", new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(variable.getName()));
                            }
                            dboItem.add(dboInput);
                        }
                    }
                    // add a buttonset with a submit and a reset button
                    DatabaseObject dboBtnSet = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("ButtonSet"));
                    DatabaseObject dboSubmit = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("SubmitButton"));
                    dboBtnSet.add(dboSubmit);
                    com.twinsoft.convertigo.beans.ngx.components.UIText sText = new com.twinsoft.convertigo.beans.ngx.components.UIText();
                    sText.bNew = true;
                    sText.hasChanged = true;
                    sText.setTextSmartType(new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType("Submit"));
                    dboSubmit.add(sText);
                    DatabaseObject dboReset = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("ResetButton"));
                    dboBtnSet.add(dboReset);
                    com.twinsoft.convertigo.beans.ngx.components.UIText rText = new com.twinsoft.convertigo.beans.ngx.components.UIText();
                    rText.bNew = true;
                    rText.hasChanged = true;
                    rText.setTextSmartType(new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType("Reset"));
                    dboReset.add(rText);
                    uiForm.add(event);
                    uiForm.add(dboList);
                    uiForm.add(dboBtnSet);
                } catch (Exception e) {
                    throw new EngineException("Unable to create filled Form from requestable", e);
                }
                return true;
            }
            // Add a CallSequenceAction
            if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.IAction || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                com.twinsoft.convertigo.beans.ngx.components.UIComponent uiComponent = GenericUtils.cast(parent);
                String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                DatabaseObject call = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("CallSequenceAction"));
                if (call != null && call instanceof com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction) {
                    com.twinsoft.convertigo.beans.ngx.components.UIDynamicAction dynAction = GenericUtils.cast(call);
                    com.twinsoft.convertigo.beans.ngx.components.dynamic.IonBean ionBean = dynAction.getIonBean();
                    if (ionBean != null && ionBean.hasProperty("requestable")) {
                        ionBean.setPropertyValue("requestable", new com.twinsoft.convertigo.beans.ngx.components.MobileSmartSourceType(projectName + "." + sequence.getName()));
                        call.bNew = true;
                        call.hasChanged = true;
                        uiComponent.add(call);
                        uiComponent.hasChanged = true;
                    }
                }
                return true;
            }
        } else // Case dbo is a SharedAction
        if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
            com.twinsoft.convertigo.beans.ngx.components.UIActionStack stack = GenericUtils.cast(databaseObject);
            // Add an InvokeAction
            if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIPageEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIAppEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIControlEvent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.IAction || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIActionStack) {
                com.twinsoft.convertigo.beans.ngx.components.UIComponent uiComponent = GenericUtils.cast(parent);
                String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                String mobileAppName = ((Element) element.getElementsByTagName("mobileapplication").item(0)).getAttribute("name");
                String applicationName = ((Element) element.getElementsByTagName("application").item(0)).getAttribute("name");
                DatabaseObject invokeAction = com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.createBean(com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.getComponentByName("InvokeAction"));
                com.twinsoft.convertigo.beans.ngx.components.UIDynamicInvoke invoke = GenericUtils.cast(invokeAction);
                if (invoke != null) {
                    invoke.setSharedActionQName(projectName + "." + mobileAppName + "." + applicationName + "." + stack.getName());
                    invoke.bNew = true;
                    invoke.hasChanged = true;
                    uiComponent.add(invoke);
                    uiComponent.hasChanged = true;
                }
                return true;
            }
        } else // Case dbo is a SharedComponent
        if (databaseObject instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent) {
            com.twinsoft.convertigo.beans.ngx.components.UISharedComponent usc = GenericUtils.cast(databaseObject);
            // Add a UseShared component
            if (parent instanceof com.twinsoft.convertigo.beans.ngx.components.PageComponent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UISharedComponent || parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIElement && !(parent instanceof com.twinsoft.convertigo.beans.ngx.components.UIUseShared)) {
                com.twinsoft.convertigo.beans.ngx.components.MobileComponent mc = GenericUtils.cast(parent);
                String projectName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name");
                String mobileAppName = ((Element) element.getElementsByTagName("mobileapplication").item(0)).getAttribute("name");
                String applicationName = ((Element) element.getElementsByTagName("application").item(0)).getAttribute("name");
                com.twinsoft.convertigo.beans.ngx.components.UIUseShared use = new com.twinsoft.convertigo.beans.ngx.components.UIUseShared();
                if (use != null) {
                    use.setSharedComponentQName(projectName + "." + mobileAppName + "." + applicationName + "." + usc.getName());
                    use.bNew = true;
                    use.hasChanged = true;
                    mc.add(use);
                    mc.hasChanged = true;
                }
                return true;
            }
        }
    }
    return false;
}
Also used : Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IOException(java.io.IOException) ObjectWithSameNameException(com.twinsoft.convertigo.engine.ObjectWithSameNameException) SAXException(org.xml.sax.SAXException) EngineException(com.twinsoft.convertigo.engine.EngineException) InvalidOperationException(com.twinsoft.convertigo.engine.InvalidOperationException)

Example 9 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class TreeDropAdapter method move.

private boolean move(Node node, TreeObject targetTreeObject) throws EngineException {
    if (targetTreeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject parent = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
        DatabaseObject databaseObject = paste(node, null, true);
        Element element = (Element) ((Element) node).getElementsByTagName("dnd").item(0);
        // SEQUENCER
        if (parent instanceof Sequence || parent instanceof StepWithExpressions) {
            ;
        } else // URLMAPPER
        if (parent instanceof UrlMappingOperation) {
            // Set associated requestable
            if (databaseObject instanceof RequestableObject) {
                String dboQName = "";
                if (databaseObject instanceof Sequence) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + databaseObject.getName();
                } else if (databaseObject instanceof Transaction) {
                    dboQName = ((Element) element.getElementsByTagName("project").item(0)).getAttribute("name") + "." + ((Element) element.getElementsByTagName("connector").item(0)).getAttribute("name") + "." + databaseObject.getName();
                }
                UrlMappingOperation operation = (UrlMappingOperation) parent;
                operation.setTargetRequestable(dboQName);
                if (operation.getComment().isEmpty()) {
                    operation.setComment(databaseObject.getComment());
                }
                operation.hasChanged = true;
                return true;
            }
        } else if (parent instanceof UrlMappingParameter) {
            // Set associated mapped variable for parameter
            if (databaseObject instanceof RequestableVariable) {
                RequestableVariable variable = (RequestableVariable) databaseObject;
                UrlMappingParameter parameter = (UrlMappingParameter) parent;
                parameter.setMappedVariableName(variable.getName());
                parameter.hasChanged = true;
                return true;
            }
        }
    }
    return false;
}
Also used : DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) UrlMappingOperation(com.twinsoft.convertigo.beans.core.UrlMappingOperation) RequestableObject(com.twinsoft.convertigo.beans.core.RequestableObject) Transaction(com.twinsoft.convertigo.beans.core.Transaction) HtmlTransaction(com.twinsoft.convertigo.beans.transactions.HtmlTransaction) UrlMappingParameter(com.twinsoft.convertigo.beans.core.UrlMappingParameter) Element(org.w3c.dom.Element) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) Sequence(com.twinsoft.convertigo.beans.core.Sequence)

Example 10 with RequestableVariable

use of com.twinsoft.convertigo.beans.variables.RequestableVariable in project convertigo by convertigo.

the class TestCase method importRequestableVariables.

public void importRequestableVariables(RequestableObject requestable) throws EngineException {
    if (!(requestable instanceof IVariableContainer))
        return;
    IVariableContainer container = (IVariableContainer) requestable;
    int size = container.numberOfVariables();
    for (int i = 0; i < size; i++) {
        RequestableVariable variable = (RequestableVariable) container.getVariable(i);
        if (variable != null) {
            String variableName = variable.getName();
            if (getVariable(variableName) == null) {
                if (!StringUtils.isNormalized(variableName))
                    throw new EngineException("Variable name is not normalized : \"" + variableName + "\".");
                TestCaseVariable testCaseVariable = variable.isMultiValued() ? new TestCaseMultiValuedVariable() : new TestCaseVariable();
                testCaseVariable.setName(variableName);
                testCaseVariable.setDescription(variable.getDescription());
                testCaseVariable.setRequired(variable.isRequired());
                testCaseVariable.setValueOrNull(variable.getValueOrNull());
                testCaseVariable.setVisibility(variable.getVisibility());
                addVariable(testCaseVariable);
                testCaseVariable.bNew = true;
                testCaseVariable.hasChanged = true;
                hasChanged = true;
            }
        }
    }
}
Also used : TestCaseMultiValuedVariable(com.twinsoft.convertigo.beans.variables.TestCaseMultiValuedVariable) EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable)

Aggregations

RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)54 EngineException (com.twinsoft.convertigo.engine.EngineException)23 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 Sequence (com.twinsoft.convertigo.beans.core.Sequence)11 Element (org.w3c.dom.Element)9 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)8 RequestableMultiValuedVariable (com.twinsoft.convertigo.beans.variables.RequestableMultiValuedVariable)7 StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)7 TestCaseVariable (com.twinsoft.convertigo.beans.variables.TestCaseVariable)7 Shell (org.eclipse.swt.widgets.Shell)6 TransactionWithVariables (com.twinsoft.convertigo.beans.core.TransactionWithVariables)5 Variable (com.twinsoft.convertigo.beans.core.Variable)5 RequestableHttpVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpVariable)5 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)5 Cursor (org.eclipse.swt.graphics.Cursor)5 Display (org.eclipse.swt.widgets.Display)5 RequestableObject (com.twinsoft.convertigo.beans.core.RequestableObject)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)3