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;
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.datadictionarymodel.DataType;
26: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Structure;
27: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Event;
28: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventDataField;
29: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EventMessageField;
30: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Message;
31:
32: public abstract class EventImpl extends ModelElementImpl implements
33: Event {
34: // Required constructor
35: protected EventImpl(StorableObject storable) {
36: super (storable);
37: }
38:
39: /** @return All combined structures and types used in this structure */
40: public Collection getCombinedTypes() {
41: Set lCombinedTypes = new HashSet();
42: populateCombinedTypes(lCombinedTypes);
43: return java.util.Collections
44: .unmodifiableCollection(lCombinedTypes);
45: }
46:
47: /** Populates passed set with all combined structures, messages and types used in this structure */
48: public void populateCombinedTypes(Set pAlredyKnownTypes) {
49: // Work on input fields
50: Collection lDataFields = getDataFields();
51: if (!lDataFields.isEmpty()) {
52: for (Iterator lDataFieldsIterator = lDataFields.iterator(); lDataFieldsIterator
53: .hasNext();) {
54: EventDataField lDataField = (EventDataField) lDataFieldsIterator
55: .next();
56: DataType lDataType = lDataField.getDataType();
57: if (lDataType != null) {
58: if (!pAlredyKnownTypes.contains(lDataType))
59: pAlredyKnownTypes.add(lDataType);
60: } else {
61: Structure lStructureType = lDataField
62: .getStructureType();
63: if (lStructureType != null) {
64: if (!pAlredyKnownTypes.contains(lStructureType)) {
65: // Register this structure and populate all types this structure depends on
66: // note that this will recursively populate all dependent types
67: pAlredyKnownTypes.add(lStructureType);
68: pAlredyKnownTypes.addAll(lStructureType
69: .getCombinedTypes());
70: }
71: }
72: }
73: }
74: }
75: // Work on output messages
76: Collection lMessageFields = getMessageFields();
77: if (!lMessageFields.isEmpty()) {
78: for (Iterator lMessageFieldsIterator = lMessageFields
79: .iterator(); lMessageFieldsIterator.hasNext();) {
80: EventMessageField lMessageField = (EventMessageField) lMessageFieldsIterator
81: .next();
82: Message lMessageType = lMessageField.getMessageType();
83: if (!pAlredyKnownTypes.contains(lMessageType)) {
84: // Register this structure and populate all types this structure depends on
85: // note that this will recursively populate all dependent types
86: pAlredyKnownTypes.add(lMessageType);
87: pAlredyKnownTypes.addAll(lMessageType
88: .getCombinedTypes());
89: }
90: }
91: }
92: }
93: }
|