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