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