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.dynamicdatamapping.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.dynamicdatamapping.model.DDMStructure;
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 DDMStructure in entity cache.
032     *
033     * @author Brian Wing Shun Chan
034     * @see DDMStructure
035     * @generated
036     */
037    public class DDMStructureCacheModel implements CacheModel<DDMStructure>,
038            Externalizable {
039            @Override
040            public String toString() {
041                    StringBundler sb = new StringBundler(33);
042    
043                    sb.append("{uuid=");
044                    sb.append(uuid);
045                    sb.append(", structureId=");
046                    sb.append(structureId);
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(", parentStructureId=");
060                    sb.append(parentStructureId);
061                    sb.append(", classNameId=");
062                    sb.append(classNameId);
063                    sb.append(", structureKey=");
064                    sb.append(structureKey);
065                    sb.append(", name=");
066                    sb.append(name);
067                    sb.append(", description=");
068                    sb.append(description);
069                    sb.append(", xsd=");
070                    sb.append(xsd);
071                    sb.append(", storageType=");
072                    sb.append(storageType);
073                    sb.append(", type=");
074                    sb.append(type);
075                    sb.append("}");
076    
077                    return sb.toString();
078            }
079    
080            public DDMStructure toEntityModel() {
081                    DDMStructureImpl ddmStructureImpl = new DDMStructureImpl();
082    
083                    if (uuid == null) {
084                            ddmStructureImpl.setUuid(StringPool.BLANK);
085                    }
086                    else {
087                            ddmStructureImpl.setUuid(uuid);
088                    }
089    
090                    ddmStructureImpl.setStructureId(structureId);
091                    ddmStructureImpl.setGroupId(groupId);
092                    ddmStructureImpl.setCompanyId(companyId);
093                    ddmStructureImpl.setUserId(userId);
094    
095                    if (userName == null) {
096                            ddmStructureImpl.setUserName(StringPool.BLANK);
097                    }
098                    else {
099                            ddmStructureImpl.setUserName(userName);
100                    }
101    
102                    if (createDate == Long.MIN_VALUE) {
103                            ddmStructureImpl.setCreateDate(null);
104                    }
105                    else {
106                            ddmStructureImpl.setCreateDate(new Date(createDate));
107                    }
108    
109                    if (modifiedDate == Long.MIN_VALUE) {
110                            ddmStructureImpl.setModifiedDate(null);
111                    }
112                    else {
113                            ddmStructureImpl.setModifiedDate(new Date(modifiedDate));
114                    }
115    
116                    ddmStructureImpl.setParentStructureId(parentStructureId);
117                    ddmStructureImpl.setClassNameId(classNameId);
118    
119                    if (structureKey == null) {
120                            ddmStructureImpl.setStructureKey(StringPool.BLANK);
121                    }
122                    else {
123                            ddmStructureImpl.setStructureKey(structureKey);
124                    }
125    
126                    if (name == null) {
127                            ddmStructureImpl.setName(StringPool.BLANK);
128                    }
129                    else {
130                            ddmStructureImpl.setName(name);
131                    }
132    
133                    if (description == null) {
134                            ddmStructureImpl.setDescription(StringPool.BLANK);
135                    }
136                    else {
137                            ddmStructureImpl.setDescription(description);
138                    }
139    
140                    if (xsd == null) {
141                            ddmStructureImpl.setXsd(StringPool.BLANK);
142                    }
143                    else {
144                            ddmStructureImpl.setXsd(xsd);
145                    }
146    
147                    if (storageType == null) {
148                            ddmStructureImpl.setStorageType(StringPool.BLANK);
149                    }
150                    else {
151                            ddmStructureImpl.setStorageType(storageType);
152                    }
153    
154                    ddmStructureImpl.setType(type);
155    
156                    ddmStructureImpl.resetOriginalValues();
157    
158                    ddmStructureImpl.setDocument(_document);
159    
160                    ddmStructureImpl.setLocalizedFieldsMap(_localizedFieldsMap);
161    
162                    ddmStructureImpl.setLocalizedTransientFieldsMap(_localizedTransientFieldsMap);
163    
164                    return ddmStructureImpl;
165            }
166    
167            public void readExternal(ObjectInput objectInput)
168                    throws ClassNotFoundException, IOException {
169                    uuid = objectInput.readUTF();
170                    structureId = objectInput.readLong();
171                    groupId = objectInput.readLong();
172                    companyId = objectInput.readLong();
173                    userId = objectInput.readLong();
174                    userName = objectInput.readUTF();
175                    createDate = objectInput.readLong();
176                    modifiedDate = objectInput.readLong();
177                    parentStructureId = objectInput.readLong();
178                    classNameId = objectInput.readLong();
179                    structureKey = objectInput.readUTF();
180                    name = objectInput.readUTF();
181                    description = objectInput.readUTF();
182                    xsd = objectInput.readUTF();
183                    storageType = objectInput.readUTF();
184                    type = objectInput.readInt();
185    
186                    _document = (com.liferay.portal.kernel.xml.Document)objectInput.readObject();
187                    _localizedFieldsMap = (java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.String>>>)objectInput.readObject();
188                    _localizedTransientFieldsMap = (java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.String>>>)objectInput.readObject();
189            }
190    
191            public void writeExternal(ObjectOutput objectOutput)
192                    throws IOException {
193                    if (uuid == null) {
194                            objectOutput.writeUTF(StringPool.BLANK);
195                    }
196                    else {
197                            objectOutput.writeUTF(uuid);
198                    }
199    
200                    objectOutput.writeLong(structureId);
201                    objectOutput.writeLong(groupId);
202                    objectOutput.writeLong(companyId);
203                    objectOutput.writeLong(userId);
204    
205                    if (userName == null) {
206                            objectOutput.writeUTF(StringPool.BLANK);
207                    }
208                    else {
209                            objectOutput.writeUTF(userName);
210                    }
211    
212                    objectOutput.writeLong(createDate);
213                    objectOutput.writeLong(modifiedDate);
214                    objectOutput.writeLong(parentStructureId);
215                    objectOutput.writeLong(classNameId);
216    
217                    if (structureKey == null) {
218                            objectOutput.writeUTF(StringPool.BLANK);
219                    }
220                    else {
221                            objectOutput.writeUTF(structureKey);
222                    }
223    
224                    if (name == null) {
225                            objectOutput.writeUTF(StringPool.BLANK);
226                    }
227                    else {
228                            objectOutput.writeUTF(name);
229                    }
230    
231                    if (description == null) {
232                            objectOutput.writeUTF(StringPool.BLANK);
233                    }
234                    else {
235                            objectOutput.writeUTF(description);
236                    }
237    
238                    if (xsd == null) {
239                            objectOutput.writeUTF(StringPool.BLANK);
240                    }
241                    else {
242                            objectOutput.writeUTF(xsd);
243                    }
244    
245                    if (storageType == null) {
246                            objectOutput.writeUTF(StringPool.BLANK);
247                    }
248                    else {
249                            objectOutput.writeUTF(storageType);
250                    }
251    
252                    objectOutput.writeInt(type);
253    
254                    objectOutput.writeObject(_document);
255                    objectOutput.writeObject(_localizedFieldsMap);
256                    objectOutput.writeObject(_localizedTransientFieldsMap);
257            }
258    
259            public String uuid;
260            public long structureId;
261            public long groupId;
262            public long companyId;
263            public long userId;
264            public String userName;
265            public long createDate;
266            public long modifiedDate;
267            public long parentStructureId;
268            public long classNameId;
269            public String structureKey;
270            public String name;
271            public String description;
272            public String xsd;
273            public String storageType;
274            public int type;
275            public com.liferay.portal.kernel.xml.Document _document;
276            public java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.String>>> _localizedFieldsMap;
277            public java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.util.Map<java.lang.String, java.lang.String>>> _localizedTransientFieldsMap;
278    }