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.modelassistant.metabossmodel.implicittypes;
016:
017: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
018: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataType;
019: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.Namespace;
020: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
021: import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
022: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
023: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
025:
026: /** This class holds the particulars of the already retireved objects during
027: * chaining of the helpers. This helps to save some time, yet have helpers calling one another in hierarchy.
028: * This is really just an internal context passed from method to method - so do
029: * not read too much into it. First piece of code which needs a particular bit of data will
030: * trigger getting it from the model. The rest will just use the member variable */
031: class HelperContext {
032: private Entity mEntity = null;
033: private Domain mDomain = null;
034: private String mDomainName = null;
035: private com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System mSystem = null;
036: private DataDictionary mSystemDataDictionary = null;
037: private Namespace mSystemNamespace = null;
038: private Namespace mDomainNamespace = null;
039: private Enterprise mEnterprise = null;
040: private DesignLibrary mDesignLibrary = null;
041: private DataDictionary mCoreDataDictionary = null;
042: private DataType mCoreLibraryBooleanFlagDataType = null;
043: private DataType mCoreLibraryCollectionOffsetDataType = null;
044: private DataType mCoreLibraryCollectionSizeDataType = null;
045: private DataType mCoreLibrarySubsetSizeDataType = null;
046: private TypeTemplate mCoreLibraryEntityInstanceIdFieldTypeTemplate = null;
047: private TypeTemplate mCoreLibraryEntityVersionIdFieldTypeTemplate = null;
048: private TypeTemplate mCoreLibraryEntityStateFieldTypeTemplate = null;
049: private TypeTemplate mCoreLibraryEnumerableValueFieldTypeTemplate = null;
050:
051: public HelperContext(Domain pDomain) {
052: mDomain = pDomain;
053: }
054:
055: public HelperContext(Entity pEntity) {
056: mEntity = pEntity;
057: }
058:
059: private Entity getEntity() {
060: return mEntity; // If entity it is not given - we can not get it from anywhere
061: }
062:
063: public Domain getDomain() {
064: if (mDomain == null) {
065: if (getEntity() == null)
066: return null;
067: mDomain = getEntity().getDomain();
068: }
069: return mDomain;
070: }
071:
072: public String getDomainName() {
073: if (mDomainName == null) {
074: if (getDomain() == null)
075: return null;
076: mDomainName = getDomain().getName();
077: }
078: return mDomainName;
079: }
080:
081: public com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System getSystem() {
082: if (mSystem == null) {
083: if (getDomain() == null)
084: return null;
085: mSystem = getDomain().getSystem();
086: }
087: return mSystem;
088: }
089:
090: public DataDictionary getSystemDataDictionary() {
091: if (mSystemDataDictionary == null) {
092: if (getSystem() == null)
093: return null;
094: mSystemDataDictionary = getSystem().getDataDictionary();
095: }
096: return mSystemDataDictionary;
097: }
098:
099: public Namespace getSystemNamespace() {
100: if (mSystemNamespace == null) {
101: if (getSystemDataDictionary() == null)
102: return null;
103: mSystemNamespace = getSystemDataDictionary()
104: .findSubNamespace("System");
105: }
106: return mSystemNamespace;
107: }
108:
109: public Namespace getDomainNamespace() {
110: if (mDomainNamespace == null) {
111: if (getSystemNamespace() == null || getDomainName() == null)
112: return null;
113: mDomainNamespace = getSystemNamespace().findSubNamespace(
114: getDomainName());
115: }
116: return mDomainNamespace;
117: }
118:
119: public Enterprise getEnterprise() {
120: if (mEnterprise == null) {
121: if (getSystem() == null)
122: return null;
123: mEnterprise = getSystem().getEnterprise();
124: }
125: return mEnterprise;
126: }
127:
128: public DesignLibrary getDesignLibrary() {
129: if (mDesignLibrary == null) {
130: if (getEnterprise() == null)
131: return null;
132: mDesignLibrary = getEnterprise().getDesignLibrary();
133: }
134: return mDesignLibrary;
135: }
136:
137: public DataDictionary getCoreDataDictionary() {
138: if (mCoreDataDictionary == null) {
139: mCoreDataDictionary = getDesignLibrary().getDataDictionary(
140: "core");
141: }
142: return mCoreDataDictionary;
143: }
144:
145: public DataType getBooleanFlagDataType() {
146: if (mCoreLibraryBooleanFlagDataType == null) {
147: if (getCoreDataDictionary() == null)
148: return null;
149: mCoreLibraryBooleanFlagDataType = getCoreDataDictionary()
150: .getDataType("BooleanField");
151: }
152: return mCoreLibraryBooleanFlagDataType;
153: }
154:
155: public DataType getCollectionOffsetDataType() {
156: if (mCoreLibraryCollectionOffsetDataType == null) {
157: if (getCoreDataDictionary() == null)
158: return null;
159: mCoreLibraryCollectionOffsetDataType = getCoreDataDictionary()
160: .getDataType("CollectionOffset");
161: }
162: return mCoreLibraryCollectionOffsetDataType;
163: }
164:
165: public DataType getCollectionSizeDataType() {
166: if (mCoreLibraryCollectionSizeDataType == null) {
167: if (getCoreDataDictionary() == null)
168: return null;
169: mCoreLibraryCollectionSizeDataType = getCoreDataDictionary()
170: .getDataType("CollectionSize");
171: }
172: return mCoreLibraryCollectionSizeDataType;
173: }
174:
175: public DataType getSubsetSizeDataType() {
176: if (mCoreLibrarySubsetSizeDataType == null) {
177: if (getCoreDataDictionary() == null)
178: return null;
179: mCoreLibrarySubsetSizeDataType = getCoreDataDictionary()
180: .getDataType("SubsetSize");
181: }
182: return mCoreLibrarySubsetSizeDataType;
183: }
184:
185: public TypeTemplate getEntityInstanceIdFieldTypeTemplate() {
186: if (mCoreLibraryEntityInstanceIdFieldTypeTemplate == null) {
187: if (getCoreDataDictionary() == null)
188: return null;
189: mCoreLibraryEntityInstanceIdFieldTypeTemplate = getCoreDataDictionary()
190: .getTypeTemplate("EntityInstanceIdentifierField");
191: }
192: return mCoreLibraryEntityInstanceIdFieldTypeTemplate;
193: }
194:
195: public TypeTemplate getEntityVersionIdFieldTypeTemplate() {
196: if (mCoreLibraryEntityVersionIdFieldTypeTemplate == null) {
197: if (getCoreDataDictionary() == null)
198: return null;
199: mCoreLibraryEntityVersionIdFieldTypeTemplate = getCoreDataDictionary()
200: .getTypeTemplate("EntityVersionIdentifierField");
201: }
202: return mCoreLibraryEntityVersionIdFieldTypeTemplate;
203: }
204:
205: public TypeTemplate getEntityStateFieldTypeTemplate() {
206: if (mCoreLibraryEntityStateFieldTypeTemplate == null) {
207: if (getCoreDataDictionary() == null)
208: return null;
209: mCoreLibraryEntityStateFieldTypeTemplate = getCoreDataDictionary()
210: .getTypeTemplate("EntityStateField");
211: }
212: return mCoreLibraryEntityStateFieldTypeTemplate;
213: }
214:
215: public TypeTemplate getEnumerableValueFieldTypeTemplate() {
216: if (mCoreLibraryEnumerableValueFieldTypeTemplate == null) {
217: if (getCoreDataDictionary() == null)
218: return null;
219: mCoreLibraryEnumerableValueFieldTypeTemplate = getCoreDataDictionary()
220: .getTypeTemplate("EnumerableValueField");
221: }
222: return mCoreLibraryEnumerableValueFieldTypeTemplate;
223: }
224: }
|