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            public DDLRecord toEntityModel() {
077                    DDLRecordImpl ddlRecordImpl = new DDLRecordImpl();
078    
079                    if (uuid == null) {
080                            ddlRecordImpl.setUuid(StringPool.BLANK);
081                    }
082                    else {
083                            ddlRecordImpl.setUuid(uuid);
084                    }
085    
086                    ddlRecordImpl.setRecordId(recordId);
087                    ddlRecordImpl.setGroupId(groupId);
088                    ddlRecordImpl.setCompanyId(companyId);
089                    ddlRecordImpl.setUserId(userId);
090    
091                    if (userName == null) {
092                            ddlRecordImpl.setUserName(StringPool.BLANK);
093                    }
094                    else {
095                            ddlRecordImpl.setUserName(userName);
096                    }
097    
098                    ddlRecordImpl.setVersionUserId(versionUserId);
099    
100                    if (versionUserName == null) {
101                            ddlRecordImpl.setVersionUserName(StringPool.BLANK);
102                    }
103                    else {
104                            ddlRecordImpl.setVersionUserName(versionUserName);
105                    }
106    
107                    if (createDate == Long.MIN_VALUE) {
108                            ddlRecordImpl.setCreateDate(null);
109                    }
110                    else {
111                            ddlRecordImpl.setCreateDate(new Date(createDate));
112                    }
113    
114                    if (modifiedDate == Long.MIN_VALUE) {
115                            ddlRecordImpl.setModifiedDate(null);
116                    }
117                    else {
118                            ddlRecordImpl.setModifiedDate(new Date(modifiedDate));
119                    }
120    
121                    ddlRecordImpl.setDDMStorageId(DDMStorageId);
122                    ddlRecordImpl.setRecordSetId(recordSetId);
123    
124                    if (version == null) {
125                            ddlRecordImpl.setVersion(StringPool.BLANK);
126                    }
127                    else {
128                            ddlRecordImpl.setVersion(version);
129                    }
130    
131                    ddlRecordImpl.setDisplayIndex(displayIndex);
132    
133                    ddlRecordImpl.resetOriginalValues();
134    
135                    return ddlRecordImpl;
136            }
137    
138            public void readExternal(ObjectInput objectInput) throws IOException {
139                    uuid = objectInput.readUTF();
140                    recordId = objectInput.readLong();
141                    groupId = objectInput.readLong();
142                    companyId = objectInput.readLong();
143                    userId = objectInput.readLong();
144                    userName = objectInput.readUTF();
145                    versionUserId = objectInput.readLong();
146                    versionUserName = objectInput.readUTF();
147                    createDate = objectInput.readLong();
148                    modifiedDate = objectInput.readLong();
149                    DDMStorageId = objectInput.readLong();
150                    recordSetId = objectInput.readLong();
151                    version = objectInput.readUTF();
152                    displayIndex = objectInput.readInt();
153            }
154    
155            public void writeExternal(ObjectOutput objectOutput)
156                    throws IOException {
157                    if (uuid == null) {
158                            objectOutput.writeUTF(StringPool.BLANK);
159                    }
160                    else {
161                            objectOutput.writeUTF(uuid);
162                    }
163    
164                    objectOutput.writeLong(recordId);
165                    objectOutput.writeLong(groupId);
166                    objectOutput.writeLong(companyId);
167                    objectOutput.writeLong(userId);
168    
169                    if (userName == null) {
170                            objectOutput.writeUTF(StringPool.BLANK);
171                    }
172                    else {
173                            objectOutput.writeUTF(userName);
174                    }
175    
176                    objectOutput.writeLong(versionUserId);
177    
178                    if (versionUserName == null) {
179                            objectOutput.writeUTF(StringPool.BLANK);
180                    }
181                    else {
182                            objectOutput.writeUTF(versionUserName);
183                    }
184    
185                    objectOutput.writeLong(createDate);
186                    objectOutput.writeLong(modifiedDate);
187                    objectOutput.writeLong(DDMStorageId);
188                    objectOutput.writeLong(recordSetId);
189    
190                    if (version == null) {
191                            objectOutput.writeUTF(StringPool.BLANK);
192                    }
193                    else {
194                            objectOutput.writeUTF(version);
195                    }
196    
197                    objectOutput.writeInt(displayIndex);
198            }
199    
200            public String uuid;
201            public long recordId;
202            public long groupId;
203            public long companyId;
204            public long userId;
205            public String userName;
206            public long versionUserId;
207            public String versionUserName;
208            public long createDate;
209            public long modifiedDate;
210            public long DDMStorageId;
211            public long recordSetId;
212            public String version;
213            public int displayIndex;
214    }