001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.dynamicdatalists.model.impl;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.StringPool;
019    import com.liferay.portal.model.CacheModel;
020    
021    import com.liferay.portlet.dynamicdatalists.model.DDLRecord;
022    
023    import java.io.Externalizable;
024    import java.io.IOException;
025    import java.io.ObjectInput;
026    import java.io.ObjectOutput;
027    
028    import java.util.Date;
029    
030    /**
031     * The cache model class for representing DDLRecord in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see DDLRecord
035     * @generated
036     */
037    public class DDLRecordCacheModel implements CacheModel<DDLRecord>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(29);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", recordId=");
046                    sb.append(recordId);
047                    sb.append(", groupId=");
048                    sb.append(groupId);
049                    sb.append(", companyId=");
050                    sb.append(companyId);
051                    sb.append(", userId=");
052                    sb.append(userId);
053                    sb.append(", userName=");
054                    sb.append(userName);
055                    sb.append(", versionUserId=");
056                    sb.append(versionUserId);
057                    sb.append(", versionUserName=");
058                    sb.append(versionUserName);
059                    sb.append(", createDate=");
060                    sb.append(createDate);
061                    sb.append(", modifiedDate=");
062                    sb.append(modifiedDate);
063                    sb.append(", DDMStorageId=");
064                    sb.append(DDMStorageId);
065                    sb.append(", recordSetId=");
066                    sb.append(recordSetId);
067                    sb.append(", version=");
068                    sb.append(version);
069                    sb.append(", displayIndex=");
070                    sb.append(displayIndex);
071                    sb.append("}");
072    
073                    return sb.toString();
074            }
075    
076            @Override
077            public DDLRecord toEntityModel() {
078                    DDLRecordImpl ddlRecordImpl = new DDLRecordImpl();
079    
080                    if (uuid == null) {
081                            ddlRecordImpl.setUuid(StringPool.BLANK);
082                    }
083                    else {
084                            ddlRecordImpl.setUuid(uuid);
085                    }
086    
087                    ddlRecordImpl.setRecordId(recordId);
088                    ddlRecordImpl.setGroupId(groupId);
089                    ddlRecordImpl.setCompanyId(companyId);
090                    ddlRecordImpl.setUserId(userId);
091    
092                    if (userName == null) {
093                            ddlRecordImpl.setUserName(StringPool.BLANK);
094                    }
095                    else {
096                            ddlRecordImpl.setUserName(userName);
097                    }
098    
099                    ddlRecordImpl.setVersionUserId(versionUserId);
100    
101                    if (versionUserName == null) {
102                            ddlRecordImpl.setVersionUserName(StringPool.BLANK);
103                    }
104                    else {
105                            ddlRecordImpl.setVersionUserName(versionUserName);
106                    }
107    
108                    if (createDate == Long.MIN_VALUE) {
109                            ddlRecordImpl.setCreateDate(null);
110                    }
111                    else {
112                            ddlRecordImpl.setCreateDate(new Date(createDate));
113                    }
114    
115                    if (modifiedDate == Long.MIN_VALUE) {
116                            ddlRecordImpl.setModifiedDate(null);
117                    }
118                    else {
119                            ddlRecordImpl.setModifiedDate(new Date(modifiedDate));
120                    }
121    
122                    ddlRecordImpl.setDDMStorageId(DDMStorageId);
123                    ddlRecordImpl.setRecordSetId(recordSetId);
124    
125                    if (version == null) {
126                            ddlRecordImpl.setVersion(StringPool.BLANK);
127                    }
128                    else {
129                            ddlRecordImpl.setVersion(version);
130                    }
131    
132                    ddlRecordImpl.setDisplayIndex(displayIndex);
133    
134                    ddlRecordImpl.resetOriginalValues();
135    
136                    return ddlRecordImpl;
137            }
138    
139            @Override
140            public void readExternal(ObjectInput objectInput) throws IOException {
141                    uuid = objectInput.readUTF();
142                    recordId = objectInput.readLong();
143                    groupId = objectInput.readLong();
144                    companyId = objectInput.readLong();
145                    userId = objectInput.readLong();
146                    userName = objectInput.readUTF();
147                    versionUserId = objectInput.readLong();
148                    versionUserName = objectInput.readUTF();
149                    createDate = objectInput.readLong();
150                    modifiedDate = objectInput.readLong();
151                    DDMStorageId = objectInput.readLong();
152                    recordSetId = objectInput.readLong();
153                    version = objectInput.readUTF();
154                    displayIndex = objectInput.readInt();
155            }
156    
157            @Override
158            public void writeExternal(ObjectOutput objectOutput)
159                    throws IOException {
160                    if (uuid == null) {
161                            objectOutput.writeUTF(StringPool.BLANK);
162                    }
163                    else {
164                            objectOutput.writeUTF(uuid);
165                    }
166    
167                    objectOutput.writeLong(recordId);
168                    objectOutput.writeLong(groupId);
169                    objectOutput.writeLong(companyId);
170                    objectOutput.writeLong(userId);
171    
172                    if (userName == null) {
173                            objectOutput.writeUTF(StringPool.BLANK);
174                    }
175                    else {
176                            objectOutput.writeUTF(userName);
177                    }
178    
179                    objectOutput.writeLong(versionUserId);
180    
181                    if (versionUserName == null) {
182                            objectOutput.writeUTF(StringPool.BLANK);
183                    }
184                    else {
185                            objectOutput.writeUTF(versionUserName);
186                    }
187    
188                    objectOutput.writeLong(createDate);
189                    objectOutput.writeLong(modifiedDate);
190                    objectOutput.writeLong(DDMStorageId);
191                    objectOutput.writeLong(recordSetId);
192    
193                    if (version == null) {
194                            objectOutput.writeUTF(StringPool.BLANK);
195                    }
196                    else {
197                            objectOutput.writeUTF(version);
198                    }
199    
200                    objectOutput.writeInt(displayIndex);
201            }
202    
203            public String uuid;
204            public long recordId;
205            public long groupId;
206            public long companyId;
207            public long userId;
208            public String userName;
209            public long versionUserId;
210            public String versionUserName;
211            public long createDate;
212            public long modifiedDate;
213            public long DDMStorageId;
214            public long recordSetId;
215            public String version;
216            public int displayIndex;
217    }