Coverage Report - org.kuali.student.lum.lu.ui.course.client.widgets.CourseWorkflowActionList
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseWorkflowActionList
0%
0/125
0%
0/36
1.75
CourseWorkflowActionList$1
0%
0/3
N/A
1.75
CourseWorkflowActionList$10
0%
0/4
0%
0/2
1.75
CourseWorkflowActionList$11
0%
0/11
0%
0/4
1.75
CourseWorkflowActionList$11$1
0%
0/15
0%
0/6
1.75
CourseWorkflowActionList$12
0%
0/8
N/A
1.75
CourseWorkflowActionList$13
0%
0/6
N/A
1.75
CourseWorkflowActionList$14
0%
0/8
0%
0/2
1.75
CourseWorkflowActionList$2
0%
0/7
0%
0/2
1.75
CourseWorkflowActionList$3
0%
0/3
N/A
1.75
CourseWorkflowActionList$4
0%
0/2
N/A
1.75
CourseWorkflowActionList$5
0%
0/6
0%
0/2
1.75
CourseWorkflowActionList$6
0%
0/4
N/A
1.75
CourseWorkflowActionList$7
0%
0/3
N/A
1.75
CourseWorkflowActionList$8
0%
0/3
N/A
1.75
CourseWorkflowActionList$9
0%
0/5
0%
0/2
1.75
 
 1  
 package org.kuali.student.lum.lu.ui.course.client.widgets;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.kuali.student.common.assembly.data.QueryPath;
 7  
 import org.kuali.student.common.dto.DtoConstants;
 8  
 import org.kuali.student.common.dto.StatusInfo;
 9  
 import org.kuali.student.common.rice.StudentIdentityConstants;
 10  
 import org.kuali.student.common.ui.client.application.Application;
 11  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 12  
 import org.kuali.student.common.ui.client.application.ViewContext;
 13  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 14  
 import org.kuali.student.common.ui.client.configurable.mvc.sections.VerticalSection;
 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.history.HistoryManager;
 18  
 import org.kuali.student.common.ui.client.service.SecurityRpcService;
 19  
 import org.kuali.student.common.ui.client.service.SecurityRpcServiceAsync;
 20  
 import org.kuali.student.common.ui.client.widgets.KSButton;
 21  
 import org.kuali.student.common.ui.client.widgets.KSButtonAbstract.ButtonStyle;
 22  
 import org.kuali.student.common.ui.client.widgets.KSCheckBox;
 23  
 import org.kuali.student.common.ui.client.widgets.KSLabel;
 24  
 import org.kuali.student.common.ui.client.widgets.KSLightBox;
 25  
 import org.kuali.student.common.ui.client.widgets.KSRadioButton;
 26  
 import org.kuali.student.common.ui.client.widgets.StylishDropDown;
 27  
 import org.kuali.student.common.ui.client.widgets.menus.KSMenuItemData;
 28  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotification;
 29  
 import org.kuali.student.common.ui.client.widgets.notification.KSNotifier;
 30  
 import org.kuali.student.common.ui.client.widgets.progress.BlockingTask;
 31  
 import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator;
 32  
 import org.kuali.student.common.ui.shared.IdAttributes.IdType;
 33  
 import org.kuali.student.lum.common.client.widgets.AppLocations;
 34  
 import org.kuali.student.lum.lu.LUConstants;
 35  
 import org.kuali.student.lum.lu.assembly.data.client.constants.orch.CreditCourseConstants;
 36  
 import org.kuali.student.lum.lu.ui.course.client.service.CourseRpcService;
 37  
 import org.kuali.student.lum.lu.ui.course.client.service.CourseRpcServiceAsync;
 38  
 import org.kuali.student.lum.lu.ui.main.client.configuration.CurriculumHomeConfigurer;
 39  
 
 40  
 import com.google.gwt.core.client.GWT;
 41  
 import com.google.gwt.event.dom.client.ClickEvent;
 42  
 import com.google.gwt.event.dom.client.ClickHandler;
 43  
 import com.google.gwt.event.logical.shared.ValueChangeEvent;
 44  
 import com.google.gwt.event.logical.shared.ValueChangeHandler;
 45  
 import com.google.gwt.user.client.Window;
 46  
 import com.google.gwt.user.client.rpc.AsyncCallback;
 47  
 import com.google.gwt.user.client.ui.Anchor;
 48  
 import com.google.gwt.user.client.ui.FlowPanel;
 49  
 import com.google.gwt.user.client.ui.HorizontalPanel;
 50  
 import com.google.gwt.user.client.ui.VerticalPanel;
 51  
 import com.google.gwt.user.client.ui.Widget;
 52  
 
 53  0
 public class CourseWorkflowActionList extends StylishDropDown {
 54  
     private static final String MSG_GROUP = "course";
 55  
     
 56  0
         private static final BlockingTask processingTask = new BlockingTask("Processing State Change....");
 57  0
         private static final CourseRpcServiceAsync courseServiceAsync = GWT.create(CourseRpcService.class);    
 58  
 
 59  
     private KSMenuItemData modifyCourseActionItem;
 60  
         private KSMenuItemData activateCourseActionItem;
 61  
         private KSMenuItemData inactivateCourseActionItem;
 62  
         private KSMenuItemData retireCourseActionItem;
 63  
         private KSMenuItemData copyCourseActionItem;
 64  
         
 65  0
         private final KSLightBox activateDialog = new KSLightBox();
 66  0
         private VerticalSection activateSection = new VerticalSection();
 67  
     
 68  
     private boolean isCurrentVersion;
 69  0
     private Boolean isInitialized = false;
 70  
     private String courseId;
 71  
     
 72  0
     private boolean hasAdminAccess = false;
 73  
        
 74  
     
 75  
     // Storing this list at multiple layers: here and in StylishDropDown.menu.items.  We need it here to test for empty
 76  0
     private List<KSMenuItemData> items = new ArrayList<KSMenuItemData>();
 77  
     
 78  
     public CourseWorkflowActionList(String label) {
 79  0
             super(label);
 80  
             
 81  0
             this.setVisible(false);
 82  0
         this.addStyleName("KS-Workflow-DropDown");
 83  
             
 84  0
     }
 85  
 
 86  
         public CourseWorkflowActionList(String label, final ViewContext viewContext, final String modifyPath, DataModel model, final Callback<String> stateChangeCallback) {
 87  0
             super(label);
 88  
         
 89  0
             this.setVisible(false);
 90  0
         this.addStyleName("KS-Workflow-DropDown");
 91  
         
 92  0
         init(viewContext, modifyPath, model, stateChangeCallback);
 93  0
         }
 94  
         
 95  
         public void init (final ViewContext viewContext, final String modifyPath, final DataModel model, final Callback<String> stateChangeCallback) {
 96  
 
 97  0
                 if (!this.isInitialized) {
 98  0
                     buildActivateDialog(stateChangeCallback);
 99  
                     
 100  0
                     this.isCurrentVersion = true;
 101  
                     
 102  
                     // TODO: use messages
 103  0
                        modifyCourseActionItem = new KSMenuItemData(this.getMessage("cluModifyItem"), new ClickHandler(){
 104  
                 
 105  
                                         @Override
 106  
                                         public void onClick(ClickEvent event) {
 107  
                                                 
 108  0
                                                 checkAdminPermission("cluModifyItem", viewContext, modifyPath, model);
 109  0
                                         }
 110  
                                 });
 111  
             
 112  0
                     copyCourseActionItem = new KSMenuItemData(this.getMessage("cluCopyItem"), new ClickHandler(){
 113  
                                 @Override
 114  
                                 public void onClick(ClickEvent event) {
 115  0
                                     if(hasCourseId(viewContext)){
 116  0
                                             viewContext.setId((String)model.get(CreditCourseConstants.ID));
 117  0
                                                 viewContext.setIdType(IdType.COPY_OF_OBJECT_ID);
 118  0
                                                 viewContext.getAttributes().remove(StudentIdentityConstants.DOCUMENT_TYPE_NAME);
 119  
                                 }
 120  0
                                         HistoryManager.navigate(modifyPath, viewContext);
 121  0
                                 }
 122  
                         });
 123  0
                     activateCourseActionItem = new KSMenuItemData(this.getMessage("cluActivateItem"), new ClickHandler(){
 124  
         
 125  
                                 @Override
 126  
                                 public void onClick(ClickEvent event) {
 127  0
                                         showStateDialog(DtoConstants.STATE_ACTIVE);
 128  0
                                 }
 129  
                         });
 130  0
                     inactivateCourseActionItem = new KSMenuItemData(this.getMessage("cluInactivateItem") + " (Not Yet Implemented)", new ClickHandler(){
 131  
         
 132  
                                 @Override
 133  
                                 public void onClick(ClickEvent event) {
 134  
                                                 // TODO: Inactivate
 135  0
                                 }
 136  
                         });
 137  0
                     retireCourseActionItem = new KSMenuItemData(this.getMessage("cluRetireItem"), new ClickHandler(){
 138  
         
 139  
                                 @Override
 140  
                                 public void onClick(ClickEvent event) {
 141  0
                                     if(hasCourseId(viewContext)){
 142  0
                                                 viewContext.setId(courseId);
 143  0
                                                 viewContext.setIdType(IdType.OBJECT_ID);
 144  
                                 }
 145  
                                         
 146  0
                                     Application.navigate(AppLocations.Locations.COURSE_RETIRE.getLocation(), viewContext);                                    
 147  0
                                 }
 148  
                         });
 149  
                 }
 150  
                 
 151  0
                 this.isInitialized = true;
 152  0
     }
 153  
     
 154  
     private void doModifyActionItem(ViewContext viewContext, String modifyPath, DataModel model){
 155  0
             if(hasCourseId(viewContext)){
 156  0
                         viewContext.setId(getCourseVersionIndId(model));
 157  0
                         viewContext.setIdType(IdType.COPY_OF_OBJECT_ID);
 158  0
             viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, LUConstants.PROPOSAL_TYPE_COURSE_MODIFY);
 159  
         }
 160  
 
 161  0
                 HistoryManager.navigate(modifyPath, viewContext);
 162  0
     }
 163  
     
 164  
         private void showStateDialog(String newState) {
 165  0
             if (newState.equals(DtoConstants.STATE_RETIRED)) {
 166  
                     // TODO: create Retire dialog
 167  0
             } else if (newState.equals(DtoConstants.STATE_ACTIVE)) {                     
 168  
                     // TODO: use message e.g. activateCurrentInstr, activateModificationInstr                    
 169  0
                     activateSection.setInstructions(getInstructions(newState));                                    
 170  0
                 activateDialog.show();
 171  0
             } else if (newState.equals(DtoConstants.STATE_SUSPENDED)) {
 172  
                     // TODO: create Inactivate dialog
 173  
             }
 174  
             
 175  0
     }
 176  
         
 177  
     private String getInstructions(String newState) {            
 178  0
             if (isCurrentVersion){
 179  
                     // TODO: message
 180  0
                     return "Activating this course makes it viewable and available for scheduling.";
 181  
             } else { 
 182  
                     // TODO: message
 183  0
                     return "Activate this course makes it viewable and available for scheduling. The previous version will be inactivated, and available for reference in the version history.";
 184  
             }
 185  
     }
 186  
     
 187  
     private void buildActivateDialog(final Callback<String> stateChangeCallback){
 188  0
             FlowPanel panel = new FlowPanel();
 189  
             
 190  0
             activateDialog.setMaxHeight(200);
 191  0
             activateDialog.setMaxWidth(200);
 192  
             
 193  
             // TODO: use messages
 194  0
             activateSection = new VerticalSection(SectionTitle.generateH2Title("Activate Course"));
 195  
             
 196  0
         panel.add((Widget)activateSection);
 197  
             
 198  0
             KSButton activate = new KSButton("Activate",new ClickHandler(){
 199  
             public void onClick(ClickEvent event) {
 200  
                 //activateSection.updateModel(cluModel);
 201  
                 //set previous active to superseded
 202  
                 //set this version to active
 203  0
                 setCourseState(courseId, DtoConstants.STATE_ACTIVE, stateChangeCallback);
 204  0
                 activateDialog.hide();                
 205  0
             }
 206  
             });
 207  0
             activateDialog.addButton(activate);
 208  
             
 209  0
             KSButton cancel = new KSButton("Cancel", ButtonStyle.ANCHOR_LARGE_CENTERED, new ClickHandler(){
 210  
             public void onClick(ClickEvent event) {
 211  0
                 activateDialog.hide();
 212  0
             }
 213  
             });
 214  0
             activateDialog.addButton(cancel);
 215  
 
 216  0
             activateDialog.setWidget(panel);
 217  0
     }
 218  
     
 219  
     private void buildModifyDialog(final ViewContext viewContext, final String modifyPath, final DataModel model){
 220  0
             final KSLightBox modifyDialog = new KSLightBox();
 221  
             
 222  
             //Create a dialog for course selection
 223  0
             modifyDialog.setTitle((getMessage("modifyCourse")));
 224  
 
 225  0
         final VerticalPanel layout = new VerticalPanel();
 226  0
         layout.addStyleName("ks-form-module-fields");
 227  
                 
 228  0
         final KSButton continueButton = new KSButton(getMessage("continue"));
 229  
         
 230  0
         modifyDialog.addButton(continueButton);
 231  0
         Anchor cancelLink = new Anchor("Cancel");
 232  0
         cancelLink.addClickHandler(new ClickHandler(){
 233  
                         public void onClick(ClickEvent event) {
 234  0
                                 modifyDialog.hide();
 235  0
                         }
 236  
         });
 237  0
         modifyDialog.addButton(cancelLink);
 238  
         
 239  0
         HorizontalPanel titlePanel = new HorizontalPanel();
 240  0
         KSLabel titleLabel = new KSLabel(getMessage("modifyCourseSubTitle"));
 241  0
         titleLabel.addStyleName("bold");
 242  0
         titlePanel.add(titleLabel);
 243  
         
 244  0
         layout.add(titlePanel);
 245  
         
 246  0
         final KSRadioButton radioOptionModifyNoVersion = new KSRadioButton("modifyCreditCourseButtonGroup", getMessage("modifyCourseNoVersion"));
 247  0
         final KSRadioButton radioOptionModifyWithVersion = new KSRadioButton("modifyCreditCourseButtonGroup", getMessage("modifyCourseWithVersion"));
 248  0
         final KSCheckBox curriculumReviewOption = new KSCheckBox(getMessage("useCurriculumReview"));
 249  
         
 250  0
         radioOptionModifyNoVersion.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 251  
                         public void onValueChange(ValueChangeEvent<Boolean> event) {
 252  0
                                 if(event.getValue()){
 253  0
                             curriculumReviewOption.setEnabled(false);
 254  0
                             curriculumReviewOption.setValue(false);
 255  
                                 }
 256  0
                         }
 257  
         });
 258  0
         radioOptionModifyNoVersion.setValue(true);
 259  0
             curriculumReviewOption.setEnabled(false);
 260  
         
 261  0
         radioOptionModifyWithVersion.addValueChangeHandler(new ValueChangeHandler<Boolean>(){
 262  
                         public void onValueChange(ValueChangeEvent<Boolean> event) {
 263  0
                                 if(event.getValue()){
 264  0
                             curriculumReviewOption.setEnabled(true);
 265  
                                 }
 266  0
                         }
 267  
         });
 268  
         
 269  0
         continueButton.addClickHandler(new ClickHandler(){
 270  
                         @Override
 271  
                         public void onClick(ClickEvent event) {
 272  0
                                 if (radioOptionModifyNoVersion.getValue()){
 273  0
                                         viewContext.setId(courseId);
 274  0
                                         viewContext.setIdType(IdType.OBJECT_ID);
 275  0
                                         Application.navigate(AppLocations.Locations.COURSE_ADMIN_NO_VERSION.getLocation(), viewContext);
 276  0
                                 } else if (radioOptionModifyWithVersion.getValue()){
 277  
                                     
 278  0
                                     String courseVerIndId = getCourseVersionIndId(model);
 279  0
                                 Long courseVersionSequence = getCourseVersionSequenceNumber(model);
 280  
                                     
 281  0
                                     courseServiceAsync.isLatestVersion(courseVerIndId, courseVersionSequence, new AsyncCallback<Boolean>(){
 282  
                                         
 283  
                                 public void onFailure(Throwable caught) {
 284  0
                                     KSNotifier.add(new KSNotification("Error determining latest version of course", false, 5000));
 285  0
                                 }
 286  
                                 
 287  
                                 public void onSuccess(Boolean result) {
 288  0
                                     if (result){
 289  0
                                         if (curriculumReviewOption.getValue()){
 290  0
                                             doModifyActionItem(viewContext, modifyPath, model);
 291  
                                         } else {
 292  0
                                             if(hasCourseId(viewContext)){
 293  0
                                                 viewContext.setId(getCourseVersionIndId(model));
 294  0
                                                 viewContext.setIdType(IdType.COPY_OF_OBJECT_ID);
 295  
                                                 // FIXME: This needs to use a new workflow document type for admin modify with version
 296  0
                                                 viewContext.setAttribute(StudentIdentityConstants.DOCUMENT_TYPE_NAME, LUConstants.PROPOSAL_TYPE_COURSE_MODIFY_ADMIN);
 297  
                                             }
 298  
 
 299  0
                                             Application.navigate(AppLocations.Locations.COURSE_ADMIN.getLocation(), viewContext);
 300  
                                         }
 301  
                                     } else {
 302  0
                                         isCurrentVersion = result;
 303  0
                                         doUpdateCourseActionItems(model);
 304  0
                                         KSNotifier.add(new KSNotification("Error creating new version for course, this is not the latest version.", false, 5000));
 305  
                                     }
 306  0
                                 }
 307  
                             });                                    
 308  
                                     
 309  
                                 }
 310  0
                             modifyDialog.hide();
 311  0
                         }                
 312  
         });
 313  
         
 314  
         //Check that this is the latest version with an async call and only show modify with version options if it is the latest
 315  
        
 316  0
         layout.add(radioOptionModifyNoVersion);
 317  0
         if(isCurrentVersion){
 318  0
                 layout.add(radioOptionModifyWithVersion);
 319  0
             layout.add(curriculumReviewOption);
 320  
         }
 321  0
         modifyDialog.setWidget(layout);
 322  0
         modifyDialog.show();
 323  0
     }
 324  
     
 325  
     // TODO: add Retire and Inactivate Dialogs
 326  
     
 327  
         /**
 328  
          * Use this method to call the {@link CourseRpcServiceAsync#changeState(String, String, com.google.gwt.user.client.rpc.AsyncCallback)
 329  
          * method, which will handle all related change state operations required for the course depending on the state being set.  
 330  
          *  
 331  
          * @param courseId
 332  
          * @param newState
 333  
          * @param stateChangeCallback The callback to execute to indicate if the state change call was successful.
 334  
          */
 335  
     public static void setCourseState(final String courseId, final String newState, final Callback<String> stateChangeCallback) {
 336  0
             KSBlockingProgressIndicator.addTask(processingTask);
 337  
             
 338  0
             courseServiceAsync.changeState(courseId, newState, new KSAsyncCallback<StatusInfo>() {
 339  
                     
 340  
                     @Override
 341  
                  public void handleFailure(Throwable caught) {
 342  0
                      Window.alert("Error Updating State: "+caught.getMessage());
 343  0
                      KSBlockingProgressIndicator.removeTask(processingTask);
 344  0
                      stateChangeCallback.exec(null);
 345  0
                  }
 346  
          
 347  
                  @Override
 348  
                  public void onSuccess(StatusInfo result) {                         
 349  0
                          KSBlockingProgressIndicator.removeTask(processingTask);
 350  0
                          stateChangeCallback.exec(newState);
 351  0
                  }
 352  
             });
 353  
             
 354  0
     }
 355  
     
 356  
     
 357  
         /**
 358  
          *  This depends heavily on {@link CourseStateUtil#setCourseState(String, String, Callback)}. 
 359  
          *  Changes here will affect assumptions made there.
 360  
           *
 361  
          */
 362  
     public void updateCourseActionItems(final DataModel cluModel) {
 363  
             
 364  
                 //First we need the model
 365  0
                 String courseVerIndId = getCourseVersionIndId(cluModel);
 366  0
                 Long courseVersionSequence = getCourseVersionSequenceNumber(cluModel);
 367  
                 //Do an async check if this is the current version
 368  0
                 if(courseVerIndId==null){
 369  0
                         isCurrentVersion = true;
 370  0
                         doUpdateCourseActionItems(cluModel);
 371  
                 }else{
 372  0
                         courseServiceAsync.isLatestVersion(courseVerIndId, courseVersionSequence, new AsyncCallback<Boolean>(){
 373  
                                 public void onFailure(Throwable caught) {
 374  0
                                         KSNotifier.add(new KSNotification("Error determining latest version of course", false, 5000));
 375  0
                                 }
 376  
                                 
 377  
                                 public void onSuccess(Boolean result) {
 378  0
                                         isCurrentVersion = result;
 379  0
                                         doUpdateCourseActionItems(cluModel);
 380  0
                                 }
 381  
                         });
 382  
                 }
 383  0
     }
 384  
     
 385  
         private void doUpdateCourseActionItems(DataModel cluModel) {
 386  
                 
 387  0
             String cluState = cluModel.get("state");
 388  0
             courseId = cluModel.get(CreditCourseConstants.ID);
 389  
             
 390  0
             items.clear();      
 391  
             
 392  0
             if (cluState.equals(DtoConstants.STATE_APPROVED)) {
 393  0
                     items.add(modifyCourseActionItem);
 394  0
                     items.add(activateCourseActionItem);
 395  0
                     if (isCurrentVersion) {
 396  0
                             items.add(retireCourseActionItem);
 397  
                     }
 398  0
             } else if (cluState.equals(DtoConstants.STATE_ACTIVE)) {
 399  0
                     items.add(modifyCourseActionItem);
 400  0
                     items.add(inactivateCourseActionItem);
 401  0
                     items.add(retireCourseActionItem);
 402  0
             } else if (cluState.equals(DtoConstants.STATE_SUSPENDED)) {
 403  0
                     items.add(activateCourseActionItem);
 404  
             }
 405  
             
 406  0
                 items.add(copyCourseActionItem);
 407  
 
 408  0
             setItems(items);
 409  
                 
 410  0
             CourseWorkflowActionList.this.setEnabled(true);
 411  0
                 if(CourseWorkflowActionList.this.isEmpty()) {
 412  0
                         CourseWorkflowActionList.this.setVisible(false);
 413  
                 }
 414  
                 else{
 415  0
                         CourseWorkflowActionList.this.setVisible(true);
 416  
                 }
 417  0
         }
 418  
         
 419  
     public boolean isEmpty() {
 420  0
             return (items.size() == 0);
 421  
     }
 422  
     
 423  
     public String getMessage(String courseMessageKey) {
 424  0
             String msg = Application.getApplicationContext().getMessage(MSG_GROUP, courseMessageKey);
 425  0
             if (msg == null) {
 426  0
                     msg = courseMessageKey;
 427  
             }
 428  0
             return msg;
 429  
     }
 430  
 
 431  
 
 432  
     /** 
 433  
      * This checks the ViewContext passed in to determine if it contains a non-empty courseId
 434  
      * 
 435  
      * @return  true if view context contains non-empty courseId, false otherwise
 436  
      */
 437  
     private boolean hasCourseId(ViewContext viewContext){
 438  0
             return viewContext != null && viewContext.getId() != null && !viewContext.getId().isEmpty();
 439  
     }
 440  
 
 441  
     /**
 442  
      * Retrieves the version independent from the course data model
 443  
      * 
 444  
      * @param courseModel
 445  
      * @return version independent id of course
 446  
      */
 447  
     private String getCourseVersionIndId(DataModel courseModel){
 448  0
             return (String)courseModel.get(CreditCourseConstants.VERSION_INFO + QueryPath.getPathSeparator() + CreditCourseConstants.VERSION_IND_ID);            
 449  
     }
 450  
     
 451  
     /**
 452  
      * Retrieves the version sequence number from the course data model
 453  
      * 
 454  
      * @param courseModel
 455  
      * @return version sequence number id of course
 456  
      */
 457  
     private Long getCourseVersionSequenceNumber(DataModel courseModel){
 458  0
                    return (Long)courseModel.get(CreditCourseConstants.VERSION_INFO + QueryPath.getPathSeparator() + CreditCourseConstants.VERSION_SEQ_NUMBER);
 459  
     }
 460  
 
 461  
     private void checkAdminPermission(String screenComponent, final ViewContext viewContext, final String modifyPath, final DataModel model) {
 462  0
                 String principalId = Application.getApplicationContext().getUserId();
 463  0
                 SecurityRpcServiceAsync securityRpc = GWT
 464  
                                 .create(SecurityRpcService.class);
 465  
 
 466  0
                 securityRpc.checkAdminPermission(principalId, screenComponent,
 467  0
                                 new KSAsyncCallback<Boolean>() {
 468  
                                         public void handleFailure(Throwable caught) {
 469  
                                                 // Assume no admin access on failure
 470  0
                                                 doModifyActionItem(viewContext, modifyPath, model);
 471  0
                                         }
 472  
 
 473  
                                         @Override
 474  
                                         public void onSuccess(Boolean result) {
 475  0
                                                 hasAdminAccess = result;
 476  
 //                                    if ("admin".equals(Application.getApplicationContext().getUserId())){
 477  0
                                    if (hasAdminAccess){
 478  
                                                     //Admin users have the option to make modifications to the course administratively or via the
 479  
                                             //curriculum review process. Clicking on the "Modify Course" item will present the user with
 480  
                                             //a modify dialog to allow them to choose the method of modification.
 481  0
                                                                     buildModifyDialog(viewContext, modifyPath, model);
 482  
                                     } else {
 483  
                                             //Non-admin users are only allowed to make modifications via proposal curriculum review process.
 484  
                                             //Clicking the "Modify Course" item will simply navigate user directly to modify course proposal screen.
 485  
 //                                                    modifyCourseActionItem = new KSMenuItemData(CourseWorkflowActionList.this.getMessage("cluModifyItem"), new ClickHandler(){
 486  0
                                                                         doModifyActionItem(viewContext, modifyPath, model);
 487  
                                     }
 488  
 
 489  
 
 490  0
                                         }
 491  
                                 });
 492  
 //                System.out.println(principalId + " access for " + screenComponent
 493  
 //                                + " is : " + hasAdminAccess);
 494  0
         }
 495  
 }