Search in sources :

Example 51 with XMLVector

use of com.twinsoft.convertigo.beans.common.XMLVector in project convertigo by convertigo.

the class DefaultInternalTranslator method buildInputDocument.

public void buildInputDocument(Context context, Object inputData) throws Exception {
    Engine.logContext.debug("Making input document");
    Map<String, Object> request = GenericUtils.cast(inputData);
    InputDocumentBuilder inputDocumentBuilder = new InputDocumentBuilder(context);
    // Indicates whether variable values were generated using strict mode or nor(text/childs only)
    inputDocumentBuilder.transactionVariablesElement.setAttribute("strictMode", Boolean.toString(bStrictMode));
    for (Entry<String, Object> entry : request.entrySet()) {
        String parameterName = entry.getKey();
        Object parameterObject = entry.getValue();
        if (!inputDocumentBuilder.handleSpecialParameter(parameterName, parameterObject)) {
            if (parameterObject instanceof String[]) {
                inputDocumentBuilder.addVariable(parameterName, (String[]) parameterObject);
            } else {
                addParameterObject(context.inputDocument, inputDocumentBuilder.transactionVariablesElement, parameterName, parameterObject);
            }
        }
    }
    TestCase tc = TestCase.getTestCase(request, context.projectName);
    if (tc != null) {
        for (TestCaseVariable var : tc.getVariables()) {
            String parameterName = var.getName();
            Object parameterObject = var.getValueOrNull();
            if (!request.containsKey(parameterName) && !inputDocumentBuilder.handleSpecialParameter(parameterName, parameterObject)) {
                if (parameterObject instanceof XMLVector) {
                    String[] strings = ((XMLVector<?>) parameterObject).toArray(new String[0]);
                    inputDocumentBuilder.addVariable(parameterName, strings);
                } else {
                    addParameterObject(context.inputDocument, inputDocumentBuilder.transactionVariablesElement, parameterName, parameterObject);
                }
            }
        }
    }
    Engine.logContext.info("Input document created");
}
Also used : XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) TestCase(com.twinsoft.convertigo.beans.core.TestCase) NativeJavaObject(org.mozilla.javascript.NativeJavaObject) TestCaseVariable(com.twinsoft.convertigo.beans.variables.TestCaseVariable)

Aggregations

XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)51 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)18 EngineException (com.twinsoft.convertigo.engine.EngineException)15 Element (org.w3c.dom.Element)15 IOException (java.io.IOException)10 NodeList (org.w3c.dom.NodeList)8 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)7 RequestableHttpVariable (com.twinsoft.convertigo.beans.variables.RequestableHttpVariable)6 RequestableVariable (com.twinsoft.convertigo.beans.variables.RequestableVariable)6 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)6 Shell (org.eclipse.swt.widgets.Shell)6 Step (com.twinsoft.convertigo.beans.core.Step)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ArrayList (java.util.ArrayList)5 Document (org.w3c.dom.Document)5 Block (com.twinsoft.convertigo.beans.core.Block)4 Sequence (com.twinsoft.convertigo.beans.core.Sequence)4 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)4 TestCase (com.twinsoft.convertigo.beans.core.TestCase)4 Variable (com.twinsoft.convertigo.beans.core.Variable)4