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