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