001: /*--
002:
003: Copyright (C) 2002-2005 Adrian Price.
004: All rights reserved.
005:
006: Redistribution and use in source and binary forms, with or without
007: modification, are permitted provided that the following conditions
008: are met:
009:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions, and the following disclaimer.
012:
013: 2. Redistributions in binary form must reproduce the above copyright
014: notice, this list of conditions, and the disclaimer that follows
015: these conditions in the documentation and/or other materials
016: provided with the distribution.
017:
018: 3. The names "OBE" and "Open Business Engine" must not be used to
019: endorse or promote products derived from this software without prior
020: written permission. For written permission, please contact
021: adrianprice@sourceforge.net.
022:
023: 4. Products derived from this software may not be called "OBE" or
024: "Open Business Engine", nor may "OBE" or "Open Business Engine"
025: appear in their name, without prior written permission from
026: Adrian Price (adrianprice@users.sourceforge.net).
027:
028: THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
029: WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
030: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
031: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT,
032: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
033: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
034: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
035: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
036: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
037: IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
038: POSSIBILITY OF SUCH DAMAGE.
039:
040: For more information on OBE, please see
041: <http://obe.sourceforge.net/>.
042:
043: */
044:
045: package org.obe.server.j2ee.repository;
046:
047: import org.apache.commons.logging.Log;
048: import org.obe.client.api.repository.RepositoryException;
049: import org.obe.server.j2ee.ejb.AbstractEntityEJB;
050: import org.obe.xpdl.model.pkg.XPDLPackage;
051: import org.wfmc.wapi.WMFilter;
052:
053: import javax.ejb.FinderException;
054: import javax.ejb.ObjectNotFoundException;
055: import java.sql.SQLException;
056: import java.util.Collection;
057: import java.util.List;
058:
059: /**
060: * Persists a package definition. Also relates to records for each process
061: * definition contained within the package.
062: *
063: * @author Adrian Price
064: * @ejb:bean type="CMP"
065: * cmp-version="2.x"
066: * name="XPDLPackageRO"
067: * display-name="OBE Package Definition (RO)"
068: * jndi-name="org/obe/ejb/PackageRO"
069: * local-jndi-name="org/obe/ejb/PackageROLocal"
070: * primkey-field="packageId"
071: * schema="PACKAGERO"
072: * reentrant="False"
073: * transaction-type="Container"
074: * view-type="local"
075: * @ejb:persistence table-name="OBEPACKAGE"
076: * @ejb:pk class="java.lang.String"
077: * unchecked="true"
078: * @ejb:home local-class="org.obe.server.j2ee.repository.PackageROLocalHome"
079: * local-extends="org.obe.server.j2ee.repository.PackageROHome,javax.ejb.EJBLocalHome"
080: * @ejb:interface local-class="org.obe.server.j2ee.repository.PackageROLocal"
081: * local-extends="org.obe.server.j2ee.repository.PackageRO,javax.ejb.EJBLocalObject"
082: * @ejb:permission unchecked="true"
083: * @ejb:transaction type="NotSupported"
084: * @ejb:finder signature="java.util.Collection findAll()"
085: * query="SELECT OBJECT(p) FROM PACKAGERO AS p"
086: * result-type-mapping="Local"
087: * unchecked="true"
088: * @ejb:ejb-ref ejb-name="ProcessDefinitionRO"
089: * view-type="local"
090: * @weblogic:ejb-local-reference-description ejb-ref-name="ejb/ProcessDefinitionRO"
091: * jndi-name="org/obe/ejb/ProcessDefinitionROLocal"
092: * @ejb:resource-ref res-name="jdbc/TxDataSource"
093: * res-type="javax.sql.DataSource"
094: * res-auth="Container"
095: * @jboss:resource-manager res-man-class="javax.sql.DataSource"
096: * res-man-name="jdbc/TxDataSource"
097: * res-man-jndi-name="java:/${xdoclet.DataSource}"
098: * @weblogic:resource-description res-ref-name="jdbc/TxDataSource"
099: * jndi-name="${xdoclet.DataSource}"
100: * @weblogic:data-source-name java:comp/env/jdbc/TxDataSource
101: * @jboss:create-table false
102: * @weblogic:pool max-beans-in-free-pool="200"
103: * initial-beans-in-free-pool="0"
104: * @weblogic:cache max-beans-in-cache="200"
105: * idle-timeout-seconds="0"
106: * read-timeout-seconds="0"
107: * concurrency-strategy="ReadOnly"
108: * @jboss:persistence read-only="true"
109: * read-time-out="0"
110: * @jboss:read-only
111: * @jboss:container-configuration name="${xdoclet.jboss.container-configuration}"
112: * @jboss:cache-invalidation value="True"
113: * @jboss:cache-invalidation-config invalidation-group-name="Package"
114: */
115: public abstract class PackageROEJB extends AbstractEntityEJB {
116: private static final long serialVersionUID = -356364373995574407L;
117: protected static final Log _logger = getLogger(PackageROEJB.class);
118:
119: /**
120: * Counts the number of matching packages.
121: *
122: * @param filter Package filter; can be <code>null</code>.
123: * @return The number of matching packages.
124: * @ejb:home-method
125: */
126: public int ejbHomeCount(WMFilter filter) throws RepositoryException {
127: try {
128: return PackageDAO.getInstance().count(filter);
129: } catch (SQLException e) {
130: throw new RepositoryException(e);
131: }
132: }
133:
134: /**
135: * Retrieves matching packages.
136: *
137: * @param filter Process definition filter; should not be <code>null</code>
138: * (use {@link PackageROLocalHome#findAll} instead).
139: * @return A collection of matching packages.
140: * @ejb:home-method
141: * @see PackageROLocalHome#findAll
142: */
143: public Collection ejbHomeXfindByFilter(WMFilter filter)
144: throws FinderException, RepositoryException {
145:
146: try {
147: List pkgs = PackageDAO.getInstance().findByFilter(filter);
148: PackageROLocalHome home = (PackageROLocalHome) _ctx
149: .getEJBLocalHome();
150: for (int i = 0; i < pkgs.size(); i++) {
151: try {
152: pkgs.set(i, home.findByPrimaryKey((String) pkgs
153: .get(i)));
154: } catch (ObjectNotFoundException e) {
155: // Someone else deleted this PK, so just skip it.
156: pkgs.remove(i--);
157: }
158: }
159: return pkgs;
160: } catch (SQLException e) {
161: throw new RepositoryException(e);
162: }
163: }
164:
165: /**
166: * @ejb:interface-method
167: * @ejb:persistence column-name="PACKAGEID"
168: */
169: public abstract String getPackageId();
170:
171: /**
172: * @ejb:persistence column-name="PACKAGEID"
173: */
174: public abstract void setPackageId(String packageId);
175:
176: /**
177: * @ejb:persistence column-name="NAME"
178: */
179: public abstract String getName();
180:
181: /**
182: * @ejb:persistence column-name="NAME"
183: */
184: public abstract void setName(String name);
185:
186: /**
187: * @ejb:persistence column-name="DESCRIPTION"
188: */
189: public abstract String getDescription();
190:
191: /**
192: * @ejb:persistence column-name="DESCRIPTION"
193: */
194: public abstract void setDescription(String description);
195:
196: /**
197: * @ejb:persistence column-name="VERSION"
198: */
199: public abstract String getVersion();
200:
201: /**
202: * @ejb:persistence column-name="VERSION"
203: */
204: public abstract void setVersion(String version);
205:
206: /**
207: * @ejb:persistence column-name="AUTHOR"
208: */
209: public abstract String getAuthor();
210:
211: /**
212: * @ejb:persistence column-name="AUTHOR"
213: */
214: public abstract void setAuthor(String author);
215:
216: /**
217: * @ejb:persistence column-name="VENDOR"
218: */
219: public abstract String getVendor();
220:
221: /**
222: * @ejb:persistence column-name="VENDOR"
223: */
224: public abstract void setVendor(String vendor);
225:
226: /**
227: * @ejb:persistence column-name="XPDLPACKAGE"
228: */
229: public abstract XPDLPackage getPackageCmp();
230:
231: /**
232: * @ejb:persistence column-name="XPDLPACKAGE"
233: */
234: public abstract void setPackageCmp(XPDLPackage pkg);
235:
236: /**
237: * @ejb:interface-method
238: */
239: public XPDLPackage getXPDLPackageBean() {
240: return getPackageCmp();
241: }
242:
243: /**
244: * @ejb:transaction type="Supports"
245: * @ejb:relation name="PackageRO-ProcessDefinitionRO"
246: * role-name="PackageRO-Has-ProcessDefinitionROs"
247: */
248: public abstract Collection getProcessDefinitionsCmr();
249:
250: public abstract void setProcessDefinitionsCmr(Collection procDefs);
251:
252: protected final Log getLogger() {
253: return _logger;
254: }
255: }
|