View Javadoc

1   /**
2    * Copyright 2011 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.mobility.dining.entity;
17  
18  import java.io.Serializable;
19  import java.text.DecimalFormat;
20  import java.text.SimpleDateFormat;
21  import java.util.ArrayList;
22  import java.util.Date;
23  import java.util.List;
24  
25  import javax.xml.bind.annotation.XmlElement;
26  import javax.xml.bind.annotation.XmlRootElement;
27  import javax.xml.bind.annotation.XmlSeeAlso;
28  
29  @XmlRootElement( name="menu" )
30  public class Menu implements Serializable {
31  
32  	private static final long serialVersionUID = -2096908398187406294L;
33  
34  	private Date date;
35  
36  	private int ratingCount;
37  	private double ratingScore;
38  	
39  	private List<FoodItem> items;
40  	
41  	public Menu() {
42  		this.items = new ArrayList<FoodItem>();
43  	}
44  
45  	public Date getDate() {
46  		return date;
47  	}
48  
49  	public void setDate(Date date) {
50  		this.date = date;
51  	}
52  
53  	public int getRatingCount() {
54  		return ratingCount;
55  	}
56  
57  	public void setRatingCount(int ratingCount) {
58  		this.ratingCount = ratingCount;
59  	}
60  
61  	public double getRatingScore() {
62  		return ratingScore;
63  	}
64  
65  	public void setRatingScore(double ratingScore) {
66  		this.ratingScore = ratingScore;
67  	}
68  
69  	@XmlElement( name="items" )
70  	public List<FoodItem> getItems() {
71  		return items;
72  	}
73  
74  	public void setItems(List<FoodItem> items) {
75  		this.items = items;
76  	}
77  	
78  	public String getFormattedRating() {
79  		DecimalFormat score = new DecimalFormat("0.0");
80  		return score.format(this.getRatingScore());
81  	}
82  	
83  	public String getDateFormatted() {
84  		if (this.getDate() != null) {
85  			SimpleDateFormat sdf = new SimpleDateFormat("MMM dd, yyyy");
86  			String date = sdf.format(new Date(this.getDate().getTime()));
87  			return date;			
88  		} 
89  		return "";
90  	}
91  	
92  }