Kuali Rice Development
  1. Kuali Rice Development
  2. KULRICE-10170

KRMS: Add button doesn't work when adding a proposition to a rule without selecting an existing proposition.


    • Type: Bug Fix Bug Fix
    • Status: Closed Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3.1
    • Component/s: Development
    • Security Level: Public (Public: Anyone can view)
    • Labels:
    • Similar issues:
      KULRICE-12300KRMS - Add Parent to blank proposition causes exception
      KULRICE-8617Delete button is not disabled when a proposition is added like the other buttons; works correctly in Internet Explorer.
      KULRICE-5900Can not add a proposition to a new rule
      KULRICE-8270KRMS Agenda Editor: Proposition Tree of Rule does not work properly
      KULRICE-6728Add support for "exists" operator in KRMS simple propositions
      KULRICE-8374Stack trace when trying to delete an empty proposition without highlighting it.
      KULRICE-8593Unsaved data want to leave dialog when clicking button to add a new KRMS proposition.
      KULRICE-6928for a proposition in edit mode, 'edit' and 'add parent' buttons should always show
      KULRICE-5971Add button to add a compound proposition parent to the selected simple proposition
      KULRICE-5934Proposition Summary displays "null", when a new proposition is created using the KRMS Rule Editor
    • Rice Module:
    • KRAD Feature Area:
      Authorization and Presentation
    • Application Requirement:
    • Sprint:
      2.3.1 Sprint 1
    • KAI Review Status:
      Not Required
    • KTI Review Status:
      Not Required
    • Code Review Status:
      Review Completed
    • Include in Release Notes?:


      Clicking the Add button to add a new proposition to a rule, with a deselected proposition, doesn't add a new proposition.

      Steps to recreate:

      Create new Agenda
      Add new Rule
      Add new Proposition
      Click "edit" button on proposition to make it view only.
      Click Proposition Name. This should deselect the proposition
      Click "Add" button to add a second proposition

      Result: Screen flickers, but no new proposition is added to the rule.
      Expected Result: A new proposition should be added creating a compound proposition.

      Workaround: Make sure the first proposition is selected before selecting the "Add" button. In this situation the "Add" button works as expected. Note, a Compound Proposition Description must be added as well to save (see KRAFDBCK-9492 for details).

      Proposed fix:

          * This method gets the last propostion in the topmost branch.
          * @param root
          * @return
          protected String getIdOfLastProposition(Node<RuleTreeNode, String> root) {
              List<Node<RuleTreeNode,String>> children = root.getChildren();
              String selectedId = "";
              // The root usually only has one child. This child either has multiple grnadchildren
              // if there is more than one proposition or is a simpe proposition with no grandchildren.
              for( int index=0; index< children.size(); index++) {
                  Node<RuleTreeNode,String> child = children.get(index);
                  List<Node<RuleTreeNode,String>> grandChildren = child.getChildren();
                  // if there are grandchildren it means multiple propositions have been added.
                  if (grandChildren.size() != 0) {
                      int lastIndex = grandChildren.size() - 1;
                      Node<RuleTreeNode,String> lastSimpleNode = grandChildren.get(lastIndex);
                      // search until you find the first simple proposition since some nodes are operators.
                      while (!(SimplePropositionNode.NODE_TYPE.equalsIgnoreCase(lastSimpleNode.getNodeType()) 
                              || SimplePropositionEditNode.NODE_TYPE.equalsIgnoreCase(lastSimpleNode.getNodeType())
                              ) && lastIndex >= 0) {
                          lastSimpleNode = grandChildren.get(lastIndex);
                      selectedId = lastSimpleNode.getData().getProposition().getId();
                  else {
                      // if there are no grandchildren, it means only a single simpleProposition
                      // has been added.
                      selectedId = child.getData().getProposition().getId();
              return selectedId;
          @RequestMapping(params = "methodToCall=" + "addProposition")
          public ModelAndView addProposition(@ModelAttribute("KualiForm") UifFormBase form, BindingResult result,
                  HttpServletRequest request, HttpServletResponse response) throws Exception {
              AgendaEditor agendaEditor = getAgendaEditor(form);
              RuleBo rule = agendaEditor.getAgendaItemLine().getRule();
              String selectedPropId = agendaEditor.getSelectedPropositionId();
              // find parent
              Node<RuleTreeNode,String> root = agendaEditor.getAgendaItemLine().getRule().getPropositionTree().getRootElement();
              // if a proposition is not selected, get the last one in the topmost
              // branch
              if (StringUtils.isEmpty(selectedPropId)) {
                  selectedPropId = getIdOfLastProposition(root);
              // parent is the proposition user selected
              Node<RuleTreeNode,String> parent = findParentPropositionNode( root, selectedPropId);

      Have not verified this solution but according to Peter: " One think to look out for IIRC there is a parent proposition that gets created when the first child/simple proposition is added. I might be confusing the agenda tree with the proposition tree there, but keep your eyes open "


        Gayathri Athreya added a comment -
        Gayathri Athreya added a comment - Review https://fisheye.kuali.org/cru/rice-276
        Gayathri Athreya added a comment -


        Gayathri Athreya added a comment - Fixed.


          • Assignee:
            Gayathri Athreya
            Gayathri Athreya
          • Votes:
            0 Vote for this issue
            2 Start watching this issue


            • Created:


                Structure Helper Panel