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.implicitselectors;
016:
017: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.DataDictionary;
018: import com.metaboss.sdlctools.models.metabossmodel.datadictionarymodel.TypeTemplate;
019: import com.metaboss.sdlctools.models.metabossmodel.designlibrarymodel.DesignLibrary;
020: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.Enterprise;
021: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Domain;
022: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Entity;
023:
024: /** This class holds the particulars of the already retireved objects during
025: * chaining of the helpers. This helps to save some time, yet have helpers calling one another in hierarchy.
026: * This is really just an internal context passed from method to method - so do
027: * not read too much into it. First piece of code which needs a particular bit of data will
028: * trigger getting it from the model. The rest will just use the member variable */
029: class HelperContext {
030: private Entity mEntity = null;
031: private Domain mDomain = null;
032: private String mDomainName = null;
033: private com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System mSystem = null;
034: private Enterprise mEnterprise = null;
035: private DesignLibrary mDesignLibrary = null;
036: private DataDictionary mCoreDataDictionary = null;
037: private TypeTemplate mCoreLibraryEnumerableValueFieldTypeTemplate = null;
038:
039: public HelperContext(Domain pDomain) {
040: mDomain = pDomain;
041: }
042:
043: public HelperContext(Entity pEntity) {
044: mEntity = pEntity;
045: }
046:
047: private Entity getEntity() {
048: return mEntity; // If entity it is not given - we can not get it from anywhere
049: }
050:
051: public Domain getDomain() {
052: if (mDomain == null) {
053: if (getEntity() != null) {
054: mDomain = getEntity().getDomain();
055: }
056: }
057: return mDomain;
058: }
059:
060: public String getDomainName() {
061: if (mDomainName == null) {
062: if (getDomain() != null) {
063: mDomainName = getDomain().getName();
064: }
065: }
066: return mDomainName;
067: }
068:
069: public com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System getSystem() {
070: if (mSystem == null) {
071: if (getDomain() != null) {
072: mSystem = getDomain().getSystem();
073: }
074: }
075: return mSystem;
076: }
077:
078: public Enterprise getEnterprise() {
079: if (mEnterprise == null) {
080: if (getSystem() != null) {
081: mEnterprise = getSystem().getEnterprise();
082: }
083: }
084: return mEnterprise;
085: }
086:
087: public DesignLibrary getDesignLibrary() {
088: if (mDesignLibrary == null) {
089: if (getEnterprise() != null) {
090: mDesignLibrary = getEnterprise().getDesignLibrary();
091: }
092: }
093: return mDesignLibrary;
094: }
095:
096: public DataDictionary getCoreDataDictionary() {
097: if (mCoreDataDictionary == null) {
098: if (getDesignLibrary() != null) {
099: mCoreDataDictionary = getDesignLibrary()
100: .getDataDictionary("core");
101: }
102: }
103: return mCoreDataDictionary;
104: }
105:
106: public TypeTemplate getEnumerableValueFieldTypeTemplate() {
107: if (mCoreLibraryEnumerableValueFieldTypeTemplate == null) {
108: if (getCoreDataDictionary() != null) {
109: mCoreLibraryEnumerableValueFieldTypeTemplate = getCoreDataDictionary()
110: .getTypeTemplate("EnumerableValueField");
111: }
112: }
113: return mCoreLibraryEnumerableValueFieldTypeTemplate;
114: }
115: }
|