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.models.impl.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel;
016:
017: import java.util.Collection;
018: import java.util.Iterator;
019:
020: import org.netbeans.mdr.storagemodel.StorableObject;
021:
022: import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementImpl;
023: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.AssociationRole;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTable;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableAttributeColumn;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTableReferenceColumn;
028:
029: public abstract class RelationalEntityTableImpl extends
030: ModelElementImpl implements RelationalEntityTable {
031: // Required constructor
032: protected RelationalEntityTableImpl(StorableObject storable) {
033: super (storable);
034: }
035:
036: /**
037: * @param pAttribute
038: * @return RelationalEntityTableAttributeColumn describing given attribute or throws exception if none found
039: */
040: public RelationalEntityTableAttributeColumn getAttributeColumn(
041: Attribute pAttribute) {
042: RelationalEntityTableAttributeColumn lFoundAttributeColumn = findAttributeColumn(pAttribute);
043: // Throw exception if nothing found
044: if (lFoundAttributeColumn == null)
045: throw new IllegalArgumentException(
046: "Unable to locate RelationalEntityTableAttributeColumn for given Attribute in the RelationalEntityTable. RelationalEntityTableRef: "
047: + getRef()
048: + ", AttributeRef: "
049: + pAttribute.getRef());
050: return lFoundAttributeColumn;
051: }
052:
053: /**
054: * @param pAttribute
055: * @return RelationalEntityTableAttributeColumn describing given ttribute or null if none found
056: */
057: public RelationalEntityTableAttributeColumn findAttributeColumn(
058: Attribute pAttribute) {
059: Collection lAttributeColumns = getAttributeColumns();
060: if (!lAttributeColumns.isEmpty()) {
061: for (Iterator lAttributeColumnsIterator = lAttributeColumns
062: .iterator(); lAttributeColumnsIterator.hasNext();) {
063: RelationalEntityTableAttributeColumn lAttributeColumn = (RelationalEntityTableAttributeColumn) lAttributeColumnsIterator
064: .next();
065: if (lAttributeColumn.getAttribute().equals(pAttribute))
066: return lAttributeColumn;
067: }
068: }
069: return null;
070: }
071:
072: /**
073: * @param pAttribute
074: * @return RelationalEntityTableAttributeColumn describing given attribute or throws exception if none found
075: */
076: public RelationalEntityTableReferenceColumn getReferenceColumn(
077: AssociationRole pAssociationRole) {
078: RelationalEntityTableReferenceColumn lFoundReferenceColumn = findReferenceColumn(pAssociationRole);
079: // Throw exception if nothing found
080: if (lFoundReferenceColumn == null)
081: throw new IllegalArgumentException(
082: "Unable to locate RelationalEntityTableReferenceColumn for given AssociationRole in the RelationalEntityTable. RelationalEntityTableRef: "
083: + getRef()
084: + ", AssociationRoleRef: "
085: + pAssociationRole.getRef());
086: return lFoundReferenceColumn;
087: }
088:
089: /**
090: * @param pAttribute
091: * @return RelationalEntityTableAttributeColumn describing given ttribute or null if none found
092: */
093: public RelationalEntityTableReferenceColumn findReferenceColumn(
094: AssociationRole pAssociationRole) {
095: Collection lReferenceColumns = getReferenceColumns();
096: if (!lReferenceColumns.isEmpty()) {
097: for (Iterator lReferenceColumnsIterator = lReferenceColumns
098: .iterator(); lReferenceColumnsIterator.hasNext();) {
099: RelationalEntityTableReferenceColumn lReferenceColumn = (RelationalEntityTableReferenceColumn) lReferenceColumnsIterator
100: .next();
101: if (lReferenceColumn.getAssociationRole().equals(
102: pAssociationRole))
103: return lReferenceColumn;
104: }
105: }
106: return null;
107: }
108: }
|