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.enterprisemodel.impl;
016:
017: import com.metaboss.enterprise.bo.BOException;
018: import com.metaboss.enterprise.bo.BOIllegalArgumentException;
019: import com.metaboss.sdlctools.domains.enterprisemodel.BOAssociationRole;
020: import com.metaboss.sdlctools.domains.enterprisemodel.BOAttribute;
021: import com.metaboss.sdlctools.domains.enterprisemodel.BOEntity;
022: import com.metaboss.sdlctools.domains.enterprisemodel.BOPrimaryKeyElement;
023: import com.metaboss.sdlctools.types.enterprisemodel.PrimaryKeyElementType;
024: import com.oldboss.framework.bo.impl.BOObjectImpl;
025:
026: public class BOPrimaryKeyElementImpl extends BOObjectImpl implements
027: BOPrimaryKeyElement {
028: protected BOMetaBossDomainImpl mMetaBossDomainImpl = null;
029: private BOEntity mOwnerEntity = null;
030: private PrimaryKeyElementType mType = null;
031: private BOAttribute mUnderlyingAttribute = null;
032: private BOAssociationRole mUnderlyingAssociationRole = null;
033:
034: /* Instance creator */
035: public static BOPrimaryKeyElement createInstanceForExisting(
036: BOMetaBossDomainImpl pMetaBossDomainImpl,
037: BOEntity pOwnerEntity, BOAttribute pUnderlyingAttribute)
038: throws BOException {
039: // Assert some input arguments
040: if (pMetaBossDomainImpl == null)
041: throw new BOIllegalArgumentException(
042: "pMetaBossDomainImpl can not be null");
043: if (pOwnerEntity == null)
044: throw new BOIllegalArgumentException(
045: "pOwnerEntity can not be null");
046: if (pUnderlyingAttribute == null)
047: throw new BOIllegalArgumentException(
048: "pUnderlyingAttribute can not be null");
049: // Create instance
050: BOPrimaryKeyElementImpl lImpl = new BOPrimaryKeyElementImpl();
051: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
052: lImpl.mOwnerEntity = pOwnerEntity;
053: lImpl.mType = PrimaryKeyElementType.ATTRIBUTE;
054: lImpl.mUnderlyingAttribute = pUnderlyingAttribute;
055: lImpl.setupForExisting();
056: return lImpl;
057: }
058:
059: /* Instance creator */
060: public static BOPrimaryKeyElement createInstanceForExisting(
061: BOMetaBossDomainImpl pMetaBossDomainImpl,
062: BOEntity pOwnerEntity,
063: BOAssociationRole pUnderlyingAssociationRole)
064: throws BOException {
065: // Assert some input arguments
066: if (pMetaBossDomainImpl == null)
067: throw new BOIllegalArgumentException(
068: "pMetaBossDomainImpl can not be null");
069: if (pOwnerEntity == null)
070: throw new BOIllegalArgumentException(
071: "pOwnerEntity can not be null");
072: if (pUnderlyingAssociationRole == null)
073: throw new BOIllegalArgumentException(
074: "pUnderlyingAssociationRole can not be null");
075: // Create instance
076: BOPrimaryKeyElementImpl lImpl = new BOPrimaryKeyElementImpl();
077: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
078: lImpl.mOwnerEntity = pOwnerEntity;
079: lImpl.mType = PrimaryKeyElementType.ASSOCIATION;
080: lImpl.mUnderlyingAssociationRole = pUnderlyingAssociationRole;
081: lImpl.setupForExisting();
082: return lImpl;
083: }
084:
085: /* Returns entity which owns this attribute */
086: public BOEntity getEntity() throws BOException {
087: return mOwnerEntity;
088: }
089:
090: /* Returns type of the element : Attribute or AssociationRole */
091: public PrimaryKeyElementType getType() throws BOException {
092: return mType;
093: }
094:
095: /* Returns underlying attribute - note that this will only return not null if element type is PrimaryKeyElementType.ATTRIBUTE */
096: public BOAttribute getUnderlyingAttribute() throws BOException {
097: return mUnderlyingAttribute;
098: }
099:
100: /* Returns underlying association role - note that this will only return not null if element type is PrimaryKeyElementType.ASSOCIATION */
101: public BOAssociationRole getUnderlyingAssociationRole()
102: throws BOException {
103: return mUnderlyingAssociationRole;
104: }
105: }
|