1
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
39 public class ListTypeUtil {
40 public static com.liferay.portal.model.ListType create(int listTypeId) {
41 return getPersistence().create(listTypeId);
42 }
43
44 public static com.liferay.portal.model.ListType remove(int listTypeId)
45 throws com.liferay.portal.SystemException,
46 com.liferay.portal.NoSuchListTypeException {
47 ModelListener listener = _getListener();
48
49 if (listener != null) {
50 listener.onBeforeRemove(findByPrimaryKey(listTypeId));
51 }
52
53 com.liferay.portal.model.ListType listType = getPersistence().remove(listTypeId);
54
55 if (listener != null) {
56 listener.onAfterRemove(listType);
57 }
58
59 return listType;
60 }
61
62 public static com.liferay.portal.model.ListType remove(
63 com.liferay.portal.model.ListType listType)
64 throws com.liferay.portal.SystemException {
65 ModelListener listener = _getListener();
66
67 if (listener != null) {
68 listener.onBeforeRemove(listType);
69 }
70
71 listType = getPersistence().remove(listType);
72
73 if (listener != null) {
74 listener.onAfterRemove(listType);
75 }
76
77 return listType;
78 }
79
80 public static com.liferay.portal.model.ListType update(
81 com.liferay.portal.model.ListType listType)
82 throws com.liferay.portal.SystemException {
83 ModelListener listener = _getListener();
84 boolean isNew = listType.isNew();
85
86 if (listener != null) {
87 if (isNew) {
88 listener.onBeforeCreate(listType);
89 }
90 else {
91 listener.onBeforeUpdate(listType);
92 }
93 }
94
95 listType = getPersistence().update(listType);
96
97 if (listener != null) {
98 if (isNew) {
99 listener.onAfterCreate(listType);
100 }
101 else {
102 listener.onAfterUpdate(listType);
103 }
104 }
105
106 return listType;
107 }
108
109 public static com.liferay.portal.model.ListType update(
110 com.liferay.portal.model.ListType listType, boolean merge)
111 throws com.liferay.portal.SystemException {
112 ModelListener listener = _getListener();
113 boolean isNew = listType.isNew();
114
115 if (listener != null) {
116 if (isNew) {
117 listener.onBeforeCreate(listType);
118 }
119 else {
120 listener.onBeforeUpdate(listType);
121 }
122 }
123
124 listType = getPersistence().update(listType, merge);
125
126 if (listener != null) {
127 if (isNew) {
128 listener.onAfterCreate(listType);
129 }
130 else {
131 listener.onAfterUpdate(listType);
132 }
133 }
134
135 return listType;
136 }
137
138 public static com.liferay.portal.model.ListType findByPrimaryKey(
139 int listTypeId)
140 throws com.liferay.portal.SystemException,
141 com.liferay.portal.NoSuchListTypeException {
142 return getPersistence().findByPrimaryKey(listTypeId);
143 }
144
145 public static com.liferay.portal.model.ListType fetchByPrimaryKey(
146 int listTypeId) throws com.liferay.portal.SystemException {
147 return getPersistence().fetchByPrimaryKey(listTypeId);
148 }
149
150 public static java.util.List findByType(java.lang.String type)
151 throws com.liferay.portal.SystemException {
152 return getPersistence().findByType(type);
153 }
154
155 public static java.util.List findByType(java.lang.String type, int begin,
156 int end) throws com.liferay.portal.SystemException {
157 return getPersistence().findByType(type, begin, end);
158 }
159
160 public static java.util.List findByType(java.lang.String type, int begin,
161 int end, com.liferay.portal.kernel.util.OrderByComparator obc)
162 throws com.liferay.portal.SystemException {
163 return getPersistence().findByType(type, begin, end, obc);
164 }
165
166 public static com.liferay.portal.model.ListType findByType_First(
167 java.lang.String type,
168 com.liferay.portal.kernel.util.OrderByComparator obc)
169 throws com.liferay.portal.SystemException,
170 com.liferay.portal.NoSuchListTypeException {
171 return getPersistence().findByType_First(type, obc);
172 }
173
174 public static com.liferay.portal.model.ListType findByType_Last(
175 java.lang.String type,
176 com.liferay.portal.kernel.util.OrderByComparator obc)
177 throws com.liferay.portal.SystemException,
178 com.liferay.portal.NoSuchListTypeException {
179 return getPersistence().findByType_Last(type, obc);
180 }
181
182 public static com.liferay.portal.model.ListType[] findByType_PrevAndNext(
183 int listTypeId, java.lang.String type,
184 com.liferay.portal.kernel.util.OrderByComparator obc)
185 throws com.liferay.portal.SystemException,
186 com.liferay.portal.NoSuchListTypeException {
187 return getPersistence().findByType_PrevAndNext(listTypeId, type, obc);
188 }
189
190 public static java.util.List findWithDynamicQuery(
191 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
192 throws com.liferay.portal.SystemException {
193 return getPersistence().findWithDynamicQuery(queryInitializer);
194 }
195
196 public static java.util.List findWithDynamicQuery(
197 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
198 int begin, int end) throws com.liferay.portal.SystemException {
199 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
200 end);
201 }
202
203 public static java.util.List findAll()
204 throws com.liferay.portal.SystemException {
205 return getPersistence().findAll();
206 }
207
208 public static java.util.List findAll(int begin, int end)
209 throws com.liferay.portal.SystemException {
210 return getPersistence().findAll(begin, end);
211 }
212
213 public static java.util.List findAll(int begin, int end,
214 com.liferay.portal.kernel.util.OrderByComparator obc)
215 throws com.liferay.portal.SystemException {
216 return getPersistence().findAll(begin, end, obc);
217 }
218
219 public static void removeByType(java.lang.String type)
220 throws com.liferay.portal.SystemException {
221 getPersistence().removeByType(type);
222 }
223
224 public static void removeAll() throws com.liferay.portal.SystemException {
225 getPersistence().removeAll();
226 }
227
228 public static int countByType(java.lang.String type)
229 throws com.liferay.portal.SystemException {
230 return getPersistence().countByType(type);
231 }
232
233 public static int countAll() throws com.liferay.portal.SystemException {
234 return getPersistence().countAll();
235 }
236
237 public static ListTypePersistence getPersistence() {
238 return _getUtil()._persistence;
239 }
240
241 public void setPersistence(ListTypePersistence persistence) {
242 _persistence = persistence;
243 }
244
245 private static ListTypeUtil _getUtil() {
246 if (_util == null) {
247 _util = (ListTypeUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
248 }
249
250 return _util;
251 }
252
253 private static ModelListener _getListener() {
254 if (Validator.isNotNull(_LISTENER)) {
255 try {
256 return (ModelListener)Class.forName(_LISTENER).newInstance();
257 }
258 catch (Exception e) {
259 _log.error(e);
260 }
261 }
262
263 return null;
264 }
265
266 private static final String _UTIL = ListTypeUtil.class.getName();
267 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
268 "value.object.listener.com.liferay.portal.model.ListType"));
269 private static Log _log = LogFactory.getLog(ListTypeUtil.class);
270 private static ListTypeUtil _util;
271 private ListTypePersistence _persistence;
272 }