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.ResourcePermission;
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 ResourcePermission in entity cache.
029     *
030     * @author Brian Wing Shun Chan
031     * @see ResourcePermission
032     * @generated
033     */
034    public class ResourcePermissionCacheModel implements CacheModel<ResourcePermission>,
035            Externalizable {
036            @Override
037            public String toString() {
038                    StringBundler sb = new StringBundler(17);
039    
040                    sb.append("{resourcePermissionId=");
041                    sb.append(resourcePermissionId);
042                    sb.append(", companyId=");
043                    sb.append(companyId);
044                    sb.append(", name=");
045                    sb.append(name);
046                    sb.append(", scope=");
047                    sb.append(scope);
048                    sb.append(", primKey=");
049                    sb.append(primKey);
050                    sb.append(", roleId=");
051                    sb.append(roleId);
052                    sb.append(", ownerId=");
053                    sb.append(ownerId);
054                    sb.append(", actionIds=");
055                    sb.append(actionIds);
056                    sb.append("}");
057    
058                    return sb.toString();
059            }
060    
061            public ResourcePermission toEntityModel() {
062                    ResourcePermissionImpl resourcePermissionImpl = new ResourcePermissionImpl();
063    
064                    resourcePermissionImpl.setResourcePermissionId(resourcePermissionId);
065                    resourcePermissionImpl.setCompanyId(companyId);
066    
067                    if (name == null) {
068                            resourcePermissionImpl.setName(StringPool.BLANK);
069                    }
070                    else {
071                            resourcePermissionImpl.setName(name);
072                    }
073    
074                    resourcePermissionImpl.setScope(scope);
075    
076                    if (primKey == null) {
077                            resourcePermissionImpl.setPrimKey(StringPool.BLANK);
078                    }
079                    else {
080                            resourcePermissionImpl.setPrimKey(primKey);
081                    }
082    
083                    resourcePermissionImpl.setRoleId(roleId);
084                    resourcePermissionImpl.setOwnerId(ownerId);
085                    resourcePermissionImpl.setActionIds(actionIds);
086    
087                    resourcePermissionImpl.resetOriginalValues();
088    
089                    return resourcePermissionImpl;
090            }
091    
092            public void readExternal(ObjectInput objectInput) throws IOException {
093                    resourcePermissionId = objectInput.readLong();
094                    companyId = objectInput.readLong();
095                    name = objectInput.readUTF();
096                    scope = objectInput.readInt();
097                    primKey = objectInput.readUTF();
098                    roleId = objectInput.readLong();
099                    ownerId = objectInput.readLong();
100                    actionIds = objectInput.readLong();
101            }
102    
103            public void writeExternal(ObjectOutput objectOutput)
104                    throws IOException {
105                    objectOutput.writeLong(resourcePermissionId);
106                    objectOutput.writeLong(companyId);
107    
108                    if (name == null) {
109                            objectOutput.writeUTF(StringPool.BLANK);
110                    }
111                    else {
112                            objectOutput.writeUTF(name);
113                    }
114    
115                    objectOutput.writeInt(scope);
116    
117                    if (primKey == null) {
118                            objectOutput.writeUTF(StringPool.BLANK);
119                    }
120                    else {
121                            objectOutput.writeUTF(primKey);
122                    }
123    
124                    objectOutput.writeLong(roleId);
125                    objectOutput.writeLong(ownerId);
126                    objectOutput.writeLong(actionIds);
127            }
128    
129            public long resourcePermissionId;
130            public long companyId;
131            public String name;
132            public int scope;
133            public String primKey;
134            public long roleId;
135            public long ownerId;
136            public long actionIds;
137    }