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.BONamingAndDirectoryServiceInvocationException;
23: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
24: import com.metaboss.enterprise.ps.PSException;
25: import com.metaboss.sdlctools.domains.enterprisemodel.BOReport;
26: import com.metaboss.sdlctools.domains.enterprisemodel.BOReportEntity;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOReportEntityList;
28: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSReport;
29: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STReportEntity;
30: import com.oldboss.framework.bo.impl.BOObjectImpl;
31:
32: public class BOReportEntityListImpl extends BOObjectImpl implements
33: BOReportEntityList {
34: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
35: private BOReport mReport = null;
36: private int mLevel = -1;
37:
38: /* Instance creator */
39: public static BOReportEntityList createInstanceForExisting(
40: BOMetaBossDomainImpl pMetaBossDomainImpl, BOReport pReport,
41: int pLevel) throws BOException {
42: BOReportEntityListImpl lImpl = new BOReportEntityListImpl();
43: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
44: lImpl.mReport = pReport;
45: lImpl.mLevel = pLevel;
46: lImpl.setupForExisting();
47: return lImpl;
48: }
49:
50: /* Private constructor restricts instance creation from outside */
51: private BOReportEntityListImpl() throws BOException {
52: }
53:
54: /* Returns true if list is empty */
55: public boolean isEmpty() throws BOException {
56: BOReportEntity[] lAllEntities = getAllEntities();
57: return lAllEntities == null || lAllEntities.length == 0;
58: }
59:
60: /* Retrieves all fields in this list */
61: public BOReportEntity[] getAllEntities() throws BOException {
62: try {
63: // Get the instance of the enterprise ps home via jndi
64: Context ctx = new InitialContext();
65: PSReport lPs = (PSReport) ctx
66: .lookup(PSReport.COMPONENT_URL);
67:
68: STReportEntity[] lEntities = lPs.getOutputEntities(mReport
69: .getRef(), mLevel);
70: if (lEntities == null || lEntities.length == 0)
71: return new BOReportEntity[0];
72: BOReportEntity[] lReturn = new BOReportEntity[lEntities.length];
73: for (int i = 0; i < lEntities.length; i++) {
74: lReturn[i] = BOReportEntityImpl
75: .createInstanceForExisting(mMetaBossDomainImpl,
76: mReport, mLevel, lEntities[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: }
|