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