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