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