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.wfmc.wapi.WMFilter;
051:
052: import javax.ejb.FinderException;
053: import javax.ejb.ObjectNotFoundException;
054: import java.sql.SQLException;
055: import java.util.Collection;
056: import java.util.Date;
057: import java.util.List;
058:
059: /**
060: * Holds the persistent state of a process definition.
061: *
062: * @author Adrian Price
063: * @ejb:bean type="CMP"
064: * cmp-version="2.x"
065: * name="ProcessDefinitionRO"
066: * display-name="OBE Process Definition (RO)"
067: * jndi-name="org/obe/ejb/ProcessDefinitionRO"
068: * local-jndi-name="org/obe/ejb/ProcessDefinitionROLocal"
069: * primkey-field="processDefinitionId"
070: * schema="PROCESSDEFINITIONRO"
071: * reentrant="False"
072: * transaction-type="Container"
073: * view-type="local"
074: * @ejb:persistence table-name="OBEPROCESSDEFINITION"
075: * @ejb:pk class="java.lang.String"
076: * unchecked="true"
077: * @ejb:home local-class="org.obe.server.j2ee.repository.ProcessDefinitionROLocalHome"
078: * local-extends="org.obe.server.j2ee.repository.ProcessDefinitionROHome,javax.ejb.EJBLocalHome"
079: * @ejb:interface local-class="org.obe.server.j2ee.repository.ProcessDefinitionROLocal"
080: * local-extends="org.obe.server.j2ee.repository.ProcessDefinitionRO,javax.ejb.EJBLocalObject"
081: * @ejb:permission unchecked="true"
082: * @ejb:transaction type="NotSupported"
083: * @ejb:finder signature="java.util.Collection findAll()"
084: * query="SELECT OBJECT(p) FROM PROCESSDEFINITIONRO AS p"
085: * result-type-mapping="Local"
086: * unchecked="true"
087: * @ejb:finder signature="java.util.Collection findByName(java.lang.String name)"
088: * query="SELECT OBJECT(p) FROM PROCESSDEFINITIONRO AS p WHERE p.name=?1"
089: * result-type-mapping="Local"
090: * unchecked="true"
091: * @ejb:finder signature="java.util.Collection findByName(java.lang.String name, java.util.Date when)"
092: * query="SELECT OBJECT(p) FROM PROCESSDEFINITIONRO AS p WHERE p.name=?1 AND p.state=1 AND p.publicationStatus <> 'UNDER_REVISION' AND (p.validFromDate IS NULL OR p.validFromDate > ?2) AND (p.validToDate IS NULL OR p.validToDate < ?2)"
093: * result-type-mapping="Local"
094: * unchecked="true"
095: * @ejb:ejb-ref ejb-name="XPDLPackageRO"
096: * view-type="local"
097: * @weblogic:ejb-local-reference-description ejb-ref-name="ejb/XPDLPackageRO"
098: * jndi-name="org/obe/ejb/PackageROLocal"
099: * @ejb:resource-ref res-name="jdbc/TxDataSource"
100: * res-type="javax.sql.DataSource"
101: * res-auth="Container"
102: * @jboss:resource-manager res-man-class="javax.sql.DataSource"
103: * res-man-name="jdbc/TxDataSource"
104: * res-man-jndi-name="java:/${xdoclet.DataSource}"
105: * @weblogic:resource-description res-ref-name="jdbc/TxDataSource"
106: * jndi-name="${xdoclet.DataSource}"
107: * @weblogic:data-source-name java:comp/env/jdbc/TxDataSource
108: * @jboss:create-table false
109: * @weblogic:pool max-beans-in-free-pool="200"
110: * initial-beans-in-free-pool="0"
111: * @weblogic:cache max-beans-in-cache="200"
112: * idle-timeout-seconds="0"
113: * read-timeout-seconds="0"
114: * concurrency-strategy="ReadOnly"
115: * @jboss:persistence read-only="true"
116: * read-time-out="0"
117: * @jboss:read-only
118: * @jboss:container-configuration name="${xdoclet.jboss.container-configuration}"
119: * @jboss:cache-invalidation value="True"
120: * @jboss:cache-invalidation-config invalidation-group-name="ProcessDefinition"
121: */
122: public abstract class ProcessDefinitionROEJB extends AbstractEntityEJB {
123: private static final long serialVersionUID = 2102085026509692550L;
124: protected static final Log _logger = getLogger(ProcessDefinitionROEJB.class);
125:
126: /**
127: * Counts the number of matching process definitions.
128: *
129: * @param filter Process definition filter; can be <code>null</code>.
130: * @return The number of matching process definitions.
131: * @ejb:home-method
132: */
133: public int ejbHomeCount(WMFilter filter) throws RepositoryException {
134: try {
135: return ProcessDefinitionDAO.getInstance().count(filter);
136: } catch (SQLException e) {
137: throw new RepositoryException(e);
138: }
139: }
140:
141: /**
142: * Retrieves matching process definitions.
143: *
144: * @param filter Process definition filter; should not be <code>null</code>
145: * (use {@link ProcessDefinitionROLocalHome#findAll} instead).
146: * @return A collection of matching process definitions.
147: * @ejb:home-method
148: * @see ProcessDefinitionROLocalHome#findAll
149: */
150: public Collection ejbHomeXfindByFilter(WMFilter filter)
151: throws FinderException, RepositoryException {
152:
153: try {
154: List procDefs = ProcessDefinitionDAO.getInstance()
155: .findByFilter(filter);
156: ProcessDefinitionROLocalHome home = (ProcessDefinitionROLocalHome) _ctx
157: .getEJBLocalHome();
158: for (int i = 0; i < procDefs.size(); i++) {
159: try {
160: procDefs
161: .set(i, home
162: .findByPrimaryKey((String) procDefs
163: .get(i)));
164: } catch (ObjectNotFoundException e) {
165: // Someone else deleted this PK, so just skip it.
166: procDefs.remove(i--);
167: }
168: }
169: return procDefs;
170: } catch (SQLException e) {
171: throw new RepositoryException(e);
172: }
173: }
174:
175: /**
176: * @ejb:interface-method
177: * @ejb:persistence column-name="PACKAGEID"
178: */
179: public abstract String getPackageId();
180:
181: /**
182: * @ejb:persistence column-name="PACKAGEID"
183: */
184: public abstract void setPackageId(String packageId);
185:
186: /**
187: * @ejb:interface-method
188: * @ejb:persistence column-name="PROCESSDEFINITIONID"
189: */
190: public abstract String getProcessDefinitionId();
191:
192: /**
193: * @ejb:persistence column-name="PROCESSDEFINITIONID"
194: */
195: public abstract void setProcessDefinitionId(
196: String processDefinitionId);
197:
198: /**
199: * @ejb:interface-method
200: * @ejb:persistence column-name="NAME"
201: */
202: public abstract String getName();
203:
204: /**
205: * @ejb:persistence column-name="NAME"
206: */
207: public abstract void setName(String name);
208:
209: /**
210: * @ejb:interface-method
211: * @ejb:persistence column-name="DESCRIPTION"
212: */
213: public abstract String getDescription();
214:
215: /**
216: * @ejb:persistence column-name="DESCRIPTION"
217: */
218: public abstract void setDescription(String description);
219:
220: /**
221: * @ejb:interface-method
222: * @ejb:persistence column-name="AUTHOR"
223: */
224: public abstract String getAuthor();
225:
226: /**
227: * @ejb:persistence column-name="AUTHOR"
228: */
229: public abstract void setAuthor(String author);
230:
231: /**
232: * @ejb:interface-method
233: * @ejb:persistence column-name="STATUS"
234: */
235: public abstract String getPublicationStatus();
236:
237: /**
238: * @ejb:persistence column-name="STATUS"
239: */
240: public abstract void setPublicationStatus(String status);
241:
242: /**
243: * @ejb:interface-method
244: * @ejb:persistence column-name="CREATEDDATE"
245: */
246: public abstract Date getCreatedDate();
247:
248: /**
249: * @ejb:persistence column-name="CREATEDDATE"
250: */
251: public abstract void setCreatedDate(Date createdDate);
252:
253: /**
254: * @ejb:interface-method
255: * @ejb:persistence column-name="VALIDFROMDATE"
256: */
257: public abstract Date getValidFromDate();
258:
259: /**
260: * @ejb:persistence column-name="VALIDFROMDATE"
261: */
262: public abstract void setValidFromDate(Date fromDate);
263:
264: /**
265: * @ejb:interface-method
266: * @ejb:persistence column-name="VALIDTODATE"
267: */
268: public abstract Date getValidToDate();
269:
270: /**
271: * @ejb:persistence column-name="VALIDTODATE"
272: */
273: public abstract void setValidToDate(Date toDate);
274:
275: /**
276: * @ejb:interface-method
277: * @ejb:persistence column-name="STATE"
278: */
279: public abstract int getState();
280:
281: /**
282: * @ejb:persistence column-name="STATE"
283: */
284: public abstract void setState(int state);
285:
286: /**
287: * @ejb:interface-method
288: * @ejb:relation name="PackageRO-ProcessDefinitionRO"
289: * role-name="ProcessDefinitionRO-Has-A-PackageRO"
290: * cascade-delete="yes"
291: * @jboss:relation related-pk-field="packageId"
292: * fk-column="PACKAGEID"
293: * @weblogic:column-map key-column="PACKAGEID"
294: * foreign-key-column="PACKAGEID"
295: */
296: public abstract PackageROLocal getXpdlPackage();
297:
298: public abstract void setXpdlPackage(PackageROLocal pkg);
299:
300: /**
301: * @ejb:interface-method
302: */
303: public PackageRO getXPDLPackageRO() {
304: return getXpdlPackage();
305: }
306:
307: protected final Log getLogger() {
308: return _logger;
309: }
310: }
|