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.BORelationalAssociationTable;
026: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainAssociationTableList;
027: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainStorage;
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 BORelationalDomainAssociationTableListImpl extends
033: BOObjectImpl implements BORelationalDomainAssociationTableList {
034: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
035: private BORelationalDomainStorage mRelationalDomainStorage = null;
036:
037: /* Instance creator */
038: public static BORelationalDomainAssociationTableList createInstanceForExisting(
039: BOMetaBossDomainImpl pMetaBossDomainImpl,
040: BORelationalDomainStorage pRelationalDomainStorage)
041: throws BOException {
042: BORelationalDomainAssociationTableListImpl lImpl = new BORelationalDomainAssociationTableListImpl();
043: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
044: lImpl.mRelationalDomainStorage = pRelationalDomainStorage;
045: lImpl.setupForExisting();
046: return lImpl;
047: }
048:
049: /* Private constructor restricts instance creation from outside */
050: private BORelationalDomainAssociationTableListImpl()
051: throws BOException {
052: }
053:
054: /* Retrieves definition of entity table or null if none found */
055: public BORelationalAssociationTable getAssociationTable(
056: String pAssociationRef) throws BOException {
057: return BORelationalAssociationTableImpl
058: .createInstanceForExisting(mMetaBossDomainImpl,
059: mRelationalDomainStorage, pAssociationRef);
060: }
061:
062: /** Retrieves all entity tables */
063: public BORelationalAssociationTable[] getAllAssociationTables()
064: throws BOException {
065: try {
066: // Get the instance of the enterprise ps home via jndi
067: Context ctx = new InitialContext();
068: PSRelationalDomainStorage lPs = (PSRelationalDomainStorage) ctx
069: .lookup(PSRelationalDomainStorage.COMPONENT_URL);
070: STDomainStorageKey lKey = new STDomainStorageKey();
071: lKey.StorageTechnologyRef = mRelationalDomainStorage
072: .getStorageTechnology().getRef();
073: lKey.DomainRef = mRelationalDomainStorage.getDomainRef();
074: String[] lAssociationRefs = lPs
075: .getAssociationTableRefs(lKey);
076: if (lAssociationRefs == null
077: || lAssociationRefs.length == 0)
078: return new BORelationalAssociationTable[0];
079: BORelationalAssociationTable[] lReturn = new BORelationalAssociationTable[lAssociationRefs.length];
080: for (int i = 0; i < lAssociationRefs.length; i++) {
081: lReturn[i] = BORelationalAssociationTableImpl
082: .createInstanceForExisting(mMetaBossDomainImpl,
083: mRelationalDomainStorage,
084: lAssociationRefs[i]);
085: }
086: return lReturn;
087: } catch (NamingException e) {
088: throw new BONamingAndDirectoryServiceInvocationException(
089: "", e);
090: } catch (PSException e) {
091: throw new BOPersistenceServiceInvocationException("", e);
092: }
093: }
094:
095: /** Creates new entity table definition */
096: public BORelationalAssociationTable create(String pAssociationRef)
097: throws BOException {
098: return BORelationalAssociationTableImpl.createInstanceForNew(
099: fetchTransaction(), mMetaBossDomainImpl,
100: mRelationalDomainStorage, pAssociationRef);
101: }
102: }
|