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: * Ping Category Restriction. An instance of this class relates an auto ping configuration {@link AutoPingData} to a
025: * specific weblog category {@link WeblogCategoryData}. When one or more instances of this class are present for a
026: * given auto ping configuration, it means that pings should only go out for changes to the categories specified by those
027: * instances. If no instances of this class are present for a given auto ping configuration, it means that the ping
028: * configuration is not restricted by category, so pings should go out for changes in any category.
029: *
030: * @author <a href="mailto:anil@busybuddha.org">Anil Gangolli</a>
031: * @ejb:bean name="AutoPingData"
032: * @hibernate.class lazy="false" table="pingcategory"
033: * @hibernate.cache usage="read-write"
034: */
035: public class PingCategoryRestrictionData extends PersistentObject
036: implements Serializable {
037: private String id;
038: private AutoPingData autoPing;
039: private WeblogCategoryData weblogCategory;
040:
041: static final long serialVersionUID = 2261280579491859418L;
042:
043: /**
044: * Default constructor. Leaves all fields null. Required for bean compliance.
045: */
046: public PingCategoryRestrictionData() {
047: }
048:
049: /**
050: * Constructor
051: *
052: * @param id unique id of this object
053: * @param autoPing auto ping configuration being restricted
054: * @param weblogCategory weblog category to which this auto ping configuration is restricted
055: */
056: public PingCategoryRestrictionData(String id,
057: AutoPingData autoPing, WeblogCategoryData weblogCategory) {
058: this .id = id;
059: this .autoPing = autoPing;
060: this .weblogCategory = weblogCategory;
061: }
062:
063: /**
064: * Setter needed by RollerImpl.storePersistentObject()
065: */
066: public void setData(PersistentObject vo) {
067: PingCategoryRestrictionData other = (PingCategoryRestrictionData) vo;
068: id = other.getId();
069: autoPing = other.getAutoping();
070: weblogCategory = other.getWeblogCategory();
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 auto ping configuration to which this category restriction applies.
096: *
097: * @return the auto ping configuration to which this category restriction applies.
098: * @ejb:persistent-field
099: * @hibernate.many-to-one column="autopingid" cascade="none" not-null="true"
100: */
101: public AutoPingData getAutoping() {
102: return autoPing;
103: }
104:
105: /**
106: * Set the auto ping configuration to which this category restriction applies.
107: *
108: * @param autoPing the auto ping configuration to which this category restriction applies.
109: * @ejb:persistent-field
110: */
111: public void setAutoping(AutoPingData autoPing) {
112: this .autoPing = autoPing;
113: }
114:
115: /**
116: * Get the weblog category. Get the weblog category to which pings should be restricted.
117: *
118: * @return the weblog category to which pings should be restricted.
119: * @ejb:persistent-field
120: * @hibernate.many-to-one column="weblogcategoryid" cascade="none" not-null="true"
121: */
122: public WeblogCategoryData getWeblogCategory() {
123: return weblogCategory;
124: }
125:
126: /**
127: * Set the ping target. Set the target to be pinged when the corresponding website changes.
128: *
129: * @param weblogCategory the weblog category to which pings should be restricted.
130: * @ejb:persistent-field
131: */
132: public void setWeblogCategory(WeblogCategoryData weblogCategory) {
133: this .weblogCategory = weblogCategory;
134: }
135:
136: /**
137: * @see Object#equals(Object)
138: */
139: public boolean equals(Object o) {
140: if (this == o)
141: return true;
142: if (!(o instanceof PingCategoryRestrictionData))
143: return false;
144:
145: final PingCategoryRestrictionData pingCategoryRestrictionData = (PingCategoryRestrictionData) o;
146:
147: if (id != null ? !id
148: .equals(pingCategoryRestrictionData.getId())
149: : pingCategoryRestrictionData.getId() != null) {
150: return false;
151: }
152: if (autoPing != null ? !autoPing
153: .equals(pingCategoryRestrictionData.getAutoping())
154: : pingCategoryRestrictionData.getAutoping() != null) {
155: return false;
156: }
157: if (weblogCategory != null ? !weblogCategory
158: .equals(pingCategoryRestrictionData.getWeblogCategory())
159: : pingCategoryRestrictionData.getWeblogCategory() != 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: }
|