001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.exception.SystemException;
019    import com.liferay.portal.kernel.util.DateUtil;
020    import com.liferay.portal.kernel.util.GetterUtil;
021    import com.liferay.portal.kernel.util.StringBundler;
022    import com.liferay.portal.kernel.util.StringPool;
023    import com.liferay.portal.model.Phone;
024    import com.liferay.portal.model.PhoneModel;
025    import com.liferay.portal.model.PhoneSoap;
026    import com.liferay.portal.service.ServiceContext;
027    import com.liferay.portal.util.PortalUtil;
028    
029    import com.liferay.portlet.expando.model.ExpandoBridge;
030    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
031    
032    import java.io.Serializable;
033    
034    import java.lang.reflect.Proxy;
035    
036    import java.sql.Types;
037    
038    import java.util.ArrayList;
039    import java.util.Date;
040    import java.util.List;
041    
042    /**
043     * The base model implementation for the Phone service. Represents a row in the "Phone" database table, with each column mapped to a property of this class.
044     *
045     * <p>
046     * This implementation and its corresponding interface {@link com.liferay.portal.model.PhoneModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PhoneImpl}.
047     * </p>
048     *
049     * <p>
050     * Never modify or reference this class directly. All methods that expect a phone model instance should use the {@link com.liferay.portal.model.Phone} interface instead.
051     * </p>
052     *
053     * @author Brian Wing Shun Chan
054     * @see PhoneImpl
055     * @see com.liferay.portal.model.Phone
056     * @see com.liferay.portal.model.PhoneModel
057     * @generated
058     */
059    public class PhoneModelImpl extends BaseModelImpl<Phone> implements PhoneModel {
060            public static final String TABLE_NAME = "Phone";
061            public static final Object[][] TABLE_COLUMNS = {
062                            { "phoneId", new Integer(Types.BIGINT) },
063                            { "companyId", new Integer(Types.BIGINT) },
064                            { "userId", new Integer(Types.BIGINT) },
065                            { "userName", new Integer(Types.VARCHAR) },
066                            { "createDate", new Integer(Types.TIMESTAMP) },
067                            { "modifiedDate", new Integer(Types.TIMESTAMP) },
068                            { "classNameId", new Integer(Types.BIGINT) },
069                            { "classPK", new Integer(Types.BIGINT) },
070                            { "number_", new Integer(Types.VARCHAR) },
071                            { "extension", new Integer(Types.VARCHAR) },
072                            { "typeId", new Integer(Types.INTEGER) },
073                            { "primary_", new Integer(Types.BOOLEAN) }
074                    };
075            public static final String TABLE_SQL_CREATE = "create table Phone (phoneId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,classNameId LONG,classPK LONG,number_ VARCHAR(75) null,extension VARCHAR(75) null,typeId INTEGER,primary_ BOOLEAN)";
076            public static final String TABLE_SQL_DROP = "drop table Phone";
077            public static final String ORDER_BY_JPQL = " ORDER BY phone.createDate ASC";
078            public static final String ORDER_BY_SQL = " ORDER BY Phone.createDate ASC";
079            public static final String DATA_SOURCE = "liferayDataSource";
080            public static final String SESSION_FACTORY = "liferaySessionFactory";
081            public static final String TX_MANAGER = "liferayTransactionManager";
082            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
083                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Phone"),
084                            true);
085            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
086                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Phone"),
087                            true);
088    
089            /**
090             * Converts the soap model instance into a normal model instance.
091             *
092             * @param soapModel the soap model instance to convert
093             * @return the normal model instance
094             */
095            public static Phone toModel(PhoneSoap soapModel) {
096                    Phone model = new PhoneImpl();
097    
098                    model.setPhoneId(soapModel.getPhoneId());
099                    model.setCompanyId(soapModel.getCompanyId());
100                    model.setUserId(soapModel.getUserId());
101                    model.setUserName(soapModel.getUserName());
102                    model.setCreateDate(soapModel.getCreateDate());
103                    model.setModifiedDate(soapModel.getModifiedDate());
104                    model.setClassNameId(soapModel.getClassNameId());
105                    model.setClassPK(soapModel.getClassPK());
106                    model.setNumber(soapModel.getNumber());
107                    model.setExtension(soapModel.getExtension());
108                    model.setTypeId(soapModel.getTypeId());
109                    model.setPrimary(soapModel.getPrimary());
110    
111                    return model;
112            }
113    
114            /**
115             * Converts the soap model instances into normal model instances.
116             *
117             * @param soapModels the soap model instances to convert
118             * @return the normal model instances
119             */
120            public static List<Phone> toModels(PhoneSoap[] soapModels) {
121                    List<Phone> models = new ArrayList<Phone>(soapModels.length);
122    
123                    for (PhoneSoap soapModel : soapModels) {
124                            models.add(toModel(soapModel));
125                    }
126    
127                    return models;
128            }
129    
130            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
131                                    "lock.expiration.time.com.liferay.portal.model.Phone"));
132    
133            public PhoneModelImpl() {
134            }
135    
136            public long getPrimaryKey() {
137                    return _phoneId;
138            }
139    
140            public void setPrimaryKey(long pk) {
141                    setPhoneId(pk);
142            }
143    
144            public Serializable getPrimaryKeyObj() {
145                    return new Long(_phoneId);
146            }
147    
148            public long getPhoneId() {
149                    return _phoneId;
150            }
151    
152            public void setPhoneId(long phoneId) {
153                    _phoneId = phoneId;
154            }
155    
156            public long getCompanyId() {
157                    return _companyId;
158            }
159    
160            public void setCompanyId(long companyId) {
161                    _companyId = companyId;
162            }
163    
164            public long getUserId() {
165                    return _userId;
166            }
167    
168            public void setUserId(long userId) {
169                    _userId = userId;
170            }
171    
172            public String getUserUuid() throws SystemException {
173                    return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid);
174            }
175    
176            public void setUserUuid(String userUuid) {
177                    _userUuid = userUuid;
178            }
179    
180            public String getUserName() {
181                    if (_userName == null) {
182                            return StringPool.BLANK;
183                    }
184                    else {
185                            return _userName;
186                    }
187            }
188    
189            public void setUserName(String userName) {
190                    _userName = userName;
191            }
192    
193            public Date getCreateDate() {
194                    return _createDate;
195            }
196    
197            public void setCreateDate(Date createDate) {
198                    _createDate = createDate;
199            }
200    
201            public Date getModifiedDate() {
202                    return _modifiedDate;
203            }
204    
205            public void setModifiedDate(Date modifiedDate) {
206                    _modifiedDate = modifiedDate;
207            }
208    
209            public String getClassName() {
210                    if (getClassNameId() <= 0) {
211                            return StringPool.BLANK;
212                    }
213    
214                    return PortalUtil.getClassName(getClassNameId());
215            }
216    
217            public long getClassNameId() {
218                    return _classNameId;
219            }
220    
221            public void setClassNameId(long classNameId) {
222                    _classNameId = classNameId;
223            }
224    
225            public long getClassPK() {
226                    return _classPK;
227            }
228    
229            public void setClassPK(long classPK) {
230                    _classPK = classPK;
231            }
232    
233            public String getNumber() {
234                    if (_number == null) {
235                            return StringPool.BLANK;
236                    }
237                    else {
238                            return _number;
239                    }
240            }
241    
242            public void setNumber(String number) {
243                    _number = number;
244            }
245    
246            public String getExtension() {
247                    if (_extension == null) {
248                            return StringPool.BLANK;
249                    }
250                    else {
251                            return _extension;
252                    }
253            }
254    
255            public void setExtension(String extension) {
256                    _extension = extension;
257            }
258    
259            public int getTypeId() {
260                    return _typeId;
261            }
262    
263            public void setTypeId(int typeId) {
264                    _typeId = typeId;
265            }
266    
267            public boolean getPrimary() {
268                    return _primary;
269            }
270    
271            public boolean isPrimary() {
272                    return _primary;
273            }
274    
275            public void setPrimary(boolean primary) {
276                    _primary = primary;
277            }
278    
279            public Phone toEscapedModel() {
280                    if (isEscapedModel()) {
281                            return (Phone)this;
282                    }
283                    else {
284                            return (Phone)Proxy.newProxyInstance(Phone.class.getClassLoader(),
285                                    new Class[] { Phone.class }, new AutoEscapeBeanHandler(this));
286                    }
287            }
288    
289            public ExpandoBridge getExpandoBridge() {
290                    if (_expandoBridge == null) {
291                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
292                                            Phone.class.getName(), getPrimaryKey());
293                    }
294    
295                    return _expandoBridge;
296            }
297    
298            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
299                    getExpandoBridge().setAttributes(serviceContext);
300            }
301    
302            public Object clone() {
303                    PhoneImpl clone = new PhoneImpl();
304    
305                    clone.setPhoneId(getPhoneId());
306                    clone.setCompanyId(getCompanyId());
307                    clone.setUserId(getUserId());
308                    clone.setUserName(getUserName());
309                    clone.setCreateDate(getCreateDate());
310                    clone.setModifiedDate(getModifiedDate());
311                    clone.setClassNameId(getClassNameId());
312                    clone.setClassPK(getClassPK());
313                    clone.setNumber(getNumber());
314                    clone.setExtension(getExtension());
315                    clone.setTypeId(getTypeId());
316                    clone.setPrimary(getPrimary());
317    
318                    return clone;
319            }
320    
321            public int compareTo(Phone phone) {
322                    int value = 0;
323    
324                    value = DateUtil.compareTo(getCreateDate(), phone.getCreateDate());
325    
326                    if (value != 0) {
327                            return value;
328                    }
329    
330                    return 0;
331            }
332    
333            public boolean equals(Object obj) {
334                    if (obj == null) {
335                            return false;
336                    }
337    
338                    Phone phone = null;
339    
340                    try {
341                            phone = (Phone)obj;
342                    }
343                    catch (ClassCastException cce) {
344                            return false;
345                    }
346    
347                    long pk = phone.getPrimaryKey();
348    
349                    if (getPrimaryKey() == pk) {
350                            return true;
351                    }
352                    else {
353                            return false;
354                    }
355            }
356    
357            public int hashCode() {
358                    return (int)getPrimaryKey();
359            }
360    
361            public String toString() {
362                    StringBundler sb = new StringBundler(25);
363    
364                    sb.append("{phoneId=");
365                    sb.append(getPhoneId());
366                    sb.append(", companyId=");
367                    sb.append(getCompanyId());
368                    sb.append(", userId=");
369                    sb.append(getUserId());
370                    sb.append(", userName=");
371                    sb.append(getUserName());
372                    sb.append(", createDate=");
373                    sb.append(getCreateDate());
374                    sb.append(", modifiedDate=");
375                    sb.append(getModifiedDate());
376                    sb.append(", classNameId=");
377                    sb.append(getClassNameId());
378                    sb.append(", classPK=");
379                    sb.append(getClassPK());
380                    sb.append(", number=");
381                    sb.append(getNumber());
382                    sb.append(", extension=");
383                    sb.append(getExtension());
384                    sb.append(", typeId=");
385                    sb.append(getTypeId());
386                    sb.append(", primary=");
387                    sb.append(getPrimary());
388                    sb.append("}");
389    
390                    return sb.toString();
391            }
392    
393            public String toXmlString() {
394                    StringBundler sb = new StringBundler(40);
395    
396                    sb.append("<model><model-name>");
397                    sb.append("com.liferay.portal.model.Phone");
398                    sb.append("</model-name>");
399    
400                    sb.append(
401                            "<column><column-name>phoneId</column-name><column-value><![CDATA[");
402                    sb.append(getPhoneId());
403                    sb.append("]]></column-value></column>");
404                    sb.append(
405                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
406                    sb.append(getCompanyId());
407                    sb.append("]]></column-value></column>");
408                    sb.append(
409                            "<column><column-name>userId</column-name><column-value><![CDATA[");
410                    sb.append(getUserId());
411                    sb.append("]]></column-value></column>");
412                    sb.append(
413                            "<column><column-name>userName</column-name><column-value><![CDATA[");
414                    sb.append(getUserName());
415                    sb.append("]]></column-value></column>");
416                    sb.append(
417                            "<column><column-name>createDate</column-name><column-value><![CDATA[");
418                    sb.append(getCreateDate());
419                    sb.append("]]></column-value></column>");
420                    sb.append(
421                            "<column><column-name>modifiedDate</column-name><column-value><![CDATA[");
422                    sb.append(getModifiedDate());
423                    sb.append("]]></column-value></column>");
424                    sb.append(
425                            "<column><column-name>classNameId</column-name><column-value><![CDATA[");
426                    sb.append(getClassNameId());
427                    sb.append("]]></column-value></column>");
428                    sb.append(
429                            "<column><column-name>classPK</column-name><column-value><![CDATA[");
430                    sb.append(getClassPK());
431                    sb.append("]]></column-value></column>");
432                    sb.append(
433                            "<column><column-name>number</column-name><column-value><![CDATA[");
434                    sb.append(getNumber());
435                    sb.append("]]></column-value></column>");
436                    sb.append(
437                            "<column><column-name>extension</column-name><column-value><![CDATA[");
438                    sb.append(getExtension());
439                    sb.append("]]></column-value></column>");
440                    sb.append(
441                            "<column><column-name>typeId</column-name><column-value><![CDATA[");
442                    sb.append(getTypeId());
443                    sb.append("]]></column-value></column>");
444                    sb.append(
445                            "<column><column-name>primary</column-name><column-value><![CDATA[");
446                    sb.append(getPrimary());
447                    sb.append("]]></column-value></column>");
448    
449                    sb.append("</model>");
450    
451                    return sb.toString();
452            }
453    
454            private long _phoneId;
455            private long _companyId;
456            private long _userId;
457            private String _userUuid;
458            private String _userName;
459            private Date _createDate;
460            private Date _modifiedDate;
461            private long _classNameId;
462            private long _classPK;
463            private String _number;
464            private String _extension;
465            private int _typeId;
466            private boolean _primary;
467            private transient ExpandoBridge _expandoBridge;
468    }