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;
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations