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.Collection;
018: import java.util.HashSet;
019: import java.util.Iterator;
020: import java.util.Set;
021:
022: import org.netbeans.mdr.storagemodel.StorableObject;
023:
024: import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementImpl;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Operation;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Service;
027: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ServiceImplementation;
028:
029: public abstract class ServiceImpl extends ModelElementImpl implements
030: Service {
031: // Required constructor
032: protected ServiceImpl(StorableObject storable) {
033: super (storable);
034: }
035:
036: /**
037: * @param pOperationName
038: * @return requested Operation or throws exception if none found
039: */
040: public Operation getOperation(String pOperationName) {
041: Operation lFoundOperation = findOperation(pOperationName);
042: // Throw exception if nothing found
043: if (lFoundOperation == null)
044: throw new IllegalArgumentException(
045: "Unable to locate Operation named '"
046: + pOperationName
047: + "' in Service. ServiceRef: " + getRef());
048: return lFoundOperation;
049: }
050:
051: /**
052: * @param pOperationName
053: * @return requested Operation or null if none found
054: */
055: public Operation findOperation(String pOperationName) {
056: Collection lOperations = getOperations();
057: if (!lOperations.isEmpty()) {
058: for (Iterator lOperationsIterator = lOperations.iterator(); lOperationsIterator
059: .hasNext();) {
060: Operation lOperation = (Operation) lOperationsIterator
061: .next();
062: if (lOperation.getName().equals(pOperationName))
063: return lOperation;
064: }
065: }
066: return null;
067: }
068:
069: /**
070: * @param pServiceImplementationName
071: * @return requested ServiceImplementation or throws exception if none found
072: */
073: public ServiceImplementation getImplementation(
074: String pImplementationName) {
075: ServiceImplementation lFoundServiceImplementation = findImplementation(pImplementationName);
076: // Throw exception if nothing found
077: if (lFoundServiceImplementation == null)
078: throw new IllegalArgumentException(
079: "Unable to locate ServiceImplementation named '"
080: + pImplementationName
081: + "' in Service. ServiceRef: " + getRef());
082: return lFoundServiceImplementation;
083: }
084:
085: /**
086: * @param pServiceImplementationName
087: * @return requested ServiceImplementation or null if none found
088: */
089: public ServiceImplementation findImplementation(
090: String pImplementationName) {
091: Collection lServiceImplementations = getImplementations();
092: if (!lServiceImplementations.isEmpty()) {
093: for (Iterator lServiceImplementationsIterator = lServiceImplementations
094: .iterator(); lServiceImplementationsIterator
095: .hasNext();) {
096: ServiceImplementation lServiceImplementation = (ServiceImplementation) lServiceImplementationsIterator
097: .next();
098: if (lServiceImplementation.getName().equals(
099: pImplementationName))
100: return lServiceImplementation;
101: }
102: }
103: return null;
104: }
105:
106: /** @return All combined structures and types used in all services */
107: public Collection getCombinedTypes() {
108: Set lCombinedTypes = new HashSet();
109: for (Iterator lOperationsIterator = getOperations().iterator(); lOperationsIterator
110: .hasNext();) {
111: Operation lOperation = (Operation) lOperationsIterator
112: .next();
113: lCombinedTypes.addAll(lOperation.getCombinedTypes());
114: }
115: return java.util.Collections
116: .unmodifiableCollection(lCombinedTypes);
117: }
118: }
|