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.portal.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.BackgroundTask;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.MVCCModel;
024    
025    import java.io.Externalizable;
026    import java.io.IOException;
027    import java.io.ObjectInput;
028    import java.io.ObjectOutput;
029    import java.io.Serializable;
030    
031    import java.util.Date;
032    import java.util.Map;
033    
034    /**
035     * The cache model class for representing BackgroundTask in entity cache.
036     *
037     * @author Brian Wing Shun Chan
038     * @see BackgroundTask
039     * @generated
040     */
041    @ProviderType
042    public class BackgroundTaskCacheModel implements CacheModel<BackgroundTask>,
043            Externalizable, MVCCModel {
044            @Override
045            public long getMvccVersion() {
046                    return mvccVersion;
047            }
048    
049            @Override
050            public void setMvccVersion(long mvccVersion) {
051                    this.mvccVersion = mvccVersion;
052            }
053    
054            @Override
055            public String toString() {
056                    StringBundler sb = new StringBundler(33);
057    
058                    sb.append("{mvccVersion=");
059                    sb.append(mvccVersion);
060                    sb.append(", backgroundTaskId=");
061                    sb.append(backgroundTaskId);
062                    sb.append(", groupId=");
063                    sb.append(groupId);
064                    sb.append(", companyId=");
065                    sb.append(companyId);
066                    sb.append(", userId=");
067                    sb.append(userId);
068                    sb.append(", userName=");
069                    sb.append(userName);
070                    sb.append(", createDate=");
071                    sb.append(createDate);
072                    sb.append(", modifiedDate=");
073                    sb.append(modifiedDate);
074                    sb.append(", name=");
075                    sb.append(name);
076                    sb.append(", servletContextNames=");
077                    sb.append(servletContextNames);
078                    sb.append(", taskExecutorClassName=");
079                    sb.append(taskExecutorClassName);
080                    sb.append(", taskContextMap=");
081                    sb.append(taskContextMap);
082                    sb.append(", completed=");
083                    sb.append(completed);
084                    sb.append(", completionDate=");
085                    sb.append(completionDate);
086                    sb.append(", status=");
087                    sb.append(status);
088                    sb.append(", statusMessage=");
089                    sb.append(statusMessage);
090                    sb.append("}");
091    
092                    return sb.toString();
093            }
094    
095            @Override
096            public BackgroundTask toEntityModel() {
097                    BackgroundTaskImpl backgroundTaskImpl = new BackgroundTaskImpl();
098    
099                    backgroundTaskImpl.setMvccVersion(mvccVersion);
100                    backgroundTaskImpl.setBackgroundTaskId(backgroundTaskId);
101                    backgroundTaskImpl.setGroupId(groupId);
102                    backgroundTaskImpl.setCompanyId(companyId);
103                    backgroundTaskImpl.setUserId(userId);
104    
105                    if (userName == null) {
106                            backgroundTaskImpl.setUserName(StringPool.BLANK);
107                    }
108                    else {
109                            backgroundTaskImpl.setUserName(userName);
110                    }
111    
112                    if (createDate == Long.MIN_VALUE) {
113                            backgroundTaskImpl.setCreateDate(null);
114                    }
115                    else {
116                            backgroundTaskImpl.setCreateDate(new Date(createDate));
117                    }
118    
119                    if (modifiedDate == Long.MIN_VALUE) {
120                            backgroundTaskImpl.setModifiedDate(null);
121                    }
122                    else {
123                            backgroundTaskImpl.setModifiedDate(new Date(modifiedDate));
124                    }
125    
126                    if (name == null) {
127                            backgroundTaskImpl.setName(StringPool.BLANK);
128                    }
129                    else {
130                            backgroundTaskImpl.setName(name);
131                    }
132    
133                    if (servletContextNames == null) {
134                            backgroundTaskImpl.setServletContextNames(StringPool.BLANK);
135                    }
136                    else {
137                            backgroundTaskImpl.setServletContextNames(servletContextNames);
138                    }
139    
140                    if (taskExecutorClassName == null) {
141                            backgroundTaskImpl.setTaskExecutorClassName(StringPool.BLANK);
142                    }
143                    else {
144                            backgroundTaskImpl.setTaskExecutorClassName(taskExecutorClassName);
145                    }
146    
147                    backgroundTaskImpl.setTaskContextMap(taskContextMap);
148                    backgroundTaskImpl.setCompleted(completed);
149    
150                    if (completionDate == Long.MIN_VALUE) {
151                            backgroundTaskImpl.setCompletionDate(null);
152                    }
153                    else {
154                            backgroundTaskImpl.setCompletionDate(new Date(completionDate));
155                    }
156    
157                    backgroundTaskImpl.setStatus(status);
158    
159                    if (statusMessage == null) {
160                            backgroundTaskImpl.setStatusMessage(StringPool.BLANK);
161                    }
162                    else {
163                            backgroundTaskImpl.setStatusMessage(statusMessage);
164                    }
165    
166                    backgroundTaskImpl.resetOriginalValues();
167    
168                    return backgroundTaskImpl;
169            }
170    
171            @Override
172            public void readExternal(ObjectInput objectInput)
173                    throws ClassNotFoundException, IOException {
174                    mvccVersion = objectInput.readLong();
175                    backgroundTaskId = objectInput.readLong();
176                    groupId = objectInput.readLong();
177                    companyId = objectInput.readLong();
178                    userId = objectInput.readLong();
179                    userName = objectInput.readUTF();
180                    createDate = objectInput.readLong();
181                    modifiedDate = objectInput.readLong();
182                    name = objectInput.readUTF();
183                    servletContextNames = objectInput.readUTF();
184                    taskExecutorClassName = objectInput.readUTF();
185                    taskContextMap = (Map<String, Serializable>)objectInput.readObject();
186                    completed = objectInput.readBoolean();
187                    completionDate = objectInput.readLong();
188                    status = objectInput.readInt();
189                    statusMessage = objectInput.readUTF();
190            }
191    
192            @Override
193            public void writeExternal(ObjectOutput objectOutput)
194                    throws IOException {
195                    objectOutput.writeLong(mvccVersion);
196                    objectOutput.writeLong(backgroundTaskId);
197                    objectOutput.writeLong(groupId);
198                    objectOutput.writeLong(companyId);
199                    objectOutput.writeLong(userId);
200    
201                    if (userName == null) {
202                            objectOutput.writeUTF(StringPool.BLANK);
203                    }
204                    else {
205                            objectOutput.writeUTF(userName);
206                    }
207    
208                    objectOutput.writeLong(createDate);
209                    objectOutput.writeLong(modifiedDate);
210    
211                    if (name == null) {
212                            objectOutput.writeUTF(StringPool.BLANK);
213                    }
214                    else {
215                            objectOutput.writeUTF(name);
216                    }
217    
218                    if (servletContextNames == null) {
219                            objectOutput.writeUTF(StringPool.BLANK);
220                    }
221                    else {
222                            objectOutput.writeUTF(servletContextNames);
223                    }
224    
225                    if (taskExecutorClassName == null) {
226                            objectOutput.writeUTF(StringPool.BLANK);
227                    }
228                    else {
229                            objectOutput.writeUTF(taskExecutorClassName);
230                    }
231    
232                    objectOutput.writeObject(taskContextMap);
233                    objectOutput.writeBoolean(completed);
234                    objectOutput.writeLong(completionDate);
235                    objectOutput.writeInt(status);
236    
237                    if (statusMessage == null) {
238                            objectOutput.writeUTF(StringPool.BLANK);
239                    }
240                    else {
241                            objectOutput.writeUTF(statusMessage);
242                    }
243            }
244    
245            public long mvccVersion;
246            public long backgroundTaskId;
247            public long groupId;
248            public long companyId;
249            public long userId;
250            public String userName;
251            public long createDate;
252            public long modifiedDate;
253            public String name;
254            public String servletContextNames;
255            public String taskExecutorClassName;
256            public Map<String, Serializable> taskContextMap;
257            public boolean completed;
258            public long completionDate;
259            public int status;
260            public String statusMessage;
261    }