Coverage Report - org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsSummaryView
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseRequirementsSummaryView
0%
0/154
0%
0/80
2.71
CourseRequirementsSummaryView$1
0%
0/5
0%
0/2
2.71
CourseRequirementsSummaryView$2
0%
0/12
0%
0/4
2.71
CourseRequirementsSummaryView$3
0%
0/3
N/A
2.71
CourseRequirementsSummaryView$3$1
0%
0/10
0%
0/2
2.71
CourseRequirementsSummaryView$3$1$1
0%
0/5
N/A
2.71
CourseRequirementsSummaryView$4
0%
0/3
N/A
2.71
CourseRequirementsSummaryView$4$1
0%
0/4
N/A
2.71
CourseRequirementsSummaryView$5
0%
0/6
N/A
2.71
CourseRequirementsSummaryView$6
0%
0/7
0%
0/4
2.71
CourseRequirementsSummaryView$6$1
0%
0/5
0%
0/2
2.71
CourseRequirementsSummaryView$7
0%
0/17
0%
0/4
2.71
CourseRequirementsSummaryView$7$1
0%
0/3
N/A
2.71
CourseRequirementsSummaryView$7$2
0%
0/5
0%
0/2
2.71
 
 1  
 package org.kuali.student.lum.lu.ui.course.client.requirements;
 2  
 
 3  
 import java.util.HashMap;
 4  
 import java.util.HashSet;
 5  
 import java.util.LinkedHashMap;
 6  
 import java.util.List;
 7  
 import java.util.Map;
 8  
 import java.util.Set;
 9  
 
 10  
 import org.kuali.student.common.dto.RichTextInfo;
 11  
 import org.kuali.student.common.ui.client.application.Application;
 12  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.views.SectionView;
 14  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 15  
 import org.kuali.student.common.ui.client.mvc.Callback;
 16  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 17  
 import org.kuali.student.common.ui.client.mvc.Model;
 18  
 import org.kuali.student.common.ui.client.mvc.ModelRequestCallback;
 19  
 import org.kuali.student.common.ui.client.mvc.View;
 20  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 21  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract;
 22  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 23  
 import org.kuali.student.common.ui.client.widgets.dialog.ConfirmationDialog;
 24  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup;
 25  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton;
 26  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.AbbrButton.AbbrButtonType;
 27  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.LabelPanel;
 28  
 import org.kuali.student.common.ui.client.widgets.field.layout.element.SpanPanel;
 29  
 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
 30  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 31  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 32  
 import org.kuali.student.core.statement.dto.StatementTypeInfo;
 33  
 import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil;
 34  
 import org.kuali.student.core.statement.ui.client.widgets.rules.SubrulePreviewWidget;
 35  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 36  
 import org.kuali.student.lum.common.client.widgets.CluSetDetailsWidget;
 37  
 import org.kuali.student.lum.common.client.widgets.CluSetRetriever;
 38  
 import org.kuali.student.lum.common.client.widgets.CluSetRetrieverImpl;
 39  
 import org.kuali.student.lum.lu.ui.course.client.configuration.AbstractCourseConfigurer;
 40  
 import org.kuali.student.lum.lu.ui.course.client.configuration.CourseProposalConfigurer;
 41  
 import org.kuali.student.lum.lu.ui.course.client.controllers.CourseProposalController;
 42  
 
 43  
 import com.google.gwt.core.client.GWT;
 44  
 import com.google.gwt.event.dom.client.ClickEvent;
 45  
 import com.google.gwt.event.dom.client.ClickHandler;
 46  
 import com.google.gwt.user.client.Window;
 47  
 import com.google.gwt.user.client.ui.FlowPanel;
 48  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 49  
 import com.google.gwt.user.client.ui.VerticalPanel;
 50  
 import com.google.gwt.user.client.ui.Widget;
 51  
 
 52  
 public class CourseRequirementsSummaryView extends VerticalSectionView {
 53  
 
 54  0
     private static CluSetRetriever cluSetRetriever = new CluSetRetrieverImpl();
 55  
 
 56  
     //view's widgets
 57  0
     protected FlowPanel layout = new FlowPanel();
 58  0
     protected ActionCancelGroup actionCancelButtons = new ActionCancelGroup(
 59  
             ButtonEnumerations.SaveContinueCancelEnum.SAVE_CONTINUE, ButtonEnumerations.SaveContinueCancelEnum.CANCEL);
 60  0
     protected Map<String, Widget> addButtonsList = new HashMap<String, Widget>();
 61  
 
 62  
     //view's data
 63  
     protected CourseRequirementsViewController parentController;
 64  
     protected CourseRequirementsDataModel rules;
 65  
     protected boolean isReadOnly;
 66  
     protected boolean showSaveButtons;
 67  0
     private static int tempProgReqInfoID = 9999;
 68  
     public static final String NEW_STMT_TREE_ID = "NEWSTMTTREE";
 69  
     public static final String NEW_REQ_COMP_ID = "NEWREQCOMP";    
 70  
 
 71  0
     protected Map<String, SpanPanel> perCourseRequisiteTypePanel = new LinkedHashMap<String, SpanPanel>();
 72  
 
 73  
     public CourseRequirementsSummaryView() {
 74  0
         super();
 75  0
     }
 76  
 
 77  
     public CourseRequirementsSummaryView(final CourseRequirementsViewController parentController, Enum<?> viewEnum, String name,
 78  
                                                             String modelId, CourseRequirementsDataModel rulesData, boolean isReadOnly, boolean showSaveButtons) {
 79  0
         super(viewEnum, name, modelId);
 80  0
         this.parentController = parentController;
 81  0
         rules = rulesData;
 82  0
         rules.setInitialized(false);
 83  0
         this.isReadOnly = isReadOnly;
 84  0
         this.showSaveButtons = showSaveButtons;
 85  0
         if (!isReadOnly && showSaveButtons) {
 86  0
             setupSaveCancelButtons();
 87  
         }
 88  0
     }
 89  
 
 90  
     public void init(final CourseRequirementsViewController parentController, Enum<?> viewEnum, String name,
 91  
             String modelId, CourseRequirementsDataModel rulesData, boolean isReadOnly, boolean showSaveButtons) {
 92  0
         super.init(viewEnum, name, modelId, true);
 93  0
         this.parentController = parentController;
 94  0
         rules = rulesData;
 95  0
         rules.setInitialized(false);
 96  0
         this.isReadOnly = isReadOnly;
 97  0
         this.showSaveButtons = showSaveButtons;
 98  0
         if (!isReadOnly && showSaveButtons) {
 99  0
             setupSaveCancelButtons();
 100  
         }
 101  0
     }
 102  
 
 103  
     @Override
 104  
     public boolean isDirty() {
 105  0
         return rules.isDirty();
 106  
     }
 107  
 
 108  
     @Override
 109  
     public void beforeShow(final Callback<Boolean> onReadyCallback) {
 110  
 
 111  
         //only when user wants to see rules then load requirements from database if they haven't been loaded yet
 112  0
         if (!rules.isInitialized()) {
 113  0
             rules.retrieveCourseRequirements(AbstractCourseConfigurer.COURSE_PROPOSAL_MODEL, new Callback<Boolean>() {
 114  
                 @Override
 115  
                 public void exec(Boolean result) {
 116  0
                     if (result) {
 117  0
                         displayRules();
 118  
                     }
 119  0
                     onReadyCallback.exec(result);
 120  0
                 }
 121  
             });
 122  0
             return;
 123  
         }
 124  
 
 125  
         //for read-only view, we don't need to worry about rules being added or modified
 126  0
         if (isReadOnly) {
 127  0
             displayRules();            
 128  0
             onReadyCallback.exec(true);
 129  0
             return;
 130  
         }
 131  
 
 132  
         //see if we need to update a rule if user is returning from rule manage screen
 133  0
         parentController.getView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE, new Callback<View>(){
 134  
                         @Override
 135  
                         public void exec(View result) {
 136  0
                                 CourseRequirementsManageView manageView = (CourseRequirementsManageView) result;
 137  
                 
 138  
                                 //return if user did not added or updated a rule
 139  0
                 if (!manageView.isDirty() || !manageView.isUserClickedSaveButton()) {
 140  0
                     rules.removeEmptyRules();
 141  0
                     onReadyCallback.exec(true);
 142  0
                     return;
 143  
                 }
 144  
 
 145  
                 //update the rule because user added or edited the rule
 146  0
                 ((SectionView)parentController.getCurrentView()).setIsDirty(false);
 147  0
                 manageView.setUserClickedSaveButton(false);
 148  
 
 149  
                 //if rule storage updated successfully, update the display as well
 150  0
                 StatementTreeViewInfo affectedRule = rules.updateRules(manageView.getRuleTree(), manageView.getInternalCourseReqID(), manageView.isNewRule());
 151  0
                 updateRequirementWidgets(affectedRule);
 152  
                 
 153  0
                         onReadyCallback.exec(true);
 154  0
                         }
 155  
                 });        
 156  0
     }
 157  
 
 158  
     public void revertRuleChanges() {
 159  0
         rules.revertRuleChanges();
 160  0
         displayRules();
 161  0
     }
 162  
 
 163  
     protected void updateRequirementWidgets(StatementTreeViewInfo rule) {
 164  0
         if (rule != null) {
 165  0
             StatementTypeInfo affectedStatementTypeInfo = rules.getStmtTypeInfo(rule.getType());
 166  0
             SpanPanel reqPanel = perCourseRequisiteTypePanel.get(affectedStatementTypeInfo.getId());
 167  
 
 168  
             //don't show 'add rule' button if we have one rule already
 169  0
             addButtonsList.get(rule.getType()).setVisible(false);
 170  
 
 171  
             //if this is a new rule then add it to the panel
 172  0
             if (reqPanel.getWidgetCount() == 0) {
 173  0
                 SubrulePreviewWidget newRulePreviewWidget = addCourseRequisite(reqPanel, rule);
 174  0
                 reqPanel.add(newRulePreviewWidget);
 175  0
                 return;
 176  
             }
 177  
 
 178  0
             for (int i = 0; i < reqPanel.getWidgetCount(); i++) {
 179  0
                 SubrulePreviewWidget subrulePreviewWidget = (SubrulePreviewWidget)reqPanel.getWidget(i);
 180  0
                 if (!rule.getStatements().isEmpty() || !rule.getReqComponents().isEmpty()) {
 181  0
                         SubrulePreviewWidget newRulePreviewWidget = addCourseRequisite(reqPanel, rule);
 182  0
                         reqPanel.insert(newRulePreviewWidget, i);
 183  
                 }        
 184  0
                 reqPanel.remove(subrulePreviewWidget);
 185  0
                 if (rule.getStatements().isEmpty() && rule.getReqComponents().isEmpty())                 
 186  0
                     addButtonsList.get(rule.getType()).setVisible(true);                        
 187  
                 break; //there should be only one rule per requisite type
 188  
             }
 189  
         }
 190  0
     }    
 191  
 
 192  
     public void displayRules() {       
 193  0
         remove(layout);
 194  0
         layout.clear();
 195  
 
 196  
         //display 'Course Requirements' page title (don't add if read only because the section itself will display the title)
 197  0
         if (!isReadOnly) {
 198  0
             SectionTitle pageTitle = SectionTitle.generateH2Title("Course Requisites");
 199  0
             pageTitle.addStyleName("ks-layout-header");  //make the header orange
 200  0
             layout.add(pageTitle);
 201  
         }
 202  
 
 203  
         //iterate and display rules for each Course Requirement type e.g. Pre-Requisites, Co-Requisites, Anti-Requisites
 204  0
         boolean firstSubHeader = true;
 205  0
         for (StatementTypeInfo stmtTypeInfo : rules.getStmtTypes()) {
 206  
 
 207  
             //Show only headers for top statement types
 208  0
             if (isTopStatement(stmtTypeInfo)) {
 209  0
                 SectionTitle title = SectionTitle.generateH3Title(stmtTypeInfo.getName());
 210  0
                 title.addStyleName("KS-Course-Requisites-Top-Stmt-Header");
 211  0
                 layout.add(title);
 212  0
                 firstSubHeader = true;
 213  0
                 continue;
 214  
             }
 215  
 
 216  
             //create and display one type of Course Requisites section
 217  0
             SpanPanel requirementsPanel = new SpanPanel();
 218  0
             perCourseRequisiteTypePanel.put(stmtTypeInfo.getId(), requirementsPanel);
 219  0
             displayRequirementSectionForGivenType(requirementsPanel, stmtTypeInfo, firstSubHeader);
 220  0
             firstSubHeader = false;
 221  
 
 222  
             //now display each requirement for this Course Requisites type; should be only one for courses
 223  0
             for (StatementTreeViewInfo ruleInfo : rules.getCourseReqInfo(stmtTypeInfo.getId())) {
 224  0
                     if (!ruleInfo.getStatements().isEmpty() || !ruleInfo.getReqComponents().isEmpty()) {
 225  0
                             SubrulePreviewWidget subrulePreviewWidget = addCourseRequisite(requirementsPanel, ruleInfo);
 226  0
                             requirementsPanel.add(subrulePreviewWidget);
 227  0
                     }        
 228  
             }
 229  0
         }
 230  
 
 231  
         //save and cancel buttons
 232  0
         if (!isReadOnly && showSaveButtons) {
 233  0
             layout.add(actionCancelButtons);
 234  
         }
 235  
 
 236  0
         addWidget(layout);
 237  0
     }
 238  
 
 239  
     protected void displayRequirementSectionForGivenType(final SpanPanel requirementsPanel,
 240  
             final StatementTypeInfo stmtTypeInfo, boolean firstSubHeader) {
 241  
 
 242  
         //display header for this Course Requisites type e.g. Enrollment Eligibility
 243  0
         SectionTitle title = SectionTitle.generateH3Title(stmtTypeInfo.getName());
 244  0
         title.setStyleName((firstSubHeader ? "KS-Course-Requisites-Preview-Rule-Type-First-Header" : "KS-Course-Requisites-Preview-Rule-Type-Header"));
 245  0
         layout.add(title);
 246  
 
 247  0
         LabelPanel labelExamples = new LabelPanel(stmtTypeInfo.getDescr());
 248  0
         labelExamples.getElement().setAttribute("style", "font-weight: normal; width: 80%;");
 249  
         
 250  0
         String examplesHtml = Application.getApplicationContext().getMessage(stmtTypeInfo.getId());
 251  
         
 252  0
         if (examplesHtml != null && !examplesHtml.equals("")) {
 253  0
                 AbbrButton examples = new AbbrButton(AbbrButtonType.EXAMPLES);
 254  0
                 examples.setVisible(true);
 255  0
                 examples.setHoverHTML(examplesHtml);
 256  0
                 examples.getHoverPopup().addStyleName("ks-example-popup");
 257  0
                 labelExamples.add(examples);
 258  
         }
 259  
         
 260  0
         HorizontalPanel spacer0 = new HorizontalPanel();
 261  0
         spacer0.addStyleName("KS-Course-Requisites-Button-Spacer");
 262  0
         labelExamples.add(spacer0);
 263  
  
 264  0
         layout.add(labelExamples);
 265  
         
 266  
         //display "Add Rule" button if user is in 'edit' mode OR a rule is already defined
 267  0
         final String stmtId = stmtTypeInfo.getId();
 268  0
         if (!isReadOnly) { // && rules.getCourseReqInfo(stmtId).isEmpty()) {
 269  0
             KSButton addCourseReqButton = new KSButton("Add " + stmtTypeInfo.getName(), KSButtonAbstract.ButtonStyle.FORM_SMALL);
 270  0
             addCourseReqButton.addClickHandler(new ClickHandler(){
 271  
                 public void onClick(ClickEvent event) {
 272  
 
 273  0
                     storeRules(false, new Callback<Boolean>() {
 274  
                         @Override
 275  
                         public void exec(Boolean courseExists) {
 276  0
                             if (courseExists) {
 277  0
                                 final StatementTreeViewInfo newRule = new StatementTreeViewInfo();
 278  0
                                 newRule.setId(generateStatementTreeId());
 279  0
                                 newRule.setType(stmtId);
 280  0
                                 RichTextInfo text = new RichTextInfo();
 281  0
                                 text.setPlain("");
 282  0
                                 newRule.setDesc(text);
 283  0
                                 parentController.getView(
 284  
                                         CourseRequirementsViewController.CourseRequirementsViews.MANAGE,
 285  0
                                         new Callback<View>() {
 286  
                                     @Override
 287  
                                     public void exec(View result) {
 288  0
                                         rules.addRule(newRule);
 289  0
                                         ((CourseRequirementsManageView) result).setRuleTree(newRule, true, rules.getInternalCourseReqID(newRule));
 290  0
                                         parentController.showView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE);
 291  0
                                     }
 292  
                                 });
 293  
                             }
 294  0
                         }
 295  
                     });
 296  0
                 };
 297  
             });
 298  0
             if (!rules.getCourseReqInfo(stmtId).isEmpty()) {
 299  0
                     boolean checkReqs = true;
 300  0
                     for(StatementTreeViewInfo ruleInfo : rules.getCourseReqInfo(stmtId)) {
 301  0
                             if (!ruleInfo.getStatements().isEmpty() || !ruleInfo.getReqComponents().isEmpty()) {
 302  0
                                     checkReqs = false;
 303  0
                                     break;
 304  
                             }
 305  
                     }    
 306  0
                     addCourseReqButton.setVisible(checkReqs);
 307  0
             } else
 308  0
                     addCourseReqButton.setVisible(rules.getCourseReqInfo(stmtId).isEmpty());
 309  0
             addButtonsList.put(stmtId, addCourseReqButton);
 310  0
             layout.add(addCourseReqButton);
 311  0
             VerticalPanel spacer = new VerticalPanel();
 312  0
             spacer.addStyleName("KS-Course-Requisites-Button-Spacer");            
 313  0
             layout.add(spacer);
 314  
         }
 315  
 
 316  0
         layout.add(requirementsPanel);
 317  0
     }
 318  
 
 319  
     protected SubrulePreviewWidget addCourseRequisite(final SpanPanel requirementsPanel,
 320  
             final StatementTreeViewInfo rule) {
 321  
 
 322  0
         Integer internalProgReqID =  rules.getInternalCourseReqID(rule);
 323  0
         String stmtTypeId = rule.getType();
 324  
         
 325  0
         final SubrulePreviewWidget rulePreviewWidget = new SubrulePreviewWidget(rule, isReadOnly, getCluSetWidgetList(rule));
 326  
 
 327  0
         addRulePreviewWidgetHandlers(requirementsPanel, rulePreviewWidget, stmtTypeId, internalProgReqID);
 328  0
         return rulePreviewWidget;
 329  
     }
 330  
 
 331  
     protected void addRulePreviewWidgetHandlers(final SpanPanel requirementsPanel,
 332  
             final SubrulePreviewWidget subRuleWidget, final String stmtTypeId, final Integer internalProgReqID) {
 333  
 
 334  0
         subRuleWidget.addEditButtonClickHandler(new ClickHandler() {
 335  
             public void onClick(ClickEvent event) {
 336  0
                 parentController.getView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE, new Callback<View>(){
 337  
                     @Override
 338  
                     public void exec(View result) {
 339  0
                         ((CourseRequirementsManageView) result).setRuleTree(rules.getRule(internalProgReqID), false, internalProgReqID);
 340  0
                         parentController.showView(CourseRequirementsViewController.CourseRequirementsViews.MANAGE);
 341  0
                     }
 342  
                 });                
 343  0
             }
 344  
         });
 345  
                 
 346  0
         subRuleWidget.addDeleteButtonClickHandler(new ClickHandler() {
 347  
             public void onClick(ClickEvent event) {
 348  
                 //deleting subrule does not delete the requirement (rule) itself
 349  0
                 rules.markRuleAsEdited(internalProgReqID);
 350  
                 //remove rule from display and storage
 351  0
                 rules.deleteRule(internalProgReqID);
 352  0
                 requirementsPanel.remove(subRuleWidget);
 353  0
                 addButtonsList.get(stmtTypeId).setVisible(true);
 354  0
             }
 355  
         });                   
 356  0
     }
 357  
 
 358  
     static public boolean isTopStatement(StatementTypeInfo stmtInfo) {
 359  0
         return ((stmtInfo.getAllowedStatementTypes() != null) && !stmtInfo.getAllowedStatementTypes().isEmpty());
 360  
     }
 361  
 
 362  
     static public Map<String, Widget> getCluSetWidgetList(StatementTreeViewInfo rule) {
 363  0
         Map<String, Widget> widgetList = new HashMap<String, Widget>();
 364  0
         Set<String> cluSetIds = new HashSet<String>();
 365  0
         findCluSetIds(rule, cluSetIds);
 366  0
         for (String clusetId : cluSetIds) {
 367  0
             widgetList.put(clusetId, new CluSetDetailsWidget(clusetId, cluSetRetriever));
 368  
         }
 369  
 
 370  0
         return widgetList;
 371  
     }
 372  
 
 373  
     static private void findCluSetIds(StatementTreeViewInfo rule, Set<String> list) {
 374  
 
 375  0
         List<StatementTreeViewInfo> statements = rule.getStatements();
 376  0
         List<ReqComponentInfo> reqComponentInfos = rule.getReqComponents();
 377  
 
 378  0
         if ((statements != null) && (statements.size() > 0)) {
 379  
             // retrieve all statements
 380  0
             for (StatementTreeViewInfo statement : statements) {
 381  0
                 findCluSetIds(statement, list); // inside set the children of this statementTreeViewInfo
 382  
             }
 383  0
         } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
 384  
             // retrieve all req. component LEAFS
 385  0
             for (ReqComponentInfo reqComponent : reqComponentInfos) {
 386  0
                 List<ReqCompFieldInfo> fieldInfos = reqComponent.getReqCompFields();
 387  0
                 for (ReqCompFieldInfo fieldInfo : fieldInfos) {
 388  0
                     if (RulesUtil.isCluSetWidget(fieldInfo.getType())) {
 389  0
                         list.add(fieldInfo.getValue());
 390  
                     }
 391  
                 }
 392  0
             }
 393  
         }
 394  0
     }
 395  
 
 396  
     private void setupSaveCancelButtons() {
 397  0
         actionCancelButtons.addStyleName("KS-Course-Requisites-Save-Button");
 398  0
         actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){
 399  
              @Override
 400  
             public void exec(ButtonEnumerations.ButtonEnum result) {
 401  0
                 if (result == ButtonEnumerations.SaveContinueCancelEnum.SAVE_CONTINUE) {
 402  0
                     storeRules(true, new Callback<Boolean>() {
 403  
                         @Override
 404  
                         public void exec(Boolean result) {
 405  0
                             if (result) {
 406  0
                                 CourseProposalController courseController = ((CourseProposalController) parentController.getParentController());
 407  0
                                 courseController.showNextViewOnMenu();
 408  
 //                                courseController.getReqDataModel().retrieveStatementTypes(courseController.getCourseId(), Controller.NO_OP_CALLBACK);
 409  
                             }
 410  0
                         }
 411  
                     });                    
 412  
                 } else {
 413  0
                     if(! ((CourseProposalController)parentController.getController()).isNew()){
 414  0
                         (parentController.getController()).showView(CourseProposalConfigurer.CourseSections.SUMMARY);
 415  
                     }
 416  
                     else{
 417  0
                         Application.navigate(AppLocations.Locations.CURRICULUM_MANAGEMENT.getLocation());
 418  
                     }
 419  
                 }
 420  0
             }
 421  
         });
 422  0
     }
 423  
 
 424  
     public void storeRules(final boolean storeRules, final Callback<Boolean> callback) {
 425  0
         parentController.requestModel(CourseRequirementsViewController.COURSE_PROPOSAL_MODEL, new ModelRequestCallback() {
 426  
             @Override
 427  
             public void onRequestFail(Throwable cause) {
 428  0
                 Window.alert(cause.getMessage());
 429  0
                 GWT.log("Unable to retrieve model for course requirements view", cause);
 430  0
                 callback.exec(false);
 431  0
             }
 432  
             @Override
 433  
             public void onModelReady(Model model) {
 434  0
                 String courseId = ((DataModel)model).getRoot().get("id");
 435  0
                 String courseState = ((DataModel)model).getRoot().get("state");
 436  0
                 if (courseId == null) {
 437  0
                     final ConfirmationDialog dialog = new ConfirmationDialog("Submit Course Title", "Before saving rules please submit course proposal title");
 438  0
                     dialog.getConfirmButton().addClickHandler(new ClickHandler(){
 439  
                         @Override
 440  
                         public void onClick(ClickEvent event) {
 441  0
                             dialog.hide();
 442  0
                         }
 443  
                     });
 444  0
                     dialog.show();
 445  0
                     callback.exec(false);
 446  0
                 } else {
 447  0
                     if (storeRules) {
 448  0
                         rules.updateCourseRequisites(courseId, courseState, new Callback<List<StatementTreeViewInfo>>() {
 449  
                             @Override
 450  
                             public void exec(List<StatementTreeViewInfo> rules) {
 451  0
                                 for (StatementTreeViewInfo rule : rules) {
 452  0
                                     updateRequirementWidgets(rule);
 453  
                                 }
 454  0
                                 callback.exec(true);                                
 455  0
                             }
 456  
                         });
 457  
                     } else {
 458  0
                         callback.exec(true);                         
 459  
                     }
 460  
                 }
 461  0
             }
 462  
         });
 463  0
     }
 464  
     
 465  
     static public String generateStatementTreeId() {
 466  0
         return (NEW_STMT_TREE_ID + Integer.toString(tempProgReqInfoID++));
 467  
     }
 468  
 }