Coverage Report - org.kuali.student.lum.program.client.requirements.ProgramRequirementsDataModel
 
Classes in this File Line Coverage Branch Coverage Complexity
ProgramRequirementsDataModel
0%
0/168
0%
0/96
2.632
ProgramRequirementsDataModel$1
0%
0/8
N/A
2.632
ProgramRequirementsDataModel$2
0%
0/8
0%
0/2
2.632
ProgramRequirementsDataModel$3
0%
0/9
0%
0/2
2.632
ProgramRequirementsDataModel$4
0%
0/17
0%
0/4
2.632
ProgramRequirementsDataModel$5
0%
0/29
0%
0/7
2.632
ProgramRequirementsDataModel$6
0%
0/1
N/A
2.632
ProgramRequirementsDataModel$requirementState
0%
0/1
N/A
2.632
 
 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  
 package org.kuali.student.lum.program.client.requirements;
 16  
 
 17  
 import java.util.*;
 18  
 
 19  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 20  
 import org.kuali.student.common.ui.client.mvc.*;
 21  
 import org.kuali.student.common.ui.client.widgets.rules.RulesUtil;
 22  
 import org.kuali.student.core.assembly.data.Data;
 23  
 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
 24  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 25  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 26  
 import org.kuali.student.core.statement.dto.StatementTypeInfo;
 27  
 import org.kuali.student.lum.program.client.ProgramConstants;
 28  
 import org.kuali.student.lum.program.client.events.StoreRequirementIDsEvent;
 29  
 import org.kuali.student.lum.program.client.events.StoreSpecRequirementIDsEvent;
 30  
 import org.kuali.student.lum.program.client.rpc.MajorDisciplineRpcService;
 31  
 import org.kuali.student.lum.program.client.rpc.MajorDisciplineRpcServiceAsync;
 32  
 import org.kuali.student.lum.program.client.rpc.StatementRpcService;
 33  
 import org.kuali.student.lum.program.client.rpc.StatementRpcServiceAsync;
 34  
 import org.kuali.student.lum.program.dto.ProgramRequirementInfo;
 35  
 
 36  
 import com.google.gwt.core.client.GWT;
 37  
 import com.google.gwt.event.shared.HandlerManager;
 38  
 import com.google.gwt.user.client.Window;
 39  
 
 40  0
 public class ProgramRequirementsDataModel {
 41  
 
 42  0
     private final MajorDisciplineRpcServiceAsync programRemoteService = GWT.create(MajorDisciplineRpcService.class);
 43  0
     private StatementRpcServiceAsync statementRpcServiceAsync = GWT.create(StatementRpcService.class);
 44  0
     private Model model = null;
 45  
     private HandlerManager eventBus;
 46  
 
 47  
     //keeping track of rules and rule state
 48  0
     public enum requirementState {STORED, ADDED, EDITED, DELETED;}
 49  0
     private Map<Integer, ProgramRequirementInfo> progReqInfos = new LinkedHashMap<Integer, ProgramRequirementInfo>();
 50  0
     private Map<Integer, ProgramRequirementInfo> origProgReqInfos = new LinkedHashMap<Integer, ProgramRequirementInfo>();
 51  0
     private Map<Integer, requirementState> progReqState = new HashMap<Integer, requirementState>();
 52  0
     private Map<Integer, requirementState> origProgReqState = new HashMap<Integer, requirementState>();
 53  0
     private List<StatementTypeInfo> stmtTypes = new ArrayList<StatementTypeInfo>();
 54  0
     private boolean isInitialized = false;
 55  0
     private static Integer progReqIDs = 111111;
 56  
 
 57  0
     public ProgramRequirementsDataModel(HandlerManager eventBus) {
 58  0
         this.eventBus = eventBus;
 59  0
     }
 60  
 
 61  
     //find out whether we need to reset rules based on whether we have a new program ID or not
 62  
     public void setupRules(Controller parentController, final Callback<Boolean> onReadyCallback) {
 63  0
         parentController.requestModel(ProgramConstants.PROGRAM_MODEL_ID, new ModelRequestCallback() {
 64  
 
 65  
             @Override
 66  
             public void onRequestFail(Throwable cause) {
 67  0
                 GWT.log("Unable to retrieve program model for program summary view", cause);
 68  0
                 onReadyCallback.exec(false);
 69  0
             }
 70  
 
 71  
             @Override
 72  
             public void onModelReady(Model modelIn) {
 73  
                 //TODO how can we reliably know that we need to reload rules (or not)
 74  
                 //String programId = (model == null ? null : (String)((DataModel)model).getRoot().get("id"));
 75  
                 //String modelProgramId = ((DataModel)modelIn).getRoot().get(ProgramConstants.ID);
 76  
                 //if ((modelProgramId == null) || (!modelProgramId.equals(programId))) {
 77  0
                     resetRules();
 78  
                 //}
 79  0
                 model = modelIn;
 80  0
                 onReadyCallback.exec(true);
 81  0
             }
 82  
         });
 83  0
     }
 84  
 
 85  
     private void resetRules() {
 86  0
         progReqInfos = new LinkedHashMap<Integer, ProgramRequirementInfo>();
 87  0
         origProgReqInfos = new LinkedHashMap<Integer, ProgramRequirementInfo>();
 88  0
         progReqState = new HashMap<Integer, requirementState>();
 89  0
         origProgReqState = new HashMap<Integer, requirementState>();
 90  0
         stmtTypes = new ArrayList<StatementTypeInfo>();
 91  0
         model = null;
 92  0
         isInitialized = false;
 93  0
     }
 94  
 
 95  
     //retrieve rules based on IDs stored in this program
 96  
     public void retrieveProgramRequirements(Controller parentController, final Callback<Boolean> onReadyCallback) {
 97  
         
 98  0
         setupRules(parentController, new Callback<Boolean>() {
 99  
             @Override
 100  
             public void exec(Boolean result) {
 101  0
                 Data program = ((DataModel)model).getRoot().get(ProgramConstants.PROGRAM_REQUIREMENTS);
 102  
 
 103  0
                 Iterator<Data.Property> realPropertyIterator = program.realPropertyIterator();
 104  0
                 ArrayList<String> programRequirementIds = new ArrayList<String>();
 105  0
                 while(realPropertyIterator.hasNext()) {
 106  0
                     programRequirementIds.add((String)realPropertyIterator.next().getValue());
 107  
                 }
 108  0
                 retrieveStatementTypes(programRequirementIds, onReadyCallback);
 109  0
             }
 110  
         });               
 111  0
     }
 112  
 
 113  
     private void retrieveStatementTypes(final List<String> programRequirementIds, final Callback<Boolean> onReadyCallback) {
 114  
 
 115  
         //retrieve available program requirement types
 116  0
         statementRpcServiceAsync.getStatementTypesForStatementType("kuali.statement.type.program", new KSAsyncCallback<List<StatementTypeInfo>>() {
 117  
             @Override
 118  
             public void handleFailure(Throwable caught) {
 119  0
                     Window.alert(caught.getMessage());
 120  0
                     GWT.log("getStatementTypes failed", caught);
 121  0
                 onReadyCallback.exec(false);
 122  0
             }
 123  
 
 124  
             @Override
 125  
             public void onSuccess(List<StatementTypeInfo> stmtInfoTypes) {
 126  
                 //store the statement types
 127  0
                 for (StatementTypeInfo stmtInfoType : stmtInfoTypes) {
 128  0
                     stmtTypes.add(stmtInfoType);
 129  
                 }
 130  
 
 131  
                 //now retrieve the actual rules
 132  0
                 retrieveRules(programRequirementIds, onReadyCallback);
 133  0
             }
 134  
         });
 135  0
     }
 136  
 
 137  
     private void retrieveRules(List<String> programRequirementIds, final Callback<Boolean> onReadyCallback) {
 138  
 
 139  
         //true if no program requirements exist yet
 140  0
         if ((programRequirementIds == null) || programRequirementIds.isEmpty()) {
 141  0
             isInitialized = true;
 142  0
             onReadyCallback.exec(true);
 143  0
             return;
 144  
         }
 145  
 
 146  0
         programRemoteService.getProgramRequirements(programRequirementIds, new KSAsyncCallback<List<ProgramRequirementInfo>>() {
 147  
             @Override
 148  
             public void handleFailure(Throwable caught) {
 149  0
                 Window.alert(caught.getMessage());
 150  0
                 GWT.log("getProgramRequirement failed", caught);
 151  0
                 onReadyCallback.exec(false);
 152  0
             }
 153  
 
 154  
             @Override
 155  
             public void onSuccess(List<ProgramRequirementInfo> programReqInfos) {
 156  
                 //update rules list with new program requirements
 157  0
                 for (ProgramRequirementInfo programReqInfo : programReqInfos) {
 158  
 
 159  0
                     if (getStmtTypeInfo(programReqInfo.getStatement().getType()) == null) {
 160  0
                         Window.alert("Did not find corresponding statement type for program requirement of type: " + programReqInfo.getStatement().getType());
 161  0
                         GWT.log("Did not find corresponding statement type for program requirement of type: " + programReqInfo.getStatement().getType(), null);
 162  
                     }
 163  
 
 164  0
                     setRuleState(programReqInfo);
 165  0
                     origProgReqInfos.put(progReqIDs, cloneProgReq(programReqInfo));
 166  0
                     origProgReqState.put(progReqIDs, requirementState.STORED);
 167  0
                     progReqInfos.put(progReqIDs, programReqInfo);
 168  0
                     progReqState.put(progReqIDs++, requirementState.STORED);
 169  
                 }
 170  
 
 171  0
                 isInitialized = true;
 172  0
                 onReadyCallback.exec(true);
 173  0
             }
 174  
         });     
 175  0
     }
 176  
 
 177  
     public ProgramRequirementInfo updateRules(StatementTreeViewInfo newSubRule, Integer internalProgReqID, boolean isNewRule) {
 178  
 
 179  0
         ProgramRequirementInfo affectedRule = progReqInfos.get(internalProgReqID);
 180  
 
 181  0
         if (affectedRule == null) {
 182  0
             Window.alert("Cannot find program requirement with a statement that has id: '" + newSubRule.getId() + "'");
 183  0
             GWT.log("Cannot find program requirement with a statement that has id: '" + newSubRule.getId() + "'", null);
 184  0
             return null;
 185  
         }
 186  
 
 187  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) {
 188  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.EDITED);
 189  
         }
 190  
 
 191  
         //if we don't have top level req. components wrapped in statement, do so before we add another statement
 192  0
         StatementTreeViewInfo affectedTopTree = affectedRule.getStatement();
 193  0
         if ((affectedTopTree.getReqComponents() != null) && !affectedTopTree.getReqComponents().isEmpty()) {
 194  0
             StatementTreeViewInfo stmtTree = new StatementTreeViewInfo();
 195  0
             stmtTree.setId(ProgramRequirementsSummaryView.generateStatementTreeId());
 196  0
             stmtTree.setType( affectedRule.getStatement().getType());
 197  0
             stmtTree.setReqComponents(affectedTopTree.getReqComponents());
 198  0
             List<StatementTreeViewInfo> stmtList = new ArrayList<StatementTreeViewInfo>();
 199  0
             stmtList.add(stmtTree);
 200  0
             affectedTopTree.setStatements(stmtList);
 201  
         }
 202  
 
 203  
         //now update the actual rule
 204  0
         List<StatementTreeViewInfo> affectedSubRules = affectedTopTree.getStatements();
 205  0
         if (isNewRule) {
 206  0
             affectedSubRules.add(newSubRule);
 207  
         } else {
 208  
             //update rule
 209  0
             if (affectedSubRules == null || affectedSubRules.isEmpty()) {
 210  0
                 affectedRule.setStatement(newSubRule);
 211  
             } else { //replace the related stored subrule with a new version
 212  0
                 for (StatementTreeViewInfo subRule : affectedSubRules) {
 213  0
                     if (subRule.getId().equals(newSubRule.getId())) {
 214  0
                         int treeIx = affectedSubRules.indexOf(subRule);
 215  
                         //only update if the rule is not empty
 216  0
                         if (!isEmptyRule(newSubRule)) {
 217  0
                             affectedSubRules.add(treeIx, newSubRule);
 218  
                         }
 219  0
                         affectedSubRules.remove(subRule);
 220  0
                         break;
 221  
                     }
 222  
                 }
 223  
             }
 224  
         }
 225  
 
 226  0
         return affectedRule;
 227  
     }
 228  
 
 229  
     public void updateProgramEntities(final Callback<List<ProgramRequirementInfo>> callback) {
 230  
 
 231  0
         final List<String> referencedProgReqIds = new ArrayList<String>();
 232  
 
 233  0
         programRemoteService.storeProgramRequirements(progReqState, progReqInfos, new KSAsyncCallback<Map<Integer, ProgramRequirementInfo>>() {
 234  
             @Override
 235  
             public void handleFailure(Throwable caught) {
 236  0
                 Window.alert(caught.getMessage());
 237  0
                 GWT.log("storeProgramRequirements failed", caught);
 238  0
             }
 239  
             @Override
 240  
             public void onSuccess(Map<Integer, ProgramRequirementInfo> storedRules) {
 241  
 
 242  0
                 for (Integer internalProgReqID : storedRules.keySet()) {
 243  0
                     ProgramRequirementInfo storedRule = storedRules.get(internalProgReqID);
 244  0
                     switch (progReqState.get(internalProgReqID)) {
 245  
                         case STORED:
 246  
                             //rule was not changed so continue
 247  0
                             referencedProgReqIds.add(progReqInfos.get(internalProgReqID).getId());
 248  0
                             break;
 249  
                         case ADDED:
 250  0
                             referencedProgReqIds.add(storedRule.getId());
 251  0
                             progReqInfos.put(internalProgReqID, storedRule);
 252  0
                             origProgReqInfos.put(internalProgReqID, cloneProgReq(storedRule));
 253  0
                             origProgReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 254  0
                             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 255  0
                             break;
 256  
                         case EDITED:
 257  0
                             referencedProgReqIds.add(storedRule.getId());
 258  0
                             progReqInfos.put(internalProgReqID, storedRule);
 259  0
                             origProgReqInfos.put(internalProgReqID, cloneProgReq(storedRule));
 260  0
                             origProgReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 261  0
                             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 262  0
                             break;
 263  
                         case DELETED:
 264  0
                             progReqInfos.remove(internalProgReqID);
 265  0
                             origProgReqInfos.remove(internalProgReqID);
 266  0
                             origProgReqState.remove(internalProgReqID);                            
 267  0
                             progReqState.remove(internalProgReqID);
 268  0
                             break;
 269  
                         default:
 270  
                             break;
 271  
                     }
 272  0
                 }
 273  
 
 274  0
                 saveRequirementIds(referencedProgReqIds, storedRules, callback);
 275  0
             }
 276  
         });        
 277  0
     }
 278  
 
 279  
     private void saveRequirementIds(final List<String> referencedProgReqIds, final Map<Integer, ProgramRequirementInfo> storedRules, final Callback<List<ProgramRequirementInfo>> callback) {
 280  0
         String programId = ((DataModel)model).getRoot().get("id");
 281  0
         String programType = ((DataModel)model).getRoot().get("type");
 282  
 
 283  
         //for some reason, credential program has type stored in 'credentialProgramType'
 284  0
         if (programType == null) {
 285  0
             programType = ((DataModel)model).getRoot().get("credentialProgramType");    
 286  
         }
 287  
 
 288  
         //specializations will be handled differently from Major
 289  0
         if (programType.equals(ProgramConstants.VARIATION_TYPE_KEY)) {
 290  0
             eventBus.fireEvent(new StoreSpecRequirementIDsEvent(programId, programType, referencedProgReqIds));
 291  
         } else {
 292  0
             eventBus.fireEvent(new StoreRequirementIDsEvent(programId, programType, referencedProgReqIds));
 293  
         }
 294  
 
 295  0
         callback.exec(new ArrayList(storedRules.values()));  //update display widgets
 296  0
     }
 297  
 
 298  
     public static void stripStatementIds(StatementTreeViewInfo tree) {
 299  0
         List<StatementTreeViewInfo> statements = tree.getStatements();
 300  0
         List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents();
 301  
 
 302  0
         if ((tree.getId() != null) && (tree.getId().indexOf(ProgramRequirementsSummaryView.NEW_STMT_TREE_ID) >= 0)) {
 303  0
             tree.setId(null);
 304  
         }
 305  0
         tree.setState("Active");
 306  
 
 307  0
         if ((statements != null) && (statements.size() > 0)) {
 308  
             // retrieve all statements
 309  0
             for (StatementTreeViewInfo statement : statements) {
 310  0
                 stripStatementIds(statement); // inside set the children of this statementTreeViewInfo
 311  
             }
 312  0
         } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
 313  
             // retrieve all req. component LEAFS
 314  0
             for (ReqComponentInfo reqComponent : reqComponentInfos) {
 315  0
                 if ((reqComponent.getId() != null) && (reqComponent.getId().indexOf(ProgramRequirementsSummaryView.NEW_REQ_COMP_ID) >= 0)) {
 316  0
                     reqComponent.setId(null);
 317  
                 }
 318  
 
 319  0
                 for (ReqCompFieldInfo field : reqComponent.getReqCompFields()) {
 320  0
                     field.setId(null);
 321  
                 }
 322  
 
 323  0
                 reqComponent.setState("Active");
 324  
             }
 325  
         }
 326  0
     }
 327  
 
 328  
     public List<ProgramRequirementInfo> getProgReqInfo(String stmtTypeId) {
 329  0
         List<ProgramRequirementInfo> rules = new ArrayList<ProgramRequirementInfo>();
 330  0
         for(ProgramRequirementInfo progReqInfo : progReqInfos.values()) {
 331  0
             if (progReqInfo.getStatement().getType().equals(stmtTypeId)) {
 332  0
                 rules.add(progReqInfo);
 333  
             }
 334  
         }
 335  0
         return rules;
 336  
     }
 337  
 
 338  
     public Integer getInternalProgReqID(ProgramRequirementInfo progReqInfo) {
 339  0
         for(Integer key : progReqInfos.keySet()) {
 340  0
             if (progReqInfos.get(key) == progReqInfo) {
 341  0
                 return key;
 342  
             }
 343  
         }
 344  
 
 345  0
         Window.alert("Problem retrieving key for program requirement: " + progReqInfo.getId());
 346  0
         GWT.log("Problem retrieving key for program requirement: " + progReqInfo.getId(), null);        
 347  
 
 348  0
         return null;
 349  
     }
 350  
 
 351  
     public StatementTypeInfo getStmtTypeInfo(String stmtTypeId) {
 352  0
         for (StatementTypeInfo stmtInfo : stmtTypes) {
 353  0
             if (stmtInfo.getId().equals(stmtTypeId)) {
 354  0
                 return stmtInfo;
 355  
             }
 356  
         }
 357  
 
 358  0
         Window.alert("Did not find StatementTypeInfo based on type: " + stmtTypeId);
 359  0
         GWT.log("Did not find StatementTypeInfo based on type: " + stmtTypeId);
 360  
 
 361  0
         return null;
 362  
     }
 363  
 
 364  
     public void deleteRule(Integer internalProgReqID) {
 365  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.ADDED) {
 366  
             //user added a rule, didn't save it and now wants to delete it
 367  0
             progReqState.remove(internalProgReqID);
 368  0
             progReqInfos.remove(internalProgReqID);
 369  
         } else {
 370  0
             markRuleAsDeleted(internalProgReqID);
 371  
         }
 372  0
     }
 373  
 
 374  
     public void addRule(ProgramRequirementInfo programReqInfo) { 
 375  0
             setRuleState(programReqInfo);
 376  0
         progReqInfos.put(progReqIDs, programReqInfo);
 377  0
         progReqState.put(progReqIDs++, requirementState.ADDED);
 378  0
     }
 379  
 
 380  
     public void updateRule(Integer internalProgReqID, ProgramRequirementInfo programReqInfo) {
 381  0
             setRuleState(programReqInfo);            
 382  0
         progReqInfos.put(internalProgReqID, programReqInfo);
 383  0
         markRuleAsEdited(internalProgReqID);
 384  0
     }
 385  
     
 386  
     /**
 387  
      * Set the state of the program requirement to state of the program.
 388  
      * 
 389  
      * @param programReqInfo
 390  
      */
 391  
     protected void setRuleState(ProgramRequirementInfo programReqInfo){
 392  0
             String programState = ((DataModel)model).get(ProgramConstants.STATE);
 393  0
             programReqInfo.setState(programState);            
 394  0
     }
 395  
 
 396  
     public void markRuleAsDeleted(Integer internalProgReqID) {
 397  0
         if ((progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) ||
 398  
             (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.EDITED)) {
 399  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.DELETED);
 400  
         }
 401  0
     }
 402  
 
 403  
     public void markRuleAsEdited(Integer internalProgReqID) {
 404  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) {
 405  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.EDITED);
 406  
         }
 407  0
     }
 408  
 
 409  
     public String getStmtTypeName(String stmtTypeId) {
 410  0
         String name = getStmtTypeInfo(stmtTypeId).getName();
 411  0
         return (name == null ? "" : name);
 412  
     }
 413  
     
 414  
     public boolean isRuleExists(String stmtTypeId) {
 415  0
         boolean showNoRuleText = true;
 416  0
         for(ProgramRequirementInfo ruleInfo : progReqInfos.values()) {
 417  0
             if ((ruleInfo.getStatement().getType().equals(stmtTypeId)) && (progReqState.get(getInternalProgReqID(ruleInfo)) != ProgramRequirementsDataModel.requirementState.DELETED)) {
 418  0
                 showNoRuleText = false;
 419  
             }
 420  
         }
 421  0
         return showNoRuleText;
 422  
     }
 423  
 
 424  
     public boolean isDirty() {
 425  
 
 426  0
         if (progReqState.size() != origProgReqState.size()) {
 427  0
             return true;
 428  
         }
 429  
 
 430  0
         for(Integer key : progReqState.keySet()) {
 431  0
             if (!progReqState.get(key).equals(origProgReqState.get(key))) {
 432  0
                 return true;
 433  
             }
 434  
         }
 435  
 
 436  
         /*
 437  
         for(Integer key : progReqInfos.keySet()) {
 438  
             if (!progReqInfos.get(key).equals(origProgReqInfos.get(key))) {
 439  
                 return true;
 440  
             }
 441  
         } */
 442  0
         return false;
 443  
     }
 444  
 
 445  
     public void revertRuleChanges() {
 446  0
         progReqInfos = new HashMap<Integer, ProgramRequirementInfo>();
 447  0
         progReqState = new HashMap<Integer, requirementState>();
 448  0
         for(Integer key : origProgReqInfos.keySet()) {
 449  0
             progReqInfos.put(key, cloneProgReq(origProgReqInfos.get(key)));
 450  0
             progReqState.put(key, origProgReqState.get(key));
 451  
         }
 452  0
     }
 453  
 
 454  
     public ProgramRequirementInfo getProgReqByInternalId(Integer internalProgReqID) {
 455  0
         return progReqInfos.get(internalProgReqID);
 456  
     }
 457  
 
 458  
     public boolean isEmptyRule(StatementTreeViewInfo tree) {
 459  0
         return (tree.getStatements() == null || tree.getStatements().isEmpty() && (tree.getReqComponents() == null || tree.getReqComponents().isEmpty()));
 460  
     }  
 461  
 
 462  
     public boolean isInitialized() {
 463  0
         return isInitialized;
 464  
     }
 465  
 
 466  
     public void setInitialized(boolean initialized) {
 467  0
         isInitialized = initialized;
 468  0
     }
 469  
 
 470  
     public List<StatementTypeInfo> getStmtTypes() {
 471  0
         return stmtTypes;
 472  
     }
 473  
 
 474  
     private ProgramRequirementInfo cloneProgReq(ProgramRequirementInfo inProgReqInfo) {
 475  0
         ProgramRequirementInfo clonedProgReqInfo = null;
 476  0
         if (inProgReqInfo != null) {
 477  0
             clonedProgReqInfo = new ProgramRequirementInfo();
 478  0
             clonedProgReqInfo.setId(inProgReqInfo.getId());
 479  0
             clonedProgReqInfo.setShortTitle(inProgReqInfo.getShortTitle());
 480  0
             clonedProgReqInfo.setLongTitle(inProgReqInfo.getLongTitle());
 481  0
             clonedProgReqInfo.setDescr(inProgReqInfo.getDescr());
 482  0
             clonedProgReqInfo.setMinCredits(inProgReqInfo.getMinCredits());
 483  0
             clonedProgReqInfo.setMaxCredits(inProgReqInfo.getMaxCredits());
 484  0
             clonedProgReqInfo.setState(inProgReqInfo.getState());
 485  0
             clonedProgReqInfo.setType(inProgReqInfo.getType());
 486  0
             clonedProgReqInfo.setStatement(RulesUtil.clone(inProgReqInfo.getStatement()));
 487  
             //TODO clonedProgReqInfo.setAttributes();
 488  
             //TODO clonedProgReqInfo.setLearningObjectives();
 489  
             //TODO clonedProgReqInfo.setMetaInfo();
 490  
         }
 491  0
         return clonedProgReqInfo;
 492  
     }  
 493  
 }