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