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