KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > rm > resources > xml > XSLResourceGroup


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.xml;
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  * Parent object to allow hierarchies of <code>XSLResource</code> objects.
31  *
32  * @author Michael Bell
33  * @version $Revision: 1.2 $
34  *
35  */

36 public class XSLResourceGroup extends AbstractParentObject {
37
38     // DB constants
39
private static final String JavaDoc TBL_XSL_GROUP = "xsl_group";
40
41     //XML constants
42
public static final String JavaDoc TAG_XSL_GROUP = "XSLGroup";
43
44     //member variables
45
private static List CHILD_CLASS_NAMES = null;
46
47     static {
48         DatabaseInfo.getInstance().registerTableName(
49             XSLResourceGroup.class.getName(),
50             TBL_XSL_GROUP);
51
52         try {
53             CHILD_CLASS_NAMES = new Vector();
54             CHILD_CLASS_NAMES.add(XSLResourceGroup.class.getName());
55             CHILD_CLASS_NAMES.add(XSLResource.class.getName());
56
57         } catch (Exception JavaDoc e) {
58             throw new RuntimeException JavaDoc(e.getMessage());
59         }
60     }
61
62     /**
63      * Basic constructor
64      */

65     public XSLResourceGroup() {
66         super();
67     }
68
69     /**
70      * Basic constructor with an interface to the DB.
71      *
72      * @param dbintrf
73      */

74     public XSLResourceGroup(AbstractDataStoreInterface dbintrf) {
75         super(dbintrf);
76     }
77
78     /**
79      * Standard constructor for a known existing <code>XSLResourceGroup</code>.
80      *
81      * @param dbintrf
82      * @param nId
83      */

84     public XSLResourceGroup(AbstractDataStoreInterface dbintrf, int nId) {
85         super(dbintrf, nId);
86     }
87
88     /* (non-Javadoc)
89      * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
90      */

91     public String JavaDoc getParentObjectClassName() {
92         return getClass().getName();
93     }
94
95     /* (non-Javadoc)
96      * @see org.openharmonise.rm.dsi.DataStoreObject#getDBTableName()
97      */

98     public String JavaDoc getDBTableName() {
99         return TBL_XSL_GROUP;
100     }
101
102     /* (non-Javadoc)
103      * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
104      */

105     public JoinConditions getInstanceJoinConditions(
106         String JavaDoc sObjectTag,
107         boolean bIsOuter)
108         throws DataStoreException {
109       JoinConditions joinConditions = new JoinConditions();
110       DatabaseInfo dbInfo = DatabaseInfo.getInstance();
111       String JavaDoc sChildTableName = null;
112       String JavaDoc sClassName = null;
113     
114       if (sObjectTag.equals("XSLResource") == true) {
115         sChildTableName = dbInfo.getTableName(XSLResource.class.getName());
116         sClassName = XSLResource.class.getName();
117       } else if (sObjectTag.equals("XSLResourceGroup") == true) {
118         sChildTableName = dbInfo.getTableName(XSLResourceGroup.class.getName());
119         sClassName = XSLResourceGroup.class.getName();
120       } else {
121         throw new DataStoreException("Invalid child object.");
122       }
123     
124       // get the child and parent keys from the join table
125
ColumnRef childKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_CHILD_KEY);
126       ColumnRef parentKeyCol = getGroupChildJoinColumnRef(sChildTableName, CLMN_PARENT_KEY);
127
128       joinConditions.addCondition(getInstanceColumnRef(AbstractObject.ATTRIB_KEY, false), parentKeyCol);
129       if (sObjectTag.equals("XSLResource") == true) {
130         joinConditions.addCondition(XSLResource.getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol);
131       } else if (sObjectTag.equals("XSLResourceGroup") == true) {
132         joinConditions.addCondition(getColumnRef(sClassName, AbstractObject.ATTRIB_KEY, false), childKeyCol);
133       }
134
135       return joinConditions;
136     }
137
138     /* (non-Javadoc)
139      * @see org.openharmonise.rm.publishing.Publishable#getTagName()
140      */

141     public String JavaDoc getTagName() {
142
143         return TAG_XSL_GROUP;
144     }
145
146     /*----------------------------------------------------------------------------
147     Protected methods
148     -----------------------------------------------------------------------------*/

149
150     /* (non-Javadoc)
151      * @see org.openharmonise.rm.resources.AbstractParentObject#getChildClassNames()
152      */

153     public List getChildClassNames() {
154         return CHILD_CLASS_NAMES;
155     }
156
157 }
158
Popular Tags