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.BOAttribute;
26: import com.metaboss.sdlctools.domains.enterprisemodel.BOEntityAttributeList;
27: import com.metaboss.sdlctools.domains.enterprisemodel.BOReportEntity;
28: import com.metaboss.sdlctools.domains.enterprisemodel.BOReportEntityAttributeList;
29: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSReport;
30: import com.oldboss.framework.bo.impl.BOObjectImpl;
31:
32: public class BOReportEntityAttributeListImpl extends BOObjectImpl
33: implements BOReportEntityAttributeList {
34: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
35: private BOReportEntity mReportEntity = null;
36:
37: /* Instance creator */
38: public static BOReportEntityAttributeList createInstanceForExisting(
39: BOMetaBossDomainImpl pMetaBossDomainImpl,
40: BOReportEntity pReportEntity) throws BOException {
41: BOReportEntityAttributeListImpl lImpl = new BOReportEntityAttributeListImpl();
42: lImpl.mReportEntity = pReportEntity;
43: lImpl.setupForExisting();
44: return lImpl;
45: }
46:
47: /* Private constructor restricts instance creation from outside */
48: private BOReportEntityAttributeListImpl() throws BOException {
49: }
50:
51: /* Retrieves all attributes in this entity */
52: public BOAttribute[] getAllAttributes() throws BOException {
53: try {
54: // Get the instance of the enterprise ps home via jndi
55: Context ctx = new InitialContext();
56: PSReport lPs = (PSReport) ctx
57: .lookup(PSReport.COMPONENT_URL);
58:
59: String[] lAttributeNames = lPs.getOutputEntitiyAttributes(
60: mReportEntity.getReport().getRef(), mReportEntity
61: .getReportLevel(), mReportEntity.getName());
62: if (lAttributeNames == null || lAttributeNames.length == 0)
63: return new BOAttribute[0];
64: BOEntityAttributeList lEntityAttributeList = mReportEntity
65: .getEntity().getAttributes();
66: BOAttribute[] lReturn = new BOAttribute[lAttributeNames.length];
67: for (int i = 0; i < lAttributeNames.length; i++) {
68: lReturn[i] = lEntityAttributeList
69: .getAttribute(lAttributeNames[i]);
70: }
71: return lReturn;
72: } catch (NamingException e) {
73: throw new BONamingAndDirectoryServiceInvocationException(
74: "", e);
75: } catch (PSException e) {
76: throw new BOPersistenceServiceInvocationException("", e);
77: }
78: }
79: }
|