01: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
02: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
03: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
04: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
05: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
06: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
07: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
08: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
09: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
10: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
11: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
12: // POSSIBILITY OF SUCH DAMAGE.
13: //
14: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
15: package com.metaboss.sdlctools.models.impl.metabossmodel.enterprisemodel.systemimplementationmodel;
16:
17: import java.util.Collection;
18: import java.util.HashSet;
19: import java.util.Iterator;
20: import java.util.Set;
21:
22: import org.netbeans.mdr.storagemodel.StorableObject;
23:
24: import com.metaboss.sdlctools.models.impl.metabossmodel.ModelElementImpl;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Selector;
26: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorCardinality;
27: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorCardinalityEnum;
28: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.SelectorInputField;
29:
30: public abstract class SelectorImpl extends ModelElementImpl implements
31: Selector {
32: // Required constructor
33: protected SelectorImpl(StorableObject storable) {
34: super (storable);
35: }
36:
37: // Returns true if this association has plural cardinality
38: public boolean isPlural() {
39: SelectorCardinality lCardinality = getCardinality();
40: return lCardinality != null
41: && lCardinality
42: .equals(SelectorCardinalityEnum.ZERO_TO_MANY);
43: }
44:
45: /**
46: * @param pFieldName
47: * @return SelectorInputField describing given field or throws exception if none found
48: */
49: public SelectorInputField getInputField(String pFieldName) {
50: SelectorInputField lFoundInputField = findInputField(pFieldName);
51: // Throw exception if nothing found
52: if (lFoundInputField == null)
53: throw new IllegalArgumentException(
54: "Unable to locate SelectorInputField named '"
55: + pFieldName
56: + "' in Selector. SelectorRef: " + getRef());
57: return lFoundInputField;
58: }
59:
60: /**
61: * @param pFieldName
62: * @return SelectorInputField describing given field or null if none found
63: */
64: public SelectorInputField findInputField(String pFieldName) {
65: Collection lInputFields = getInputFields();
66: if (!lInputFields.isEmpty()) {
67: for (Iterator lInputFieldsIterator = lInputFields
68: .iterator(); lInputFieldsIterator.hasNext();) {
69: SelectorInputField lInputField = (SelectorInputField) lInputFieldsIterator
70: .next();
71: if (lInputField.getName().equals(pFieldName))
72: return lInputField;
73: }
74: }
75: return null;
76: }
77:
78: // Returns list of DataTypes, Structures and Messages used in the Selector. This includes owned and referenced elements
79: public Collection getCombinedTypes() {
80: Set lCombinedTypes = new HashSet();
81: // Interrogate the entities
82: for (Iterator lInputFieldsIterator = getInputFields()
83: .iterator(); lInputFieldsIterator.hasNext();) {
84: SelectorInputField lInputField = (SelectorInputField) lInputFieldsIterator
85: .next();
86: lCombinedTypes.add(lInputField.getDataType());
87: }
88: return java.util.Collections
89: .unmodifiableCollection(lCombinedTypes);
90: }
91: }
|