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