001    /**
002     * Copyright (c) 2000-2012 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.CacheModel;
020    import com.liferay.portal.model.WorkflowDefinitionLink;
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 WorkflowDefinitionLink in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see WorkflowDefinitionLink
034     * @generated
035     */
036    public class WorkflowDefinitionLinkCacheModel implements CacheModel<WorkflowDefinitionLink>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(25);
041    
042                    sb.append("{workflowDefinitionLinkId=");
043                    sb.append(workflowDefinitionLinkId);
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(", classNameId=");
057                    sb.append(classNameId);
058                    sb.append(", classPK=");
059                    sb.append(classPK);
060                    sb.append(", typePK=");
061                    sb.append(typePK);
062                    sb.append(", workflowDefinitionName=");
063                    sb.append(workflowDefinitionName);
064                    sb.append(", workflowDefinitionVersion=");
065                    sb.append(workflowDefinitionVersion);
066                    sb.append("}");
067    
068                    return sb.toString();
069            }
070    
071            public WorkflowDefinitionLink toEntityModel() {
072                    WorkflowDefinitionLinkImpl workflowDefinitionLinkImpl = new WorkflowDefinitionLinkImpl();
073    
074                    workflowDefinitionLinkImpl.setWorkflowDefinitionLinkId(workflowDefinitionLinkId);
075                    workflowDefinitionLinkImpl.setGroupId(groupId);
076                    workflowDefinitionLinkImpl.setCompanyId(companyId);
077                    workflowDefinitionLinkImpl.setUserId(userId);
078    
079                    if (userName == null) {
080                            workflowDefinitionLinkImpl.setUserName(StringPool.BLANK);
081                    }
082                    else {
083                            workflowDefinitionLinkImpl.setUserName(userName);
084                    }
085    
086                    if (createDate == Long.MIN_VALUE) {
087                            workflowDefinitionLinkImpl.setCreateDate(null);
088                    }
089                    else {
090                            workflowDefinitionLinkImpl.setCreateDate(new Date(createDate));
091                    }
092    
093                    if (modifiedDate == Long.MIN_VALUE) {
094                            workflowDefinitionLinkImpl.setModifiedDate(null);
095                    }
096                    else {
097                            workflowDefinitionLinkImpl.setModifiedDate(new Date(modifiedDate));
098                    }
099    
100                    workflowDefinitionLinkImpl.setClassNameId(classNameId);
101                    workflowDefinitionLinkImpl.setClassPK(classPK);
102                    workflowDefinitionLinkImpl.setTypePK(typePK);
103    
104                    if (workflowDefinitionName == null) {
105                            workflowDefinitionLinkImpl.setWorkflowDefinitionName(StringPool.BLANK);
106                    }
107                    else {
108                            workflowDefinitionLinkImpl.setWorkflowDefinitionName(workflowDefinitionName);
109                    }
110    
111                    workflowDefinitionLinkImpl.setWorkflowDefinitionVersion(workflowDefinitionVersion);
112    
113                    workflowDefinitionLinkImpl.resetOriginalValues();
114    
115                    return workflowDefinitionLinkImpl;
116            }
117    
118            public void readExternal(ObjectInput objectInput) throws IOException {
119                    workflowDefinitionLinkId = objectInput.readLong();
120                    groupId = objectInput.readLong();
121                    companyId = objectInput.readLong();
122                    userId = objectInput.readLong();
123                    userName = objectInput.readUTF();
124                    createDate = objectInput.readLong();
125                    modifiedDate = objectInput.readLong();
126                    classNameId = objectInput.readLong();
127                    classPK = objectInput.readLong();
128                    typePK = objectInput.readLong();
129                    workflowDefinitionName = objectInput.readUTF();
130                    workflowDefinitionVersion = objectInput.readInt();
131            }
132    
133            public void writeExternal(ObjectOutput objectOutput)
134                    throws IOException {
135                    objectOutput.writeLong(workflowDefinitionLinkId);
136                    objectOutput.writeLong(groupId);
137                    objectOutput.writeLong(companyId);
138                    objectOutput.writeLong(userId);
139    
140                    if (userName == null) {
141                            objectOutput.writeUTF(StringPool.BLANK);
142                    }
143                    else {
144                            objectOutput.writeUTF(userName);
145                    }
146    
147                    objectOutput.writeLong(createDate);
148                    objectOutput.writeLong(modifiedDate);
149                    objectOutput.writeLong(classNameId);
150                    objectOutput.writeLong(classPK);
151                    objectOutput.writeLong(typePK);
152    
153                    if (workflowDefinitionName == null) {
154                            objectOutput.writeUTF(StringPool.BLANK);
155                    }
156                    else {
157                            objectOutput.writeUTF(workflowDefinitionName);
158                    }
159    
160                    objectOutput.writeInt(workflowDefinitionVersion);
161            }
162    
163            public long workflowDefinitionLinkId;
164            public long groupId;
165            public long companyId;
166            public long userId;
167            public String userName;
168            public long createDate;
169            public long modifiedDate;
170            public long classNameId;
171            public long classPK;
172            public long typePK;
173            public String workflowDefinitionName;
174            public int workflowDefinitionVersion;
175    }