Uploaded image for project: '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
    • Status: Closed
    • Priority: 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:
    • 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 "



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


          gathreya Gayathri Athreya added a comment - Fixed.


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


              • Created: