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