KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > publishing > WebPageGroup


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.rm.resources.publishing;
20
21 import java.util.*;
22
23 import org.openharmonise.commons.dsi.*;
24 import org.openharmonise.commons.dsi.dml.*;
25 import org.openharmonise.rm.dsi.*;
26 import org.openharmonise.rm.resources.*;
27
28
29
30
31 /**
32  * Parent object to allow hierarchies of <code>WebPage</code> objects.
33  *
34  * @author Michael Bell
35  * @version $Revision: 1.2 $
36  *
37  */

38 public class WebPageGroup extends AbstractParentObject {
39
40    
41     //DB constants
42
private static final String JavaDoc TBL_PAGEGROUP = "page_group";
43     
44     //XML constants
45
public static final String JavaDoc TAG_PAGEGROUP = "PageGroup";
46     
47     private static List CHILD_CLASS_NAMES = null;
48
49
50     static {
51         DatabaseInfo.getInstance().registerTableName(WebPageGroup.class.getName(),TBL_PAGEGROUP);
52         
53         try {
54             CHILD_CLASS_NAMES = new Vector();
55             CHILD_CLASS_NAMES.add(WebPage.class.getName());
56             CHILD_CLASS_NAMES.add(WebPageGroup.class.getName());
57             
58         } catch (Exception JavaDoc e) {
59             throw new RuntimeException JavaDoc(e.getMessage());
60         }
61     }
62
63     /**
64      * Empty constructor.
65      */

66     public WebPageGroup() {
67         super();
68     }
69
70     /**
71      * Constructs an object with an interface to the DB.
72      *
73      * @param dbintrf
74      */

75     public WebPageGroup(AbstractDataStoreInterface dbintrf) {
76         super(dbintrf);
77     }
78
79     /**
80      * Standard constructor for a known object which may be historical.
81      *
82      * @param dbintrf
83      * @param nId
84      * @param bIsHist
85      */

86     public WebPageGroup(
87         AbstractDataStoreInterface dbintrf,
88         int nId,
89         int nKey,
90         boolean bIsHist) {
91         super(dbintrf, nId, nKey, bIsHist);
92     }
93
94     /**
95      * Standard constructor for a known object.
96      *
97      * @param dbintrf
98      * @param nId
99      */

100     public WebPageGroup(AbstractDataStoreInterface dbintrf, int nId) {
101         super(dbintrf, nId);
102     }
103
104
105     /* (non-Javadoc)
106      * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
107      */

108     public String JavaDoc getParentObjectClassName() {
109         return getClass().getName();
110     }
111
112     /* (non-Javadoc)
113      * @see org.openharmonise.rm.dsi.DataStoreObject#getDBTableName()
114      */

115     public String JavaDoc getDBTableName() {
116         return TBL_PAGEGROUP;
117     }
118
119     /* (non-Javadoc)
120      * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
121      */

122     public JoinConditions getInstanceJoinConditions(String JavaDoc sObjectTag, boolean bIsOuter) throws DataStoreException {
123         JoinConditions joinConditions = new JoinConditions();
124         DatabaseInfo dbInfo = DatabaseInfo.getInstance();
125         String JavaDoc sChildTableName = null;
126         String JavaDoc sClassName = null;
127         
128         if (sObjectTag.equals("WebPage") == true) {
129           sChildTableName = dbInfo.getTableName(WebPage.class.getName());
130           sClassName = WebPage.class.getName();
131         } else if (sObjectTag.equals("WebPageGroup") == true) {
132           sChildTableName = dbInfo.getTableName(WebPageGroup.class.getName());
133           sClassName = WebPageGroup.class.getName();
134         } else {
135           throw new DataStoreException("Invalid child object.");
136         }
137         
138         // get the child and parent keys from the join table
139
ColumnRef childKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_CHILD_KEY);
140         ColumnRef parentKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_PARENT_KEY);
141     
142         joinConditions.addCondition(getInstanceColumnRef(AbstractObject.ATTRIB_KEY, false), parentKeyCol);
143         if (sObjectTag.equals("WebPage") == true) {
144           joinConditions.addCondition(WebPage.getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol);
145         } else if (sObjectTag.equals("WebPageGroup") == true) {
146           joinConditions.addCondition(getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol);
147         }
148     
149         return joinConditions;
150     }
151
152     /* (non-Javadoc)
153      * @see org.openharmonise.rm.publishing.Publishable#getTagName()
154      */

155     public String JavaDoc getTagName() {
156     
157         return TAG_PAGEGROUP;
158     }
159     
160     /*----------------------------------------------------------------------------
161     Protected methods
162     -----------------------------------------------------------------------------*/

163
164     /* (non-Javadoc)
165      * @see org.openharmonise.rm.resources.AbstractParentObject#getChildClassNames()
166      */

167     public List getChildClassNames() {
168         return CHILD_CLASS_NAMES;
169     }
170
171 }
172
Popular Tags