001    /**
002     * Copyright (c) 2000-present 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 aQute.bnd.annotation.ProviderType;
018    
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.CacheModel;
022    
023    import com.liferay.portlet.dynamicdatamapping.model.DDMTemplateVersion;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    
030    import java.util.Date;
031    
032    /**
033     * The cache model class for representing DDMTemplateVersion in entity cache.
034     *
035     * @author Brian Wing Shun Chan
036     * @see DDMTemplateVersion
037     * @generated
038     */
039    @ProviderType
040    public class DDMTemplateVersionCacheModel implements CacheModel<DDMTemplateVersion>,
041            Externalizable {
042            @Override
043            public String toString() {
044                    StringBundler sb = new StringBundler(25);
045    
046                    sb.append("{templateVersionId=");
047                    sb.append(templateVersionId);
048                    sb.append(", groupId=");
049                    sb.append(groupId);
050                    sb.append(", companyId=");
051                    sb.append(companyId);
052                    sb.append(", userId=");
053                    sb.append(userId);
054                    sb.append(", userName=");
055                    sb.append(userName);
056                    sb.append(", createDate=");
057                    sb.append(createDate);
058                    sb.append(", templateId=");
059                    sb.append(templateId);
060                    sb.append(", version=");
061                    sb.append(version);
062                    sb.append(", name=");
063                    sb.append(name);
064                    sb.append(", description=");
065                    sb.append(description);
066                    sb.append(", language=");
067                    sb.append(language);
068                    sb.append(", script=");
069                    sb.append(script);
070                    sb.append("}");
071    
072                    return sb.toString();
073            }
074    
075            @Override
076            public DDMTemplateVersion toEntityModel() {
077                    DDMTemplateVersionImpl ddmTemplateVersionImpl = new DDMTemplateVersionImpl();
078    
079                    ddmTemplateVersionImpl.setTemplateVersionId(templateVersionId);
080                    ddmTemplateVersionImpl.setGroupId(groupId);
081                    ddmTemplateVersionImpl.setCompanyId(companyId);
082                    ddmTemplateVersionImpl.setUserId(userId);
083    
084                    if (userName == null) {
085                            ddmTemplateVersionImpl.setUserName(StringPool.BLANK);
086                    }
087                    else {
088                            ddmTemplateVersionImpl.setUserName(userName);
089                    }
090    
091                    if (createDate == Long.MIN_VALUE) {
092                            ddmTemplateVersionImpl.setCreateDate(null);
093                    }
094                    else {
095                            ddmTemplateVersionImpl.setCreateDate(new Date(createDate));
096                    }
097    
098                    ddmTemplateVersionImpl.setTemplateId(templateId);
099    
100                    if (version == null) {
101                            ddmTemplateVersionImpl.setVersion(StringPool.BLANK);
102                    }
103                    else {
104                            ddmTemplateVersionImpl.setVersion(version);
105                    }
106    
107                    if (name == null) {
108                            ddmTemplateVersionImpl.setName(StringPool.BLANK);
109                    }
110                    else {
111                            ddmTemplateVersionImpl.setName(name);
112                    }
113    
114                    if (description == null) {
115                            ddmTemplateVersionImpl.setDescription(StringPool.BLANK);
116                    }
117                    else {
118                            ddmTemplateVersionImpl.setDescription(description);
119                    }
120    
121                    if (language == null) {
122                            ddmTemplateVersionImpl.setLanguage(StringPool.BLANK);
123                    }
124                    else {
125                            ddmTemplateVersionImpl.setLanguage(language);
126                    }
127    
128                    if (script == null) {
129                            ddmTemplateVersionImpl.setScript(StringPool.BLANK);
130                    }
131                    else {
132                            ddmTemplateVersionImpl.setScript(script);
133                    }
134    
135                    ddmTemplateVersionImpl.resetOriginalValues();
136    
137                    return ddmTemplateVersionImpl;
138            }
139    
140            @Override
141            public void readExternal(ObjectInput objectInput) throws IOException {
142                    templateVersionId = objectInput.readLong();
143                    groupId = objectInput.readLong();
144                    companyId = objectInput.readLong();
145                    userId = objectInput.readLong();
146                    userName = objectInput.readUTF();
147                    createDate = objectInput.readLong();
148                    templateId = objectInput.readLong();
149                    version = objectInput.readUTF();
150                    name = objectInput.readUTF();
151                    description = objectInput.readUTF();
152                    language = objectInput.readUTF();
153                    script = objectInput.readUTF();
154            }
155    
156            @Override
157            public void writeExternal(ObjectOutput objectOutput)
158                    throws IOException {
159                    objectOutput.writeLong(templateVersionId);
160                    objectOutput.writeLong(groupId);
161                    objectOutput.writeLong(companyId);
162                    objectOutput.writeLong(userId);
163    
164                    if (userName == null) {
165                            objectOutput.writeUTF(StringPool.BLANK);
166                    }
167                    else {
168                            objectOutput.writeUTF(userName);
169                    }
170    
171                    objectOutput.writeLong(createDate);
172                    objectOutput.writeLong(templateId);
173    
174                    if (version == null) {
175                            objectOutput.writeUTF(StringPool.BLANK);
176                    }
177                    else {
178                            objectOutput.writeUTF(version);
179                    }
180    
181                    if (name == null) {
182                            objectOutput.writeUTF(StringPool.BLANK);
183                    }
184                    else {
185                            objectOutput.writeUTF(name);
186                    }
187    
188                    if (description == null) {
189                            objectOutput.writeUTF(StringPool.BLANK);
190                    }
191                    else {
192                            objectOutput.writeUTF(description);
193                    }
194    
195                    if (language == null) {
196                            objectOutput.writeUTF(StringPool.BLANK);
197                    }
198                    else {
199                            objectOutput.writeUTF(language);
200                    }
201    
202                    if (script == null) {
203                            objectOutput.writeUTF(StringPool.BLANK);
204                    }
205                    else {
206                            objectOutput.writeUTF(script);
207                    }
208            }
209    
210            public long templateVersionId;
211            public long groupId;
212            public long companyId;
213            public long userId;
214            public String userName;
215            public long createDate;
216            public long templateId;
217            public String version;
218            public String name;
219            public String description;
220            public String language;
221            public String script;
222    }