01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.domains.storagemodel.impl;
16:
17: import javax.naming.Context;
18: import javax.naming.InitialContext;
19: import javax.naming.NamingException;
20:
21: import com.metaboss.enterprise.bo.BOException;
22: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
23: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
24: import com.metaboss.enterprise.ps.PSException;
25: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainEntityTableList;
26: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainStorage;
27: import com.metaboss.sdlctools.domains.storagemodel.BORelationalEntityTable;
28: import com.metaboss.sdlctools.domains.storagemodel.storage.PSRelationalDomainStorage;
29: import com.metaboss.sdlctools.domains.storagemodel.storage.STDomainStorageKey;
30: import com.oldboss.framework.bo.impl.BOObjectImpl;
31:
32: public class BORelationalDomainEntityTableListImpl extends BOObjectImpl
33: implements BORelationalDomainEntityTableList {
34: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
35: private BORelationalDomainStorage mRelationalDomainStorage = null;
36:
37: /* Instance creator */
38: public static BORelationalDomainEntityTableList createInstanceForExisting(
39: BOMetaBossDomainImpl pMetaBossDomainImpl,
40: BORelationalDomainStorage pRelationalDomainStorage)
41: throws BOException {
42: BORelationalDomainEntityTableListImpl lImpl = new BORelationalDomainEntityTableListImpl();
43: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
44: lImpl.mRelationalDomainStorage = pRelationalDomainStorage;
45: lImpl.setupForExisting();
46: return lImpl;
47: }
48:
49: /* Private constructor restricts instance creation from outside */
50: private BORelationalDomainEntityTableListImpl() throws BOException {
51: }
52:
53: /* Retrieves definition of entity table or null if none found */
54: public BORelationalEntityTable getEntityTable(String pEntityRef)
55: throws BOException {
56: return BORelationalEntityTableImpl.createInstanceForExisting(
57: mMetaBossDomainImpl, mRelationalDomainStorage,
58: pEntityRef);
59: }
60:
61: /** Retrieves all entity tables */
62: public BORelationalEntityTable[] getAllEntityTables()
63: throws BOException {
64: try {
65: // Get the instance of the enterprise ps home via jndi
66: Context ctx = new InitialContext();
67: PSRelationalDomainStorage lPs = (PSRelationalDomainStorage) ctx
68: .lookup(PSRelationalDomainStorage.COMPONENT_URL);
69: STDomainStorageKey lKey = new STDomainStorageKey();
70: lKey.StorageTechnologyRef = mRelationalDomainStorage
71: .getStorageTechnology().getRef();
72: lKey.DomainRef = mRelationalDomainStorage.getDomainRef();
73: String[] lEntityRefs = lPs.getEntityTableRefs(lKey);
74: if (lEntityRefs == null || lEntityRefs.length == 0)
75: return new BORelationalEntityTable[0];
76: BORelationalEntityTable[] lReturn = new BORelationalEntityTable[lEntityRefs.length];
77: for (int i = 0; i < lEntityRefs.length; i++) {
78: lReturn[i] = BORelationalEntityTableImpl
79: .createInstanceForExisting(mMetaBossDomainImpl,
80: mRelationalDomainStorage,
81: lEntityRefs[i]);
82: }
83: return lReturn;
84: } catch (NamingException e) {
85: throw new BONamingAndDirectoryServiceInvocationException(
86: "", e);
87: } catch (PSException e) {
88: throw new BOPersistenceServiceInvocationException("", e);
89: }
90: }
91:
92: /** Creates new entity table definition */
93: public BORelationalEntityTable create(String pEntityRef)
94: throws BOException {
95: return BORelationalEntityTableImpl.createInstanceForNew(
96: fetchTransaction(), mMetaBossDomainImpl,
97: mRelationalDomainStorage, pEntityRef);
98: }
99: }
|