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.BORelationalDomainReferenceTableList;
026: import com.metaboss.sdlctools.domains.storagemodel.BORelationalDomainStorage;
027: import com.metaboss.sdlctools.domains.storagemodel.BORelationalReferenceTable;
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 BORelationalDomainReferenceTableListImpl extends
033: BOObjectImpl implements BORelationalDomainReferenceTableList {
034: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
035: private BORelationalDomainStorage mRelationalDomainStorage = null;
036:
037: /* Instance creator */
038: public static BORelationalDomainReferenceTableList createInstanceForExisting(
039: BOMetaBossDomainImpl pMetaBossDomainImpl,
040: BORelationalDomainStorage pRelationalDomainStorage)
041: throws BOException {
042: BORelationalDomainReferenceTableListImpl lImpl = new BORelationalDomainReferenceTableListImpl();
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 BORelationalDomainReferenceTableListImpl()
051: throws BOException {
052: }
053:
054: /* Retrieves definition of entity table or null if none found */
055: public BORelationalReferenceTable getReferenceTable(
056: String pDataTypeRef) throws BOException {
057: return BORelationalReferenceTableImpl
058: .createInstanceForExisting(mMetaBossDomainImpl,
059: mRelationalDomainStorage, pDataTypeRef);
060: }
061:
062: /** Retrieves all entity tables */
063: public BORelationalReferenceTable[] getAllReferenceTables()
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[] lDataTypeRefs = lPs.getReferenceTableRefs(lKey);
075: if (lDataTypeRefs == null || lDataTypeRefs.length == 0)
076: return new BORelationalReferenceTable[0];
077: BORelationalReferenceTable[] lReturn = new BORelationalReferenceTable[lDataTypeRefs.length];
078: for (int i = 0; i < lDataTypeRefs.length; i++) {
079: lReturn[i] = BORelationalReferenceTableImpl
080: .createInstanceForExisting(mMetaBossDomainImpl,
081: mRelationalDomainStorage,
082: lDataTypeRefs[i]);
083: }
084: return lReturn;
085: } catch (NamingException e) {
086: throw new BONamingAndDirectoryServiceInvocationException(
087: "", e);
088: } catch (PSException e) {
089: throw new BOPersistenceServiceInvocationException("", e);
090: }
091: }
092:
093: /** Creates new entity table definition */
094: public BORelationalReferenceTable create(String pDataTypeRef)
095: throws BOException {
096: return BORelationalReferenceTableImpl.createInstanceForNew(
097: fetchTransaction(), mMetaBossDomainImpl,
098: mRelationalDomainStorage, pDataTypeRef);
099: }
100: }
|