Search in sources :

Example 11 with RequestableVariable

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

the class TransactionWithVariables method getVariableValue.

@Override
public Object getVariableValue(String requestedVariableName) throws EngineException {
    // Request parameter value (see parseInputDocument())
    Object value = ((variables == null) ? null : variables.get(requestedVariableName));
    // If no value is found, find the default value and return it.
    if (value == null) {
        Object valueToPrint = null;
        RequestableVariable variable = (RequestableVariable) getVariable(requestedVariableName);
        if (variable != null) {
            // new 5.0.3 (may return null)
            value = variable.getValueOrNull();
            valueToPrint = Visibility.Logs.printValue(variable.getVisibility(), value);
            if (Engine.logBeans.isDebugEnabled()) {
                if ((value != null) && (value instanceof String))
                    Engine.logBeans.debug("Default value: " + requestedVariableName + " = \"" + valueToPrint + "\"");
                else
                    Engine.logBeans.debug("Default value: " + requestedVariableName + " = " + valueToPrint);
            }
            if (value == null && variable.isRequired()) {
                throw new EngineException("Variable named \"" + requestedVariableName + "\" is required for transaction \"" + getName() + "\"");
            }
        }
    }
    if ((value != null) && (value instanceof List)) {
        List<?> lValue = GenericUtils.cast(value);
        value = lValue.toArray(new Object[lValue.size()]);
    }
    return value;
}
Also used : EngineException(com.twinsoft.convertigo.engine.EngineException) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) ArrayList(java.util.ArrayList) NodeList(org.w3c.dom.NodeList) List(java.util.List)

Example 12 with RequestableVariable

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

the class TransactionWithVariables method generateXsdArrayOfData.

@Override
public String generateXsdArrayOfData() throws Exception {
    String xsdArrayData = "";
    RequestableVariable variable = null;
    for (int i = 0; i < numberOfVariables(); i++) {
        variable = (RequestableVariable) getVariable(i);
        if (variable.isWsdl()) {
            if (variable.isMultiValued()) {
                xsdArrayData += Engine.getArrayOfSchema(variable.getSchemaType());
            }
        }
    }
    return xsdArrayData;
}
Also used : RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Example 13 with RequestableVariable

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

the class TransactionWithVariables method getVariablesDefinition.

/**
 * Compatibility for version older than 4.6.0 *
 */
@Deprecated
public XMLVector<XMLVector<Object>> getVariablesDefinition() {
    XMLVector<XMLVector<Object>> xmlv = new XMLVector<XMLVector<Object>>();
    getVariablesList();
    if (hasVariables()) {
        for (int i = 0; i < numberOfVariables(); i++) {
            RequestableVariable variable = (RequestableVariable) getVariable(i);
            XMLVector<Object> v = new XMLVector<Object>();
            v.add(variable.getName());
            v.add(variable.getDescription());
            v.add(variable.getDefaultValue());
            v.add(variable.isWsdl());
            v.add(variable.isMultiValued());
            v.add(variable.isPersonalizable());
            v.add(variable.isCachedKey());
            xmlv.add(v);
        }
    }
    return xmlv;
}
Also used : XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Example 14 with RequestableVariable

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

the class TransactionWithVariables method addSchemaRequestDataType.

@Override
protected XmlSchemaComplexType addSchemaRequestDataType(XmlSchema xmlSchema) {
    XmlSchemaComplexType xmlSchemaComplexType = super.addSchemaRequestDataType(xmlSchema);
    int len = numberOfVariables();
    if (len > 0) {
        XmlSchemaSequence xmlSchemaSequence = new XmlSchemaSequence();
        for (int i = 0; i < len; i++) {
            RequestableVariable variable = (RequestableVariable) getVariable(i);
            if (variable.isWsdl()) {
                XmlSchemaElement xmlSchemaElement = new XmlSchemaElement();
                xmlSchemaElement.setName(variable.getName());
                if (variable.isMultiValued()) {
                    xmlSchemaElement.setMaxOccurs(Long.MAX_VALUE);
                }
                // String[] qn = variable.getSchemaType().split(":");
                // QName typeName = new QName(xmlSchema.getNamespaceContext().getNamespaceURI(qn[0]), qn[1], qn[0]);
                // xmlSchemaElement.setSchemaTypeName(typeName);
                xmlSchemaElement.setSchemaTypeName(variable.getTypeAffectation());
                addSchemaCommentAnnotation(xmlSchemaElement, variable.getComment(), variable.getDescription());
                xmlSchemaSequence.getItems().add(xmlSchemaElement);
            }
        }
        xmlSchemaComplexType.setParticle(xmlSchemaSequence);
    }
    return xmlSchemaComplexType;
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable)

Example 15 with RequestableVariable

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

the class InputVariablesStep method getXmlSchemaObject.

@Override
public XmlSchemaParticle getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    List<RequestableVariable> variables = getParentSequence().getAllVariables();
    XmlSchemaSequence sequence = variables.size() > 0 ? XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence()) : null;
    for (RequestableVariable variable : variables) {
        XmlSchemaElement element = XmlSchemaUtils.makeDynamic(this, new XmlSchemaElement());
        element.setName(variable.getName());
        element.setSchemaTypeName(variable.getTypeAffectation());
        element.setMinOccurs(0);
        if (variable.isMultiValued()) {
            element.setMaxOccurs(Long.MAX_VALUE);
        }
        sequence.getItems().add(element);
    }
    if (sequence != null) {
        return getXmlSchemaParticle(collection, schema, sequence);
    } else {
        return (XmlSchemaParticle) super.getXmlSchemaObject(collection, schema);
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) RequestableVariable(com.twinsoft.convertigo.beans.variables.RequestableVariable) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle)

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