001
014
015 package com.liferay.portlet.asset.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.model.CacheModel;
022
023 import com.liferay.portlet.asset.model.AssetLink;
024
025 import java.io.Externalizable;
026 import java.io.IOException;
027 import java.io.ObjectInput;
028 import java.io.ObjectOutput;
029
030 import java.util.Date;
031
032
039 @ProviderType
040 public class AssetLinkCacheModel implements CacheModel<AssetLink>,
041 Externalizable {
042 @Override
043 public String toString() {
044 StringBundler sb = new StringBundler(19);
045
046 sb.append("{linkId=");
047 sb.append(linkId);
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(", entryId1=");
057 sb.append(entryId1);
058 sb.append(", entryId2=");
059 sb.append(entryId2);
060 sb.append(", type=");
061 sb.append(type);
062 sb.append(", weight=");
063 sb.append(weight);
064 sb.append("}");
065
066 return sb.toString();
067 }
068
069 @Override
070 public AssetLink toEntityModel() {
071 AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
072
073 assetLinkImpl.setLinkId(linkId);
074 assetLinkImpl.setCompanyId(companyId);
075 assetLinkImpl.setUserId(userId);
076
077 if (userName == null) {
078 assetLinkImpl.setUserName(StringPool.BLANK);
079 }
080 else {
081 assetLinkImpl.setUserName(userName);
082 }
083
084 if (createDate == Long.MIN_VALUE) {
085 assetLinkImpl.setCreateDate(null);
086 }
087 else {
088 assetLinkImpl.setCreateDate(new Date(createDate));
089 }
090
091 assetLinkImpl.setEntryId1(entryId1);
092 assetLinkImpl.setEntryId2(entryId2);
093 assetLinkImpl.setType(type);
094 assetLinkImpl.setWeight(weight);
095
096 assetLinkImpl.resetOriginalValues();
097
098 return assetLinkImpl;
099 }
100
101 @Override
102 public void readExternal(ObjectInput objectInput) throws IOException {
103 linkId = objectInput.readLong();
104 companyId = objectInput.readLong();
105 userId = objectInput.readLong();
106 userName = objectInput.readUTF();
107 createDate = objectInput.readLong();
108 entryId1 = objectInput.readLong();
109 entryId2 = objectInput.readLong();
110 type = objectInput.readInt();
111 weight = objectInput.readInt();
112 }
113
114 @Override
115 public void writeExternal(ObjectOutput objectOutput)
116 throws IOException {
117 objectOutput.writeLong(linkId);
118 objectOutput.writeLong(companyId);
119 objectOutput.writeLong(userId);
120
121 if (userName == null) {
122 objectOutput.writeUTF(StringPool.BLANK);
123 }
124 else {
125 objectOutput.writeUTF(userName);
126 }
127
128 objectOutput.writeLong(createDate);
129 objectOutput.writeLong(entryId1);
130 objectOutput.writeLong(entryId2);
131 objectOutput.writeInt(type);
132 objectOutput.writeInt(weight);
133 }
134
135 public long linkId;
136 public long companyId;
137 public long userId;
138 public String userName;
139 public long createDate;
140 public long entryId1;
141 public long entryId2;
142 public int type;
143 public int weight;
144 }