1   /**
2    * Copyright (c) 2000-2007 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.service.persistence;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.kernel.util.Validator;
27  import com.liferay.portal.model.ModelListener;
28  import com.liferay.portal.util.PropsUtil;
29  
30  import org.apache.commons.logging.Log;
31  import org.apache.commons.logging.LogFactory;
32  
33  /**
34   * <a href="OrgLaborUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class OrgLaborUtil {
40      public static com.liferay.portal.model.OrgLabor create(long orgLaborId) {
41          return getPersistence().create(orgLaborId);
42      }
43  
44      public static com.liferay.portal.model.OrgLabor remove(long orgLaborId)
45          throws com.liferay.portal.SystemException, 
46              com.liferay.portal.NoSuchOrgLaborException {
47          ModelListener listener = _getListener();
48  
49          if (listener != null) {
50              listener.onBeforeRemove(findByPrimaryKey(orgLaborId));
51          }
52  
53          com.liferay.portal.model.OrgLabor orgLabor = getPersistence().remove(orgLaborId);
54  
55          if (listener != null) {
56              listener.onAfterRemove(orgLabor);
57          }
58  
59          return orgLabor;
60      }
61  
62      public static com.liferay.portal.model.OrgLabor remove(
63          com.liferay.portal.model.OrgLabor orgLabor)
64          throws com.liferay.portal.SystemException {
65          ModelListener listener = _getListener();
66  
67          if (listener != null) {
68              listener.onBeforeRemove(orgLabor);
69          }
70  
71          orgLabor = getPersistence().remove(orgLabor);
72  
73          if (listener != null) {
74              listener.onAfterRemove(orgLabor);
75          }
76  
77          return orgLabor;
78      }
79  
80      public static com.liferay.portal.model.OrgLabor update(
81          com.liferay.portal.model.OrgLabor orgLabor)
82          throws com.liferay.portal.SystemException {
83          ModelListener listener = _getListener();
84          boolean isNew = orgLabor.isNew();
85  
86          if (listener != null) {
87              if (isNew) {
88                  listener.onBeforeCreate(orgLabor);
89              }
90              else {
91                  listener.onBeforeUpdate(orgLabor);
92              }
93          }
94  
95          orgLabor = getPersistence().update(orgLabor);
96  
97          if (listener != null) {
98              if (isNew) {
99                  listener.onAfterCreate(orgLabor);
100             }
101             else {
102                 listener.onAfterUpdate(orgLabor);
103             }
104         }
105 
106         return orgLabor;
107     }
108 
109     public static com.liferay.portal.model.OrgLabor update(
110         com.liferay.portal.model.OrgLabor orgLabor, boolean merge)
111         throws com.liferay.portal.SystemException {
112         ModelListener listener = _getListener();
113         boolean isNew = orgLabor.isNew();
114 
115         if (listener != null) {
116             if (isNew) {
117                 listener.onBeforeCreate(orgLabor);
118             }
119             else {
120                 listener.onBeforeUpdate(orgLabor);
121             }
122         }
123 
124         orgLabor = getPersistence().update(orgLabor, merge);
125 
126         if (listener != null) {
127             if (isNew) {
128                 listener.onAfterCreate(orgLabor);
129             }
130             else {
131                 listener.onAfterUpdate(orgLabor);
132             }
133         }
134 
135         return orgLabor;
136     }
137 
138     public static com.liferay.portal.model.OrgLabor findByPrimaryKey(
139         long orgLaborId)
140         throws com.liferay.portal.SystemException, 
141             com.liferay.portal.NoSuchOrgLaborException {
142         return getPersistence().findByPrimaryKey(orgLaborId);
143     }
144 
145     public static com.liferay.portal.model.OrgLabor fetchByPrimaryKey(
146         long orgLaborId) throws com.liferay.portal.SystemException {
147         return getPersistence().fetchByPrimaryKey(orgLaborId);
148     }
149 
150     public static java.util.List findByOrganizationId(long organizationId)
151         throws com.liferay.portal.SystemException {
152         return getPersistence().findByOrganizationId(organizationId);
153     }
154 
155     public static java.util.List findByOrganizationId(long organizationId,
156         int begin, int end) throws com.liferay.portal.SystemException {
157         return getPersistence().findByOrganizationId(organizationId, begin, end);
158     }
159 
160     public static java.util.List findByOrganizationId(long organizationId,
161         int begin, int end, com.liferay.portal.kernel.util.OrderByComparator obc)
162         throws com.liferay.portal.SystemException {
163         return getPersistence().findByOrganizationId(organizationId, begin,
164             end, obc);
165     }
166 
167     public static com.liferay.portal.model.OrgLabor findByOrganizationId_First(
168         long organizationId,
169         com.liferay.portal.kernel.util.OrderByComparator obc)
170         throws com.liferay.portal.SystemException, 
171             com.liferay.portal.NoSuchOrgLaborException {
172         return getPersistence().findByOrganizationId_First(organizationId, obc);
173     }
174 
175     public static com.liferay.portal.model.OrgLabor findByOrganizationId_Last(
176         long organizationId,
177         com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portal.NoSuchOrgLaborException {
180         return getPersistence().findByOrganizationId_Last(organizationId, obc);
181     }
182 
183     public static com.liferay.portal.model.OrgLabor[] findByOrganizationId_PrevAndNext(
184         long orgLaborId, long organizationId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portal.NoSuchOrgLaborException {
188         return getPersistence().findByOrganizationId_PrevAndNext(orgLaborId,
189             organizationId, obc);
190     }
191 
192     public static java.util.List findWithDynamicQuery(
193         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
194         throws com.liferay.portal.SystemException {
195         return getPersistence().findWithDynamicQuery(queryInitializer);
196     }
197 
198     public static java.util.List findWithDynamicQuery(
199         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
200         int begin, int end) throws com.liferay.portal.SystemException {
201         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
202             end);
203     }
204 
205     public static java.util.List findAll()
206         throws com.liferay.portal.SystemException {
207         return getPersistence().findAll();
208     }
209 
210     public static java.util.List findAll(int begin, int end)
211         throws com.liferay.portal.SystemException {
212         return getPersistence().findAll(begin, end);
213     }
214 
215     public static java.util.List findAll(int begin, int end,
216         com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException {
218         return getPersistence().findAll(begin, end, obc);
219     }
220 
221     public static void removeByOrganizationId(long organizationId)
222         throws com.liferay.portal.SystemException {
223         getPersistence().removeByOrganizationId(organizationId);
224     }
225 
226     public static void removeAll() throws com.liferay.portal.SystemException {
227         getPersistence().removeAll();
228     }
229 
230     public static int countByOrganizationId(long organizationId)
231         throws com.liferay.portal.SystemException {
232         return getPersistence().countByOrganizationId(organizationId);
233     }
234 
235     public static int countAll() throws com.liferay.portal.SystemException {
236         return getPersistence().countAll();
237     }
238 
239     public static OrgLaborPersistence getPersistence() {
240         return _getUtil()._persistence;
241     }
242 
243     public void setPersistence(OrgLaborPersistence persistence) {
244         _persistence = persistence;
245     }
246 
247     private static OrgLaborUtil _getUtil() {
248         if (_util == null) {
249             _util = (OrgLaborUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
250         }
251 
252         return _util;
253     }
254 
255     private static ModelListener _getListener() {
256         if (Validator.isNotNull(_LISTENER)) {
257             try {
258                 return (ModelListener)Class.forName(_LISTENER).newInstance();
259             }
260             catch (Exception e) {
261                 _log.error(e);
262             }
263         }
264 
265         return null;
266     }
267 
268     private static final String _UTIL = OrgLaborUtil.class.getName();
269     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
270                 "value.object.listener.com.liferay.portal.model.OrgLabor"));
271     private static Log _log = LogFactory.getLog(OrgLaborUtil.class);
272     private static OrgLaborUtil _util;
273     private OrgLaborPersistence _persistence;
274 }