Coverage Report - org.kuali.student.lum.program.client.requirements.ProgramRequirementsDataModel
 
Classes in this File Line Coverage Branch Coverage Complexity
ProgramRequirementsDataModel
0%
0/169
0%
0/98
2.658
ProgramRequirementsDataModel$1
0%
0/8
N/A
2.658
ProgramRequirementsDataModel$2
0%
0/8
0%
0/2
2.658
ProgramRequirementsDataModel$3
0%
0/9
0%
0/2
2.658
ProgramRequirementsDataModel$4
0%
0/21
0%
0/4
2.658
ProgramRequirementsDataModel$5
0%
0/29
0%
0/7
2.658
ProgramRequirementsDataModel$6
0%
0/1
N/A
2.658
ProgramRequirementsDataModel$requirementState
0%
0/1
N/A
2.658
 
 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.assembly.data.Data;
 20  
 import org.kuali.student.common.ui.client.application.KSAsyncCallback;
 21  
 import org.kuali.student.common.ui.client.mvc.*;
 22  
 import org.kuali.student.core.statement.dto.ReqCompFieldInfo;
 23  
 import org.kuali.student.core.statement.dto.ReqComponentInfo;
 24  
 import org.kuali.student.core.statement.dto.StatementTreeViewInfo;
 25  
 import org.kuali.student.core.statement.dto.StatementTypeInfo;
 26  
 import org.kuali.student.core.statement.ui.client.widgets.rules.RulesUtil;
 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
                 origProgReqInfos.clear();
 158  0
                 origProgReqState.clear();
 159  0
                 progReqInfos.clear();
 160  0
                 progReqState.clear();
 161  0
                 for (ProgramRequirementInfo programReqInfo : programReqInfos) {
 162  
 
 163  0
                     if (getStmtTypeInfo(programReqInfo.getStatement().getType()) == null) {
 164  0
                         Window.alert("Did not find corresponding statement type for program requirement of type: " + programReqInfo.getStatement().getType());
 165  0
                         GWT.log("Did not find corresponding statement type for program requirement of type: " + programReqInfo.getStatement().getType(), null);
 166  
                     }
 167  
 
 168  0
                     setRuleState(programReqInfo);
 169  0
                     origProgReqInfos.put(progReqIDs, cloneProgReq(programReqInfo));
 170  0
                     origProgReqState.put(progReqIDs, requirementState.STORED);
 171  0
                     progReqInfos.put(progReqIDs, programReqInfo);
 172  0
                     progReqState.put(progReqIDs++, requirementState.STORED);
 173  
                 }
 174  
 
 175  0
                 isInitialized = true;
 176  0
                 onReadyCallback.exec(true);
 177  0
             }
 178  
         });     
 179  0
     }
 180  
 
 181  
     public ProgramRequirementInfo updateRules(StatementTreeViewInfo newSubRule, Integer internalProgReqID, boolean isNewRule) {
 182  
 
 183  0
         ProgramRequirementInfo affectedRule = progReqInfos.get(internalProgReqID);
 184  
 
 185  0
         if (affectedRule == null) {
 186  0
             Window.alert("Cannot find program requirement with a statement that has id: '" + newSubRule.getId() + "'");
 187  0
             GWT.log("Cannot find program requirement with a statement that has id: '" + newSubRule.getId() + "'", null);
 188  0
             return null;
 189  
         }
 190  
 
 191  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) {
 192  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.EDITED);
 193  
         }
 194  
 
 195  
         //if we don't have top level req. components wrapped in statement, do so before we add another statement
 196  0
         StatementTreeViewInfo affectedTopTree = affectedRule.getStatement();
 197  0
         if ((affectedTopTree.getReqComponents() != null) && !affectedTopTree.getReqComponents().isEmpty()) {
 198  0
             StatementTreeViewInfo stmtTree = new StatementTreeViewInfo();
 199  0
             stmtTree.setId(ProgramRequirementsSummaryView.generateStatementTreeId());
 200  0
             stmtTree.setType( affectedRule.getStatement().getType());
 201  0
             stmtTree.setReqComponents(affectedTopTree.getReqComponents());
 202  0
             List<StatementTreeViewInfo> stmtList = new ArrayList<StatementTreeViewInfo>();
 203  0
             stmtList.add(stmtTree);
 204  0
             affectedTopTree.setStatements(stmtList);
 205  
         }
 206  
 
 207  
         //now update the actual rule
 208  0
         List<StatementTreeViewInfo> affectedSubRules = affectedTopTree.getStatements();
 209  0
         if (isNewRule) {
 210  0
             affectedSubRules.add(newSubRule);
 211  
         } else {
 212  
             //update rule
 213  0
             if (affectedSubRules == null || affectedSubRules.isEmpty()) {
 214  0
                 affectedRule.setStatement(newSubRule);
 215  
             } else { //replace the related stored subrule with a new version
 216  0
                 for (StatementTreeViewInfo subRule : affectedSubRules) {
 217  0
                     if (subRule.getId().equals(newSubRule.getId())) {
 218  0
                         int treeIx = affectedSubRules.indexOf(subRule);
 219  
                         //only update if the rule is not empty
 220  0
                         if (!isEmptyRule(newSubRule)) {
 221  0
                             affectedSubRules.add(treeIx, newSubRule);
 222  
                         }
 223  0
                         affectedSubRules.remove(subRule);
 224  0
                         break;
 225  
                     }
 226  
                 }
 227  
             }
 228  
         }
 229  
 
 230  0
         return affectedRule;
 231  
     }
 232  
 
 233  
     public void updateProgramEntities(final Callback<List<ProgramRequirementInfo>> callback) {
 234  
 
 235  0
         final List<String> referencedProgReqIds = new ArrayList<String>();
 236  
 
 237  0
         programRemoteService.storeProgramRequirements(progReqState, progReqInfos, new KSAsyncCallback<Map<Integer, ProgramRequirementInfo>>() {
 238  
             @Override
 239  
             public void handleFailure(Throwable caught) {
 240  0
                 Window.alert(caught.getMessage());
 241  0
                 GWT.log("storeProgramRequirements failed", caught);
 242  0
             }
 243  
             @Override
 244  
             public void onSuccess(Map<Integer, ProgramRequirementInfo> storedRules) {
 245  
 
 246  0
                 for (Integer internalProgReqID : storedRules.keySet()) {
 247  0
                     ProgramRequirementInfo storedRule = storedRules.get(internalProgReqID);
 248  0
                     switch (progReqState.get(internalProgReqID)) {
 249  
                         case STORED:
 250  
                             //rule was not changed so continue
 251  0
                             referencedProgReqIds.add(progReqInfos.get(internalProgReqID).getId());
 252  0
                             break;
 253  
                         case ADDED:
 254  0
                             referencedProgReqIds.add(storedRule.getId());
 255  0
                             progReqInfos.put(internalProgReqID, storedRule);
 256  0
                             origProgReqInfos.put(internalProgReqID, cloneProgReq(storedRule));
 257  0
                             origProgReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 258  0
                             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 259  0
                             break;
 260  
                         case EDITED:
 261  0
                             referencedProgReqIds.add(storedRule.getId());
 262  0
                             progReqInfos.put(internalProgReqID, storedRule);
 263  0
                             origProgReqInfos.put(internalProgReqID, cloneProgReq(storedRule));
 264  0
                             origProgReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 265  0
                             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.STORED);
 266  0
                             break;
 267  
                         case DELETED:
 268  0
                             progReqInfos.remove(internalProgReqID);
 269  0
                             origProgReqInfos.remove(internalProgReqID);
 270  0
                             origProgReqState.remove(internalProgReqID);                            
 271  0
                             progReqState.remove(internalProgReqID);
 272  0
                             break;
 273  
                         default:
 274  
                             break;
 275  
                     }
 276  0
                 }
 277  
 
 278  0
                 saveRequirementIds(referencedProgReqIds, storedRules, callback);
 279  0
             }
 280  
         });        
 281  0
     }
 282  
 
 283  
     private void saveRequirementIds(final List<String> referencedProgReqIds, final Map<Integer, ProgramRequirementInfo> storedRules, final Callback<List<ProgramRequirementInfo>> callback) {
 284  0
         String programId = ((DataModel)model).getRoot().get("id");
 285  0
         String programType = ((DataModel)model).getRoot().get("type");
 286  
 
 287  
         //for some reason, credential program has type stored in 'credentialProgramType'
 288  0
         if (programType == null) {
 289  0
             programType = ((DataModel)model).getRoot().get("credentialProgramType");    
 290  
         }
 291  
 
 292  
         //specializations will be handled differently from Major
 293  0
         if (programType.equals(ProgramConstants.VARIATION_TYPE_KEY)) {
 294  0
             eventBus.fireEvent(new StoreSpecRequirementIDsEvent(programId, programType, referencedProgReqIds));
 295  
         } else {
 296  0
             eventBus.fireEvent(new StoreRequirementIDsEvent(programId, programType, referencedProgReqIds));
 297  
         }
 298  
 
 299  0
         callback.exec(new ArrayList(storedRules.values()));  //update display widgets
 300  0
     }
 301  
 
 302  
     public static void stripStatementIds(StatementTreeViewInfo tree) {
 303  0
         List<StatementTreeViewInfo> statements = tree.getStatements();
 304  0
         List<ReqComponentInfo> reqComponentInfos = tree.getReqComponents();
 305  
 
 306  0
         if ((tree.getId() != null) && (tree.getId().indexOf(ProgramRequirementsSummaryView.NEW_STMT_TREE_ID) >= 0)) {
 307  0
             tree.setId(null);
 308  
         }
 309  0
         tree.setState("Active");
 310  
 
 311  0
         if ((statements != null) && (statements.size() > 0)) {
 312  
             // retrieve all statements
 313  0
             for (StatementTreeViewInfo statement : statements) {
 314  0
                 stripStatementIds(statement); // inside set the children of this statementTreeViewInfo
 315  
             }
 316  0
         } else if ((reqComponentInfos != null) && (reqComponentInfos.size() > 0)) {
 317  
             // retrieve all req. component LEAFS
 318  0
             for (ReqComponentInfo reqComponent : reqComponentInfos) {
 319  0
                 if ((reqComponent.getId() != null) && (reqComponent.getId().indexOf(ProgramRequirementsSummaryView.NEW_REQ_COMP_ID) >= 0)) {
 320  0
                     reqComponent.setId(null);
 321  
                 }
 322  
 
 323  0
                 for (ReqCompFieldInfo field : reqComponent.getReqCompFields()) {
 324  0
                     field.setId(null);
 325  
                 }
 326  
 
 327  0
                 reqComponent.setState("Active");
 328  
             }
 329  
         }
 330  0
     }
 331  
 
 332  
     public List<ProgramRequirementInfo> getProgReqInfo(String stmtTypeId) {
 333  0
         List<ProgramRequirementInfo> rules = new ArrayList<ProgramRequirementInfo>();
 334  0
         for(ProgramRequirementInfo progReqInfo : progReqInfos.values()) {
 335  0
             if (progReqInfo.getStatement().getType().equals(stmtTypeId)) {
 336  0
                 rules.add(progReqInfo);
 337  
             }
 338  
         }
 339  0
         return rules;
 340  
     }
 341  
 
 342  
     public Integer getInternalProgReqID(ProgramRequirementInfo progReqInfo) {
 343  0
         for(Integer key : progReqInfos.keySet()) {
 344  0
             if (progReqInfos.get(key) == progReqInfo) {
 345  0
                 return key;
 346  
             }
 347  
         }
 348  
 
 349  0
         Window.alert("Problem retrieving key for program requirement: " + progReqInfo.getId());
 350  0
         GWT.log("Problem retrieving key for program requirement: " + progReqInfo.getId(), null);        
 351  
 
 352  0
         return null;
 353  
     }
 354  
 
 355  
     public StatementTypeInfo getStmtTypeInfo(String stmtTypeId) {
 356  0
         for (StatementTypeInfo stmtInfo : stmtTypes) {
 357  0
             if (stmtInfo.getId().equals(stmtTypeId)) {
 358  0
                 return stmtInfo;
 359  
             }
 360  
         }
 361  
 
 362  0
         Window.alert("Did not find StatementTypeInfo based on type: " + stmtTypeId);
 363  0
         GWT.log("Did not find StatementTypeInfo based on type: " + stmtTypeId);
 364  
 
 365  0
         return null;
 366  
     }
 367  
 
 368  
     public void deleteRule(Integer internalProgReqID) {
 369  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.ADDED) {
 370  
             //user added a rule, didn't save it and now wants to delete it
 371  0
             progReqState.remove(internalProgReqID);
 372  0
             progReqInfos.remove(internalProgReqID);
 373  
         } else {
 374  0
             markRuleAsDeleted(internalProgReqID);
 375  
         }
 376  0
     }
 377  
 
 378  
     public void addRule(ProgramRequirementInfo programReqInfo) { 
 379  0
             setRuleState(programReqInfo);
 380  0
         progReqInfos.put(progReqIDs, programReqInfo);
 381  0
         progReqState.put(progReqIDs++, requirementState.ADDED);
 382  0
     }
 383  
 
 384  
     public void updateRule(Integer internalProgReqID, ProgramRequirementInfo programReqInfo) {
 385  0
             setRuleState(programReqInfo);            
 386  0
         progReqInfos.put(internalProgReqID, programReqInfo);
 387  0
         markRuleAsEdited(internalProgReqID);
 388  0
     }
 389  
     
 390  
     /**
 391  
      * Set the state of the program requirement to state of the program.
 392  
      * 
 393  
      * @param programReqInfo
 394  
      */
 395  
     protected void setRuleState(ProgramRequirementInfo programReqInfo) {
 396  0
         if (model != null) {
 397  0
             String programState = ((DataModel) model).get(ProgramConstants.STATE);
 398  0
             programReqInfo.setState(programState);
 399  
         }
 400  0
     }
 401  
 
 402  
     public void markRuleAsDeleted(Integer internalProgReqID) {
 403  0
         if ((progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) ||
 404  
             (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.EDITED)) {
 405  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.DELETED);
 406  
         }
 407  0
     }
 408  
 
 409  
     public void markRuleAsEdited(Integer internalProgReqID) {
 410  0
         if (progReqState.get(internalProgReqID) == ProgramRequirementsDataModel.requirementState.STORED) {
 411  0
             progReqState.put(internalProgReqID, ProgramRequirementsDataModel.requirementState.EDITED);
 412  
         }
 413  0
     }
 414  
 
 415  
     public String getStmtTypeName(String stmtTypeId) {
 416  0
         String name = getStmtTypeInfo(stmtTypeId).getName();
 417  0
         return (name == null ? "" : name);
 418  
     }
 419  
     
 420  
     public boolean isRuleExists(String stmtTypeId) {
 421  0
         boolean showNoRuleText = true;
 422  0
         for(ProgramRequirementInfo ruleInfo : progReqInfos.values()) {
 423  0
             if ((ruleInfo.getStatement().getType().equals(stmtTypeId)) && (progReqState.get(getInternalProgReqID(ruleInfo)) != ProgramRequirementsDataModel.requirementState.DELETED)) {
 424  0
                 showNoRuleText = false;
 425  
             }
 426  
         }
 427  0
         return showNoRuleText;
 428  
     }
 429  
 
 430  
     public boolean isDirty() {
 431  
 
 432  0
         if (progReqState.size() != origProgReqState.size()) {
 433  0
             return true;
 434  
         }
 435  
 
 436  0
         for(Integer key : progReqState.keySet()) {
 437  0
             if (!progReqState.get(key).equals(origProgReqState.get(key))) {
 438  0
                 return true;
 439  
             }
 440  
         }
 441  
 
 442  
         /*
 443  
         for(Integer key : progReqInfos.keySet()) {
 444  
             if (!progReqInfos.get(key).equals(origProgReqInfos.get(key))) {
 445  
                 return true;
 446  
             }
 447  
         } */
 448  0
         return false;
 449  
     }
 450  
 
 451  
     public void revertRuleChanges() {
 452  0
         progReqInfos = new HashMap<Integer, ProgramRequirementInfo>();
 453  0
         progReqState = new HashMap<Integer, requirementState>();
 454  0
         for(Integer key : origProgReqInfos.keySet()) {
 455  0
             progReqInfos.put(key, cloneProgReq(origProgReqInfos.get(key)));
 456  0
             progReqState.put(key, origProgReqState.get(key));
 457  
         }
 458  0
     }
 459  
 
 460  
     public ProgramRequirementInfo getProgReqByInternalId(Integer internalProgReqID) {
 461  0
         return progReqInfos.get(internalProgReqID);
 462  
     }
 463  
 
 464  
     public boolean isEmptyRule(StatementTreeViewInfo tree) {
 465  0
         return (tree.getStatements() == null || tree.getStatements().isEmpty() && (tree.getReqComponents() == null || tree.getReqComponents().isEmpty()));
 466  
     }  
 467  
 
 468  
     public boolean isInitialized() {
 469  0
         return isInitialized;
 470  
     }
 471  
 
 472  
     public void setInitialized(boolean initialized) {
 473  0
         isInitialized = initialized;
 474  0
     }
 475  
 
 476  
     public List<StatementTypeInfo> getStmtTypes() {
 477  0
         return stmtTypes;
 478  
     }
 479  
 
 480  
     private ProgramRequirementInfo cloneProgReq(ProgramRequirementInfo inProgReqInfo) {
 481  0
         ProgramRequirementInfo clonedProgReqInfo = null;
 482  0
         if (inProgReqInfo != null) {
 483  0
             clonedProgReqInfo = new ProgramRequirementInfo();
 484  0
             clonedProgReqInfo.setId(inProgReqInfo.getId());
 485  0
             clonedProgReqInfo.setShortTitle(inProgReqInfo.getShortTitle());
 486  0
             clonedProgReqInfo.setLongTitle(inProgReqInfo.getLongTitle());
 487  0
             clonedProgReqInfo.setDescr(inProgReqInfo.getDescr());
 488  0
             clonedProgReqInfo.setMinCredits(inProgReqInfo.getMinCredits());
 489  0
             clonedProgReqInfo.setMaxCredits(inProgReqInfo.getMaxCredits());
 490  0
             clonedProgReqInfo.setState(inProgReqInfo.getState());
 491  0
             clonedProgReqInfo.setType(inProgReqInfo.getType());
 492  0
             clonedProgReqInfo.setStatement(RulesUtil.clone(inProgReqInfo.getStatement()));
 493  
             //TODO clonedProgReqInfo.setAttributes();
 494  
             //TODO clonedProgReqInfo.setLearningObjectives();
 495  
             //TODO clonedProgReqInfo.setMetaInfo();
 496  
         }
 497  0
         return clonedProgReqInfo;
 498  
     }  
 499  
 }