Ejemplo n.º 1
0
 public FindByAnd(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(
         simpleMethod,
         element,
         "entity-name",
         "use-cache",
         "fields-to-select-list",
         "use-iterator",
         "list",
         "map",
         "order-by-list",
         "delegator-name");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "list", "map");
     MiniLangValidate.expressionAttributes(
         simpleMethod,
         element,
         "list",
         "map",
         "fields-to-select-list",
         "order-by-list",
         "delegator-name");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
   listFma = FlexibleMapAccessor.getInstance(element.getAttribute("list"));
   mapFma = FlexibleMapAccessor.getInstance(element.getAttribute("map"));
   orderByListFma = FlexibleMapAccessor.getInstance(element.getAttribute("order-by-list"));
   fieldsToSelectListFma =
       FlexibleMapAccessor.getInstance(element.getAttribute("fields-to-select-list"));
   useCacheFse = FlexibleStringExpander.getInstance(element.getAttribute("use-cache"));
   useIteratorFse = FlexibleStringExpander.getInstance(element.getAttribute("use-iterator"));
 }
Ejemplo n.º 2
0
 public NowTimestampToEnv(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     // MiniLangValidate.handleError("Deprecated - use <now>", simpleMethod, element);
     MiniLangValidate.attributeNames(simpleMethod, element, "field");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
 }
Ejemplo n.º 3
0
 public TransactionRollback(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(simpleMethod, element, "began-transaction-name");
     MiniLangValidate.expressionAttributes(simpleMethod, element, "began-transaction-name");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   beganTransactionFma =
       FlexibleMapAccessor.getInstance(
           MiniLangValidate.checkAttribute(
               element.getAttribute("began-transaction-name"), "beganTransaction"));
 }
Ejemplo n.º 4
0
 public CombinedCondition(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   List<? extends Element> childElements = UtilXml.childElementList(element);
   if (MiniLangValidate.validationOn() && childElements.isEmpty()) {
     MiniLangValidate.handleError("No conditional elements.", simpleMethod, element);
   }
   List<Conditional> conditionalList = new ArrayList<Conditional>(childElements.size());
   for (Element conditionalElement : UtilXml.childElementList(element)) {
     conditionalList.add(ConditionalFactory.makeConditional(conditionalElement, simpleMethod));
   }
   this.subConditions = Collections.unmodifiableList(conditionalList);
 }
Ejemplo n.º 5
0
 private ResultToField(Element element, SimpleMethod simpleMethod) throws ValidationException {
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(simpleMethod, element, "result-name", "field");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "result-name");
     MiniLangValidate.expressionAttributes(simpleMethod, element, "result-name", "field");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   this.resultNameFma = FlexibleMapAccessor.getInstance(element.getAttribute("result-name"));
   String fieldAttribute = element.getAttribute("field");
   if (fieldAttribute.length() == 0) {
     this.fieldFma = this.resultNameFma;
   } else {
     this.fieldFma = FlexibleMapAccessor.getInstance(fieldAttribute);
   }
 }
Ejemplo n.º 6
0
 public CallBsh(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.handleError(
         "<call-bsh> element is deprecated (use <script>)", simpleMethod, element);
     MiniLangValidate.attributeNames(simpleMethod, element, "resource");
     MiniLangValidate.constantAttributes(simpleMethod, element, "resource");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   boolean elementModified = autoCorrect(element);
   if (elementModified && MiniLangUtil.autoCorrectOn()) {
     MiniLangUtil.flagDocumentAsCorrected(element);
   }
   this.inline = StringUtil.convertOperatorSubstitutions(UtilXml.elementValue(element));
   this.resource = element.getAttribute("resource");
 }
Ejemplo n.º 7
0
 public SessionToField(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(simpleMethod, element, "field", "session-name", "default");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "field");
     MiniLangValidate.expressionAttributes(simpleMethod, element, "field");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   this.fieldFma = FlexibleMapAccessor.getInstance(element.getAttribute("field"));
   String attributeName = element.getAttribute("session-name");
   if (!attributeName.isEmpty()) {
     this.attributeNameFse = FlexibleStringExpander.getInstance(attributeName);
   } else {
     this.attributeNameFse = FlexibleStringExpander.getInstance(this.fieldFma.toString());
   }
   this.defaultFse = FlexibleStringExpander.getInstance(element.getAttribute("default"));
 }
Ejemplo n.º 8
0
 public EntityData(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(
         simpleMethod,
         element,
         "location",
         "timeout",
         "delegator-name",
         "error-list-name",
         "mode");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "location");
     MiniLangValidate.expressionAttributes(simpleMethod, element, "delegator-name");
     MiniLangValidate.constantAttributes(simpleMethod, element, "timeout", "mode");
     MiniLangValidate.noChildElements(simpleMethod, element);
   }
   locationFse = FlexibleStringExpander.getInstance(element.getAttribute("location"));
   mode = MiniLangValidate.checkAttribute(element.getAttribute("mode"), "load");
   String timeoutAttribute = element.getAttribute("timeout");
   if (!"load".equals(mode) && !timeoutAttribute.isEmpty()) {
     MiniLangValidate.handleError(
         "timeout attribute is valid only when mode=\"load\".", simpleMethod, element);
   }
   int timeout = -1;
   if (!timeoutAttribute.isEmpty()) {
     try {
       timeout = Integer.parseInt(timeoutAttribute);
     } catch (NumberFormatException e) {
       MiniLangValidate.handleError(
           "Exception thrown while parsing timeout attribute: " + e.getMessage(),
           simpleMethod,
           element);
     }
   }
   this.timeout = timeout;
   errorListFma =
       FlexibleMapAccessor.getInstance(
           MiniLangValidate.checkAttribute(element.getAttribute("error-list-name"), "error_list"));
 }
Ejemplo n.º 9
0
 public EntityCount(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(
         simpleMethod, element, "entity-name", "count-field", "delegator-name");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "entity-name", "count-field");
     MiniLangValidate.expressionAttributes(simpleMethod, element, "count-field", "delegator-name");
     MiniLangValidate.childElements(
         simpleMethod,
         element,
         "condition-expr",
         "condition-list",
         "condition-object",
         "having-condition-list");
     MiniLangValidate.requireAnyChildElement(
         simpleMethod, element, "condition-expr", "condition-list", "condition-object");
   }
   this.entityNameFse = FlexibleStringExpander.getInstance(element.getAttribute("entity-name"));
   this.countFma = FlexibleMapAccessor.getInstance(element.getAttribute("count-field"));
   int conditionElementCount = 0;
   Element conditionExprElement = UtilXml.firstChildElement(element, "condition-expr");
   conditionElementCount =
       conditionExprElement == null ? conditionElementCount : conditionElementCount++;
   Element conditionListElement = UtilXml.firstChildElement(element, "condition-list");
   conditionElementCount =
       conditionListElement == null ? conditionElementCount : conditionElementCount++;
   Element conditionObjectElement = UtilXml.firstChildElement(element, "condition-object");
   conditionElementCount =
       conditionObjectElement == null ? conditionElementCount : conditionElementCount++;
   if (conditionElementCount > 1) {
     MiniLangValidate.handleError(
         "Element must include only one condition child element",
         simpleMethod,
         conditionObjectElement);
   }
   if (conditionExprElement != null) {
     this.whereCondition = new ConditionExpr(conditionExprElement);
   } else if (conditionListElement != null) {
     this.whereCondition = new ConditionList(conditionListElement);
   } else if (conditionObjectElement != null) {
     this.whereCondition = new ConditionObject(conditionObjectElement);
   } else {
     this.whereCondition = null;
   }
   Element havingConditionListElement =
       UtilXml.firstChildElement(element, "having-condition-list");
   if (havingConditionListElement != null) {
     this.havingCondition = new ConditionList(havingConditionListElement);
   } else {
     this.havingCondition = null;
   }
 }
Ejemplo n.º 10
0
 public CallSimpleMethod(Element element, SimpleMethod simpleMethod) throws MiniLangException {
   super(element, simpleMethod);
   if (MiniLangValidate.validationOn()) {
     MiniLangValidate.attributeNames(
         simpleMethod, element, "method-name", "xml-resource", "scope");
     MiniLangValidate.requiredAttributes(simpleMethod, element, "method-name");
     MiniLangValidate.constantAttributes(
         simpleMethod, element, "method-name", "xml-resource", "scope");
     MiniLangValidate.childElements(simpleMethod, element, "result-to-field");
   }
   this.methodName = element.getAttribute("method-name");
   String xmlResourceAttribute = element.getAttribute("xml-resource");
   if (xmlResourceAttribute.isEmpty()) {
     xmlResourceAttribute = simpleMethod.getFromLocation();
   }
   this.xmlResource = xmlResourceAttribute;
   URL xmlURL = null;
   try {
     xmlURL = FlexibleLocation.resolveLocation(this.xmlResource);
   } catch (MalformedURLException e) {
     MiniLangValidate.handleError(
         "Could not find SimpleMethod XML document in resource: "
             + this.xmlResource
             + "; error was: "
             + e.toString(),
         simpleMethod,
         element);
   }
   this.xmlURL = xmlURL;
   this.scope = element.getAttribute("scope");
   List<? extends Element> resultToFieldElements =
       UtilXml.childElementList(element, "result-to-field");
   if (UtilValidate.isNotEmpty(resultToFieldElements)) {
     if (!"function".equals(this.scope)) {
       MiniLangValidate.handleError(
           "Inline scope cannot include <result-to-field> elements.", simpleMethod, element);
     }
     List<ResultToField> resultToFieldList =
         new ArrayList<ResultToField>(resultToFieldElements.size());
     for (Element resultToFieldElement : resultToFieldElements) {
       resultToFieldList.add(new ResultToField(resultToFieldElement, simpleMethod));
     }
     this.resultToFieldList = resultToFieldList;
   } else {
     this.resultToFieldList = null;
   }
 }