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.BOIllegalArgumentException;
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.BODatatype;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BODatatypeList;
28: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSDatatype;
29: import com.oldboss.framework.bo.impl.BOObjectImpl;
30:
31: public class BODatatypeListImpl extends BOObjectImpl implements
32: BODatatypeList {
33: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
34:
35: /* Instance creator */
36: public static BODatatypeList createInstanceForExisting(
37: BOMetaBossDomainImpl pMetaBossDomainImpl)
38: throws BOException {
39: BODatatypeListImpl lImpl = new BODatatypeListImpl();
40: lImpl.initialiseForExisting(pMetaBossDomainImpl);
41: return lImpl;
42: }
43:
44: /* Private constructor restricts instance creation from outside */
45: private BODatatypeListImpl() throws BOException {
46: }
47:
48: /* Instance initialisation */
49: private void initialiseForExisting(
50: BOMetaBossDomainImpl pMetaBossDomainImpl)
51: throws BOException {
52: mMetaBossDomainImpl = pMetaBossDomainImpl;
53: setupForExisting();
54: }
55:
56: /* Retrieves all elements comprising this entity */
57: public BODatatype[] getAllDatatypes() throws BOException {
58: try {
59: // Get the instance of the enterprise ps home via jndi
60: Context ctx = new InitialContext();
61: PSDatatype lPs = (PSDatatype) ctx
62: .lookup(PSDatatype.COMPONENT_URL);
63:
64: String[] lDatatypes = lPs.getPublicDatatypeRefs();
65: if (lDatatypes == null || lDatatypes.length == 0)
66: return new BODatatype[0];
67: BODatatype[] lReturn = new BODatatype[lDatatypes.length];
68: for (int i = 0; i < lDatatypes.length; i++) {
69: lReturn[i] = BODatatypeImpl.createInstanceForExisting(
70: mMetaBossDomainImpl, lDatatypes[i]);
71: }
72: return lReturn;
73: } catch (NamingException e) {
74: throw new BONamingAndDirectoryServiceInvocationException(
75: "", e);
76: } catch (PSException e) {
77: throw new BOPersistenceServiceInvocationException("", e);
78: }
79: }
80:
81: /* Retrieves the datatype corresponding to give reference */
82: public BODatatype getDatatype(String pDatatypeRef)
83: throws BOException {
84: // Make sure that this is public datatype
85: if (!pDatatypeRef.startsWith("."))
86: throw new BOIllegalArgumentException(
87: "pDatatypeRef for public Datatypes is expected to start with '.'");
88: return BODatatypeImpl.createInstanceForExisting(
89: mMetaBossDomainImpl, pDatatypeRef);
90: }
91: }
|