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            public Organization toEntityModel() {
080                    OrganizationImpl organizationImpl = new OrganizationImpl();
081    
082                    if (uuid == null) {
083                            organizationImpl.setUuid(StringPool.BLANK);
084                    }
085                    else {
086                            organizationImpl.setUuid(uuid);
087                    }
088    
089                    organizationImpl.setOrganizationId(organizationId);
090                    organizationImpl.setCompanyId(companyId);
091                    organizationImpl.setUserId(userId);
092    
093                    if (userName == null) {
094                            organizationImpl.setUserName(StringPool.BLANK);
095                    }
096                    else {
097                            organizationImpl.setUserName(userName);
098                    }
099    
100                    if (createDate == Long.MIN_VALUE) {
101                            organizationImpl.setCreateDate(null);
102                    }
103                    else {
104                            organizationImpl.setCreateDate(new Date(createDate));
105                    }
106    
107                    if (modifiedDate == Long.MIN_VALUE) {
108                            organizationImpl.setModifiedDate(null);
109                    }
110                    else {
111                            organizationImpl.setModifiedDate(new Date(modifiedDate));
112                    }
113    
114                    organizationImpl.setParentOrganizationId(parentOrganizationId);
115    
116                    if (treePath == null) {
117                            organizationImpl.setTreePath(StringPool.BLANK);
118                    }
119                    else {
120                            organizationImpl.setTreePath(treePath);
121                    }
122    
123                    if (name == null) {
124                            organizationImpl.setName(StringPool.BLANK);
125                    }
126                    else {
127                            organizationImpl.setName(name);
128                    }
129    
130                    if (type == null) {
131                            organizationImpl.setType(StringPool.BLANK);
132                    }
133                    else {
134                            organizationImpl.setType(type);
135                    }
136    
137                    organizationImpl.setRecursable(recursable);
138                    organizationImpl.setRegionId(regionId);
139                    organizationImpl.setCountryId(countryId);
140                    organizationImpl.setStatusId(statusId);
141    
142                    if (comments == null) {
143                            organizationImpl.setComments(StringPool.BLANK);
144                    }
145                    else {
146                            organizationImpl.setComments(comments);
147                    }
148    
149                    organizationImpl.resetOriginalValues();
150    
151                    return organizationImpl;
152            }
153    
154            public void readExternal(ObjectInput objectInput) throws IOException {
155                    uuid = objectInput.readUTF();
156                    organizationId = objectInput.readLong();
157                    companyId = objectInput.readLong();
158                    userId = objectInput.readLong();
159                    userName = objectInput.readUTF();
160                    createDate = objectInput.readLong();
161                    modifiedDate = objectInput.readLong();
162                    parentOrganizationId = objectInput.readLong();
163                    treePath = objectInput.readUTF();
164                    name = objectInput.readUTF();
165                    type = objectInput.readUTF();
166                    recursable = objectInput.readBoolean();
167                    regionId = objectInput.readLong();
168                    countryId = objectInput.readLong();
169                    statusId = objectInput.readInt();
170                    comments = objectInput.readUTF();
171            }
172    
173            public void writeExternal(ObjectOutput objectOutput)
174                    throws IOException {
175                    if (uuid == null) {
176                            objectOutput.writeUTF(StringPool.BLANK);
177                    }
178                    else {
179                            objectOutput.writeUTF(uuid);
180                    }
181    
182                    objectOutput.writeLong(organizationId);
183                    objectOutput.writeLong(companyId);
184                    objectOutput.writeLong(userId);
185    
186                    if (userName == null) {
187                            objectOutput.writeUTF(StringPool.BLANK);
188                    }
189                    else {
190                            objectOutput.writeUTF(userName);
191                    }
192    
193                    objectOutput.writeLong(createDate);
194                    objectOutput.writeLong(modifiedDate);
195                    objectOutput.writeLong(parentOrganizationId);
196    
197                    if (treePath == null) {
198                            objectOutput.writeUTF(StringPool.BLANK);
199                    }
200                    else {
201                            objectOutput.writeUTF(treePath);
202                    }
203    
204                    if (name == null) {
205                            objectOutput.writeUTF(StringPool.BLANK);
206                    }
207                    else {
208                            objectOutput.writeUTF(name);
209                    }
210    
211                    if (type == null) {
212                            objectOutput.writeUTF(StringPool.BLANK);
213                    }
214                    else {
215                            objectOutput.writeUTF(type);
216                    }
217    
218                    objectOutput.writeBoolean(recursable);
219                    objectOutput.writeLong(regionId);
220                    objectOutput.writeLong(countryId);
221                    objectOutput.writeInt(statusId);
222    
223                    if (comments == null) {
224                            objectOutput.writeUTF(StringPool.BLANK);
225                    }
226                    else {
227                            objectOutput.writeUTF(comments);
228                    }
229            }
230    
231            public String uuid;
232            public long organizationId;
233            public long companyId;
234            public long userId;
235            public String userName;
236            public long createDate;
237            public long modifiedDate;
238            public long parentOrganizationId;
239            public String treePath;
240            public String name;
241            public String type;
242            public boolean recursable;
243            public long regionId;
244            public long countryId;
245            public int statusId;
246            public String comments;
247    }