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.applications.designstudio.userobjects;
016:
017: import com.metaboss.applications.designstudio.Application;
018: import com.metaboss.applications.designstudio.BasePropertiesDialog;
019: import com.metaboss.applications.designstudio.BaseUserObject;
020: import com.metaboss.applications.designstudio.propertiesdialogs.SimpleObjectPropertiesdialog;
021: import com.metaboss.applications.designstudio.propertiesview.PropertiesTableModel;
022: import com.metaboss.sdlctools.models.metabossmodel.MetaBossModelPackage;
023: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.EnterpriseModelPackage;
024: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.System;
025: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.SystemDependency;
026: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.SystemDependencyClass;
027:
028: /* System Depenedency user object */
029:
030: public class SystemDependencyUserObject extends BaseUserObject {
031: private SystemDependency mDependency = null;
032:
033: public SystemDependencyUserObject(SystemDependency pDependency) {
034: super (pDependency);
035: mDependency = pDependency;
036: }
037:
038: // create new system
039: public static SystemDependencyUserObject addNewSystem(System pSystem)
040: throws Exception {
041: return (SystemDependencyUserObject) new SystemDependencyUserObject(
042: null).addNewObject(getObjectPackage(pSystem), pSystem
043: .getServantDependencies());
044: }
045:
046: public BaseUserObject createNewObject(MetaBossModelPackage pPackage) {
047: EnterpriseModelPackage lEnterpriseModelPackage = pPackage
048: .getEnterpriseModel();
049: SystemDependencyClass lSystemClass = lEnterpriseModelPackage
050: .getSystemDependency();
051: return new SystemDependencyUserObject(lSystemClass
052: .createSystemDependency());
053: }
054:
055: public static SystemDependencyUserObject addSystemDependency(
056: System pSystem, System pUsedSystem) throws Exception {
057: SystemDependencyUserObject lResult = null;
058: if (pSystem != null || pUsedSystem != null) {
059: Application.beginTransaction();
060: try {
061: lResult = (SystemDependencyUserObject) new SystemDependencyUserObject(
062: null)
063: .createNewObject(getObjectPackage(pSystem));
064: SystemDependency lDependency = lResult
065: .getSystemDependency();
066: if (lDependency != null) {
067: lDependency.setClient(pSystem);
068: lDependency.setServant(pUsedSystem);
069: }
070: Application.commit();
071: } finally {
072: Application.checkAndRollback();
073: }
074: }
075: return lResult;
076: }
077:
078: public void systemsChanged(System pSystem, System pUsedSystem)
079: throws Exception {
080: if (mDependency == null)
081: return;
082:
083: System lSystem = mDependency.getClient();
084: System lUsedSystem = mDependency.getServant();
085:
086: Application.beginTransaction();
087: try {
088: if ((lUsedSystem == null && pUsedSystem != null)
089: || (lUsedSystem != null && pUsedSystem == null)
090: || (lUsedSystem != null && !lUsedSystem
091: .equals(pUsedSystem))) {
092: mDependency.setServant(pUsedSystem);
093: }
094: if ((lSystem == null && pSystem != null)
095: || (lSystem != null && pSystem == null)
096: || (lSystem != null && !lSystem.equals(pSystem))) {
097: mDependency.setClient(pSystem);
098: }
099: Application.commit();
100: } finally {
101: Application.checkAndRollback();
102: }
103: }
104:
105: public SystemDependency getSystemDependency() {
106: return mDependency;
107: }
108:
109: // load object properties into grid control
110: public void loadObjectProperties(PropertiesTableModel pModel)
111: throws Exception {
112: super .loadObjectProperties(pModel);
113: if (pModel == null || mDependency == null)
114: return;
115:
116: addModelElement(pModel, "Client", mDependency.getClient());
117: addModelElement(pModel, "Servant", mDependency.getServant());
118: }
119:
120: // get object editor
121: public BasePropertiesDialog getObjectEditor() {
122: return new SimpleObjectPropertiesdialog("System Dependency");
123: }
124:
125: public boolean addToTree() {
126: return false;
127: }
128: }
|