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.portlet.tags.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="TagsPropertyUtil.java.html"><b><i>View Source</i></b></a>
35   *
36   * @author Brian Wing Shun Chan
37   *
38   */
39  public class TagsPropertyUtil {
40      public static com.liferay.portlet.tags.model.TagsProperty create(
41          long propertyId) {
42          return getPersistence().create(propertyId);
43      }
44  
45      public static com.liferay.portlet.tags.model.TagsProperty remove(
46          long propertyId)
47          throws com.liferay.portal.SystemException, 
48              com.liferay.portlet.tags.NoSuchPropertyException {
49          ModelListener listener = _getListener();
50  
51          if (listener != null) {
52              listener.onBeforeRemove(findByPrimaryKey(propertyId));
53          }
54  
55          com.liferay.portlet.tags.model.TagsProperty tagsProperty = getPersistence()
56                                                                         .remove(propertyId);
57  
58          if (listener != null) {
59              listener.onAfterRemove(tagsProperty);
60          }
61  
62          return tagsProperty;
63      }
64  
65      public static com.liferay.portlet.tags.model.TagsProperty remove(
66          com.liferay.portlet.tags.model.TagsProperty tagsProperty)
67          throws com.liferay.portal.SystemException {
68          ModelListener listener = _getListener();
69  
70          if (listener != null) {
71              listener.onBeforeRemove(tagsProperty);
72          }
73  
74          tagsProperty = getPersistence().remove(tagsProperty);
75  
76          if (listener != null) {
77              listener.onAfterRemove(tagsProperty);
78          }
79  
80          return tagsProperty;
81      }
82  
83      public static com.liferay.portlet.tags.model.TagsProperty update(
84          com.liferay.portlet.tags.model.TagsProperty tagsProperty)
85          throws com.liferay.portal.SystemException {
86          ModelListener listener = _getListener();
87          boolean isNew = tagsProperty.isNew();
88  
89          if (listener != null) {
90              if (isNew) {
91                  listener.onBeforeCreate(tagsProperty);
92              }
93              else {
94                  listener.onBeforeUpdate(tagsProperty);
95              }
96          }
97  
98          tagsProperty = getPersistence().update(tagsProperty);
99  
100         if (listener != null) {
101             if (isNew) {
102                 listener.onAfterCreate(tagsProperty);
103             }
104             else {
105                 listener.onAfterUpdate(tagsProperty);
106             }
107         }
108 
109         return tagsProperty;
110     }
111 
112     public static com.liferay.portlet.tags.model.TagsProperty update(
113         com.liferay.portlet.tags.model.TagsProperty tagsProperty, boolean merge)
114         throws com.liferay.portal.SystemException {
115         ModelListener listener = _getListener();
116         boolean isNew = tagsProperty.isNew();
117 
118         if (listener != null) {
119             if (isNew) {
120                 listener.onBeforeCreate(tagsProperty);
121             }
122             else {
123                 listener.onBeforeUpdate(tagsProperty);
124             }
125         }
126 
127         tagsProperty = getPersistence().update(tagsProperty, merge);
128 
129         if (listener != null) {
130             if (isNew) {
131                 listener.onAfterCreate(tagsProperty);
132             }
133             else {
134                 listener.onAfterUpdate(tagsProperty);
135             }
136         }
137 
138         return tagsProperty;
139     }
140 
141     public static com.liferay.portlet.tags.model.TagsProperty findByPrimaryKey(
142         long propertyId)
143         throws com.liferay.portal.SystemException, 
144             com.liferay.portlet.tags.NoSuchPropertyException {
145         return getPersistence().findByPrimaryKey(propertyId);
146     }
147 
148     public static com.liferay.portlet.tags.model.TagsProperty fetchByPrimaryKey(
149         long propertyId) throws com.liferay.portal.SystemException {
150         return getPersistence().fetchByPrimaryKey(propertyId);
151     }
152 
153     public static java.util.List findByCompanyId(long companyId)
154         throws com.liferay.portal.SystemException {
155         return getPersistence().findByCompanyId(companyId);
156     }
157 
158     public static java.util.List findByCompanyId(long companyId, int begin,
159         int end) throws com.liferay.portal.SystemException {
160         return getPersistence().findByCompanyId(companyId, begin, end);
161     }
162 
163     public static java.util.List findByCompanyId(long companyId, int begin,
164         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165         throws com.liferay.portal.SystemException {
166         return getPersistence().findByCompanyId(companyId, begin, end, obc);
167     }
168 
169     public static com.liferay.portlet.tags.model.TagsProperty findByCompanyId_First(
170         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
171         throws com.liferay.portal.SystemException, 
172             com.liferay.portlet.tags.NoSuchPropertyException {
173         return getPersistence().findByCompanyId_First(companyId, obc);
174     }
175 
176     public static com.liferay.portlet.tags.model.TagsProperty findByCompanyId_Last(
177         long companyId, com.liferay.portal.kernel.util.OrderByComparator obc)
178         throws com.liferay.portal.SystemException, 
179             com.liferay.portlet.tags.NoSuchPropertyException {
180         return getPersistence().findByCompanyId_Last(companyId, obc);
181     }
182 
183     public static com.liferay.portlet.tags.model.TagsProperty[] findByCompanyId_PrevAndNext(
184         long propertyId, long companyId,
185         com.liferay.portal.kernel.util.OrderByComparator obc)
186         throws com.liferay.portal.SystemException, 
187             com.liferay.portlet.tags.NoSuchPropertyException {
188         return getPersistence().findByCompanyId_PrevAndNext(propertyId,
189             companyId, obc);
190     }
191 
192     public static java.util.List findByEntryId(long entryId)
193         throws com.liferay.portal.SystemException {
194         return getPersistence().findByEntryId(entryId);
195     }
196 
197     public static java.util.List findByEntryId(long entryId, int begin, int end)
198         throws com.liferay.portal.SystemException {
199         return getPersistence().findByEntryId(entryId, begin, end);
200     }
201 
202     public static java.util.List findByEntryId(long entryId, int begin,
203         int end, com.liferay.portal.kernel.util.OrderByComparator obc)
204         throws com.liferay.portal.SystemException {
205         return getPersistence().findByEntryId(entryId, begin, end, obc);
206     }
207 
208     public static com.liferay.portlet.tags.model.TagsProperty findByEntryId_First(
209         long entryId, com.liferay.portal.kernel.util.OrderByComparator obc)
210         throws com.liferay.portal.SystemException, 
211             com.liferay.portlet.tags.NoSuchPropertyException {
212         return getPersistence().findByEntryId_First(entryId, obc);
213     }
214 
215     public static com.liferay.portlet.tags.model.TagsProperty findByEntryId_Last(
216         long entryId, com.liferay.portal.kernel.util.OrderByComparator obc)
217         throws com.liferay.portal.SystemException, 
218             com.liferay.portlet.tags.NoSuchPropertyException {
219         return getPersistence().findByEntryId_Last(entryId, obc);
220     }
221 
222     public static com.liferay.portlet.tags.model.TagsProperty[] findByEntryId_PrevAndNext(
223         long propertyId, long entryId,
224         com.liferay.portal.kernel.util.OrderByComparator obc)
225         throws com.liferay.portal.SystemException, 
226             com.liferay.portlet.tags.NoSuchPropertyException {
227         return getPersistence().findByEntryId_PrevAndNext(propertyId, entryId,
228             obc);
229     }
230 
231     public static java.util.List findByC_K(long companyId, java.lang.String key)
232         throws com.liferay.portal.SystemException {
233         return getPersistence().findByC_K(companyId, key);
234     }
235 
236     public static java.util.List findByC_K(long companyId,
237         java.lang.String key, int begin, int end)
238         throws com.liferay.portal.SystemException {
239         return getPersistence().findByC_K(companyId, key, begin, end);
240     }
241 
242     public static java.util.List findByC_K(long companyId,
243         java.lang.String key, int begin, int end,
244         com.liferay.portal.kernel.util.OrderByComparator obc)
245         throws com.liferay.portal.SystemException {
246         return getPersistence().findByC_K(companyId, key, begin, end, obc);
247     }
248 
249     public static com.liferay.portlet.tags.model.TagsProperty findByC_K_First(
250         long companyId, java.lang.String key,
251         com.liferay.portal.kernel.util.OrderByComparator obc)
252         throws com.liferay.portal.SystemException, 
253             com.liferay.portlet.tags.NoSuchPropertyException {
254         return getPersistence().findByC_K_First(companyId, key, obc);
255     }
256 
257     public static com.liferay.portlet.tags.model.TagsProperty findByC_K_Last(
258         long companyId, java.lang.String key,
259         com.liferay.portal.kernel.util.OrderByComparator obc)
260         throws com.liferay.portal.SystemException, 
261             com.liferay.portlet.tags.NoSuchPropertyException {
262         return getPersistence().findByC_K_Last(companyId, key, obc);
263     }
264 
265     public static com.liferay.portlet.tags.model.TagsProperty[] findByC_K_PrevAndNext(
266         long propertyId, long companyId, java.lang.String key,
267         com.liferay.portal.kernel.util.OrderByComparator obc)
268         throws com.liferay.portal.SystemException, 
269             com.liferay.portlet.tags.NoSuchPropertyException {
270         return getPersistence().findByC_K_PrevAndNext(propertyId, companyId,
271             key, obc);
272     }
273 
274     public static com.liferay.portlet.tags.model.TagsProperty findByE_K(
275         long entryId, java.lang.String key)
276         throws com.liferay.portal.SystemException, 
277             com.liferay.portlet.tags.NoSuchPropertyException {
278         return getPersistence().findByE_K(entryId, key);
279     }
280 
281     public static com.liferay.portlet.tags.model.TagsProperty fetchByE_K(
282         long entryId, java.lang.String key)
283         throws com.liferay.portal.SystemException {
284         return getPersistence().fetchByE_K(entryId, key);
285     }
286 
287     public static java.util.List findWithDynamicQuery(
288         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
289         throws com.liferay.portal.SystemException {
290         return getPersistence().findWithDynamicQuery(queryInitializer);
291     }
292 
293     public static java.util.List findWithDynamicQuery(
294         com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
295         int begin, int end) throws com.liferay.portal.SystemException {
296         return getPersistence().findWithDynamicQuery(queryInitializer, begin,
297             end);
298     }
299 
300     public static java.util.List findAll()
301         throws com.liferay.portal.SystemException {
302         return getPersistence().findAll();
303     }
304 
305     public static java.util.List findAll(int begin, int end)
306         throws com.liferay.portal.SystemException {
307         return getPersistence().findAll(begin, end);
308     }
309 
310     public static java.util.List findAll(int begin, int end,
311         com.liferay.portal.kernel.util.OrderByComparator obc)
312         throws com.liferay.portal.SystemException {
313         return getPersistence().findAll(begin, end, obc);
314     }
315 
316     public static void removeByCompanyId(long companyId)
317         throws com.liferay.portal.SystemException {
318         getPersistence().removeByCompanyId(companyId);
319     }
320 
321     public static void removeByEntryId(long entryId)
322         throws com.liferay.portal.SystemException {
323         getPersistence().removeByEntryId(entryId);
324     }
325 
326     public static void removeByC_K(long companyId, java.lang.String key)
327         throws com.liferay.portal.SystemException {
328         getPersistence().removeByC_K(companyId, key);
329     }
330 
331     public static void removeByE_K(long entryId, java.lang.String key)
332         throws com.liferay.portal.SystemException, 
333             com.liferay.portlet.tags.NoSuchPropertyException {
334         getPersistence().removeByE_K(entryId, key);
335     }
336 
337     public static void removeAll() throws com.liferay.portal.SystemException {
338         getPersistence().removeAll();
339     }
340 
341     public static int countByCompanyId(long companyId)
342         throws com.liferay.portal.SystemException {
343         return getPersistence().countByCompanyId(companyId);
344     }
345 
346     public static int countByEntryId(long entryId)
347         throws com.liferay.portal.SystemException {
348         return getPersistence().countByEntryId(entryId);
349     }
350 
351     public static int countByC_K(long companyId, java.lang.String key)
352         throws com.liferay.portal.SystemException {
353         return getPersistence().countByC_K(companyId, key);
354     }
355 
356     public static int countByE_K(long entryId, java.lang.String key)
357         throws com.liferay.portal.SystemException {
358         return getPersistence().countByE_K(entryId, key);
359     }
360 
361     public static int countAll() throws com.liferay.portal.SystemException {
362         return getPersistence().countAll();
363     }
364 
365     public static TagsPropertyPersistence getPersistence() {
366         return _getUtil()._persistence;
367     }
368 
369     public void setPersistence(TagsPropertyPersistence persistence) {
370         _persistence = persistence;
371     }
372 
373     private static TagsPropertyUtil _getUtil() {
374         if (_util == null) {
375             _util = (TagsPropertyUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
376         }
377 
378         return _util;
379     }
380 
381     private static ModelListener _getListener() {
382         if (Validator.isNotNull(_LISTENER)) {
383             try {
384                 return (ModelListener)Class.forName(_LISTENER).newInstance();
385             }
386             catch (Exception e) {
387                 _log.error(e);
388             }
389         }
390 
391         return null;
392     }
393 
394     private static final String _UTIL = TagsPropertyUtil.class.getName();
395     private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
396                 "value.object.listener.com.liferay.portlet.tags.model.TagsProperty"));
397     private static Log _log = LogFactory.getLog(TagsPropertyUtil.class);
398     private static TagsPropertyUtil _util;
399     private TagsPropertyPersistence _persistence;
400 }