KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > users > UserGroup


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.users;
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.publishing.*;
27 import org.openharmonise.rm.resources.*;
28 import org.openharmonise.rm.resources.lifecycle.*;
29
30
31 /**
32  * This class provides the functionality to manage groups of
33  * <code>User</code> objects.
34  *
35  * @author Michael Bell
36  * @version $Revision: 1.2 $
37  *
38  */

39 public class UserGroup
40     extends AbstractParentObject
41     implements DataStoreObject, Publishable, Editable, Cloneable JavaDoc, Comparable JavaDoc {
42
43     //DB constants
44
private static final String JavaDoc TBL_USERGROUP = "users_group";
45
46     //XML constants
47
public static final String JavaDoc TAG_USERGROUP = "UserGroup";
48
49     // member variables
50
private static List CHILD_CLASS_NAMES = null;
51
52     static {
53         DatabaseInfo.getInstance().registerTableName(
54             UserGroup.class.getName(),
55             TBL_USERGROUP);
56
57         try {
58             CHILD_CLASS_NAMES = new Vector();
59             CHILD_CLASS_NAMES.add(User.class.getName());
60             CHILD_CLASS_NAMES.add(UserGroup.class.getName());
61
62         } catch (Exception JavaDoc e) {
63             throw new RuntimeException JavaDoc(e.getMessage());
64         }
65     }
66
67     /**
68      * Basic empty constructor.
69      *
70      */

71     public UserGroup() {
72         super();
73
74     }
75
76     /**
77      * Constructs an object with an interface to the DB.
78      *
79      * @param dbinterf
80      */

81     public UserGroup(AbstractDataStoreInterface dbinterf) {
82         super(dbinterf);
83     }
84
85     /**
86      * Constructs a historical object with an interface to the DB.
87      *
88      * @param dbinterf
89      * @param bHist
90      */

91     public UserGroup(AbstractDataStoreInterface dbinterf, boolean bHist) {
92         super(dbinterf);
93     }
94
95     /**
96      * Standard constructor for an object with a known id.
97      *
98      * @param dbinterf
99      * @param nId
100      */

101     public UserGroup(AbstractDataStoreInterface dbinterf, int nId) {
102         super(dbinterf, nId);
103
104     }
105
106     /**
107      * Standard constructor for a historical object with a known id.
108      *
109      * @param dbinterf
110      * @param nId
111      * @param bHist
112      */

113     public UserGroup(
114         AbstractDataStoreInterface dbinterf,
115         int nId,
116         int nKey,
117         boolean bHist)
118         throws Exception JavaDoc {
119         super(dbinterf, nId, nKey, bHist);
120
121     }
122
123     /* (non-Javadoc)
124      * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
125      */

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

155     public String JavaDoc toString() {
156         String JavaDoc output = "";
157
158         try {
159             output = output + super.toString();
160
161             output =
162                 output
163                     + " UserGroup id:"
164                     + Integer.toString(m_nId)
165                     + " title:"
166                     + this.m_sName
167                     + " summary:"
168                     + this.m_sSummary;
169
170         } catch (Exception JavaDoc e) {
171             throw new RuntimeException JavaDoc("UserGroup toString exploded!");
172         }
173
174         return output;
175     }
176
177     /* (non-Javadoc)
178      * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
179      */

180     public String JavaDoc getParentObjectClassName() {
181         return UserGroup.class.getName();
182     }
183
184     /* (non-Javadoc)
185      * @see org.openharmonise.rm.dsi.DataStoreObject#getDBTableName()
186      */

187     public String JavaDoc getDBTableName() {
188         return TBL_USERGROUP;
189     }
190
191     /* (non-Javadoc)
192      * @see org.openharmonise.rm.publishing.Publishable#getTagName()
193      */

194     public String JavaDoc getTagName() {
195         return TAG_USERGROUP;
196     }
197
198     /*----------------------------------------------------------------------------
199     Protected methods
200     -----------------------------------------------------------------------------*/

201
202     /* (non-Javadoc)
203      * @see org.openharmonise.rm.resources.AbstractParentObject#getChildClassNames()
204      */

205     public List getChildClassNames() {
206         return CHILD_CLASS_NAMES;
207     }
208 }
Popular Tags