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.Repository;
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 Repository in entity cache.
031     *
032     * @author Brian Wing Shun Chan
033     * @see Repository
034     * @generated
035     */
036    public class RepositoryCacheModel implements CacheModel<Repository>,
037            Externalizable {
038            @Override
039            public String toString() {
040                    StringBundler sb = new StringBundler(29);
041    
042                    sb.append("{uuid=");
043                    sb.append(uuid);
044                    sb.append(", repositoryId=");
045                    sb.append(repositoryId);
046                    sb.append(", groupId=");
047                    sb.append(groupId);
048                    sb.append(", companyId=");
049                    sb.append(companyId);
050                    sb.append(", userId=");
051                    sb.append(userId);
052                    sb.append(", userName=");
053                    sb.append(userName);
054                    sb.append(", createDate=");
055                    sb.append(createDate);
056                    sb.append(", modifiedDate=");
057                    sb.append(modifiedDate);
058                    sb.append(", classNameId=");
059                    sb.append(classNameId);
060                    sb.append(", name=");
061                    sb.append(name);
062                    sb.append(", description=");
063                    sb.append(description);
064                    sb.append(", portletId=");
065                    sb.append(portletId);
066                    sb.append(", typeSettings=");
067                    sb.append(typeSettings);
068                    sb.append(", dlFolderId=");
069                    sb.append(dlFolderId);
070                    sb.append("}");
071    
072                    return sb.toString();
073            }
074    
075            @Override
076            public Repository toEntityModel() {
077                    RepositoryImpl repositoryImpl = new RepositoryImpl();
078    
079                    if (uuid == null) {
080                            repositoryImpl.setUuid(StringPool.BLANK);
081                    }
082                    else {
083                            repositoryImpl.setUuid(uuid);
084                    }
085    
086                    repositoryImpl.setRepositoryId(repositoryId);
087                    repositoryImpl.setGroupId(groupId);
088                    repositoryImpl.setCompanyId(companyId);
089                    repositoryImpl.setUserId(userId);
090    
091                    if (userName == null) {
092                            repositoryImpl.setUserName(StringPool.BLANK);
093                    }
094                    else {
095                            repositoryImpl.setUserName(userName);
096                    }
097    
098                    if (createDate == Long.MIN_VALUE) {
099                            repositoryImpl.setCreateDate(null);
100                    }
101                    else {
102                            repositoryImpl.setCreateDate(new Date(createDate));
103                    }
104    
105                    if (modifiedDate == Long.MIN_VALUE) {
106                            repositoryImpl.setModifiedDate(null);
107                    }
108                    else {
109                            repositoryImpl.setModifiedDate(new Date(modifiedDate));
110                    }
111    
112                    repositoryImpl.setClassNameId(classNameId);
113    
114                    if (name == null) {
115                            repositoryImpl.setName(StringPool.BLANK);
116                    }
117                    else {
118                            repositoryImpl.setName(name);
119                    }
120    
121                    if (description == null) {
122                            repositoryImpl.setDescription(StringPool.BLANK);
123                    }
124                    else {
125                            repositoryImpl.setDescription(description);
126                    }
127    
128                    if (portletId == null) {
129                            repositoryImpl.setPortletId(StringPool.BLANK);
130                    }
131                    else {
132                            repositoryImpl.setPortletId(portletId);
133                    }
134    
135                    if (typeSettings == null) {
136                            repositoryImpl.setTypeSettings(StringPool.BLANK);
137                    }
138                    else {
139                            repositoryImpl.setTypeSettings(typeSettings);
140                    }
141    
142                    repositoryImpl.setDlFolderId(dlFolderId);
143    
144                    repositoryImpl.resetOriginalValues();
145    
146                    return repositoryImpl;
147            }
148    
149            @Override
150            public void readExternal(ObjectInput objectInput) throws IOException {
151                    uuid = objectInput.readUTF();
152                    repositoryId = objectInput.readLong();
153                    groupId = objectInput.readLong();
154                    companyId = objectInput.readLong();
155                    userId = objectInput.readLong();
156                    userName = objectInput.readUTF();
157                    createDate = objectInput.readLong();
158                    modifiedDate = objectInput.readLong();
159                    classNameId = objectInput.readLong();
160                    name = objectInput.readUTF();
161                    description = objectInput.readUTF();
162                    portletId = objectInput.readUTF();
163                    typeSettings = objectInput.readUTF();
164                    dlFolderId = objectInput.readLong();
165            }
166    
167            @Override
168            public void writeExternal(ObjectOutput objectOutput)
169                    throws IOException {
170                    if (uuid == null) {
171                            objectOutput.writeUTF(StringPool.BLANK);
172                    }
173                    else {
174                            objectOutput.writeUTF(uuid);
175                    }
176    
177                    objectOutput.writeLong(repositoryId);
178                    objectOutput.writeLong(groupId);
179                    objectOutput.writeLong(companyId);
180                    objectOutput.writeLong(userId);
181    
182                    if (userName == null) {
183                            objectOutput.writeUTF(StringPool.BLANK);
184                    }
185                    else {
186                            objectOutput.writeUTF(userName);
187                    }
188    
189                    objectOutput.writeLong(createDate);
190                    objectOutput.writeLong(modifiedDate);
191                    objectOutput.writeLong(classNameId);
192    
193                    if (name == null) {
194                            objectOutput.writeUTF(StringPool.BLANK);
195                    }
196                    else {
197                            objectOutput.writeUTF(name);
198                    }
199    
200                    if (description == null) {
201                            objectOutput.writeUTF(StringPool.BLANK);
202                    }
203                    else {
204                            objectOutput.writeUTF(description);
205                    }
206    
207                    if (portletId == null) {
208                            objectOutput.writeUTF(StringPool.BLANK);
209                    }
210                    else {
211                            objectOutput.writeUTF(portletId);
212                    }
213    
214                    if (typeSettings == null) {
215                            objectOutput.writeUTF(StringPool.BLANK);
216                    }
217                    else {
218                            objectOutput.writeUTF(typeSettings);
219                    }
220    
221                    objectOutput.writeLong(dlFolderId);
222            }
223    
224            public String uuid;
225            public long repositoryId;
226            public long groupId;
227            public long companyId;
228            public long userId;
229            public String userName;
230            public long createDate;
231            public long modifiedDate;
232            public long classNameId;
233            public String name;
234            public String description;
235            public String portletId;
236            public String typeSettings;
237            public long dlFolderId;
238    }