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.domains.enterprisemodel.impl;
16:
17: import javax.naming.Context;
18: import javax.naming.InitialContext;
19: import javax.naming.NamingException;
20:
21: import com.metaboss.enterprise.bo.BOException;
22: import com.metaboss.enterprise.bo.BOInvalidOperationForReadOnlyObjectException;
23: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
24: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
25: import com.metaboss.enterprise.ps.PSException;
26: import com.metaboss.sdlctools.domains.enterprisemodel.BOMessage;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOMessageField;
28: import com.metaboss.sdlctools.domains.enterprisemodel.BOMessageFieldList;
29: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSMessage;
30: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STMessageField;
31: import com.oldboss.framework.bo.impl.BOObjectImpl;
32:
33: public class BOMessageFieldListImpl extends BOObjectImpl implements
34: BOMessageFieldList {
35: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
36: private BOMessage mMessage = null;
37:
38: /* Instance creator */
39: public static BOMessageFieldList createInstanceForExisting(
40: BOMetaBossDomainImpl pMetaBossDomainImpl, BOMessage pMessage)
41: throws BOException {
42: BOMessageFieldListImpl lImpl = new BOMessageFieldListImpl();
43: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
44: lImpl.mMessage = pMessage;
45: lImpl.setupForExisting();
46: return lImpl;
47: }
48:
49: /* Private constructor restricts instance creation from outside */
50: private BOMessageFieldListImpl() throws BOException {
51: }
52:
53: /** Retrieves message this field list belongs to */
54: public BOMessage getMessage() throws BOException {
55: return mMessage;
56: }
57:
58: /* Retrieves all fields in this list */
59: public BOMessageField[] getAllFields() throws BOException {
60: try {
61: // Get the instance of the enterprise ps home via jndi
62: Context ctx = new InitialContext();
63: PSMessage lPs = (PSMessage) ctx
64: .lookup(PSMessage.COMPONENT_URL);
65:
66: STMessageField[] lFields = lPs.getFields(mMessage.getRef());
67: if (lFields == null || lFields.length == 0)
68: return new BOMessageField[0];
69: BOMessageField[] lReturn = new BOMessageField[lFields.length];
70: for (int i = 0; i < lFields.length; i++) {
71: lReturn[i] = BOMessageFieldImpl
72: .createInstanceForExisting(mMetaBossDomainImpl,
73: mMessage, lFields[i]);
74: }
75: return lReturn;
76: } catch (NamingException e) {
77: throw new BONamingAndDirectoryServiceInvocationException(
78: "", e);
79: } catch (PSException e) {
80: throw new BOPersistenceServiceInvocationException("", e);
81: }
82: }
83:
84: /** Creates the new instance of the fields */
85: public BOMessageField create(String pFieldName) throws BOException {
86: if (!isBeingEdited())
87: throw new BOInvalidOperationForReadOnlyObjectException();
88: return BOMessageFieldImpl.createInstanceForNew(
89: fetchTransaction(), mMetaBossDomainImpl, mMessage,
90: pFieldName);
91: }
92: }
|