Пример #1
0
  protected static void processAssigmentExpression(
      Collection<RuleLine> ruleLines,
      AssignmentExpression assignmentExpression,
      Map<String, ArchetypeElementInstantiationRuleLine> gtCodeELementMap) {
    String gtCode = assignmentExpression.getVariable().getCode();
    ExpressionItem expressionItemAux = assignmentExpression.getAssignment();
    String attribute = assignmentExpression.getVariable().getAttribute();
    GTCodeRuleLineElement gtCodeRuleLineElement =
        gtCodeELementMap.get(gtCode).getGTCodeRuleLineElement();
    if (attribute == null) {
      if (expressionItemAux instanceof Variable) {
        String gtCodeAux = ((Variable) expressionItemAux).getCode();
        SetElementWithElementActionRuleLine sewearl = new SetElementWithElementActionRuleLine();
        sewearl.getArchetypeElementRuleLineElement().setValue(gtCodeRuleLineElement);
        GTCodeRuleLineElement gtCodeRuleLineElementAux =
            gtCodeELementMap.get(gtCodeAux).getGTCodeRuleLineElement();
        sewearl.getSecondArchetypeElementRuleLineElement().setValue(gtCodeRuleLineElementAux);
        ruleLines.add(sewearl);
      } else if (expressionItemAux instanceof ConstantExpression) {
        SetElementWithDataValueActionRuleLine sedvar = new SetElementWithDataValueActionRuleLine();
        sedvar.getArchetypeElementRuleLineElement().setValue(gtCodeRuleLineElement);
        DataValueRuleLineElement dataValueRuleLineElement = sedvar.getDataValueRuleLineElement();
        String dvStr = ((ConstantExpression) expressionItemAux).getValue();
        ArchetypeElementVO archetypeElementVO = gtCodeELementMap.get(gtCode).getArchetypeElement();

        log.debug("processAssigmentExpression for varialbe: " + gtCode);

        String rmType = archetypeElementVO.getRMType();
        DataValue dv = parseDataValue(rmType, dvStr);
        dataValueRuleLineElement.setValue(dv);
        ruleLines.add(sedvar);
      } else {
        log.error("Unknown expression '" + expressionItemAux.getClass().getName() + "'");
      }
    } else {
      SetElementAttributeActionRuleLine seaarl = new SetElementAttributeActionRuleLine();
      seaarl.getArchetypeElementAttributeRuleLineElement().setAttributeFunction(attribute);
      ArchetypeElementRuleLineElement aerle = new ArchetypeElementRuleLineElement(seaarl);
      aerle.setValue(gtCodeRuleLineElement);
      seaarl.getArchetypeElementAttributeRuleLineElement().setValue(aerle);
      seaarl.getExpressionRuleLineElement().setValue(expressionItemAux);
      ruleLines.add(seaarl);
    }
  }
Пример #2
0
 protected static void processExpressionItem(
     Collection<RuleLine> ruleLines,
     RuleLine parentRuleLine,
     ExpressionItem expressionItem,
     Map<String, ArchetypeElementInstantiationRuleLine> gtCodeELementMap) {
   if (expressionItem instanceof AssignmentExpression) {
     processAssigmentExpression(
         ruleLines, (AssignmentExpression) expressionItem, gtCodeELementMap);
   } else if (expressionItem instanceof BinaryExpression) {
     processBinaryExpression(
         ruleLines, parentRuleLine, (BinaryExpression) expressionItem, gtCodeELementMap);
   } else if (expressionItem instanceof UnaryExpression) {
     processUnaryExpression(
         ruleLines, parentRuleLine, (UnaryExpression) expressionItem, gtCodeELementMap);
   } else {
     log.error("Unknown expression '" + expressionItem.getClass().getName() + "'");
   }
 }