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.UserGroup;
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 UserGroup in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see UserGroup
034     * @generated
035     */
036    public class UserGroupCacheModel implements CacheModel<UserGroup>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(23);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", userGroupId=");
045                    sb.append(userGroupId);
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(", parentUserGroupId=");
057                    sb.append(parentUserGroupId);
058                    sb.append(", name=");
059                    sb.append(name);
060                    sb.append(", description=");
061                    sb.append(description);
062                    sb.append(", addedByLDAPImport=");
063                    sb.append(addedByLDAPImport);
064                    sb.append("}");
065    
066                    return sb.toString();
067            }
068    
069            public UserGroup toEntityModel() {
070                    UserGroupImpl userGroupImpl = new UserGroupImpl();
071    
072                    if (uuid == null) {
073                            userGroupImpl.setUuid(StringPool.BLANK);
074                    }
075                    else {
076                            userGroupImpl.setUuid(uuid);
077                    }
078    
079                    userGroupImpl.setUserGroupId(userGroupId);
080                    userGroupImpl.setCompanyId(companyId);
081                    userGroupImpl.setUserId(userId);
082    
083                    if (userName == null) {
084                            userGroupImpl.setUserName(StringPool.BLANK);
085                    }
086                    else {
087                            userGroupImpl.setUserName(userName);
088                    }
089    
090                    if (createDate == Long.MIN_VALUE) {
091                            userGroupImpl.setCreateDate(null);
092                    }
093                    else {
094                            userGroupImpl.setCreateDate(new Date(createDate));
095                    }
096    
097                    if (modifiedDate == Long.MIN_VALUE) {
098                            userGroupImpl.setModifiedDate(null);
099                    }
100                    else {
101                            userGroupImpl.setModifiedDate(new Date(modifiedDate));
102                    }
103    
104                    userGroupImpl.setParentUserGroupId(parentUserGroupId);
105    
106                    if (name == null) {
107                            userGroupImpl.setName(StringPool.BLANK);
108                    }
109                    else {
110                            userGroupImpl.setName(name);
111                    }
112    
113                    if (description == null) {
114                            userGroupImpl.setDescription(StringPool.BLANK);
115                    }
116                    else {
117                            userGroupImpl.setDescription(description);
118                    }
119    
120                    userGroupImpl.setAddedByLDAPImport(addedByLDAPImport);
121    
122                    userGroupImpl.resetOriginalValues();
123    
124                    return userGroupImpl;
125            }
126    
127            public void readExternal(ObjectInput objectInput) throws IOException {
128                    uuid = objectInput.readUTF();
129                    userGroupId = objectInput.readLong();
130                    companyId = objectInput.readLong();
131                    userId = objectInput.readLong();
132                    userName = objectInput.readUTF();
133                    createDate = objectInput.readLong();
134                    modifiedDate = objectInput.readLong();
135                    parentUserGroupId = objectInput.readLong();
136                    name = objectInput.readUTF();
137                    description = objectInput.readUTF();
138                    addedByLDAPImport = objectInput.readBoolean();
139            }
140    
141            public void writeExternal(ObjectOutput objectOutput)
142                    throws IOException {
143                    if (uuid == null) {
144                            objectOutput.writeUTF(StringPool.BLANK);
145                    }
146                    else {
147                            objectOutput.writeUTF(uuid);
148                    }
149    
150                    objectOutput.writeLong(userGroupId);
151                    objectOutput.writeLong(companyId);
152                    objectOutput.writeLong(userId);
153    
154                    if (userName == null) {
155                            objectOutput.writeUTF(StringPool.BLANK);
156                    }
157                    else {
158                            objectOutput.writeUTF(userName);
159                    }
160    
161                    objectOutput.writeLong(createDate);
162                    objectOutput.writeLong(modifiedDate);
163                    objectOutput.writeLong(parentUserGroupId);
164    
165                    if (name == null) {
166                            objectOutput.writeUTF(StringPool.BLANK);
167                    }
168                    else {
169                            objectOutput.writeUTF(name);
170                    }
171    
172                    if (description == null) {
173                            objectOutput.writeUTF(StringPool.BLANK);
174                    }
175                    else {
176                            objectOutput.writeUTF(description);
177                    }
178    
179                    objectOutput.writeBoolean(addedByLDAPImport);
180            }
181    
182            public String uuid;
183            public long userGroupId;
184            public long companyId;
185            public long userId;
186            public String userName;
187            public long createDate;
188            public long modifiedDate;
189            public long parentUserGroupId;
190            public String name;
191            public String description;
192            public boolean addedByLDAPImport;
193    }