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.BOField;
26: import com.metaboss.sdlctools.domains.enterprisemodel.BOReport;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOReportOutputFieldList;
28: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSReport;
29: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STField;
30: import com.oldboss.framework.bo.impl.BOObjectImpl;
31:
32: public class BOReportOutputFieldListImpl extends BOObjectImpl implements
33: BOReportOutputFieldList {
34: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
35: private BOReport mReport = null;
36: private int mLevel = -1;
37:
38: /* Instance creator */
39: public static BOReportOutputFieldList createInstanceForExisting(
40: BOMetaBossDomainImpl pMetaBossDomainImpl, BOReport pReport,
41: int pLevel) throws BOException {
42: BOReportOutputFieldListImpl lImpl = new BOReportOutputFieldListImpl();
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 BOReportOutputFieldListImpl() throws BOException {
52: }
53:
54: /* Returns true if list is empty */
55: public boolean isEmpty() throws BOException {
56: BOField[] lAllFields = getAllFields();
57: return lAllFields == null || lAllFields.length == 0;
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: PSReport lPs = (PSReport) ctx
66: .lookup(PSReport.COMPONENT_URL);
67:
68: STField[] lFields = lPs.getOutputFields(mReport.getRef(),
69: mLevel);
70: if (lFields == null || lFields.length == 0)
71: return new BOField[0];
72: BOField[] lReturn = new BOField[lFields.length];
73: for (int i = 0; i < lFields.length; i++) {
74: lReturn[i] = BOFieldImpl
75: .createInstanceForExistingReportOutputField(
76: mMetaBossDomainImpl, mReport, mLevel,
77: lFields[i]);
78: }
79: return lReturn;
80: } catch (NamingException e) {
81: throw new BONamingAndDirectoryServiceInvocationException(
82: "", e);
83: } catch (PSException e) {
84: throw new BOPersistenceServiceInvocationException("", e);
85: }
86: }
87: }
|