Coverage Report - org.kuali.student.core.academiccalendar.dto.TermInfo
 
Classes in this File Line Coverage Branch Coverage Complexity
TermInfo
0%
0/19
0%
0/8
1.429
TermInfo$Builder
0%
0/20
0%
0/4
1.429
 
 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.core.academiccalendar.dto;
 17  
 
 18  
 import java.io.Serializable;
 19  
 import java.util.Date;
 20  
 import java.util.List;
 21  
 import java.util.ArrayList;
 22  
 import org.w3c.dom.Element;
 23  
 
 24  
 import javax.xml.bind.annotation.XmlAccessType;
 25  
 import javax.xml.bind.annotation.XmlAccessorType;
 26  
 import javax.xml.bind.annotation.XmlAnyElement;
 27  
 import javax.xml.bind.annotation.XmlAttribute;
 28  
 import javax.xml.bind.annotation.XmlElement;
 29  
 import javax.xml.bind.annotation.XmlType;
 30  
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 31  
 
 32  
 import org.kuali.student.common.infc.ModelBuilder;
 33  
 import org.kuali.student.common.dto.KeyEntityInfo;
 34  
 import org.kuali.student.core.academiccalendar.infc.TermInfc;
 35  
 
 36  
 
 37  
 /**
 38  
  * Information about a Term.
 39  
  *
 40  
  * @Author tom
 41  
  * @Since Tue Apr 05 14:22:34 EDT 2011
 42  
  */ 
 43  
 
 44  
 @XmlAccessorType(XmlAccessType.FIELD)
 45  
 @XmlType(name = "TermCalendarInfo", propOrder = {"key", "typeKey", "stateKey", "name", "descr", "startDate", "endDate", "terms", "metaInfo", "attributes", "_futureElements"})
 46  
 public class TermInfo extends KeyEntityInfo implements TermInfc, Serializable {
 47  
 
 48  
     private static final long serialVersionUID = 1L;
 49  
 
 50  
     @XmlElement
 51  
     private final Date startDate;
 52  
 
 53  
     @XmlElement
 54  
     private final Date endDate;
 55  
 
 56  
     @XmlElement
 57  
     private final List<TermInfo> terms;
 58  
 
 59  
     @XmlAnyElement
 60  
     private final List<Element> _futureElements;  
 61  
 
 62  0
     private TermInfo() {
 63  0
             startDate = null;
 64  0
         endDate = null;
 65  0
         terms = null;
 66  0
         _futureElements = null;
 67  0
     }
 68  
 
 69  
     /**
 70  
      * Constructs a new TermInfo from another
 71  
      * Term.
 72  
      *
 73  
      * @paramterm the Term to copy
 74  
      */
 75  
     public TermInfo(TermInfc term) {
 76  0
         super(term);
 77  0
         this.startDate = null != term.getStartDate() ? new Date(term.getStartDate().getTime()) : null;
 78  0
         this.endDate = null != term.getEndDate() ? new Date(term.getEndDate().getTime()) : null;
 79  
 
 80  0
         if (term.getTerms() != null) {
 81  0
             this.terms = new ArrayList<TermInfo>(term.getTerms().size());
 82  0
             for (TermInfc t : term.getTerms()) {
 83  0
                 this.terms.add(new TermInfo(t));
 84  
             }
 85  
         } else {
 86  0
             this.terms = new ArrayList<TermInfo>();
 87  
         }
 88  0
         _futureElements = null;
 89  0
     }
 90  
 
 91  
     /**
 92  
      * Name: StartDate
 93  
      * Date and time the term becomes effective. This does not provide
 94  
      * a bound on date ranges or milestones associated with this time
 95  
      * period, but instead indicates the time period proper. This is a
 96  
      * similar concept to the effective date on enumerated
 97  
      * values. When an end date has been specified, this field must be
 98  
      * less than or equal to the end date.
 99  
      *
 100  
      * @return the Term start date
 101  
      */
 102  
     @Override
 103  
     public Date getStartDate() {
 104  0
         return startDate;
 105  
     }
 106  
 
 107  
     /**
 108  
      * Name: EndDate
 109  
      * Date and time the term becomes ineffective. This does not
 110  
      * provide a bound on date ranges or milestones associated with
 111  
      * this time period, but instead indicates the time period
 112  
      * proper. If specified, this must be greater than or equal to the
 113  
      * start date. If this field is not specified, then no end date
 114  
      * has been currently defined and should automatically be
 115  
      * considered greater than the effective date.
 116  
      *
 117  
      * @return the Term end date
 118  
      */
 119  
     @Override
 120  
     public Date getEndDate() {
 121  0
         return endDate;
 122  
     }
 123  
 
 124  
 
 125  
     /**
 126  
      * Name: Terms
 127  
      * Gets the Terms nested inside this Term.
 128  
      */
 129  
     @Override
 130  
     public List<TermInfo> getTerms() {
 131  0
         return terms;
 132  
     }
 133  
 
 134  
     /**
 135  
      * The builder class for this TermInfo.
 136  
      */
 137  0
     public static class Builder extends KeyEntityInfo.Builder implements ModelBuilder<TermInfo>, TermInfc {
 138  
             
 139  
             private Date startDate;
 140  
         private Date endDate;
 141  
         private List<TermInfo> terms;
 142  
 
 143  
         /**
 144  
          * Constructs a new builder.
 145  
          */
 146  0
         public Builder() {}
 147  
 
 148  
         /**
 149  
          * Constructs a new builder initialized from another Term
 150  
          */
 151  
             public Builder(TermInfc term) {
 152  0
             super(term);
 153  0
             this.startDate = term.getStartDate();
 154  0
             this.startDate = term.getEndDate();
 155  0
             if (term.getTerms() != null) {
 156  0
                 this.terms = new ArrayList(term.getTerms().size());
 157  0
                 for (TermInfc t : term.getTerms()) {
 158  0
                     this.terms.add(new TermInfo(t));
 159  
                 }
 160  
             }
 161  0
             }
 162  
                 
 163  
         /**
 164  
          * Builds the Term.
 165  
          *
 166  
          * @return a new Term
 167  
          */
 168  
         public TermInfo build() {
 169  0
             return new TermInfo(this);
 170  
         }
 171  
 
 172  
         /**
 173  
          * Gets the start date.
 174  
          *
 175  
          * @return the Term start date
 176  
          */
 177  
         @Override
 178  
         public Date getStartDate() {
 179  0
             return startDate;
 180  
         }
 181  
 
 182  
         /**
 183  
          * Sets the Term start date.
 184  
          *
 185  
          * @param startDate the start date for the Term
 186  
          */
 187  
         public void setStartDate(Date startDate) {
 188  0
             this.startDate = startDate;
 189  0
         }
 190  
 
 191  
         /**
 192  
          * Gets the start date.
 193  
          *
 194  
          * @return the Term end date
 195  
          */
 196  
         @Override
 197  
         public Date getEndDate() {
 198  0
             return endDate;
 199  
         }
 200  
             
 201  
         /**
 202  
          * Sets the Term end date.
 203  
          *
 204  
          * @param endDate the end date for the Term
 205  
          */
 206  
 
 207  
         public void setEndDate(Date endDate) {
 208  0
             this.endDate = endDate;
 209  0
         }
 210  
 
 211  
         /**
 212  
          * Gets the Terms nested inside this Term.
 213  
          */
 214  
         @Override
 215  
         public List<TermInfo> getTerms() {
 216  0
             return terms;
 217  
         }
 218  
 
 219  
         public void setTerms(List<TermInfo> terms) {
 220  0
             this.terms = terms;
 221  0
         }
 222  
     }
 223  
 }