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.BOField;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOStructure;
28: import com.metaboss.sdlctools.domains.enterprisemodel.BOStructureFieldList;
29: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSStructure;
30: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STField;
31: import com.oldboss.framework.bo.impl.BOObjectImpl;
32:
33: public class BOStructureFieldListImpl extends BOObjectImpl implements
34: BOStructureFieldList {
35: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
36: private BOStructure mStructure = null;
37:
38: /* Instance creator */
39: public static BOStructureFieldList createInstanceForExisting(
40: BOMetaBossDomainImpl pMetaBossDomainImpl,
41: BOStructure pStructure) throws BOException {
42: BOStructureFieldListImpl lImpl = new BOStructureFieldListImpl();
43: lImpl.initialiseForExisting(pMetaBossDomainImpl, pStructure);
44: return lImpl;
45: }
46:
47: /* Private constructor restricts instance creation from outside */
48: private BOStructureFieldListImpl() throws BOException {
49: }
50:
51: /* Instance initialisation */
52: private void initialiseForExisting(
53: BOMetaBossDomainImpl pMetaBossDomainImpl,
54: BOStructure pStructure) throws BOException {
55: mMetaBossDomainImpl = pMetaBossDomainImpl;
56: mStructure = pStructure;
57: setupForExisting();
58: }
59:
60: /* Retrieves all fields in this list */
61: public BOField[] getAllFields() throws BOException {
62: try {
63: // Get the instance of the enterprise ps home via jndi
64: Context ctx = new InitialContext();
65: PSStructure lPs = (PSStructure) ctx
66: .lookup(PSStructure.COMPONENT_URL);
67:
68: STField[] lFields = lPs.getFields(mStructure.getRef());
69: if (lFields == null || lFields.length == 0)
70: return new BOField[0];
71: BOField[] lReturn = new BOField[lFields.length];
72: for (int i = 0; i < lFields.length; i++) {
73: lReturn[i] = BOFieldImpl
74: .createInstanceForExistingStructureField(
75: mMetaBossDomainImpl, mStructure,
76: lFields[i]);
77: }
78: return lReturn;
79: } catch (NamingException e) {
80: throw new BONamingAndDirectoryServiceInvocationException(
81: "", e);
82: } catch (PSException e) {
83: throw new BOPersistenceServiceInvocationException("", e);
84: }
85: }
86:
87: /** Creates the new instance of the fields */
88: public BOField create(String pFieldName) throws BOException {
89: if (!isBeingEdited())
90: throw new BOInvalidOperationForReadOnlyObjectException();
91: return BOFieldImpl.createInstanceForNewStructureField(
92: fetchTransaction(), mMetaBossDomainImpl, mStructure,
93: pFieldName);
94: }
95: }
|