Coverage Report - org.kuali.student.lum.lu.ui.course.client.controllers.CourseAdminRetireController
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseAdminRetireController
0%
0/29
N/A
1.143
CourseAdminRetireController$1
0%
0/3
N/A
1.143
CourseAdminRetireController$2
0%
0/3
N/A
1.143
CourseAdminRetireController$3
0%
0/7
0%
0/2
1.143
CourseAdminRetireController$3$1
0%
0/6
0%
0/2
1.143
 
 1  
 package org.kuali.student.lum.lu.ui.course.client.controllers;
 2  
 
 3  
 import org.kuali.student.common.dto.DtoConstants;
 4  
 import org.kuali.student.common.ui.client.application.Application;
 5  
 import org.kuali.student.common.ui.client.application.ViewContext;
 6  
 import org.kuali.student.common.ui.client.event.ActionEvent;
 7  
 import org.kuali.student.common.ui.client.event.SaveActionEvent;
 8  
 import org.kuali.student.common.ui.client.mvc.ActionCompleteCallback;
 9  
 import org.kuali.student.common.ui.client.mvc.Callback;
 10  
 import org.kuali.student.common.ui.client.mvc.DataModel;
 11  
 import org.kuali.student.common.ui.client.service.BaseDataOrchestrationRpcServiceAsync;
 12  
 import org.kuali.student.common.ui.client.util.WindowTitleUtils;
 13  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 14  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotification;
 15  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotifier;
 16  
 import org.kuali.student.common.ui.shared.IdAttributes.IdType;
 17  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 18  
 import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants;
 19  
 import org.kuali.student.lum.lu.ui.course.client.configuration.CourseAdminRetireConfigurer;
 20  
 import org.kuali.student.lum.lu.ui.course.client.widgets.CourseWorkflowActionList;
 21  
 
 22  
 import com.google.gwt.core.client.GWT;
 23  
 import com.google.gwt.event.dom.client.ClickEvent;
 24  
 import com.google.gwt.event.dom.client.ClickHandler;
 25  
 
 26  
 /**
 27  
  * Controller for retire screen
 28  
  * 
 29  
  * @author Will
 30  
  *
 31  
  */
 32  0
 public class CourseAdminRetireController extends CourseAdminWithoutVersionController{
 33  
                 
 34  
         /**
 35  
          * Override the intitailzeController method to use CourseAdminConfigurer 
 36  
          */
 37  
         @Override
 38  
         protected void initializeController() {
 39  
                    
 40  0
                 super.cfg = GWT.create(CourseAdminRetireConfigurer.class);
 41  
                 
 42  0
                    cfg.setState(DtoConstants.STATE_RETIRED.toUpperCase());
 43  0
                    super.setDefaultModelId(cfg.getModelId());
 44  0
                    super.registerModelsAndHandlers();
 45  0
                    super.addStyleName("ks-course-admin");                                                
 46  0
     }
 47  
         
 48  
         /**
 49  
          * Override the getSaveButton to provide a new set of buttons for the admin screens
 50  
          */
 51  
         @Override
 52  
         public KSButton getSaveButton(){
 53  0
                 KSButton saveButton =  new KSButton("Retire", new ClickHandler(){
 54  
             public void onClick(ClickEvent event) {
 55  0
                     handleButtonClick(DtoConstants.STATE_RETIRED);                    
 56  0
             }
 57  
         });
 58  
                 
 59  0
                 return saveButton;
 60  
         }
 61  
                                 
 62  
         public KSButton getCancelButton(){
 63  0
                 KSButton button = new KSButton("Cancel", new ClickHandler(){
 64  
             public void onClick(ClickEvent event) {       
 65  0
                     Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation());
 66  0
             }
 67  
         });
 68  
         
 69  0
                 button.addStyleName("ks-button-spacing");
 70  0
                 return button;
 71  
     }
 72  
         
 73  
         /**
 74  
          * This processes the save or activate button clicks
 75  
          * 
 76  
          * @param state The state to set on the course when saving course data.
 77  
          */
 78  
         protected void handleButtonClick(final String state){
 79  0
                 final SaveActionEvent saveActionEvent = new SaveActionEvent(false);
 80  
 
 81  0
             saveActionEvent.setActionCompleteCallback(new ActionCompleteCallback(){
 82  
                         @Override
 83  
                         public void onActionComplete(ActionEvent actionEvent) {
 84  0
                                 if (saveActionEvent.isSaveSuccessful()){
 85  0
                         final ViewContext viewContext = new ViewContext();
 86  0
                         viewContext.setId((String)cluProposalModel.get(CreditCourseConstants.ID));
 87  0
                         viewContext.setIdType(IdType.OBJECT_ID);                                                                                        
 88  
 
 89  
                         
 90  0
                                         CourseWorkflowActionList.setCourseState(viewContext.getId(), DtoConstants.STATE_RETIRED, new Callback<String>(){
 91  
                                                 @Override
 92  
                                                 public void exec(String result) {
 93  0
                                                         if (result == null){
 94  0
                                                                 KSNotifier.add(new KSNotification("Course saved, but unable to set retire state.", false, true, 5000));
 95  
                                                         } else {
 96  0
                                                                 KSNotifier.show("Course saved and retired.");                                                                        
 97  0
                                                                 Application.navigate(AppLocations.Locations.VIEW_COURSE.getLocation(), viewContext);
 98  
                                                         }                                                        
 99  0
                                                 }
 100  
                                         });                                                        
 101  
                                 }      
 102  0
                         }
 103  
             });
 104  
             
 105  0
                    CourseAdminRetireController.this.fireApplicationEvent(saveActionEvent);                    
 106  0
         }
 107  
         
 108  
         
 109  
         /**
 110  
      * Override the setHeaderTitle to display proper header title for admin screens
 111  
      */
 112  
         @Override
 113  
         protected void setHeaderTitle(){
 114  0
                 StringBuffer sb = new StringBuffer();
 115  0
                 sb.append(cluProposalModel.get(cfg.getCourseTitlePath()));
 116  0
                 sb.append(" (Retirement)");
 117  
                                 
 118  0
                 currentTitle = sb.toString();
 119  
                 
 120  0
                 this.setContentTitle(currentTitle);
 121  0
             this.setName(currentTitle);
 122  0
             WindowTitleUtils.setContextTitle(currentTitle);                
 123  0
     }
 124  
 
 125  
         protected  BaseDataOrchestrationRpcServiceAsync getCourseProposalRpcService(){
 126  0
             return courseServiceAsync;
 127  
     }
 128  
             
 129  
     public boolean startSectionRequired(){
 130  
             //There is no start section for retire screen
 131  0
             return false;
 132  
     }
 133  
 
 134  
     @Override
 135  
         public boolean isAuthorizationRequired() {
 136  
                 //FIXME: Need to add proper authorization checks for admin modify.
 137  0
                 return false;
 138  
         }
 139  
 
 140  
         @Override
 141  
         protected void progressiveEnableFields() {
 142  
                 //Does nothing, there are no progressive enabled fields on retire screens.
 143  0
         }
 144  
         
 145  
         /**
 146  
          * Override the getStateforSaveAction since the save action for retire course will change state to 
 147  
          * retired.  
 148  
          */
 149  
         @Override
 150  
     protected String getStateforSaveAction(DataModel model){
 151  0
             return cfg.getState();
 152  
     }
 153  
     
 154  
 }