1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.announcements.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.GetterUtil;
28  import com.liferay.portal.kernel.util.HtmlUtil;
29  import com.liferay.portal.model.impl.BaseModelImpl;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.announcements.model.AnnouncementsDelivery;
33  import com.liferay.portlet.announcements.model.AnnouncementsDeliverySoap;
34  
35  import java.io.Serializable;
36  
37  import java.lang.reflect.Proxy;
38  
39  import java.sql.Types;
40  
41  import java.util.ArrayList;
42  import java.util.List;
43  
44  /**
45   * <a href="AnnouncementsDeliveryModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This interface is a model that represents the AnnouncementsDelivery table in the
54   * database.
55   * </p>
56   *
57   * @author    Brian Wing Shun Chan
58   * @see       AnnouncementsDeliveryImpl
59   * @see       com.liferay.portlet.announcements.model.AnnouncementsDelivery
60   * @see       com.liferay.portlet.announcements.model.AnnouncementsDeliveryModel
61   * @generated
62   */
63  public class AnnouncementsDeliveryModelImpl extends BaseModelImpl<AnnouncementsDelivery> {
64      public static final String TABLE_NAME = "AnnouncementsDelivery";
65      public static final Object[][] TABLE_COLUMNS = {
66              { "deliveryId", new Integer(Types.BIGINT) },
67              { "companyId", new Integer(Types.BIGINT) },
68              { "userId", new Integer(Types.BIGINT) },
69              { "type_", new Integer(Types.VARCHAR) },
70              { "email", new Integer(Types.BOOLEAN) },
71              { "sms", new Integer(Types.BOOLEAN) },
72              { "website", new Integer(Types.BOOLEAN) }
73          };
74      public static final String TABLE_SQL_CREATE = "create table AnnouncementsDelivery (deliveryId LONG not null primary key,companyId LONG,userId LONG,type_ VARCHAR(75) null,email BOOLEAN,sms BOOLEAN,website BOOLEAN)";
75      public static final String TABLE_SQL_DROP = "drop table AnnouncementsDelivery";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.entity.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
81              true);
82      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83                  "value.object.finder.cache.enabled.com.liferay.portlet.announcements.model.AnnouncementsDelivery"),
84              true);
85  
86      public static AnnouncementsDelivery toModel(
87          AnnouncementsDeliverySoap soapModel) {
88          AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
89  
90          model.setDeliveryId(soapModel.getDeliveryId());
91          model.setCompanyId(soapModel.getCompanyId());
92          model.setUserId(soapModel.getUserId());
93          model.setType(soapModel.getType());
94          model.setEmail(soapModel.getEmail());
95          model.setSms(soapModel.getSms());
96          model.setWebsite(soapModel.getWebsite());
97  
98          return model;
99      }
100 
101     public static List<AnnouncementsDelivery> toModels(
102         AnnouncementsDeliverySoap[] soapModels) {
103         List<AnnouncementsDelivery> models = new ArrayList<AnnouncementsDelivery>(soapModels.length);
104 
105         for (AnnouncementsDeliverySoap soapModel : soapModels) {
106             models.add(toModel(soapModel));
107         }
108 
109         return models;
110     }
111 
112     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
113                 "lock.expiration.time.com.liferay.portlet.announcements.model.AnnouncementsDelivery"));
114 
115     public AnnouncementsDeliveryModelImpl() {
116     }
117 
118     public long getPrimaryKey() {
119         return _deliveryId;
120     }
121 
122     public void setPrimaryKey(long pk) {
123         setDeliveryId(pk);
124     }
125 
126     public Serializable getPrimaryKeyObj() {
127         return new Long(_deliveryId);
128     }
129 
130     public long getDeliveryId() {
131         return _deliveryId;
132     }
133 
134     public void setDeliveryId(long deliveryId) {
135         _deliveryId = deliveryId;
136     }
137 
138     public long getCompanyId() {
139         return _companyId;
140     }
141 
142     public void setCompanyId(long companyId) {
143         _companyId = companyId;
144     }
145 
146     public long getUserId() {
147         return _userId;
148     }
149 
150     public void setUserId(long userId) {
151         _userId = userId;
152 
153         if (!_setOriginalUserId) {
154             _setOriginalUserId = true;
155 
156             _originalUserId = userId;
157         }
158     }
159 
160     public String getUserUuid() throws SystemException {
161         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
162     }
163 
164     public void setUserUuid(String userUuid) {
165         _userUuid = userUuid;
166     }
167 
168     public long getOriginalUserId() {
169         return _originalUserId;
170     }
171 
172     public String getType() {
173         return GetterUtil.getString(_type);
174     }
175 
176     public void setType(String type) {
177         _type = type;
178 
179         if (_originalType == null) {
180             _originalType = type;
181         }
182     }
183 
184     public String getOriginalType() {
185         return GetterUtil.getString(_originalType);
186     }
187 
188     public boolean getEmail() {
189         return _email;
190     }
191 
192     public boolean isEmail() {
193         return _email;
194     }
195 
196     public void setEmail(boolean email) {
197         _email = email;
198     }
199 
200     public boolean getSms() {
201         return _sms;
202     }
203 
204     public boolean isSms() {
205         return _sms;
206     }
207 
208     public void setSms(boolean sms) {
209         _sms = sms;
210     }
211 
212     public boolean getWebsite() {
213         return _website;
214     }
215 
216     public boolean isWebsite() {
217         return _website;
218     }
219 
220     public void setWebsite(boolean website) {
221         _website = website;
222     }
223 
224     public AnnouncementsDelivery toEscapedModel() {
225         if (isEscapedModel()) {
226             return (AnnouncementsDelivery)this;
227         }
228         else {
229             AnnouncementsDelivery model = new AnnouncementsDeliveryImpl();
230 
231             model.setNew(isNew());
232             model.setEscapedModel(true);
233 
234             model.setDeliveryId(getDeliveryId());
235             model.setCompanyId(getCompanyId());
236             model.setUserId(getUserId());
237             model.setType(HtmlUtil.escape(getType()));
238             model.setEmail(getEmail());
239             model.setSms(getSms());
240             model.setWebsite(getWebsite());
241 
242             model = (AnnouncementsDelivery)Proxy.newProxyInstance(AnnouncementsDelivery.class.getClassLoader(),
243                     new Class[] { AnnouncementsDelivery.class },
244                     new ReadOnlyBeanHandler(model));
245 
246             return model;
247         }
248     }
249 
250     public Object clone() {
251         AnnouncementsDeliveryImpl clone = new AnnouncementsDeliveryImpl();
252 
253         clone.setDeliveryId(getDeliveryId());
254         clone.setCompanyId(getCompanyId());
255         clone.setUserId(getUserId());
256         clone.setType(getType());
257         clone.setEmail(getEmail());
258         clone.setSms(getSms());
259         clone.setWebsite(getWebsite());
260 
261         return clone;
262     }
263 
264     public int compareTo(AnnouncementsDelivery announcementsDelivery) {
265         long pk = announcementsDelivery.getPrimaryKey();
266 
267         if (getPrimaryKey() < pk) {
268             return -1;
269         }
270         else if (getPrimaryKey() > pk) {
271             return 1;
272         }
273         else {
274             return 0;
275         }
276     }
277 
278     public boolean equals(Object obj) {
279         if (obj == null) {
280             return false;
281         }
282 
283         AnnouncementsDelivery announcementsDelivery = null;
284 
285         try {
286             announcementsDelivery = (AnnouncementsDelivery)obj;
287         }
288         catch (ClassCastException cce) {
289             return false;
290         }
291 
292         long pk = announcementsDelivery.getPrimaryKey();
293 
294         if (getPrimaryKey() == pk) {
295             return true;
296         }
297         else {
298             return false;
299         }
300     }
301 
302     public int hashCode() {
303         return (int)getPrimaryKey();
304     }
305 
306     public String toString() {
307         StringBuilder sb = new StringBuilder();
308 
309         sb.append("{deliveryId=");
310         sb.append(getDeliveryId());
311         sb.append(", companyId=");
312         sb.append(getCompanyId());
313         sb.append(", userId=");
314         sb.append(getUserId());
315         sb.append(", type=");
316         sb.append(getType());
317         sb.append(", email=");
318         sb.append(getEmail());
319         sb.append(", sms=");
320         sb.append(getSms());
321         sb.append(", website=");
322         sb.append(getWebsite());
323         sb.append("}");
324 
325         return sb.toString();
326     }
327 
328     public String toXmlString() {
329         StringBuilder sb = new StringBuilder();
330 
331         sb.append("<model><model-name>");
332         sb.append(
333             "com.liferay.portlet.announcements.model.AnnouncementsDelivery");
334         sb.append("</model-name>");
335 
336         sb.append(
337             "<column><column-name>deliveryId</column-name><column-value><![CDATA[");
338         sb.append(getDeliveryId());
339         sb.append("]]></column-value></column>");
340         sb.append(
341             "<column><column-name>companyId</column-name><column-value><![CDATA[");
342         sb.append(getCompanyId());
343         sb.append("]]></column-value></column>");
344         sb.append(
345             "<column><column-name>userId</column-name><column-value><![CDATA[");
346         sb.append(getUserId());
347         sb.append("]]></column-value></column>");
348         sb.append(
349             "<column><column-name>type</column-name><column-value><![CDATA[");
350         sb.append(getType());
351         sb.append("]]></column-value></column>");
352         sb.append(
353             "<column><column-name>email</column-name><column-value><![CDATA[");
354         sb.append(getEmail());
355         sb.append("]]></column-value></column>");
356         sb.append(
357             "<column><column-name>sms</column-name><column-value><![CDATA[");
358         sb.append(getSms());
359         sb.append("]]></column-value></column>");
360         sb.append(
361             "<column><column-name>website</column-name><column-value><![CDATA[");
362         sb.append(getWebsite());
363         sb.append("]]></column-value></column>");
364 
365         sb.append("</model>");
366 
367         return sb.toString();
368     }
369 
370     private long _deliveryId;
371     private long _companyId;
372     private long _userId;
373     private String _userUuid;
374     private long _originalUserId;
375     private boolean _setOriginalUserId;
376     private String _type;
377     private String _originalType;
378     private boolean _email;
379     private boolean _sms;
380     private boolean _website;
381 }