001: /*
002: * Copyright 2005 Sun Microsystems, Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.apache.roller.planet.pojos;
017:
018: import java.io.Serializable;
019: import java.util.ArrayList;
020: import java.util.Collection;
021: import java.util.Date;
022: import java.util.HashSet;
023: import java.util.Iterator;
024: import java.util.List;
025: import java.util.Set;
026: import org.apache.roller.pojos.*;
027:
028: /**
029: * @struts.form include-all="true"
030: * @ejb:bean name="PlanetSubscriptionData"
031: * @hibernate.class lazy="false" table="rag_subscription"
032: */
033: public class PlanetSubscriptionData extends PersistentObject implements
034: Serializable, Comparable {
035: /** Database ID */
036: protected String id;
037:
038: /** Title of the blog or website */
039: protected String title;
040:
041: /** Name of blog or website author */
042: protected String author;
043:
044: /** URL of the newsfeed */
045: protected String feedUrl;
046:
047: /** URL of the blog or website */
048: protected String siteUrl;
049:
050: /** Last update time of site */
051: protected Date lastUpdated;
052:
053: /** Most recent entries from site (a set of EntityData objects) */
054: protected List entries = new ArrayList();
055:
056: /** Inbound links according to Technorati */
057: protected int inboundlinks = 0;
058:
059: /** Inbound blogs according to Technorati */
060: protected int inboundblogs = 0;
061:
062: protected Set groups = new HashSet();
063:
064: //----------------------------------------------------------- persistent fields
065:
066: /**
067: * @hibernate.set table="rag_group_subscription" lazy="true" cascade="save-update"
068: * @hibernate.collection-key column="subscription_id"
069: * @hibernate.collection-many-to-many column="group_id" class="org.apache.roller.planet.pojos.PlanetGroupData"
070: */
071: public Set getGroups() {
072: return groups;
073: }
074:
075: public void setGroups(Set groups) {
076: this .groups = groups;
077: }
078:
079: /**
080: * @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
081: * @roller.wrapPojoMethod type="simple"
082: */
083: public String getId() {
084: return id;
085: }
086:
087: public void setId(String id) {
088: this .id = id;
089: }
090:
091: /**
092: * @hibernate.property column="feed_url" non-null="true" unique="false"
093: * @roller.wrapPojoMethod type="simple"
094: */
095: public String getFeedURL() {
096: return feedUrl;
097: }
098:
099: public void setFeedURL(String feedUrl) {
100: this .feedUrl = feedUrl;
101: }
102:
103: /**
104: * @hibernate.property column="last_updated" non-null="false" unique="false"
105: * @roller.wrapPojoMethod type="simple"
106: */
107: public Date getLastUpdated() {
108: return lastUpdated;
109: }
110:
111: public void setLastUpdated(Date lastUpdated) {
112: this .lastUpdated = lastUpdated;
113: }
114:
115: /**
116: * @hibernate.property column="site_url" non-null="false" unique="false"
117: * @roller.wrapPojoMethod type="simple"
118: */
119: public String getSiteURL() {
120: return siteUrl;
121: }
122:
123: public void setSiteURL(String siteUrl) {
124: this .siteUrl = siteUrl;
125: }
126:
127: /**
128: * @hibernate.property column="title" non-null="false" unique="false"
129: * @roller.wrapPojoMethod type="simple"
130: */
131: public String getTitle() {
132: return title;
133: }
134:
135: public void setTitle(String title) {
136: this .title = title;
137: }
138:
139: /**
140: * @hibernate.property column="author" non-null="false" unique="false"
141: * @roller.wrapPojoMethod type="simple"
142: */
143: public String getAuthor() {
144: return author;
145: }
146:
147: public void setAuthor(String author) {
148: this .author = author;
149: }
150:
151: /**
152: * @hibernate.property column="inbound_links" non-null="false" unique="false"
153: * @roller.wrapPojoMethod type="simple"
154: */
155: public int getInboundlinks() {
156: return inboundlinks;
157: }
158:
159: public void setInboundlinks(int inboundlinks) {
160: this .inboundlinks = inboundlinks;
161: }
162:
163: /**
164: * @hibernate.property column="inbound_blogs" non-null="false" unique="false"
165: * @roller.wrapPojoMethod type="simple"
166: */
167: public int getInboundblogs() {
168: return inboundblogs;
169: }
170:
171: public void setInboundblogs(int inboundblogs) {
172: this .inboundblogs = inboundblogs;
173: }
174:
175: /**
176: * @roller.wrapPojoMethod type="simple"
177: */
178: public String getName() {
179: return title;
180: }
181:
182: public void setName(String name) {
183: // no op to please XDoclet
184: }
185:
186: /**
187: * @roller.wrapPojoMethod type="simple"
188: */
189: public String getURL() {
190: return siteUrl;
191: }
192:
193: public void setURL(String url) {
194: // no op to please XDoclet
195: }
196:
197: //-------------------------------------------------------------- implementation
198:
199: /**
200: */
201: public void setData(PersistentObject vo) {
202: // TODO Auto-generated method stub
203: }
204:
205: /**
206: */
207: public int compareTo(Object o) {
208: PlanetSubscriptionData other = (PlanetSubscriptionData) o;
209: return getFeedURL().compareTo(other.getFeedURL());
210: }
211:
212: public boolean equals(Object other) {
213:
214: if (this == other)
215: return true;
216: if (!(other instanceof PlanetSubscriptionData))
217: return false;
218:
219: final PlanetSubscriptionData that = (PlanetSubscriptionData) other;
220: return this .feedUrl.equals(that.getFeedURL());
221: }
222:
223: public int hashCode() {
224: return this .feedUrl.hashCode();
225: }
226:
227: /**
228: * @hibernate.bag lazy="true" inverse="true" cascade="all-delete-orphan"
229: * @hibernate.collection-key column="subscription_id"
230: * @hibernate.collection-one-to-many class="org.apache.roller.planet.pojos.PlanetEntryData"
231: */
232: public List getEntries() {
233: return entries;
234: }
235:
236: private void setEntries(List entries) {
237: this .entries = entries;
238: }
239:
240: public void addEntry(PlanetEntryData entry) {
241: // bi-directional one-to-many
242: entry.setSubscription(this );
243: this .getEntries().add(entry);
244: }
245:
246: public void addEntries(Collection newEntries) {
247: // bi-directional one-to-many
248: for (Iterator it = newEntries.iterator(); it.hasNext();) {
249: PlanetEntryData entry = (PlanetEntryData) it.next();
250: entry.setSubscription(this );
251: }
252: this .getEntries().addAll(newEntries);
253: }
254:
255: public void purgeEntries() {
256: this.getEntries().clear();
257: }
258: }
|