Coverage Report - org.kuali.student.lum.lu.ui.course.client.requirements.CourseRequirementsManageView
 
Classes in this File Line Coverage Branch Coverage Complexity
CourseRequirementsManageView
0%
0/108
0%
0/20
1.548
CourseRequirementsManageView$1
0%
0/4
0%
0/2
1.548
CourseRequirementsManageView$10
0%
0/5
0%
0/2
1.548
CourseRequirementsManageView$10$1
0%
0/6
N/A
1.548
CourseRequirementsManageView$11
0%
0/7
0%
0/4
1.548
CourseRequirementsManageView$2
0%
0/5
N/A
1.548
CourseRequirementsManageView$3
0%
0/3
N/A
1.548
CourseRequirementsManageView$4
0%
0/8
0%
0/2
1.548
CourseRequirementsManageView$4$1
0%
0/26
0%
0/8
1.548
CourseRequirementsManageView$5
0%
0/3
N/A
1.548
CourseRequirementsManageView$6
0%
0/11
0%
0/4
1.548
CourseRequirementsManageView$7
0%
0/3
N/A
1.548
CourseRequirementsManageView$7$1
0%
0/6
N/A
1.548
CourseRequirementsManageView$7$1$1
0%
0/6
N/A
1.548
CourseRequirementsManageView$8
0%
0/3
N/A
1.548
CourseRequirementsManageView$8$1
0%
0/6
N/A
1.548
CourseRequirementsManageView$8$1$1
0%
0/6
N/A
1.548
CourseRequirementsManageView$9
0%
0/3
N/A
1.548
CourseRequirementsManageView$9$1
0%
0/6
N/A
1.548
 
 1  
 /**
 2  
  * Copyright 2010 The Kuali Foundation Licensed under the
 3  
  * Educational Community License, Version 2.0 (the "License"); you may
 4  
  * not use this file except in compliance with the License. You may
 5  
  * obtain a copy of the License at
 6  
  *
 7  
  * http://www.osedu.org/licenses/ECL-2.0
 8  
  *
 9  
  * Unless required by applicable law or agreed to in writing,
 10  
  * software distributed under the License is distributed on an "AS IS"
 11  
  * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 12  
  * or implied. See the License for the specific language governing
 13  
  * permissions and limitations under the License.
 14  
  */
 15  
 
 16  
 package org.kuali.student.lum.lu.ui.course.client.requirements;
 17  
 
 18  
 import java.util.HashMap;
 19  
 import java.util.List;
 20  
 import java.util.Map;
 21  
 
 22  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 23  
 import org.kuali.student.common.ui.client.configurable.mvc.SectionTitle;
 24  
 import org.kuali.student.common.ui.client.configurable.mvc.views.VerticalSectionView;
 25  
 import org.kuali.student.common.ui.client.mvc.Callback;
 26  
 import org.kuali.student.common.ui.client.service.MetadataRpcService;
 27  
 import org.kuali.student.common.ui.client.service.MetadataRpcServiceAsync;
 28  
 import org.kuali.student.common.ui.client.widgets.KSProgressIndicator;
 29  
 import org.kuali.student.common.ui.client.widgets.buttongroups.ButtonEnumerations;
 30  
 import org.kuali.student.common.ui.client.widgets.field.layout.button.ActionCancelGroup;
 31  
 import org.kuali.student.common.ui.client.widgets.progress.BlockingTask;
 32  
 import org.kuali.student.common.ui.client.widgets.progress.KSBlockingProgressIndicator;
 33  
 import org.kuali.student.common.ui.client.widgets.rules.ReqCompEditWidget;
 34  
 import org.kuali.student.common.ui.client.widgets.rules.ReqComponentInfoUi;
 35  
 import org.kuali.student.common.ui.client.widgets.rules.RuleManageWidget;
 36  
 import org.kuali.student.common.ui.client.widgets.rules.RulesUtil;
 37  
 import org.kuali.student.core.assembly.data.Metadata;
 38  
 import org.kuali.student.core.statement.dto.*;
 39  
 import org.kuali.student.core.versionmanagement.dto.VersionDisplayInfo;
 40  
 import org.kuali.student.lum.common.client.widgets.*;
 41  
 import org.kuali.student.lum.lu.dto.CluInfo;
 42  
 import org.kuali.student.lum.lu.ui.course.client.service.LuRpcService;
 43  
 import org.kuali.student.lum.lu.ui.course.client.service.LuRpcServiceAsync;
 44  
 import org.kuali.student.lum.program.client.rpc.StatementRpcService;
 45  
 import org.kuali.student.lum.program.client.rpc.StatementRpcServiceAsync;
 46  
 
 47  
 import com.google.gwt.core.client.GWT;
 48  
 import com.google.gwt.user.client.Window;
 49  
 import com.google.gwt.user.client.rpc.AsyncCallback;
 50  
 import com.google.gwt.user.client.ui.SimplePanel;
 51  
 import com.google.gwt.user.client.ui.VerticalPanel;
 52  
 import com.google.gwt.user.client.ui.Widget;
 53  
 
 54  0
 public class CourseRequirementsManageView extends VerticalSectionView {
 55  
 
 56  0
     private StatementRpcServiceAsync statementRpcServiceAsync = GWT.create(StatementRpcService.class);
 57  0
     private MetadataRpcServiceAsync metadataServiceAsync = GWT.create(MetadataRpcService.class);
 58  0
     private LuRpcServiceAsync luRpcServiceAsync = GWT.create(LuRpcService.class);    
 59  
 
 60  
     protected static final String TEMLATE_LANGUAGE = "en";
 61  
     protected static final String RULEEDIT_TEMLATE = "KUALI.RULE";
 62  
     protected static final String RULEPREVIEW_TEMLATE = "KUALI.RULE.PREVIEW";
 63  
     protected static final String COMPOSITION_TEMLATE = "KUALI.RULE.COMPOSITION";
 64  
     private static final String LU_NAMESPACE = "http://student.kuali.org/wsdl/lu";
 65  
     private static final String CLU_NAMESPACE_URI = "{" + LU_NAMESPACE + "}cluInfo";
 66  
 
 67  
     private CourseRequirementsViewController parentController;
 68  
 
 69  
     //view's widgets
 70  0
     private VerticalPanel layout = new VerticalPanel();
 71  
     private ReqCompEditWidget editReqCompWidget;
 72  
     private RuleManageWidget ruleManageWidget;
 73  0
     private SimplePanel twiddlerPanel = new SimplePanel();
 74  0
     private ActionCancelGroup actionCancelButtons = new ActionCancelGroup(ButtonEnumerations.SaveCancelEnum.SAVE, ButtonEnumerations.SaveCancelEnum.CANCEL);
 75  
 
 76  
     //view's data
 77  0
     private StatementTreeViewInfo rule = null;
 78  0
     private boolean isInitialized = false;
 79  0
     private boolean isNewRule = false;
 80  0
     private ReqComponentInfo editedReqCompInfo = null;
 81  0
     private static int tempStmtTreeViewInfoID = 9999;
 82  0
     private Integer internalCourseReqID = null;
 83  
     private String originalReqCompNL;
 84  
     private String originalLogicExpression;
 85  
 
 86  
     //   private boolean isLocalDirty = false;
 87  0
     private boolean userClickedSaveButton = false;
 88  0
         private BlockingTask creatingRuleTask = new BlockingTask("Creating Rule");
 89  
 
 90  
     public CourseRequirementsManageView(CourseRequirementsViewController parentController, Enum<?> viewEnum, String name, String modelId) {
 91  0
         super(viewEnum, name, modelId);
 92  0
         this.parentController = parentController;
 93  0
     }
 94  
 
 95  
     @Override
 96  
     public void beforeShow(final Callback<Boolean> onReadyCallback) {
 97  
 
 98  0
         retrieveAndSetupReqCompTypes(); //TODO cache it for each statement type?
 99  0
         if (!isInitialized) {
 100  0
             setupHandlers();
 101  0
             draw();
 102  0
             isInitialized = true;
 103  
         }
 104  
 
 105  0
         onReadyCallback.exec(true);
 106  0
     }
 107  
 
 108  
     private void setupHandlers() {
 109  0
         editReqCompWidget.setReqCompConfirmButtonClickCallback(actionButtonClickedReqCompCallback);
 110  0
         editReqCompWidget.setNewReqCompSelectedCallbackCallback(newReqCompSelectedCallbackCallback);
 111  0
         editReqCompWidget.setRetrieveCompositionTemplateCallback(retrieveCompositionTemplateCallback);
 112  0
         editReqCompWidget.setRetrieveFieldsMetadataCallback(retrieveFieldsMetadataCallback);
 113  0
         editReqCompWidget.setRetrieveCustomWidgetCallback(retrieveCustomWidgetCallback);
 114  0
     }
 115  
 
 116  
     private void draw() {
 117  
 
 118  0
         remove(layout);
 119  0
         layout.clear();
 120  
 
 121  
         //STEP 1
 122  0
         SectionTitle title = SectionTitle.generateH3Title("Step 1: Build and Add Rules");
 123  0
         title.setStyleName("KS-Course-Requisites-Manage-Step-header1");
 124  0
         layout.add(title);
 125  
 
 126  0
         layout.add(editReqCompWidget);
 127  
 
 128  
         //STEP 2
 129  0
         title = SectionTitle.generateH3Title("Step 2: Combine Rules with Logic");
 130  0
         title.setStyleName("KS-Course-Requisites-Manage-Step-header2");
 131  0
         layout.add(title);
 132  
 
 133  0
         layout.add(ruleManageWidget);
 134  
 
 135  
         //add progressive indicator when rules are being simplified
 136  0
         KSProgressIndicator twiddler = new KSProgressIndicator();
 137  0
         twiddler.setVisible(false);
 138  0
         twiddlerPanel.setWidget(twiddler);
 139  0
         layout.add(twiddlerPanel);
 140  
 
 141  0
         addWidget(layout);
 142  
 
 143  0
         displaySaveButton();
 144  0
     }
 145  
 
 146  
     private void displaySaveButton() {
 147  0
         actionCancelButtons.addStyleName("KS-Course-Requisites-Save-Button");
 148  0
         actionCancelButtons.addCallback(new Callback<ButtonEnumerations.ButtonEnum>(){
 149  
              @Override
 150  
             public void exec(ButtonEnumerations.ButtonEnum result) {
 151  0
                 userClickedSaveButton = (result == ButtonEnumerations.SaveCancelEnum.SAVE);
 152  0
                 parentController.showView(CourseRequirementsViewController.CourseRequirementsViews.PREVIEW);
 153  0
             }
 154  
         });
 155  0
         addWidget(actionCancelButtons);
 156  0
     }
 157  
 
 158  
     // called by requirement display widget when user wants to edit or add a sub-rule
 159  
     public void setRuleTree(StatementTreeViewInfo stmtTreeInfo, boolean newRuleFlag, Integer internalCourseReqID) {
 160  
 
 161  0
         if (!isInitialized) {
 162  0
             editReqCompWidget = new ReqCompEditWidget(CourseRequirementsSummaryView.NEW_REQ_COMP_ID);
 163  0
             ruleManageWidget = new RuleManageWidget();
 164  0
             ruleManageWidget.setReqCompEditButtonClickCallback(editReqCompCallback);
 165  0
             ruleManageWidget.setRuleChangedButtonClickCallback(ruleChangedCallback);
 166  
         }
 167  
 
 168  0
         this.internalCourseReqID = internalCourseReqID;
 169  0
         editedReqCompInfo = null;
 170  0
         userClickedSaveButton = false;
 171  0
         rule = RulesUtil.clone(stmtTreeInfo);
 172  0
         isNewRule = newRuleFlag;
 173  0
         originalReqCompNL = getAllReqCompNLs();
 174  
 
 175  
         //update screen elements
 176  0
         editReqCompWidget.setupNewReqComp();
 177  0
         ruleManageWidget.redraw(rule, false);
 178  
        // originalLogicExpression = ruleManageWidget.getLogicExpression();
 179  0
     }
 180  
 
 181  
     //retrieve the latest version from rule table widget and update the local copy
 182  
     public StatementTreeViewInfo getRuleTree() {
 183  0
         rule = ruleManageWidget.getStatementTreeViewInfo();
 184  0
         return rule;
 185  
     }
 186  
 
 187  
     public boolean isNewRule() {
 188  0
         return isNewRule;
 189  
     }
 190  
 
 191  
     //called when user clicked on rule 'edit' link
 192  0
     protected Callback<ReqComponentInfo> editReqCompCallback = new Callback<ReqComponentInfo>(){
 193  
         public void exec(ReqComponentInfo reqComp) {
 194  0
             setEnabled(false);
 195  0
             editReqCompWidget.setupExistingReqComp(reqComp);
 196  0
             editedReqCompInfo = reqComp;
 197  0
         }
 198  
     };
 199  
 
 200  0
     protected Callback<Boolean> ruleChangedCallback = new Callback<Boolean>(){
 201  
         public void exec(Boolean ruleChanged) {
 202  0
             actionCancelButtons.getButton(ButtonEnumerations.SaveCancelEnum.SAVE).setEnabled(ruleChanged);
 203  0
         }
 204  
     };
 205  
 
 206  
     protected void setEnabled(boolean enabled) {
 207  0
         ruleManageWidget.setEnabled(enabled);
 208  0
         actionCancelButtons.getButton(ButtonEnumerations.SaveCancelEnum.SAVE).setEnabled(enabled);
 209  0
     }
 210  
 
 211  
     @Override
 212  
     public boolean isDirty() {
 213  0
         if (!isInitialized) {
 214  0
             return false;
 215  
         }
 216  
 
 217  
         //TODO until we figure out how to detect changes, always return true
 218  0
         return true;
 219  
 
 220  
         //first check logic expression
 221  
 //        if (!ruleManageWidget.getLogicExpression().equals(originalLogicExpression)) {
 222  
 //            return true;
 223  
 //        }
 224  
 
 225  
         //next check NL for req. components
 226  
       //  if ((originalNL == null) && (rule.getNaturalLanguageTranslation() == null)) {
 227  
       //      return !ruleManageWidget.getLogicExpression().equals(originalLogicExpression);
 228  
       //  }
 229  
         //TODO how to check whether rule changed or not?
 230  
        // !(ruleManageWidget.getLogicExpression().equals(originalLogicExpression) && getAllReqCompNLs().equals(originalReqCompNL));
 231  
     }
 232  
 
 233  
     private String getAllReqCompNLs() {
 234  0
         StringBuilder NL = new StringBuilder();
 235  0
         for (StatementTreeViewInfo tree : rule.getStatements()) {
 236  0
             for (ReqComponentInfo reqComp : tree.getReqComponents()) {
 237  0
                 NL.append(reqComp.getNaturalLanguageTranslation());
 238  
             }
 239  
         }
 240  0
         return NL.toString();
 241  
     }
 242  
 
 243  
     //called when user clicks 'Add Rule' or 'Update Rule' when editing a req. component
 244  0
     protected Callback<ReqComponentInfoUi> actionButtonClickedReqCompCallback = new Callback<ReqComponentInfoUi>(){
 245  
         public void exec(final ReqComponentInfoUi reqComp) {
 246  
 
 247  0
             editReqCompWidget.setupNewReqComp();
 248  0
             setEnabled(true);
 249  
 
 250  
             //true if user cancel adding/editing req. component
 251  0
             if (reqComp == null) {
 252  0
                 return;
 253  
             }
 254  
 
 255  0
             KSBlockingProgressIndicator.addTask(creatingRuleTask);
 256  
 
 257  
             //1. update NL for the req. component
 258  0
             statementRpcServiceAsync.translateReqComponentToNLs(reqComp, new String[]{RULEEDIT_TEMLATE, RULEPREVIEW_TEMLATE}, TEMLATE_LANGUAGE, new KSAsyncCallback<List<String>>() {
 259  
                 public void handleFailure(Throwable caught) {
 260  0
                     KSBlockingProgressIndicator.removeTask(creatingRuleTask);
 261  0
                     Window.alert(caught.getMessage());
 262  0
                     GWT.log("translateReqComponentToNL failed", caught);
 263  0
                }
 264  
 
 265  
                 public void onSuccess(final List<String> reqCompNL) {
 266  
 
 267  0
                     reqComp.setNaturalLanguageTranslation(reqCompNL.get(0));
 268  0
                     reqComp.setPreviewNaturalLanguageTranslation(reqCompNL.get(1));
 269  
 
 270  
                     //2. add / update req. component
 271  0
                     rule = ruleManageWidget.getStatementTreeViewInfo();  //TODO ?
 272  
 
 273  0
                     if (editedReqCompInfo == null) {  //add req. component
 274  0
                         if (rule.getStatements() != null && !rule.getStatements().isEmpty()) {
 275  0
                             StatementTreeViewInfo newStatementTreeViewInfo = new StatementTreeViewInfo();
 276  0
                             newStatementTreeViewInfo.setId(CourseRequirementsSummaryView.NEW_STMT_TREE_ID + Integer.toString(tempStmtTreeViewInfoID++));
 277  0
                             newStatementTreeViewInfo.setOperator(rule.getStatements().get(0).getOperator());
 278  0
                             newStatementTreeViewInfo.getReqComponents().add(reqComp);
 279  0
                             rule.getStatements().add(newStatementTreeViewInfo);
 280  0
                         } else {
 281  0
                             rule.getReqComponents().add(reqComp);
 282  
                             //set default operator between req. components of the rule
 283  0
                             if (rule.getOperator() == null) {
 284  0
                                 rule.setOperator(StatementOperatorTypeKey.AND);
 285  
                             }
 286  
                         }
 287  
                     } else {    //update req. component
 288  0
                         editedReqCompInfo.setNaturalLanguageTranslation(reqComp.getNaturalLanguageTranslation());
 289  0
                         editedReqCompInfo.setReqCompFields(reqComp.getReqCompFields());
 290  0
                         editedReqCompInfo.setType(reqComp.getType());
 291  0
                         editedReqCompInfo = null;  //de-reference from existing req. component
 292  
                     }
 293  
 
 294  0
                     ruleManageWidget.redraw(rule, true);
 295  0
                     KSBlockingProgressIndicator.removeTask(creatingRuleTask);
 296  0
                 }
 297  
             });
 298  0
         }
 299  
     };
 300  
 
 301  
     //called when user selects a rule type in the editor
 302  0
     protected Callback<ReqComponentInfo> newReqCompSelectedCallbackCallback = new Callback<ReqComponentInfo>(){
 303  
         public void exec(final ReqComponentInfo reqComp) {
 304  0
             setEnabled(false);
 305  0
         }
 306  
     };
 307  
 
 308  
     private void retrieveAndSetupReqCompTypes() {
 309  
 
 310  0
         statementRpcServiceAsync.getReqComponentTypesForStatementType(rule.getType(), new KSAsyncCallback<List<ReqComponentTypeInfo>>() {
 311  
             public void handleFailure(Throwable cause) {
 312  0
                     GWT.log("Failed to get req. component types for statement of type:" + rule.getType(), cause);
 313  0
                     Window.alert("Failed to get req. component types for statement of type:" + rule.getType());
 314  0
             }
 315  
 
 316  
             public void onSuccess(final List<ReqComponentTypeInfo> reqComponentTypeInfoList) {
 317  0
                 if (reqComponentTypeInfoList == null || reqComponentTypeInfoList.size() == 0) {
 318  0
                     GWT.log("Missing Requirement Component Types", null);
 319  0
                     Window.alert("Missing Requirement Component Types");
 320  0
                     return;
 321  
                 }
 322  0
                 editReqCompWidget.setReqCompList(reqComponentTypeInfoList);
 323  0
                 editReqCompWidget.setCustomWidgets(getCustomWidgets(reqComponentTypeInfoList));                
 324  0
             }
 325  
         });
 326  0
     }
 327  
 
 328  
     private Map<String, Widget> getCustomWidgets(List<ReqComponentTypeInfo> reqComponentTypeInfoList) {
 329  0
         Map<String, Widget> customWidgets = new HashMap<String, Widget>();
 330  
 
 331  0
         for (ReqComponentTypeInfo reqCompTypeInfo : reqComponentTypeInfoList) {
 332  0
             for (ReqCompFieldTypeInfo fieldTypeInfo : reqCompTypeInfo.getReqCompFieldTypeInfos()) {
 333  0
                 if (RulesUtil.isGradeWidget(fieldTypeInfo.getId())) {
 334  0
                     customWidgets.put("kuali.reqComponent.field.type.grade.id", new GradeWidget());
 335  0
                 } else if (RulesUtil.isCourseWidget(fieldTypeInfo.getId())) {
 336  
 
 337  0
                     final CourseWidget courseWidget = new CourseWidget();
 338  
                     
 339  0
                     courseWidget.addGetCluNameCallback(new Callback() {
 340  
 
 341  
                         @Override
 342  
                         public void exec(Object id) {
 343  
 
 344  0
                             luRpcServiceAsync.getCurrentVersion(CLU_NAMESPACE_URI, (String)id, new AsyncCallback<VersionDisplayInfo>() {
 345  
                                 @Override
 346  
                                 public void onFailure(Throwable throwable) {
 347  0
                                     Window.alert(throwable.getMessage());
 348  0
                                     GWT.log("Failed to retrieve clu for id: '" +  "'", throwable);
 349  0
                                 }
 350  
 
 351  
                                 @Override
 352  
                                 public void onSuccess(final VersionDisplayInfo versionInfo) {
 353  0
                                     luRpcServiceAsync.getClu(versionInfo.getId(), new AsyncCallback<CluInfo>() {
 354  
                                         @Override
 355  
                                         public void onFailure(Throwable throwable) {
 356  0
                                             Window.alert(throwable.getMessage());
 357  0
                                             GWT.log("Failed to retrieve clu", throwable);
 358  0
                                         }
 359  
 
 360  
                                         @Override
 361  
                                         public void onSuccess(CluInfo cluInfo) {
 362  0
                                             courseWidget.setLabelContent(cluInfo.getVersionInfo().getVersionIndId(), cluInfo.getOfficialIdentifier().getCode());
 363  0
                                         }
 364  
                                     });
 365  0
                                 }
 366  
                             });
 367  
 
 368  
 
 369  0
                         }
 370  
                     });
 371  
 
 372  0
                     customWidgets.put("kuali.reqComponent.field.type.course.clu.id", courseWidget);
 373  0
                 } else if (RulesUtil.isProgramWidget(fieldTypeInfo.getId())) {
 374  0
                     final ProgramWidget programWidget = new ProgramWidget();
 375  
 
 376  0
                     programWidget.addGetCluNameCallback(new Callback() {
 377  
 
 378  
                         @Override
 379  
                         public void exec(Object id) {
 380  
 
 381  0
                             statementRpcServiceAsync.getCurrentVersion(CLU_NAMESPACE_URI, (String)id, new AsyncCallback<VersionDisplayInfo>() {
 382  
                                 @Override
 383  
                                 public void onFailure(Throwable throwable) {
 384  0
                                     Window.alert(throwable.getMessage());
 385  0
                                     GWT.log("Failed to retrieve clu for id: '" +  "'", throwable);
 386  0
                                 }
 387  
 
 388  
                                 @Override
 389  
                                 public void onSuccess(final VersionDisplayInfo versionInfo) {
 390  0
                                     statementRpcServiceAsync.getClu(versionInfo.getId(), new AsyncCallback<CluInfo>() {
 391  
                                         @Override
 392  
                                         public void onFailure(Throwable throwable) {
 393  0
                                             Window.alert(throwable.getMessage());
 394  0
                                             GWT.log("Failed to retrieve clu", throwable);
 395  0
                                         }
 396  
 
 397  
                                         @Override
 398  
                                         public void onSuccess(CluInfo cluInfo) {
 399  0
                                             programWidget.setLabelContent(cluInfo.getVersionInfo().getVersionIndId(), cluInfo.getOfficialIdentifier().getCode());
 400  0
                                         }
 401  
                                     });
 402  0
                                 }
 403  
                             });
 404  0
                         }
 405  
                     });
 406  
 
 407  0
                     customWidgets.put("kuali.reqComponent.field.type.program.clu.id", programWidget);
 408  0
                 }
 409  
             }
 410  
         }
 411  0
         return customWidgets;
 412  
     }
 413  
 
 414  
     //called when user selects a rule type in the rule editor
 415  0
     protected Callback<ReqComponentInfo> retrieveCompositionTemplateCallback = new Callback<ReqComponentInfo>(){
 416  
         public void exec(final ReqComponentInfo reqComp) {
 417  0
             statementRpcServiceAsync.translateReqComponentToNL(reqComp, COMPOSITION_TEMLATE, TEMLATE_LANGUAGE, new KSAsyncCallback<String>() {
 418  
                 public void handleFailure(Throwable caught) {
 419  0
                     Window.alert(caught.getMessage());
 420  0
                     GWT.log("translateReqComponentToNL failed for req. comp. type: '" + reqComp.getType() + "'",caught);
 421  0
                 }
 422  
 
 423  
                 public void onSuccess(final String compositionTemplate) {
 424  0
                     editReqCompWidget.displayFieldsStart(compositionTemplate);
 425  0
                 }
 426  
             });
 427  0
         }
 428  
     };
 429  
 
 430  0
     protected Callback<List<String>> retrieveFieldsMetadataCallback = new Callback<List<String>>(){
 431  
         public void exec(final List<String> fieldTypes) {
 432  
 
 433  0
             if (fieldTypes.contains("kuali.reqComponent.field.type.grade.id")) {
 434  0
                 fieldTypes.add("kuali.reqComponent.field.type.gradeType.id");
 435  
             }
 436  
 
 437  0
             metadataServiceAsync.getMetadataList("org.kuali.student.core.statement.dto.ReqCompFieldInfo", fieldTypes, null, new KSAsyncCallback<List<Metadata>>() {
 438  
                 public void handleFailure(Throwable caught) {
 439  0
                     Window.alert(caught.getMessage());
 440  0
                     GWT.log("getMetadataList failed for req. comp. types: '" + fieldTypes.toString() + "'",caught);
 441  0
                 }
 442  
 
 443  
                 public void onSuccess(final List<Metadata> metadataList) {
 444  0
                     editReqCompWidget.displayFieldsEnd(metadataList);
 445  0
                 }
 446  
             });
 447  0
         }
 448  
     };
 449  
 
 450  0
     protected Callback<String> retrieveCustomWidgetCallback = new Callback<String>(){
 451  
         public void exec(final String fieldType) {
 452  0
             if (RulesUtil.isCluSetWidget(fieldType)) {
 453  0
                 String clusetType = "kuali.cluSet.type.Course";
 454  0
                 if (fieldType.toLowerCase().indexOf("program") > 0) {
 455  0
                     clusetType = "kuali.cluSet.type.Program";
 456  
                 }
 457  0
                 editReqCompWidget.displayCustomWidget(fieldType, new BuildCluSetWidget(new CluSetRetrieverImpl(), clusetType, false));
 458  
             }
 459  0
         }
 460  
     };
 461  
 
 462  
     public boolean isUserClickedSaveButton() {
 463  0
         return userClickedSaveButton;
 464  
     }
 465  
 
 466  
     public void setUserClickedSaveButton(boolean userClickedSaveButton) {
 467  0
         this.userClickedSaveButton = userClickedSaveButton;
 468  0
     }
 469  
 
 470  
     public Integer getInternalCourseReqID() {
 471  0
         return internalCourseReqID;
 472  
     }
 473  
 }