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.datadictionarymodel.DataType;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Association;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.DomainRelationalStorageDefinition;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalAssociationTable;
028: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalEntityTable;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.domainimplementationmodel.RelationalReferenceTable;
030:
031: public abstract class DomainRelationalStorageDefinitionImpl extends
032: ModelElementImpl implements DomainRelationalStorageDefinition {
033: // Required constructor
034: protected DomainRelationalStorageDefinitionImpl(
035: StorableObject storable) {
036: super (storable);
037: }
038:
039: /**
040: * @param pAssociation
041: * @return RelationalAssociationTable describing given association or throws exception if none found
042: */
043: public RelationalAssociationTable getAssociationTable(
044: Association pAssociation) {
045: RelationalAssociationTable lFoundAssociationTable = findAssociationTable(pAssociation);
046: // Throw exception if nothing found
047: if (lFoundAssociationTable == null)
048: throw new IllegalArgumentException(
049: "Unable to locate RelationalAssociationTable for given Association in the DomainRelationalStorageDefinition. DomainRelationalStorageDefinitionRef: "
050: + getRef()
051: + ", AssociationRef: "
052: + pAssociation.getRef());
053: return lFoundAssociationTable;
054: }
055:
056: /**
057: * @param pAssociation
058: * @return RelationalAssociationTable describing given association or null if none found
059: */
060: public RelationalAssociationTable findAssociationTable(
061: Association pAssociation) {
062: Collection lAssociationTables = getAssociationTables();
063: if (!lAssociationTables.isEmpty()) {
064: for (Iterator lAssociationTablesIterator = lAssociationTables
065: .iterator(); lAssociationTablesIterator.hasNext();) {
066: RelationalAssociationTable lAssociationTable = (RelationalAssociationTable) lAssociationTablesIterator
067: .next();
068: if (lAssociationTable.getAssociation().equals(
069: pAssociation))
070: return lAssociationTable;
071: }
072: }
073: return null;
074: }
075:
076: /**
077: * @param pEntity
078: * @return RelationalEntityTable describing given entity or throws exception if none found
079: */
080: public RelationalEntityTable getEntityTable(Entity pEntity) {
081: RelationalEntityTable lFoundEntityTable = findEntityTable(pEntity);
082: // Throw exception if nothing found
083: if (lFoundEntityTable == null)
084: throw new IllegalArgumentException(
085: "Unable to locate RelationalEntityTable for given Entity in the DomainRelationalStorageDefinition. DomainRelationalStorageDefinitionRef: "
086: + getRef()
087: + ", EntityRef: "
088: + pEntity.getRef());
089: return lFoundEntityTable;
090: }
091:
092: /**
093: * @param pEntity
094: * @return RelationalEntityTable describing given entity or null if none found
095: */
096: public RelationalEntityTable findEntityTable(Entity pEntity) {
097: Collection lEntityTables = getEntityTables();
098: if (!lEntityTables.isEmpty()) {
099: for (Iterator lEntityTablesIterator = lEntityTables
100: .iterator(); lEntityTablesIterator.hasNext();) {
101: RelationalEntityTable lEntityTable = (RelationalEntityTable) lEntityTablesIterator
102: .next();
103: if (lEntityTable.getEntity().equals(pEntity))
104: return lEntityTable;
105: }
106: }
107: return null;
108: }
109:
110: /**
111: * @param pEntity
112: * @return RelationalEntityTable describing given entity or throws exception if none found
113: */
114: public RelationalReferenceTable getReferenceTable(DataType pDatatype) {
115: RelationalReferenceTable lFoundReferenceTable = findReferenceTable(pDatatype);
116: // Throw exception if nothing found
117: if (lFoundReferenceTable == null)
118: throw new IllegalArgumentException(
119: "Unable to locate RelationalReferenceTable for given DataType in the DomainRelationalStorageDefinition. DomainRelationalStorageDefinitionRef: "
120: + getRef()
121: + ", DataTypeRef: "
122: + pDatatype.getRef());
123: return lFoundReferenceTable;
124: }
125:
126: /**
127: * @param pEntity
128: * @return RelationalEntityTable describing given entity or null if none found
129: */
130: public RelationalReferenceTable findReferenceTable(
131: DataType pDatatype) {
132: Collection lReferenceTables = getReferenceTables();
133: if (!lReferenceTables.isEmpty()) {
134: for (Iterator lReferenceTablesIterator = lReferenceTables
135: .iterator(); lReferenceTablesIterator.hasNext();) {
136: RelationalReferenceTable lReferenceTable = (RelationalReferenceTable) lReferenceTablesIterator
137: .next();
138: if (lReferenceTable.getDataType().equals(pDatatype))
139: return lReferenceTable;
140: }
141: }
142: return null;
143: }
144: }
|