Coverage Report - org.kuali.student.contract.model.validation.OrchestrationModelValidator
 
Classes in this File Line Coverage Branch Coverage Complexity
OrchestrationModelValidator
0%
0/19
0%
0/6
1.75
 
 1  
 /*
 2  
  * Copyright 2009 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may        obtain a copy of the License at
 7  
  *
 8  
  *         http://www.osedu.org/licenses/ECL-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.student.contract.model.validation;
 17  
 
 18  
 import org.kuali.student.contract.model.DictionaryModel;
 19  
 import org.kuali.student.contract.model.OrchObj;
 20  
 import org.kuali.student.contract.model.util.ModelFinder;
 21  
 
 22  
 import java.util.ArrayList;
 23  
 import java.util.Collection;
 24  
 import java.util.List;
 25  
 
 26  
 /**
 27  
  * Validates the entire spreadsheet model
 28  
  * @author nwright
 29  
  */
 30  
 public class OrchestrationModelValidator implements ModelValidator
 31  
 {
 32  
 
 33  
  private DictionaryModel model;
 34  
  private ModelFinder finder;
 35  
 
 36  
  public OrchestrationModelValidator (DictionaryModel model)
 37  0
  {
 38  0
   this.model = model;
 39  0
   this.finder = new ModelFinder (model);
 40  0
  }
 41  
 
 42  
  List<String> errors;
 43  
 
 44  
  @Override
 45  
  public Collection<String> validate ()
 46  
  {
 47  0
   errors = new ArrayList ();
 48  0
   validateOrchObjs ();
 49  0
   errors.addAll (new DictionaryModelValidator (model).validate ());
 50  0
   return errors;
 51  
  }
 52  
 
 53  
  private void validateOrchObjs ()
 54  
  {
 55  0
   if (model.getOrchObjs ().size () == 0)
 56  
   {
 57  0
    addError ("No orchestration objects found");
 58  
   }
 59  0
   for (OrchObj orch : model.getOrchObjs ())
 60  
   {
 61  0
    OrchObjValidator cv = new OrchObjValidator (orch);
 62  0
    errors.addAll (cv.validate ());
 63  0
   }
 64  0
  }
 65  
 
 66  
  private void addError (String msg)
 67  
  {
 68  0
   String error = "Error in orchestration dictionary spreadsheet: " + msg;
 69  0
   if ( ! errors.contains (error))
 70  
   {
 71  0
    errors.add (error);
 72  
   }
 73  0
  }
 74  
 
 75  
 }