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.applications.designstudio.userobjects;
16:
17: import java.util.Collection;
18:
19: import com.metaboss.applications.designstudio.Application;
20: import com.metaboss.applications.designstudio.BasePropertiesDialog;
21: import com.metaboss.applications.designstudio.BaseUserObject;
22: import com.metaboss.applications.designstudio.propertiesdialogs.ReportEntityAttributePropertiesDialog;
23: import com.metaboss.sdlctools.models.metabossmodel.ModelElement;
24: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.Attribute;
25: import com.metaboss.sdlctools.models.metabossmodel.enterprisemodel.systemimplementationmodel.ReportOutputEntity;
26:
27: /* Report Entity Attribute User Object */
28:
29: public class ReportEntityAttributeUserObject extends
30: AttributeUserObject {
31: private ReportOutputEntity mMaster = null;
32:
33: public ReportEntityAttributeUserObject(Attribute pAttribute,
34: ReportOutputEntity pMaster) {
35: super (pAttribute);
36: mMaster = pMaster;
37: }
38:
39: public ModelElement getMasterElement() {
40: return mMaster;
41: }
42:
43: // create new report entity attribute
44: public static void addNewReportEntityAttribute(
45: ReportOutputEntity pEntity) throws Exception {
46: ReportEntityAttributeUserObject lObject = new ReportEntityAttributeUserObject(
47: null, pEntity);
48: lObject.addNewObject(pEntity.getAttributes());
49: }
50:
51: // add new object
52: public BaseUserObject addNewObject(Collection pMasterCollection)
53: throws Exception {
54: BaseUserObject lResult = null;
55: ReportEntityAttributePropertiesDialog lDialog = new ReportEntityAttributePropertiesDialog();
56: if (lDialog != null) {
57: lDialog.loadProperties(mMaster);
58: if (lDialog.getModalResult() == BasePropertiesDialog.MR_OK) {
59: Attribute lElement = lDialog.getAttribute();
60: if (lElement != null && pMasterCollection != null) {
61: Application.beginTransaction();
62: try {
63: pMasterCollection.add(lElement);
64: Application.commit();
65: } finally {
66: Application.checkAndRollback();
67: }
68: lResult = new ReportEntityAttributeUserObject(
69: lElement, mMaster);
70: Application.fireObjectInserted(lResult);
71: }
72: }
73: }
74: return lResult;
75: }
76:
77: // delete object
78: public void deleteObject() throws Exception {
79: Attribute lAttribute = getAttribute();
80: if (lAttribute == null || mMaster == null)
81: return;
82:
83: Application.beginTransaction();
84: try {
85: mMaster.getAttributes().remove(lAttribute);
86: Application.commit();
87: } finally {
88: if (Application.isInTransaction())
89: Application.rollback();
90: }
91: Application.fireObjectDeleted(this);
92: }
93: }
|