001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * 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. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018:
019: package org.apache.roller.pojos;
020:
021: import java.io.Serializable;
022:
023: /**
024: * Automatic ping configuration. An instance of this class relates a website and ping target; it indicates that the specified
025: * ping target should be pinged when the corresponding website is changed. Pinging can be restricted to changes to
026: * specific categories on the website by instances of the {@link PingCategoryRestrictionData} object. In the absence of
027: * any category restrictions, the ping target is pinged whenever the corresponding website changes.
028: *
029: * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
030: * @ejb:bean name="AutoPingData"
031: * @hibernate.class lazy="false" table="autoping"
032: * @hibernate.cache usage="read-write"
033: */
034: public class AutoPingData extends PersistentObject implements
035: Serializable {
036: private String id = null;
037: private PingTargetData pingTarget = null;
038: private WebsiteData website = null;
039:
040: public static final long serialVersionUID = -9105985454111986435L;
041:
042: /**
043: * Default constructor. Leaves all fields null. Required for bean compliance.
044: */
045: public AutoPingData() {
046: }
047:
048: /**
049: * Constructor.
050: *
051: * @param id unique id (primary key) for this instance
052: * @param pingtarget ping target that should be pinged
053: * @param website website to which this configuration applies
054: */
055: public AutoPingData(String id, PingTargetData pingtarget,
056: WebsiteData website) {
057: this .id = id;
058: this .website = website;
059: this .pingTarget = pingtarget;
060: }
061:
062: /**
063: * Setter needed by RollerImpl.storePersistentObject()
064: */
065: public void setData(PersistentObject vo) {
066: AutoPingData other = (AutoPingData) vo;
067:
068: id = other.getId();
069: website = other.getWebsite();
070: pingTarget = other.getPingTarget();
071: }
072:
073: /**
074: * Get the unique id (primary key) of this object.
075: *
076: * @return the unique id of this object. -- struts.validator type="required" msgkey="errors.required"
077: * @ejb:persistent-field
078: * @hibernate.id column="id" generator-class="uuid.hex" unsaved-value="null"
079: */
080: public String getId() {
081: return id;
082: }
083:
084: /**
085: * Set the unique id (primary key) of this object
086: *
087: * @param id
088: * @ejb:persistent-field
089: */
090: public void setId(String id) {
091: this .id = id;
092: }
093:
094: /**
095: * Get the website. Get the website whose changes should result in a ping to the ping target specified by this
096: * object.
097: *
098: * @return the website.
099: * @ejb:persistent-field
100: * @hibernate.many-to-one column="websiteid" cascade="none" not-null="false"
101: */
102: public WebsiteData getWebsite() {
103: return website;
104: }
105:
106: /**
107: * Set the website. Set the website whose changes should result in a ping to the ping target specified by this
108: * object.
109: *
110: * @param website the website.
111: * @ejb:persistent-field
112: */
113: public void setWebsite(WebsiteData website) {
114: this .website = website;
115: }
116:
117: /**
118: * Get the ping target. Get the target to be pinged when the corresponding website changes.
119: *
120: * @return the target to be pinged.
121: * @ejb:persistent-field
122: * @hibernate.many-to-one column="pingtargetid" cascade="none" not-null="false"
123: */
124: public PingTargetData getPingTarget() {
125: return pingTarget;
126: }
127:
128: /**
129: * Set the ping target. Set the target to be pinged when the corresponding website changes.
130: *
131: * @param pingtarget the target to be pinged.
132: * @ejb:persistent-field
133: */
134: public void setPingTarget(PingTargetData pingtarget) {
135: this .pingTarget = pingtarget;
136: }
137:
138: /**
139: * @see Object#equals(Object)
140: */
141: public boolean equals(Object o) {
142: if (this == o)
143: return true;
144: if (!(o instanceof AutoPingData))
145: return false;
146:
147: final AutoPingData autoPingData = (AutoPingData) o;
148:
149: if (id != null ? !id.equals(autoPingData.getId())
150: : autoPingData.getId() != null)
151: return false;
152: if (pingTarget != null ? !pingTarget.equals(autoPingData
153: .getPingTarget())
154: : autoPingData.getPingTarget() != null) {
155: return false;
156: }
157: if (website != null ? !website
158: .equals(autoPingData.getWebsite()) : autoPingData
159: .getWebsite() != null) {
160: return false;
161: }
162:
163: return true;
164: }
165:
166: /**
167: * @see Object#hashCode()
168: */
169: public int hashCode() {
170: return (id != null ? id.hashCode() : 0);
171: }
172:
173: /**
174: * Generate a string form of the object appropriate for logging or debugging.
175: *
176: * @return a string form of the object appropriate for logging or debugging.
177: * @see Object#toString()
178: */
179: public String toString() {
180: return "AutoPingData{"
181: + "id='"
182: + id
183: + "'"
184: + ", pingTarget="
185: + pingTarget
186: + ", website= "
187: + (website == null ? "null" : "{id='" + website.getId()
188: + "'} ") + "}";
189: }
190: }
|