View Javadoc

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.OrchObj;
19  
20  import java.util.ArrayList;
21  import java.util.Collection;
22  import java.util.List;
23  
24  /**
25   * This validates a constraint.
26   * @author nwright
27   */
28  public class OrchObjValidator implements ModelValidator {
29  
30      private OrchObj orch;
31  
32      public OrchObjValidator(OrchObj orch) {
33          this.orch = orch;
34      }
35      private Collection errors;
36  
37      @Override
38      public Collection<String> validate() {
39          this.errors = new ArrayList();
40          if (orch.getXmlType().equals("")) {
41              this.addError("XML Type is required");
42          }
43          // TODO: more validation
44          return this.errors;
45      }
46  
47      private void addError(String msg) {
48          String key = orch.getId();
49          if (key.equals("")) {
50              key = "";
51          }
52          String error = "Error in: " + key + ": " + msg;
53          if (!errors.contains(error)) {
54              errors.add(error);
55          }
56      }
57  }