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