001: // THIS SOFTWARE IS PROVIDED BY SOFTARIS PTY.LTD. AND OTHER METABOSS
002: // CONTRIBUTORS ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
003: // BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
004: // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SOFTARIS PTY.LTD.
005: // OR OTHER METABOSS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
006: // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
007: // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
008: // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
009: // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
010: // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
011: // EVEN IF SOFTARIS PTY.LTD. OR OTHER METABOSS CONTRIBUTORS ARE ADVISED OF THE
012: // POSSIBILITY OF SUCH DAMAGE.
013: //
014: // Copyright 2000-2005 © Softaris Pty.Ltd. All Rights Reserved.
015: package com.metaboss.sdlctools.domains.enterprisemodel.impl;
016:
017: import javax.naming.Context;
018: import javax.naming.InitialContext;
019: import javax.naming.NamingException;
020:
021: import com.metaboss.enterprise.bo.BOException;
022: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
023: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
024: import com.metaboss.enterprise.ps.PSException;
025: import com.metaboss.sdlctools.domains.enterprisemodel.BODomain;
026: import com.metaboss.sdlctools.domains.enterprisemodel.BODomainReportList;
027: import com.metaboss.sdlctools.domains.enterprisemodel.BOReport;
028: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSDomain;
029: import com.oldboss.framework.bo.impl.BOObjectImpl;
030:
031: public class BODomainReportListImpl extends BOObjectImpl implements
032: BODomainReportList {
033: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
034: private BODomain mDomain = null;
035:
036: /* Instance creator */
037: public static BODomainReportList createInstanceForExisting(
038: BOMetaBossDomainImpl pMetaBossDomainImpl, BODomain pDomain)
039: throws BOException {
040: BODomainReportListImpl lImpl = new BODomainReportListImpl();
041: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
042: lImpl.mDomain = pDomain;
043: lImpl.setupForExisting();
044: return lImpl;
045: }
046:
047: /* Private constructor restricts instance creation from outside */
048: private BODomainReportListImpl() throws BOException {
049: }
050:
051: /* Retrieves an attribute object by it's reference or null if none exists */
052: public BOReport getReport(String pReportRef) throws BOException {
053: try {
054: // Get the instance of the enterprise ps home via jndi
055: Context ctx = new InitialContext();
056: PSDomain lPs = (PSDomain) ctx
057: .lookup(PSDomain.COMPONENT_URL);
058:
059: String[] lReports = lPs.getAllReportRefs(mDomain.getRef());
060: if (lReports == null || lReports.length == 0)
061: return null;
062: for (int i = 0; i < lReports.length; i++) {
063: if (lReports[i].equals(pReportRef))
064: return BOReportImpl.createInstanceForExisting(
065: mMetaBossDomainImpl, mDomain, lReports[i]);
066: }
067: return null;
068: } catch (NamingException e) {
069: throw new BONamingAndDirectoryServiceInvocationException(
070: "", e);
071: } catch (PSException e) {
072: throw new BOPersistenceServiceInvocationException("", e);
073: }
074: }
075:
076: /** Retrieves all Reports in this domain */
077: public BOReport[] getAllReports() throws BOException {
078: try {
079: // Get the instance of the enterprise ps home via jndi
080: Context ctx = new InitialContext();
081: PSDomain lPs = (PSDomain) ctx
082: .lookup(PSDomain.COMPONENT_URL);
083:
084: String[] lReports = lPs.getAllReportRefs(mDomain.getRef());
085: if (lReports == null || lReports.length == 0)
086: return new BOReport[0];
087: BOReport[] lReturn = new BOReport[lReports.length];
088: for (int i = 0; i < lReports.length; i++) {
089: lReturn[i] = BOReportImpl.createInstanceForExisting(
090: mMetaBossDomainImpl, mDomain, lReports[i]);
091: }
092: return lReturn;
093: } catch (NamingException e) {
094: throw new BONamingAndDirectoryServiceInvocationException(
095: "", e);
096: } catch (PSException e) {
097: throw new BOPersistenceServiceInvocationException("", e);
098: }
099: }
100: }
|