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: package org.apache.roller.pojos;
019:
020: import org.apache.roller.RollerException;
021: import org.apache.roller.business.RollerFactory;
022:
023: /**
024: * <p>WeblogCategoryAssoc represents association between weblog categories
025: * in the weblog category hierarchy. For each category, there will be zero
026: * or one parent category association and zero or more grandparent
027: * associations.</p>
028: *
029: * <p>Creating a new Cat</p>
030: * WeblogManager creates new Cat, not a PO<br />
031: * Cat has a parent Cat or null if parent is null. Parent must be PO.<br />
032: * On save, CatAssoc will be created for Cat.<br />
033: *
034: * <p>Saving an existing Cat</p>
035: * If Cat has a new parent Cat, then update all of Cat's CatAssocs<br />
036: *
037: * @author David M Johnson
038: *
039: * @ejb:bean name="WeblogCategoryAssoc"
040: * @hibernate.class lazy="false" table="weblogcategoryassoc"
041: * @hibernate.cache usage="read-write"
042: */
043: public class WeblogCategoryAssoc extends PersistentObject implements
044: Assoc {
045: static final long serialVersionUID = 674856287447472015L;
046:
047: private String id;
048: private WeblogCategoryData category;
049: private WeblogCategoryData ancestor;
050: private java.lang.String relation;
051:
052: public WeblogCategoryAssoc() {
053: }
054:
055: public WeblogCategoryAssoc(String id, WeblogCategoryData category,
056: WeblogCategoryData ancestor, java.lang.String relation) {
057: this .id = id;
058: this .category = category;
059: this .ancestor = ancestor;
060: this .relation = relation;
061: }
062:
063: public WeblogCategoryAssoc(WeblogCategoryAssoc otherData) {
064: setData(otherData);
065: }
066:
067: /**
068: * @ejb:persistent-field
069: * @hibernate.id column="id"
070: * generator-class="uuid.hex" unsaved-value="null"
071: */
072: public java.lang.String getId() {
073: return this .id;
074: }
075:
076: /** @ejb:persistent-field */
077: public void setId(java.lang.String id) {
078: this .id = id;
079: }
080:
081: /**
082: * Setter is needed in RollerImpl.storePersistentObject()
083: */
084: public void setData(
085: org.apache.roller.pojos.PersistentObject otherData) {
086: this .id = otherData.getId();
087: this .category = ((WeblogCategoryAssoc) otherData).getCategory();
088: this .ancestor = ((WeblogCategoryAssoc) otherData)
089: .getAncestorCategory();
090: this .relation = ((WeblogCategoryAssoc) otherData).getRelation();
091: }
092:
093: /**
094: * @ejb:persistent-field
095: * @hibernate.many-to-one column="ancestorid" cascade="none"
096: */
097: public WeblogCategoryData getAncestorCategory() {
098: return ancestor;
099: }
100:
101: /** @ejb:persistent-field */
102: public void setAncestorCategory(WeblogCategoryData data) {
103: ancestor = data;
104: }
105:
106: /**
107: * @ejb:persistent-field
108: * @hibernate.many-to-one column="categoryid" cascade="none" not-null="true"
109: */
110: public WeblogCategoryData getCategory() {
111: return category;
112: }
113:
114: /** @ejb:persistent-field */
115: public void setCategory(WeblogCategoryData data) {
116: category = data;
117: }
118:
119: /**
120: * @ejb:persistent-field
121: * @hibernate.property column="relation" non-null="true" unique="false"
122: */
123: public java.lang.String getRelation() {
124: return relation;
125: }
126:
127: /** @ejb:persistent-field */
128: public void setRelation(java.lang.String string) {
129: relation = string;
130: }
131:
132: public HierarchicalPersistentObject getObject() {
133: return getCategory();
134: }
135:
136: public void setObject(HierarchicalPersistentObject hpo) {
137: setCategory((WeblogCategoryData) hpo);
138: }
139:
140: public HierarchicalPersistentObject getAncestor() {
141: return getAncestorCategory();
142: }
143:
144: public void setAncestor(HierarchicalPersistentObject hpo) {
145: setAncestorCategory((WeblogCategoryData) hpo);
146: }
147: }
|