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