001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.rm.resources.publishing;
020:
021: import java.util.*;
022:
023: import org.openharmonise.commons.dsi.*;
024: import org.openharmonise.commons.dsi.dml.*;
025: import org.openharmonise.rm.dsi.*;
026: import org.openharmonise.rm.resources.*;
027:
028: /**
029: * Parent object to allow hierarchies of <code>WebPage</code> objects.
030: *
031: * @author Michael Bell
032: * @version $Revision: 1.2 $
033: *
034: */
035: public class WebPageGroup extends AbstractParentObject {
036:
037: //DB constants
038: private static final String TBL_PAGEGROUP = "page_group";
039:
040: //XML constants
041: public static final String TAG_PAGEGROUP = "PageGroup";
042:
043: private static List CHILD_CLASS_NAMES = null;
044:
045: static {
046: DatabaseInfo.getInstance().registerTableName(
047: WebPageGroup.class.getName(), TBL_PAGEGROUP);
048:
049: try {
050: CHILD_CLASS_NAMES = new Vector();
051: CHILD_CLASS_NAMES.add(WebPage.class.getName());
052: CHILD_CLASS_NAMES.add(WebPageGroup.class.getName());
053:
054: } catch (Exception e) {
055: throw new RuntimeException(e.getMessage());
056: }
057: }
058:
059: /**
060: * Empty constructor.
061: */
062: public WebPageGroup() {
063: super ();
064: }
065:
066: /**
067: * Constructs an object with an interface to the DB.
068: *
069: * @param dbintrf
070: */
071: public WebPageGroup(AbstractDataStoreInterface dbintrf) {
072: super (dbintrf);
073: }
074:
075: /**
076: * Standard constructor for a known object which may be historical.
077: *
078: * @param dbintrf
079: * @param nId
080: * @param bIsHist
081: */
082: public WebPageGroup(AbstractDataStoreInterface dbintrf, int nId,
083: int nKey, boolean bIsHist) {
084: super (dbintrf, nId, nKey, bIsHist);
085: }
086:
087: /**
088: * Standard constructor for a known object.
089: *
090: * @param dbintrf
091: * @param nId
092: */
093: public WebPageGroup(AbstractDataStoreInterface dbintrf, int nId) {
094: super (dbintrf, nId);
095: }
096:
097: /* (non-Javadoc)
098: * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
099: */
100: public String getParentObjectClassName() {
101: return getClass().getName();
102: }
103:
104: /* (non-Javadoc)
105: * @see org.openharmonise.rm.dsi.DataStoreObject#getDBTableName()
106: */
107: public String getDBTableName() {
108: return TBL_PAGEGROUP;
109: }
110:
111: /* (non-Javadoc)
112: * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
113: */
114: public JoinConditions getInstanceJoinConditions(String sObjectTag,
115: boolean bIsOuter) throws DataStoreException {
116: JoinConditions joinConditions = new JoinConditions();
117: DatabaseInfo dbInfo = DatabaseInfo.getInstance();
118: String sChildTableName = null;
119: String sClassName = null;
120:
121: if (sObjectTag.equals("WebPage") == true) {
122: sChildTableName = dbInfo.getTableName(WebPage.class
123: .getName());
124: sClassName = WebPage.class.getName();
125: } else if (sObjectTag.equals("WebPageGroup") == true) {
126: sChildTableName = dbInfo.getTableName(WebPageGroup.class
127: .getName());
128: sClassName = WebPageGroup.class.getName();
129: } else {
130: throw new DataStoreException("Invalid child object.");
131: }
132:
133: // get the child and parent keys from the join table
134: ColumnRef childKeyCol = getGroupChildJoinColumnRef(
135: sChildTableName, CLMN_CHILD_KEY);
136: ColumnRef parentKeyCol = getGroupChildJoinColumnRef(
137: sChildTableName, CLMN_PARENT_KEY);
138:
139: joinConditions.addCondition(getInstanceColumnRef(
140: AbstractObject.ATTRIB_KEY, false), parentKeyCol);
141: if (sObjectTag.equals("WebPage") == true) {
142: joinConditions.addCondition(WebPage.getColumnRef(
143: sClassName, AbstractObject.ATTRIB_KEY, false),
144: childKeyCol);
145: } else if (sObjectTag.equals("WebPageGroup") == true) {
146: joinConditions.addCondition(getColumnRef(sClassName,
147: AbstractObject.ATTRIB_KEY, false), childKeyCol);
148: }
149:
150: return joinConditions;
151: }
152:
153: /* (non-Javadoc)
154: * @see org.openharmonise.rm.publishing.Publishable#getTagName()
155: */
156: public String getTagName() {
157:
158: return TAG_PAGEGROUP;
159: }
160:
161: /*----------------------------------------------------------------------------
162: Protected methods
163: -----------------------------------------------------------------------------*/
164:
165: /* (non-Javadoc)
166: * @see org.openharmonise.rm.resources.AbstractParentObject#getChildClassNames()
167: */
168: public List getChildClassNames() {
169: return CHILD_CLASS_NAMES;
170: }
171:
172: }
|