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.xml;
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>XSLResource</code> objects.
030: *
031: * @author Michael Bell
032: * @version $Revision: 1.2 $
033: *
034: */
035: public class XSLResourceGroup extends AbstractParentObject {
036:
037: // DB constants
038: private static final String TBL_XSL_GROUP = "xsl_group";
039:
040: //XML constants
041: public static final String TAG_XSL_GROUP = "XSLGroup";
042:
043: //member variables
044: private static List CHILD_CLASS_NAMES = null;
045:
046: static {
047: DatabaseInfo.getInstance().registerTableName(
048: XSLResourceGroup.class.getName(), TBL_XSL_GROUP);
049:
050: try {
051: CHILD_CLASS_NAMES = new Vector();
052: CHILD_CLASS_NAMES.add(XSLResourceGroup.class.getName());
053: CHILD_CLASS_NAMES.add(XSLResource.class.getName());
054:
055: } catch (Exception e) {
056: throw new RuntimeException(e.getMessage());
057: }
058: }
059:
060: /**
061: * Basic constructor
062: */
063: public XSLResourceGroup() {
064: super ();
065: }
066:
067: /**
068: * Basic constructor with an interface to the DB.
069: *
070: * @param dbintrf
071: */
072: public XSLResourceGroup(AbstractDataStoreInterface dbintrf) {
073: super (dbintrf);
074: }
075:
076: /**
077: * Standard constructor for a known existing <code>XSLResourceGroup</code>.
078: *
079: * @param dbintrf
080: * @param nId
081: */
082: public XSLResourceGroup(AbstractDataStoreInterface dbintrf, int nId) {
083: super (dbintrf, nId);
084: }
085:
086: /* (non-Javadoc)
087: * @see org.openharmonise.rm.resources.AbstractChildObject#getParentObjectClassName()
088: */
089: public String getParentObjectClassName() {
090: return getClass().getName();
091: }
092:
093: /* (non-Javadoc)
094: * @see org.openharmonise.rm.dsi.DataStoreObject#getDBTableName()
095: */
096: public String getDBTableName() {
097: return TBL_XSL_GROUP;
098: }
099:
100: /* (non-Javadoc)
101: * @see org.openharmonise.rm.dsi.DataStoreObject#getInstanceJoinConditions(java.lang.String, boolean)
102: */
103: public JoinConditions getInstanceJoinConditions(String sObjectTag,
104: boolean bIsOuter) throws DataStoreException {
105: JoinConditions joinConditions = new JoinConditions();
106: DatabaseInfo dbInfo = DatabaseInfo.getInstance();
107: String sChildTableName = null;
108: String sClassName = null;
109:
110: if (sObjectTag.equals("XSLResource") == true) {
111: sChildTableName = dbInfo.getTableName(XSLResource.class
112: .getName());
113: sClassName = XSLResource.class.getName();
114: } else if (sObjectTag.equals("XSLResourceGroup") == true) {
115: sChildTableName = dbInfo
116: .getTableName(XSLResourceGroup.class.getName());
117: sClassName = XSLResourceGroup.class.getName();
118: } else {
119: throw new DataStoreException("Invalid child object.");
120: }
121:
122: // get the child and parent keys from the join table
123: ColumnRef childKeyCol = getGroupChildJoinColumnRef(
124: sChildTableName, CLMN_CHILD_KEY);
125: ColumnRef parentKeyCol = getGroupChildJoinColumnRef(
126: sChildTableName, CLMN_PARENT_KEY);
127:
128: joinConditions.addCondition(getInstanceColumnRef(
129: AbstractObject.ATTRIB_KEY, false), parentKeyCol);
130: if (sObjectTag.equals("XSLResource") == true) {
131: joinConditions.addCondition(XSLResource.getColumnRef(
132: sClassName, AbstractObject.ATTRIB_KEY, false),
133: childKeyCol);
134: } else if (sObjectTag.equals("XSLResourceGroup") == true) {
135: joinConditions.addCondition(getColumnRef(sClassName,
136: AbstractObject.ATTRIB_KEY, false), childKeyCol);
137: }
138:
139: return joinConditions;
140: }
141:
142: /* (non-Javadoc)
143: * @see org.openharmonise.rm.publishing.Publishable#getTagName()
144: */
145: public String getTagName() {
146:
147: return TAG_XSL_GROUP;
148: }
149:
150: /*----------------------------------------------------------------------------
151: Protected methods
152: -----------------------------------------------------------------------------*/
153:
154: /* (non-Javadoc)
155: * @see org.openharmonise.rm.resources.AbstractParentObject#getChildClassNames()
156: */
157: public List getChildClassNames() {
158: return CHILD_CLASS_NAMES;
159: }
160:
161: }
|