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.Portlet;
021    
022    import java.io.Externalizable;
023    import java.io.IOException;
024    import java.io.ObjectInput;
025    import java.io.ObjectOutput;
026    
027    /**
028     * The cache model class for representing Portlet in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see Portlet
032     * @generated
033     */
034    public class PortletCacheModel implements CacheModel<Portlet>, Externalizable {
035            @Override
036            public String toString() {
037                    StringBundler sb = new StringBundler(11);
038    
039                    sb.append("{id=");
040                    sb.append(id);
041                    sb.append(", companyId=");
042                    sb.append(companyId);
043                    sb.append(", portletId=");
044                    sb.append(portletId);
045                    sb.append(", roles=");
046                    sb.append(roles);
047                    sb.append(", active=");
048                    sb.append(active);
049                    sb.append("}");
050    
051                    return sb.toString();
052            }
053    
054            public Portlet toEntityModel() {
055                    PortletImpl portletImpl = new PortletImpl();
056    
057                    portletImpl.setId(id);
058                    portletImpl.setCompanyId(companyId);
059    
060                    if (portletId == null) {
061                            portletImpl.setPortletId(StringPool.BLANK);
062                    }
063                    else {
064                            portletImpl.setPortletId(portletId);
065                    }
066    
067                    if (roles == null) {
068                            portletImpl.setRoles(StringPool.BLANK);
069                    }
070                    else {
071                            portletImpl.setRoles(roles);
072                    }
073    
074                    portletImpl.setActive(active);
075    
076                    portletImpl.resetOriginalValues();
077    
078                    return portletImpl;
079            }
080    
081            public void readExternal(ObjectInput objectInput) throws IOException {
082                    id = objectInput.readLong();
083                    companyId = objectInput.readLong();
084                    portletId = objectInput.readUTF();
085                    roles = objectInput.readUTF();
086                    active = objectInput.readBoolean();
087            }
088    
089            public void writeExternal(ObjectOutput objectOutput)
090                    throws IOException {
091                    objectOutput.writeLong(id);
092                    objectOutput.writeLong(companyId);
093    
094                    if (portletId == null) {
095                            objectOutput.writeUTF(StringPool.BLANK);
096                    }
097                    else {
098                            objectOutput.writeUTF(portletId);
099                    }
100    
101                    if (roles == null) {
102                            objectOutput.writeUTF(StringPool.BLANK);
103                    }
104                    else {
105                            objectOutput.writeUTF(roles);
106                    }
107    
108                    objectOutput.writeBoolean(active);
109            }
110    
111            public long id;
112            public long companyId;
113            public String portletId;
114            public String roles;
115            public boolean active;
116    }