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.news.entity;
17  
18  import java.io.Serializable;
19  import java.util.ArrayList;
20  import java.util.List;
21  
22  /**
23   * Represents a full news feed.  Each NewsFeed object corresponds to one NewsSource object and contains a list of NewsArticle objects.
24   * 
25   * @author Kuali Mobility Team (moblitiy.collab@kuali.org)
26   */
27  public class NewsFeed implements Serializable, Comparable<NewsFeed> {
28  
29  	private static final long serialVersionUID = 475441282491797666L;
30  	
31  	private String title;
32  	private String author;
33  	private String description;
34  	private long sourceId;
35  	private List<NewsArticle> articles;
36  	private int order;
37  	
38  	public NewsFeed copy() {
39  		NewsFeed copy = new NewsFeed();
40  		copy.setSourceId(sourceId);
41  		copy.setOrder(order);
42  		if (title != null) {
43  			copy.setTitle(new String(title));
44  		}
45  		if (author != null) {
46  			copy.setAuthor(new String(author));
47  		}
48  		if (description != null) {
49  			copy.setDescription(new String(description));
50  		}
51  		if (!articles.isEmpty()) {
52  			List<NewsArticle> articlesCopy = new ArrayList<NewsArticle>();
53  			for (NewsArticle article : articles) {
54  				articlesCopy.add(article.copy());
55  			}
56  			copy.setArticles(articlesCopy);
57  		}
58  		return copy;
59  	}
60      
61  	public NewsFeed() {
62  		articles = new ArrayList<NewsArticle>();
63  	}
64  	
65  	@Override
66  	public int compareTo(NewsFeed o) {
67  		return order - o.order;
68  	}
69  
70  	/**
71  	 * @return the title
72  	 */
73  	public String getTitle() {
74  		return title;
75  	}
76  
77  	/**
78  	 * @param title the title to set
79  	 */
80  	public void setTitle(String title) {
81  		this.title = title;
82  	}
83  
84  	/**
85  	 * @return the author
86  	 */
87  	public String getAuthor() {
88  		return author;
89  	}
90  
91  	/**
92  	 * @param author the author to set
93  	 */
94  	public void setAuthor(String author) {
95  		this.author = author;
96  	}
97  
98  	/**
99  	 * @return the description of the feed
100 	 */
101 	public String getDescription() {
102 		return description;
103 	}
104 
105 	/**
106 	 * @param description the description of the feed
107 	 */
108 	public void setDescription(String description) {
109 		this.description = description;
110 	}
111 
112 	/**
113 	 * @return the id of the associated NewsSource
114 	 */
115 	public long getSourceId() {
116 		return sourceId;
117 	}
118 
119 	/**
120 	 * @param sourceId id of the associated NewsSource
121 	 */
122 	public void setSourceId(long sourceId) {
123 		this.sourceId = sourceId;
124 	}
125 
126 	/**
127 	 * @return the articles
128 	 */
129 	public List<NewsArticle> getArticles() {
130 		return articles;
131 	}
132 
133 	/**
134 	 * @param articles the articles to set
135 	 */
136 	public void setArticles(List<NewsArticle> articles) {
137 		this.articles = articles;
138 	}
139 
140 	/**
141 	 * @return the display order
142 	 */
143 	public int getOrder() {
144 		return order;
145 	}
146 
147 	/**
148 	 * @param order the display order to set
149 	 */
150 	public void setOrder(int order) {
151 		this.order = order;
152 	}
153 }