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.BOInvalidOperationForReadOnlyObjectException;
023: import com.metaboss.enterprise.bo.BONamingAndDirectoryServiceInvocationException;
024: import com.metaboss.enterprise.bo.BOPersistenceServiceInvocationException;
025: import com.metaboss.enterprise.ps.PSException;
026: import com.metaboss.sdlctools.domains.enterprisemodel.BOMessage;
027: import com.metaboss.sdlctools.domains.enterprisemodel.BOOperation;
028: import com.metaboss.sdlctools.domains.enterprisemodel.BOOperationOutputMessageList;
029: import com.metaboss.sdlctools.domains.enterprisemodel.BOOutputMessage;
030: import com.metaboss.sdlctools.domains.enterprisemodel.storage.PSService;
031: import com.metaboss.sdlctools.domains.enterprisemodel.storage.STOutputMessage;
032: import com.oldboss.framework.bo.impl.BOObjectImpl;
033:
034: public class BOOperationOutputMessageListImpl extends BOObjectImpl
035: implements BOOperationOutputMessageList {
036: private BOMetaBossDomainImpl mMetaBossDomainImpl = null;
037: private BOOperation mOperation = null;
038:
039: /* Instance creator */
040: public static BOOperationOutputMessageList createInstanceForExisting(
041: BOMetaBossDomainImpl pMetaBossDomainImpl,
042: BOOperation pOperation) throws BOException {
043: BOOperationOutputMessageListImpl lImpl = new BOOperationOutputMessageListImpl();
044: lImpl.mMetaBossDomainImpl = pMetaBossDomainImpl;
045: lImpl.mOperation = pOperation;
046: lImpl.setupForExisting();
047: return lImpl;
048: }
049:
050: /* Private constructor restricts instance creation from outside */
051: private BOOperationOutputMessageListImpl() throws BOException {
052: }
053:
054: /** Getter for the owner Operation */
055: public BOOperation getOperation() throws BOException {
056: return mOperation;
057: }
058:
059: /** Retrieves number of elements in this list */
060: public long size() throws BOException {
061: try {
062: // Get the instance of the enterprise ps home via jndi
063: Context ctx = new InitialContext();
064: PSService lPs = (PSService) ctx
065: .lookup(PSService.COMPONENT_URL);
066:
067: STOutputMessage[] lOutputMessages = lPs.getOutputMessages(
068: mOperation.getService().getRef(), mOperation
069: .getName());
070: if (lOutputMessages == null)
071: return 0;
072: return lOutputMessages.length;
073: } catch (NamingException e) {
074: throw new BONamingAndDirectoryServiceInvocationException(
075: "", e);
076: } catch (PSException e) {
077: throw new BOPersistenceServiceInvocationException("", e);
078: }
079: }
080:
081: /* Retrieves all output messages for this operation */
082: public BOOutputMessage[] getAllOutputMessages() throws BOException {
083: try {
084: // Get the instance of the enterprise ps home via jndi
085: Context ctx = new InitialContext();
086: PSService lPs = (PSService) ctx
087: .lookup(PSService.COMPONENT_URL);
088:
089: STOutputMessage[] lOutputMessages = lPs.getOutputMessages(
090: mOperation.getService().getRef(), mOperation
091: .getName());
092: if (lOutputMessages == null || lOutputMessages.length == 0)
093: return new BOOutputMessage[0];
094: BOOutputMessage[] lReturn = new BOOutputMessage[lOutputMessages.length];
095: for (int i = 0; i < lOutputMessages.length; i++) {
096: lReturn[i] = BOOutputMessageImpl
097: .createInstanceForExistingOperationOutputMessage(
098: mMetaBossDomainImpl, mOperation,
099: lOutputMessages[i]);
100: }
101: return lReturn;
102: } catch (NamingException e) {
103: throw new BONamingAndDirectoryServiceInvocationException(
104: "", e);
105: } catch (PSException e) {
106: throw new BOPersistenceServiceInvocationException("", e);
107: }
108: }
109:
110: /** Creates the new instance of the output message */
111: public BOOutputMessage create(String pOutputMessageName,
112: BOMessage pMessage) throws BOException {
113: if (!isBeingEdited())
114: throw new BOInvalidOperationForReadOnlyObjectException();
115: return BOOutputMessageImpl
116: .createInstanceForNewOperationOutputMessage(
117: fetchTransaction(), mMetaBossDomainImpl,
118: mOperation, pMessage, pOutputMessageName);
119: }
120: }
|