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;
016:
017: import java.util.ArrayList;
018: import java.util.Collection;
019: import java.util.Collections;
020: import java.util.HashSet;
021: import java.util.Iterator;
022: import java.util.List;
023: import java.util.Set;
024:
025: import org.netbeans.mdr.storagemodel.StorableObject;
026:
027: import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementImpl;
028: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
029: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Servicemodule;
030: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.SystemDependency;
031: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
032:
033: public abstract class SystemImpl extends ModelElementImpl
034: implements
035: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System {
036: // Required constructor
037: protected SystemImpl(StorableObject storable) {
038: super (storable);
039: }
040:
041: /**
042: * @param pServicemoduleName
043: * @return requested Servicemodule or throws exception if none found
044: */
045: public Servicemodule getServicemodule(String pServicemoduleName) {
046: Servicemodule lFoundServicemodule = findServicemodule(pServicemoduleName);
047: // Throw exception if nothing found
048: if (lFoundServicemodule == null)
049: throw new IllegalArgumentException(
050: "Unable to locate Servicemodule named '"
051: + pServicemoduleName
052: + "' in System. SystemRef: " + getRef());
053: return lFoundServicemodule;
054: }
055:
056: /**
057: * @param pServicemoduleName
058: * @return requested Servicemodule or null if none found
059: */
060: public Servicemodule findServicemodule(String pServicemoduleName) {
061: Collection lServicemodules = getServicemodules();
062: if (!lServicemodules.isEmpty()) {
063: for (Iterator lServicemodulesIterator = lServicemodules
064: .iterator(); lServicemodulesIterator.hasNext();) {
065: Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
066: .next();
067: if (lServicemodule.getName().equals(pServicemoduleName))
068: return lServicemodule;
069: }
070: }
071: return null;
072: }
073:
074: /** Returns read-only collection of all data types available for use in this system Includes all own types, enterprise dictionary types and types from all used systems */
075: public Collection getAvailableDatatypes() {
076: List lAvailableDatatypes = new ArrayList();
077: // Add all datatypes from own data dictionary
078: lAvailableDatatypes.addAll(getDataDictionary()
079: .getCombinedDataTypes());
080: // Add all datatypes from all design library data dictionaries
081: for (Iterator lDesignLibraryDictionariesIterator = getEnterprise()
082: .getDesignLibrary().getDataDictionaries().iterator(); lDesignLibraryDictionariesIterator
083: .hasNext();) {
084: DataDictionary lDesignLibraryDataDictionary = (DataDictionary) lDesignLibraryDictionariesIterator
085: .next();
086: lAvailableDatatypes.addAll(lDesignLibraryDataDictionary
087: .getCombinedDataTypes());
088: }
089: // Add all datatypes from the servant systems
090: for (Iterator lServantSystemsIterator = getServants()
091: .iterator(); lServantSystemsIterator.hasNext();) {
092: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lServantSystem = (com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System) lServantSystemsIterator
093: .next();
094: lAvailableDatatypes.addAll(lServantSystem
095: .getDataDictionary().getCombinedDataTypes());
096: }
097: return Collections.unmodifiableCollection(lAvailableDatatypes);
098: }
099:
100: /** Returns read-only collection of all client systems */
101: public Collection getClients() {
102: List lClients = new ArrayList();
103: for (Iterator lClientDependenciesIterator = getClientDependencies()
104: .iterator(); lClientDependenciesIterator.hasNext();) {
105: SystemDependency lClientDependency = (SystemDependency) lClientDependenciesIterator
106: .next();
107: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lClientSystem = lClientDependency
108: .getClient();
109: lClients.add(lClientSystem);
110: }
111: return Collections.unmodifiableCollection(lClients);
112: }
113:
114: /** Returns read-only collection of all servant systems */
115: public Collection getServants() {
116: List lServants = new ArrayList();
117: for (Iterator lServantDependenciesIterator = getServantDependencies()
118: .iterator(); lServantDependenciesIterator.hasNext();) {
119: SystemDependency lServantDependency = (SystemDependency) lServantDependenciesIterator
120: .next();
121: com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System lServantSystem = lServantDependency
122: .getServant();
123: lServants.add(lServantSystem);
124: }
125: return Collections.unmodifiableCollection(lServants);
126: }
127:
128: /**
129: * @param pDomainName
130: * @return requested Domain or throws exception if none found
131: */
132: public Domain getDomain(String pDomainName) {
133: Domain lFoundDomain = findDomain(pDomainName);
134: // Throw exception if nothing found
135: if (lFoundDomain == null)
136: throw new IllegalArgumentException(
137: "Unable to locate Domain named '" + pDomainName
138: + "' in System. SystemRef: " + getRef());
139: return lFoundDomain;
140: }
141:
142: /**
143: * @param pDomainName
144: * @return requested Domain or null if none found
145: */
146: public Domain findDomain(String pDomainName) {
147: Collection lDomains = getDomains();
148: if (!lDomains.isEmpty()) {
149: for (Iterator lDomainsIterator = lDomains.iterator(); lDomainsIterator
150: .hasNext();) {
151: Domain lDomain = (Domain) lDomainsIterator.next();
152: if (lDomain.getName().equals(pDomainName))
153: return lDomain;
154: }
155: }
156: return null;
157: }
158:
159: // Returns list of DataTypes, Structures and Messages used in the Servicemodule. This includes owned and referenced elements
160: public Collection getCombinedTypes() {
161: Set lCombinedTypes = new HashSet();
162: // Interrogate the datadictionary types
163: lCombinedTypes.addAll(getDataDictionary().getCombinedTypes());
164: for (Iterator lServicemodulesIterator = getServicemodules()
165: .iterator(); lServicemodulesIterator.hasNext();) {
166: Servicemodule lServicemodule = (Servicemodule) lServicemodulesIterator
167: .next();
168: lCombinedTypes.addAll(lServicemodule.getCombinedTypes());
169: }
170: for (Iterator lDomainsIterator = getDomains().iterator(); lDomainsIterator
171: .hasNext();) {
172: Domain lDomain = (Domain) lDomainsIterator.next();
173: lCombinedTypes.addAll(lDomain.getCombinedTypes());
174: }
175: return java.util.Collections
176: .unmodifiableCollection(lCombinedTypes);
177: }
178: }
|