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