001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.domains.storagemodel.impl;
016:
017: import javax.naming.Context;
018: import javax.naming.InitialContext;
019: import javax.naming.NamingException;
020:
021: import com.metaboss.enterprise.bo.BOException;
022: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
023: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
024: import com.metaboss.enterprise.ps.PSException;
025: import com.metaboss.sdlctools.domains.storagemodel.BORelationalEntityTable;
026: import com.metaboss.sdlctools.domains.storagemodel.BORelationalEntityTableAssociationRole;
027: import com.metaboss.sdlctools.domains.storagemodel.BORelationalEntityTableAssociationRoleList;
028: import com.metaboss.sdlctools.domains.storagemodel.storage.PSRelationalDomainStorage;
029: import com.metaboss.sdlctools.domains.storagemodel.storage.STDomainStorageKey;
030: import com.oldboss.framework.bo.impl.BOObjectImpl;
031:
032: public class BORelationalEntityTableAssociationRoleListImpl extends
033: BOObjectImpl implements
034: BORelationalEntityTableAssociationRoleList {
035: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
036: private BORelationalEntityTable mRelationalEntityTable = null;
037:
038: /* Instance creator */
039: public static BORelationalEntityTableAssociationRoleList createInstanceForExisting(
040: BOMetaBossDomainImpl pMetaBossDomainImpl,
041: BORelationalEntityTable pRelationalEntityTable)
042: throws BOException {
043: BORelationalEntityTableAssociationRoleListImpl lImpl = new BORelationalEntityTableAssociationRoleListImpl();
044: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
045: lImpl.mRelationalEntityTable = pRelationalEntityTable;
046: lImpl.setupForExisting();
047: return lImpl;
048: }
049:
050: /* Private constructor restricts instance creation from outside */
051: private BORelationalEntityTableAssociationRoleListImpl()
052: throws BOException {
053: }
054:
055: /* Retrieves definition of entity table or null if none found */
056: public BORelationalEntityTableAssociationRole getEntityTableAssociationRole(
057: String pAssociationRoleRef) throws BOException {
058: return BORelationalEntityTableAssociationRoleImpl
059: .createInstanceForExisting(mMetaBossDomainImpl,
060: mRelationalEntityTable, pAssociationRoleRef);
061: }
062:
063: /* Retrieves all entity tables */
064: public BORelationalEntityTableAssociationRole[] getAllEntityTableAssociationRoles()
065: throws BOException {
066: try {
067: // Get the instance of the enterprise ps home via jndi
068: Context ctx = new InitialContext();
069: PSRelationalDomainStorage lPs = (PSRelationalDomainStorage) ctx
070: .lookup(PSRelationalDomainStorage.COMPONENT_URL);
071: STDomainStorageKey lKey = new STDomainStorageKey();
072: lKey.StorageTechnologyRef = mRelationalEntityTable
073: .getDomainStorage().getStorageTechnology().getRef();
074: lKey.DomainRef = mRelationalEntityTable.getDomainStorage()
075: .getDomainRef();
076: String[] lAssociationRoleRefs = lPs
077: .getEntityTableAssociationRoleRefs(lKey,
078: mRelationalEntityTable.getEntityRef());
079: if (lAssociationRoleRefs == null
080: || lAssociationRoleRefs.length == 0)
081: return new BORelationalEntityTableAssociationRole[0];
082: BORelationalEntityTableAssociationRole[] lReturn = new BORelationalEntityTableAssociationRole[lAssociationRoleRefs.length];
083: for (int i = 0; i < lAssociationRoleRefs.length; i++) {
084: lReturn[i] = BORelationalEntityTableAssociationRoleImpl
085: .createInstanceForExisting(mMetaBossDomainImpl,
086: mRelationalEntityTable,
087: lAssociationRoleRefs[i]);
088: }
089: return lReturn;
090: } catch (NamingException e) {
091: throw new BONamingAndDirectoryServiceInvocationException(
092: "", e);
093: } catch (PSException e) {
094: throw new BOPersistenceServiceInvocationException("", e);
095: }
096: }
097:
098: /** Creates new entity table definition */
099: public BORelationalEntityTableAssociationRole create(
100: String pAssociationRoleRef) throws BOException {
101: return BORelationalEntityTableAssociationRoleImpl
102: .createInstanceForNew(fetchTransaction(),
103: mMetaBossDomainImpl, mRelationalEntityTable,
104: pAssociationRoleRef);
105: }
106: }
|