1
22
23 package com.liferay.portlet.bookmarks.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
39 public class BookmarksEntryUtil {
40 public static com.liferay.portlet.bookmarks.model.BookmarksEntry create(
41 long entryId) {
42 return getPersistence().create(entryId);
43 }
44
45 public static com.liferay.portlet.bookmarks.model.BookmarksEntry remove(
46 long entryId)
47 throws com.liferay.portal.SystemException,
48 com.liferay.portlet.bookmarks.NoSuchEntryException {
49 ModelListener listener = _getListener();
50
51 if (listener != null) {
52 listener.onBeforeRemove(findByPrimaryKey(entryId));
53 }
54
55 com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry = getPersistence()
56 .remove(entryId);
57
58 if (listener != null) {
59 listener.onAfterRemove(bookmarksEntry);
60 }
61
62 return bookmarksEntry;
63 }
64
65 public static com.liferay.portlet.bookmarks.model.BookmarksEntry remove(
66 com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry)
67 throws com.liferay.portal.SystemException {
68 ModelListener listener = _getListener();
69
70 if (listener != null) {
71 listener.onBeforeRemove(bookmarksEntry);
72 }
73
74 bookmarksEntry = getPersistence().remove(bookmarksEntry);
75
76 if (listener != null) {
77 listener.onAfterRemove(bookmarksEntry);
78 }
79
80 return bookmarksEntry;
81 }
82
83 public static com.liferay.portlet.bookmarks.model.BookmarksEntry update(
84 com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry)
85 throws com.liferay.portal.SystemException {
86 ModelListener listener = _getListener();
87 boolean isNew = bookmarksEntry.isNew();
88
89 if (listener != null) {
90 if (isNew) {
91 listener.onBeforeCreate(bookmarksEntry);
92 }
93 else {
94 listener.onBeforeUpdate(bookmarksEntry);
95 }
96 }
97
98 bookmarksEntry = getPersistence().update(bookmarksEntry);
99
100 if (listener != null) {
101 if (isNew) {
102 listener.onAfterCreate(bookmarksEntry);
103 }
104 else {
105 listener.onAfterUpdate(bookmarksEntry);
106 }
107 }
108
109 return bookmarksEntry;
110 }
111
112 public static com.liferay.portlet.bookmarks.model.BookmarksEntry update(
113 com.liferay.portlet.bookmarks.model.BookmarksEntry bookmarksEntry,
114 boolean merge) throws com.liferay.portal.SystemException {
115 ModelListener listener = _getListener();
116 boolean isNew = bookmarksEntry.isNew();
117
118 if (listener != null) {
119 if (isNew) {
120 listener.onBeforeCreate(bookmarksEntry);
121 }
122 else {
123 listener.onBeforeUpdate(bookmarksEntry);
124 }
125 }
126
127 bookmarksEntry = getPersistence().update(bookmarksEntry, merge);
128
129 if (listener != null) {
130 if (isNew) {
131 listener.onAfterCreate(bookmarksEntry);
132 }
133 else {
134 listener.onAfterUpdate(bookmarksEntry);
135 }
136 }
137
138 return bookmarksEntry;
139 }
140
141 public static com.liferay.portlet.bookmarks.model.BookmarksEntry findByPrimaryKey(
142 long entryId)
143 throws com.liferay.portal.SystemException,
144 com.liferay.portlet.bookmarks.NoSuchEntryException {
145 return getPersistence().findByPrimaryKey(entryId);
146 }
147
148 public static com.liferay.portlet.bookmarks.model.BookmarksEntry fetchByPrimaryKey(
149 long entryId) throws com.liferay.portal.SystemException {
150 return getPersistence().fetchByPrimaryKey(entryId);
151 }
152
153 public static java.util.List findByFolderId(long folderId)
154 throws com.liferay.portal.SystemException {
155 return getPersistence().findByFolderId(folderId);
156 }
157
158 public static java.util.List findByFolderId(long folderId, int begin,
159 int end) throws com.liferay.portal.SystemException {
160 return getPersistence().findByFolderId(folderId, begin, end);
161 }
162
163 public static java.util.List findByFolderId(long folderId, int begin,
164 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
165 throws com.liferay.portal.SystemException {
166 return getPersistence().findByFolderId(folderId, begin, end, obc);
167 }
168
169 public static com.liferay.portlet.bookmarks.model.BookmarksEntry findByFolderId_First(
170 long folderId, com.liferay.portal.kernel.util.OrderByComparator obc)
171 throws com.liferay.portal.SystemException,
172 com.liferay.portlet.bookmarks.NoSuchEntryException {
173 return getPersistence().findByFolderId_First(folderId, obc);
174 }
175
176 public static com.liferay.portlet.bookmarks.model.BookmarksEntry findByFolderId_Last(
177 long folderId, com.liferay.portal.kernel.util.OrderByComparator obc)
178 throws com.liferay.portal.SystemException,
179 com.liferay.portlet.bookmarks.NoSuchEntryException {
180 return getPersistence().findByFolderId_Last(folderId, obc);
181 }
182
183 public static com.liferay.portlet.bookmarks.model.BookmarksEntry[] findByFolderId_PrevAndNext(
184 long entryId, long folderId,
185 com.liferay.portal.kernel.util.OrderByComparator obc)
186 throws com.liferay.portal.SystemException,
187 com.liferay.portlet.bookmarks.NoSuchEntryException {
188 return getPersistence().findByFolderId_PrevAndNext(entryId, folderId,
189 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 removeByFolderId(long folderId)
222 throws com.liferay.portal.SystemException {
223 getPersistence().removeByFolderId(folderId);
224 }
225
226 public static void removeAll() throws com.liferay.portal.SystemException {
227 getPersistence().removeAll();
228 }
229
230 public static int countByFolderId(long folderId)
231 throws com.liferay.portal.SystemException {
232 return getPersistence().countByFolderId(folderId);
233 }
234
235 public static int countAll() throws com.liferay.portal.SystemException {
236 return getPersistence().countAll();
237 }
238
239 public static BookmarksEntryPersistence getPersistence() {
240 return _getUtil()._persistence;
241 }
242
243 public void setPersistence(BookmarksEntryPersistence persistence) {
244 _persistence = persistence;
245 }
246
247 private static BookmarksEntryUtil _getUtil() {
248 if (_util == null) {
249 _util = (BookmarksEntryUtil)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 = BookmarksEntryUtil.class.getName();
269 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
270 "value.object.listener.com.liferay.portlet.bookmarks.model.BookmarksEntry"));
271 private static Log _log = LogFactory.getLog(BookmarksEntryUtil.class);
272 private static BookmarksEntryUtil _util;
273 private BookmarksEntryPersistence _persistence;
274 }