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 ReleaseUtil {
40 public static com.liferay.portal.model.Release create(long releaseId) {
41 return getPersistence().create(releaseId);
42 }
43
44 public static com.liferay.portal.model.Release remove(long releaseId)
45 throws com.liferay.portal.NoSuchReleaseException,
46 com.liferay.portal.SystemException {
47 ModelListener listener = _getListener();
48
49 if (listener != null) {
50 listener.onBeforeRemove(findByPrimaryKey(releaseId));
51 }
52
53 com.liferay.portal.model.Release release = getPersistence().remove(releaseId);
54
55 if (listener != null) {
56 listener.onAfterRemove(release);
57 }
58
59 return release;
60 }
61
62 public static com.liferay.portal.model.Release remove(
63 com.liferay.portal.model.Release release)
64 throws com.liferay.portal.SystemException {
65 ModelListener listener = _getListener();
66
67 if (listener != null) {
68 listener.onBeforeRemove(release);
69 }
70
71 release = getPersistence().remove(release);
72
73 if (listener != null) {
74 listener.onAfterRemove(release);
75 }
76
77 return release;
78 }
79
80 public static com.liferay.portal.model.Release update(
81 com.liferay.portal.model.Release release)
82 throws com.liferay.portal.SystemException {
83 ModelListener listener = _getListener();
84 boolean isNew = release.isNew();
85
86 if (listener != null) {
87 if (isNew) {
88 listener.onBeforeCreate(release);
89 }
90 else {
91 listener.onBeforeUpdate(release);
92 }
93 }
94
95 release = getPersistence().update(release);
96
97 if (listener != null) {
98 if (isNew) {
99 listener.onAfterCreate(release);
100 }
101 else {
102 listener.onAfterUpdate(release);
103 }
104 }
105
106 return release;
107 }
108
109 public static com.liferay.portal.model.Release update(
110 com.liferay.portal.model.Release release, boolean merge)
111 throws com.liferay.portal.SystemException {
112 ModelListener listener = _getListener();
113 boolean isNew = release.isNew();
114
115 if (listener != null) {
116 if (isNew) {
117 listener.onBeforeCreate(release);
118 }
119 else {
120 listener.onBeforeUpdate(release);
121 }
122 }
123
124 release = getPersistence().update(release, merge);
125
126 if (listener != null) {
127 if (isNew) {
128 listener.onAfterCreate(release);
129 }
130 else {
131 listener.onAfterUpdate(release);
132 }
133 }
134
135 return release;
136 }
137
138 public static com.liferay.portal.model.Release findByPrimaryKey(
139 long releaseId)
140 throws com.liferay.portal.NoSuchReleaseException,
141 com.liferay.portal.SystemException {
142 return getPersistence().findByPrimaryKey(releaseId);
143 }
144
145 public static com.liferay.portal.model.Release fetchByPrimaryKey(
146 long releaseId) throws com.liferay.portal.SystemException {
147 return getPersistence().fetchByPrimaryKey(releaseId);
148 }
149
150 public static java.util.List findWithDynamicQuery(
151 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer)
152 throws com.liferay.portal.SystemException {
153 return getPersistence().findWithDynamicQuery(queryInitializer);
154 }
155
156 public static java.util.List findWithDynamicQuery(
157 com.liferay.portal.kernel.dao.DynamicQueryInitializer queryInitializer,
158 int begin, int end) throws com.liferay.portal.SystemException {
159 return getPersistence().findWithDynamicQuery(queryInitializer, begin,
160 end);
161 }
162
163 public static java.util.List findAll()
164 throws com.liferay.portal.SystemException {
165 return getPersistence().findAll();
166 }
167
168 public static java.util.List findAll(int begin, int end)
169 throws com.liferay.portal.SystemException {
170 return getPersistence().findAll(begin, end);
171 }
172
173 public static java.util.List findAll(int begin, int end,
174 com.liferay.portal.kernel.util.OrderByComparator obc)
175 throws com.liferay.portal.SystemException {
176 return getPersistence().findAll(begin, end, obc);
177 }
178
179 public static void removeAll() throws com.liferay.portal.SystemException {
180 getPersistence().removeAll();
181 }
182
183 public static int countAll() throws com.liferay.portal.SystemException {
184 return getPersistence().countAll();
185 }
186
187 public static ReleasePersistence getPersistence() {
188 return _getUtil()._persistence;
189 }
190
191 public void setPersistence(ReleasePersistence persistence) {
192 _persistence = persistence;
193 }
194
195 private static ReleaseUtil _getUtil() {
196 if (_util == null) {
197 _util = (ReleaseUtil)com.liferay.portal.kernel.bean.BeanLocatorUtil.locate(_UTIL);
198 }
199
200 return _util;
201 }
202
203 private static ModelListener _getListener() {
204 if (Validator.isNotNull(_LISTENER)) {
205 try {
206 return (ModelListener)Class.forName(_LISTENER).newInstance();
207 }
208 catch (Exception e) {
209 _log.error(e);
210 }
211 }
212
213 return null;
214 }
215
216 private static final String _UTIL = ReleaseUtil.class.getName();
217 private static final String _LISTENER = GetterUtil.getString(PropsUtil.get(
218 "value.object.listener.com.liferay.portal.model.Release"));
219 private static Log _log = LogFactory.getLog(ReleaseUtil.class);
220 private static ReleaseUtil _util;
221 private ReleasePersistence _persistence;
222 }