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