001    /**
002     * Copyright (c) 2000-2012 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.journal.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.journal.model.JournalStructure;
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 JournalStructure in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see JournalStructure
035     * @generated
036     */
037    public class JournalStructureCacheModel implements CacheModel<JournalStructure>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(27);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", id=");
046                    sb.append(id);
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(", createDate=");
056                    sb.append(createDate);
057                    sb.append(", modifiedDate=");
058                    sb.append(modifiedDate);
059                    sb.append(", structureId=");
060                    sb.append(structureId);
061                    sb.append(", parentStructureId=");
062                    sb.append(parentStructureId);
063                    sb.append(", name=");
064                    sb.append(name);
065                    sb.append(", description=");
066                    sb.append(description);
067                    sb.append(", xsd=");
068                    sb.append(xsd);
069                    sb.append("}");
070    
071                    return sb.toString();
072            }
073    
074            public JournalStructure toEntityModel() {
075                    JournalStructureImpl journalStructureImpl = new JournalStructureImpl();
076    
077                    if (uuid == null) {
078                            journalStructureImpl.setUuid(StringPool.BLANK);
079                    }
080                    else {
081                            journalStructureImpl.setUuid(uuid);
082                    }
083    
084                    journalStructureImpl.setId(id);
085                    journalStructureImpl.setGroupId(groupId);
086                    journalStructureImpl.setCompanyId(companyId);
087                    journalStructureImpl.setUserId(userId);
088    
089                    if (userName == null) {
090                            journalStructureImpl.setUserName(StringPool.BLANK);
091                    }
092                    else {
093                            journalStructureImpl.setUserName(userName);
094                    }
095    
096                    if (createDate == Long.MIN_VALUE) {
097                            journalStructureImpl.setCreateDate(null);
098                    }
099                    else {
100                            journalStructureImpl.setCreateDate(new Date(createDate));
101                    }
102    
103                    if (modifiedDate == Long.MIN_VALUE) {
104                            journalStructureImpl.setModifiedDate(null);
105                    }
106                    else {
107                            journalStructureImpl.setModifiedDate(new Date(modifiedDate));
108                    }
109    
110                    if (structureId == null) {
111                            journalStructureImpl.setStructureId(StringPool.BLANK);
112                    }
113                    else {
114                            journalStructureImpl.setStructureId(structureId);
115                    }
116    
117                    if (parentStructureId == null) {
118                            journalStructureImpl.setParentStructureId(StringPool.BLANK);
119                    }
120                    else {
121                            journalStructureImpl.setParentStructureId(parentStructureId);
122                    }
123    
124                    if (name == null) {
125                            journalStructureImpl.setName(StringPool.BLANK);
126                    }
127                    else {
128                            journalStructureImpl.setName(name);
129                    }
130    
131                    if (description == null) {
132                            journalStructureImpl.setDescription(StringPool.BLANK);
133                    }
134                    else {
135                            journalStructureImpl.setDescription(description);
136                    }
137    
138                    if (xsd == null) {
139                            journalStructureImpl.setXsd(StringPool.BLANK);
140                    }
141                    else {
142                            journalStructureImpl.setXsd(xsd);
143                    }
144    
145                    journalStructureImpl.resetOriginalValues();
146    
147                    return journalStructureImpl;
148            }
149    
150            public void readExternal(ObjectInput objectInput) throws IOException {
151                    uuid = objectInput.readUTF();
152                    id = objectInput.readLong();
153                    groupId = objectInput.readLong();
154                    companyId = objectInput.readLong();
155                    userId = objectInput.readLong();
156                    userName = objectInput.readUTF();
157                    createDate = objectInput.readLong();
158                    modifiedDate = objectInput.readLong();
159                    structureId = objectInput.readUTF();
160                    parentStructureId = objectInput.readUTF();
161                    name = objectInput.readUTF();
162                    description = objectInput.readUTF();
163                    xsd = objectInput.readUTF();
164            }
165    
166            public void writeExternal(ObjectOutput objectOutput)
167                    throws IOException {
168                    if (uuid == null) {
169                            objectOutput.writeUTF(StringPool.BLANK);
170                    }
171                    else {
172                            objectOutput.writeUTF(uuid);
173                    }
174    
175                    objectOutput.writeLong(id);
176                    objectOutput.writeLong(groupId);
177                    objectOutput.writeLong(companyId);
178                    objectOutput.writeLong(userId);
179    
180                    if (userName == null) {
181                            objectOutput.writeUTF(StringPool.BLANK);
182                    }
183                    else {
184                            objectOutput.writeUTF(userName);
185                    }
186    
187                    objectOutput.writeLong(createDate);
188                    objectOutput.writeLong(modifiedDate);
189    
190                    if (structureId == null) {
191                            objectOutput.writeUTF(StringPool.BLANK);
192                    }
193                    else {
194                            objectOutput.writeUTF(structureId);
195                    }
196    
197                    if (parentStructureId == null) {
198                            objectOutput.writeUTF(StringPool.BLANK);
199                    }
200                    else {
201                            objectOutput.writeUTF(parentStructureId);
202                    }
203    
204                    if (name == null) {
205                            objectOutput.writeUTF(StringPool.BLANK);
206                    }
207                    else {
208                            objectOutput.writeUTF(name);
209                    }
210    
211                    if (description == null) {
212                            objectOutput.writeUTF(StringPool.BLANK);
213                    }
214                    else {
215                            objectOutput.writeUTF(description);
216                    }
217    
218                    if (xsd == null) {
219                            objectOutput.writeUTF(StringPool.BLANK);
220                    }
221                    else {
222                            objectOutput.writeUTF(xsd);
223                    }
224            }
225    
226            public String uuid;
227            public long id;
228            public long groupId;
229            public long companyId;
230            public long userId;
231            public String userName;
232            public long createDate;
233            public long modifiedDate;
234            public String structureId;
235            public String parentStructureId;
236            public String name;
237            public String description;
238            public String xsd;
239    }