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.portal.model.impl;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
27  import com.liferay.portal.kernel.util.DateUtil;
28  import com.liferay.portal.kernel.util.GetterUtil;
29  import com.liferay.portal.kernel.util.HtmlUtil;
30  import com.liferay.portal.kernel.util.StringPool;
31  import com.liferay.portal.model.EmailAddress;
32  import com.liferay.portal.model.EmailAddressSoap;
33  import com.liferay.portal.util.PortalUtil;
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.Date;
43  import java.util.List;
44  
45  /**
46   * <a href="EmailAddressModelImpl.java.html"><b><i>View Source</i></b></a>
47   *
48   * <p>
49   * ServiceBuilder generated this class. Modifications in this class will be
50   * overwritten the next time is generated.
51   * </p>
52   *
53   * <p>
54   * This interface is a model that represents the EmailAddress table in the
55   * database.
56   * </p>
57   *
58   * @author    Brian Wing Shun Chan
59   * @see       EmailAddressImpl
60   * @see       com.liferay.portal.model.EmailAddress
61   * @see       com.liferay.portal.model.EmailAddressModel
62   * @generated
63   */
64  public class EmailAddressModelImpl extends BaseModelImpl<EmailAddress> {
65      public static final String TABLE_NAME = "EmailAddress";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "emailAddressId", new Integer(Types.BIGINT) },
68              { "companyId", new Integer(Types.BIGINT) },
69              { "userId", new Integer(Types.BIGINT) },
70              { "userName", new Integer(Types.VARCHAR) },
71              { "createDate", new Integer(Types.TIMESTAMP) },
72              { "modifiedDate", new Integer(Types.TIMESTAMP) },
73              { "classNameId", new Integer(Types.BIGINT) },
74              { "classPK", new Integer(Types.BIGINT) },
75              { "address", new Integer(Types.VARCHAR) },
76              { "typeId", new Integer(Types.INTEGER) },
77              { "primary_", new Integer(Types.BOOLEAN) }
78          };
79      public static final String TABLE_SQL_CREATE = "create table EmailAddress (emailAddressId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,address VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
80      public static final String TABLE_SQL_DROP = "drop table EmailAddress";
81      public static final String DATA_SOURCE = "liferayDataSource";
82      public static final String SESSION_FACTORY = "liferaySessionFactory";
83      public static final String TX_MANAGER = "liferayTransactionManager";
84      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
85                  "value.object.entity.cache.enabled.com.liferay.portal.model.EmailAddress"),
86              true);
87      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
88                  "value.object.finder.cache.enabled.com.liferay.portal.model.EmailAddress"),
89              true);
90  
91      public static EmailAddress toModel(EmailAddressSoap soapModel) {
92          EmailAddress model = new EmailAddressImpl();
93  
94          model.setEmailAddressId(soapModel.getEmailAddressId());
95          model.setCompanyId(soapModel.getCompanyId());
96          model.setUserId(soapModel.getUserId());
97          model.setUserName(soapModel.getUserName());
98          model.setCreateDate(soapModel.getCreateDate());
99          model.setModifiedDate(soapModel.getModifiedDate());
100         model.setClassNameId(soapModel.getClassNameId());
101         model.setClassPK(soapModel.getClassPK());
102         model.setAddress(soapModel.getAddress());
103         model.setTypeId(soapModel.getTypeId());
104         model.setPrimary(soapModel.getPrimary());
105 
106         return model;
107     }
108 
109     public static List<EmailAddress> toModels(EmailAddressSoap[] soapModels) {
110         List<EmailAddress> models = new ArrayList<EmailAddress>(soapModels.length);
111 
112         for (EmailAddressSoap soapModel : soapModels) {
113             models.add(toModel(soapModel));
114         }
115 
116         return models;
117     }
118 
119     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
120                 "lock.expiration.time.com.liferay.portal.model.EmailAddress"));
121 
122     public EmailAddressModelImpl() {
123     }
124 
125     public long getPrimaryKey() {
126         return _emailAddressId;
127     }
128 
129     public void setPrimaryKey(long pk) {
130         setEmailAddressId(pk);
131     }
132 
133     public Serializable getPrimaryKeyObj() {
134         return new Long(_emailAddressId);
135     }
136 
137     public long getEmailAddressId() {
138         return _emailAddressId;
139     }
140 
141     public void setEmailAddressId(long emailAddressId) {
142         _emailAddressId = emailAddressId;
143     }
144 
145     public long getCompanyId() {
146         return _companyId;
147     }
148 
149     public void setCompanyId(long companyId) {
150         _companyId = companyId;
151     }
152 
153     public long getUserId() {
154         return _userId;
155     }
156 
157     public void setUserId(long userId) {
158         _userId = userId;
159     }
160 
161     public String getUserUuid() throws SystemException {
162         return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
163     }
164 
165     public void setUserUuid(String userUuid) {
166         _userUuid = userUuid;
167     }
168 
169     public String getUserName() {
170         return GetterUtil.getString(_userName);
171     }
172 
173     public void setUserName(String userName) {
174         _userName = userName;
175     }
176 
177     public Date getCreateDate() {
178         return _createDate;
179     }
180 
181     public void setCreateDate(Date createDate) {
182         _createDate = createDate;
183     }
184 
185     public Date getModifiedDate() {
186         return _modifiedDate;
187     }
188 
189     public void setModifiedDate(Date modifiedDate) {
190         _modifiedDate = modifiedDate;
191     }
192 
193     public String getClassName() {
194         if (getClassNameId() <= 0) {
195             return StringPool.BLANK;
196         }
197 
198         return PortalUtil.getClassName(getClassNameId());
199     }
200 
201     public long getClassNameId() {
202         return _classNameId;
203     }
204 
205     public void setClassNameId(long classNameId) {
206         _classNameId = classNameId;
207     }
208 
209     public long getClassPK() {
210         return _classPK;
211     }
212 
213     public void setClassPK(long classPK) {
214         _classPK = classPK;
215     }
216 
217     public String getAddress() {
218         return GetterUtil.getString(_address);
219     }
220 
221     public void setAddress(String address) {
222         _address = address;
223     }
224 
225     public int getTypeId() {
226         return _typeId;
227     }
228 
229     public void setTypeId(int typeId) {
230         _typeId = typeId;
231     }
232 
233     public boolean getPrimary() {
234         return _primary;
235     }
236 
237     public boolean isPrimary() {
238         return _primary;
239     }
240 
241     public void setPrimary(boolean primary) {
242         _primary = primary;
243     }
244 
245     public EmailAddress toEscapedModel() {
246         if (isEscapedModel()) {
247             return (EmailAddress)this;
248         }
249         else {
250             EmailAddress model = new EmailAddressImpl();
251 
252             model.setNew(isNew());
253             model.setEscapedModel(true);
254 
255             model.setEmailAddressId(getEmailAddressId());
256             model.setCompanyId(getCompanyId());
257             model.setUserId(getUserId());
258             model.setUserName(HtmlUtil.escape(getUserName()));
259             model.setCreateDate(getCreateDate());
260             model.setModifiedDate(getModifiedDate());
261             model.setClassNameId(getClassNameId());
262             model.setClassPK(getClassPK());
263             model.setAddress(HtmlUtil.escape(getAddress()));
264             model.setTypeId(getTypeId());
265             model.setPrimary(getPrimary());
266 
267             model = (EmailAddress)Proxy.newProxyInstance(EmailAddress.class.getClassLoader(),
268                     new Class[] { EmailAddress.class },
269                     new ReadOnlyBeanHandler(model));
270 
271             return model;
272         }
273     }
274 
275     public Object clone() {
276         EmailAddressImpl clone = new EmailAddressImpl();
277 
278         clone.setEmailAddressId(getEmailAddressId());
279         clone.setCompanyId(getCompanyId());
280         clone.setUserId(getUserId());
281         clone.setUserName(getUserName());
282         clone.setCreateDate(getCreateDate());
283         clone.setModifiedDate(getModifiedDate());
284         clone.setClassNameId(getClassNameId());
285         clone.setClassPK(getClassPK());
286         clone.setAddress(getAddress());
287         clone.setTypeId(getTypeId());
288         clone.setPrimary(getPrimary());
289 
290         return clone;
291     }
292 
293     public int compareTo(EmailAddress emailAddress) {
294         int value = 0;
295 
296         value = DateUtil.compareTo(getCreateDate(), emailAddress.getCreateDate());
297 
298         if (value != 0) {
299             return value;
300         }
301 
302         return 0;
303     }
304 
305     public boolean equals(Object obj) {
306         if (obj == null) {
307             return false;
308         }
309 
310         EmailAddress emailAddress = null;
311 
312         try {
313             emailAddress = (EmailAddress)obj;
314         }
315         catch (ClassCastException cce) {
316             return false;
317         }
318 
319         long pk = emailAddress.getPrimaryKey();
320 
321         if (getPrimaryKey() == pk) {
322             return true;
323         }
324         else {
325             return false;
326         }
327     }
328 
329     public int hashCode() {
330         return (int)getPrimaryKey();
331     }
332 
333     public String toString() {
334         StringBuilder sb = new StringBuilder();
335 
336         sb.append("{emailAddressId=");
337         sb.append(getEmailAddressId());
338         sb.append(", companyId=");
339         sb.append(getCompanyId());
340         sb.append(", userId=");
341         sb.append(getUserId());
342         sb.append(", userName=");
343         sb.append(getUserName());
344         sb.append(", createDate=");
345         sb.append(getCreateDate());
346         sb.append(", modifiedDate=");
347         sb.append(getModifiedDate());
348         sb.append(", classNameId=");
349         sb.append(getClassNameId());
350         sb.append(", classPK=");
351         sb.append(getClassPK());
352         sb.append(", address=");
353         sb.append(getAddress());
354         sb.append(", typeId=");
355         sb.append(getTypeId());
356         sb.append(", primary=");
357         sb.append(getPrimary());
358         sb.append("}");
359 
360         return sb.toString();
361     }
362 
363     public String toXmlString() {
364         StringBuilder sb = new StringBuilder();
365 
366         sb.append("<model><model-name>");
367         sb.append("com.liferay.portal.model.EmailAddress");
368         sb.append("</model-name>");
369 
370         sb.append(
371             "<column><column-name>emailAddressId</column-name><column-value><![CDATA[");
372         sb.append(getEmailAddressId());
373         sb.append("]]></column-value></column>");
374         sb.append(
375             "<column><column-name>companyId</column-name><column-value><![CDATA[");
376         sb.append(getCompanyId());
377         sb.append("]]></column-value></column>");
378         sb.append(
379             "<column><column-name>userId</column-name><column-value><![CDATA[");
380         sb.append(getUserId());
381         sb.append("]]></column-value></column>");
382         sb.append(
383             "<column><column-name>userName</column-name><column-value><![CDATA[");
384         sb.append(getUserName());
385         sb.append("]]></column-value></column>");
386         sb.append(
387             "<column><column-name>createDate</column-name><column-value><![CDATA[");
388         sb.append(getCreateDate());
389         sb.append("]]></column-value></column>");
390         sb.append(
391             "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
392         sb.append(getModifiedDate());
393         sb.append("]]></column-value></column>");
394         sb.append(
395             "<column><column-name>classNameId</column-name><column-value><![CDATA[");
396         sb.append(getClassNameId());
397         sb.append("]]></column-value></column>");
398         sb.append(
399             "<column><column-name>classPK</column-name><column-value><![CDATA[");
400         sb.append(getClassPK());
401         sb.append("]]></column-value></column>");
402         sb.append(
403             "<column><column-name>address</column-name><column-value><![CDATA[");
404         sb.append(getAddress());
405         sb.append("]]></column-value></column>");
406         sb.append(
407             "<column><column-name>typeId</column-name><column-value><![CDATA[");
408         sb.append(getTypeId());
409         sb.append("]]></column-value></column>");
410         sb.append(
411             "<column><column-name>primary</column-name><column-value><![CDATA[");
412         sb.append(getPrimary());
413         sb.append("]]></column-value></column>");
414 
415         sb.append("</model>");
416 
417         return sb.toString();
418     }
419 
420     private long _emailAddressId;
421     private long _companyId;
422     private long _userId;
423     private String _userUuid;
424     private String _userName;
425     private Date _createDate;
426     private Date _modifiedDate;
427     private long _classNameId;
428     private long _classPK;
429     private String _address;
430     private int _typeId;
431     private boolean _primary;
432 }