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.BOTypetemplate;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOTypetemplateList;
28: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSTypeTemplate;
29: import com.oldboss.framework.bo.impl.BOObjectImpl;
30:
31: public class BOTypetemplateListImpl extends BOObjectImpl implements
32: BOTypetemplateList {
33: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
34:
35: /* Instance creator */
36: public static BOTypetemplateList createInstanceForExisting(
37: BOMetaBossDomainImpl pMetaBossDomainImpl)
38: throws BOException {
39: BOTypetemplateListImpl lImpl = new BOTypetemplateListImpl();
40: lImpl.initialiseForExisting(pMetaBossDomainImpl);
41: return lImpl;
42: }
43:
44: /* Private constructor restricts instance creation from outside */
45: private BOTypetemplateListImpl() 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 BOTypetemplate[] getAllTypetemplates() throws BOException {
58: try {
59: // Get the instance of the enterprise ps home via jndi
60: Context ctx = new InitialContext();
61: PSTypeTemplate lPs = (PSTypeTemplate) ctx
62: .lookup(PSTypeTemplate.COMPONENT_URL);
63:
64: String[] lTypeTemplates = lPs.getPublicTypeTemplateRefs();
65: if (lTypeTemplates == null || lTypeTemplates.length == 0)
66: return new BOTypetemplate[0];
67: BOTypetemplate[] lReturn = new BOTypetemplate[lTypeTemplates.length];
68: for (int i = 0; i < lTypeTemplates.length; i++) {
69: lReturn[i] = BOTypetemplateImpl
70: .createInstanceForExisting(mMetaBossDomainImpl,
71: lTypeTemplates[i]);
72: }
73: return lReturn;
74: } catch (NamingException e) {
75: throw new BONamingAndDirectoryServiceInvocationException(
76: "", e);
77: } catch (PSException e) {
78: throw new BOPersistenceServiceInvocationException("", e);
79: }
80: }
81:
82: /* Retrieves the typetemplate corresponding to given reference */
83: public BOTypetemplate getTypetemplate(String pTypetemplateRef)
84: throws BOException {
85: // Make sure that this is public typetemplate
86: if (!pTypetemplateRef.startsWith("."))
87: throw new BOIllegalArgumentException(
88: "pTypetemplateRef for public Typetemplates is expected to start with '.'");
89: return BOTypetemplateImpl.createInstanceForExisting(
90: mMetaBossDomainImpl, pTypetemplateRef);
91: }
92: }
|