001
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.Ticket;
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
036 public class TicketCacheModel implements CacheModel<Ticket>, Externalizable {
037 @Override
038 public String toString() {
039 StringBundler sb = new StringBundler(19);
040
041 sb.append("{ticketId=");
042 sb.append(ticketId);
043 sb.append(", companyId=");
044 sb.append(companyId);
045 sb.append(", createDate=");
046 sb.append(createDate);
047 sb.append(", classNameId=");
048 sb.append(classNameId);
049 sb.append(", classPK=");
050 sb.append(classPK);
051 sb.append(", key=");
052 sb.append(key);
053 sb.append(", type=");
054 sb.append(type);
055 sb.append(", extraInfo=");
056 sb.append(extraInfo);
057 sb.append(", expirationDate=");
058 sb.append(expirationDate);
059 sb.append("}");
060
061 return sb.toString();
062 }
063
064 public Ticket toEntityModel() {
065 TicketImpl ticketImpl = new TicketImpl();
066
067 ticketImpl.setTicketId(ticketId);
068 ticketImpl.setCompanyId(companyId);
069
070 if (createDate == Long.MIN_VALUE) {
071 ticketImpl.setCreateDate(null);
072 }
073 else {
074 ticketImpl.setCreateDate(new Date(createDate));
075 }
076
077 ticketImpl.setClassNameId(classNameId);
078 ticketImpl.setClassPK(classPK);
079
080 if (key == null) {
081 ticketImpl.setKey(StringPool.BLANK);
082 }
083 else {
084 ticketImpl.setKey(key);
085 }
086
087 ticketImpl.setType(type);
088
089 if (extraInfo == null) {
090 ticketImpl.setExtraInfo(StringPool.BLANK);
091 }
092 else {
093 ticketImpl.setExtraInfo(extraInfo);
094 }
095
096 if (expirationDate == Long.MIN_VALUE) {
097 ticketImpl.setExpirationDate(null);
098 }
099 else {
100 ticketImpl.setExpirationDate(new Date(expirationDate));
101 }
102
103 ticketImpl.resetOriginalValues();
104
105 return ticketImpl;
106 }
107
108 public void readExternal(ObjectInput objectInput) throws IOException {
109 ticketId = objectInput.readLong();
110 companyId = objectInput.readLong();
111 createDate = objectInput.readLong();
112 classNameId = objectInput.readLong();
113 classPK = objectInput.readLong();
114 key = objectInput.readUTF();
115 type = objectInput.readInt();
116 extraInfo = objectInput.readUTF();
117 expirationDate = objectInput.readLong();
118 }
119
120 public void writeExternal(ObjectOutput objectOutput)
121 throws IOException {
122 objectOutput.writeLong(ticketId);
123 objectOutput.writeLong(companyId);
124 objectOutput.writeLong(createDate);
125 objectOutput.writeLong(classNameId);
126 objectOutput.writeLong(classPK);
127
128 if (key == null) {
129 objectOutput.writeUTF(StringPool.BLANK);
130 }
131 else {
132 objectOutput.writeUTF(key);
133 }
134
135 objectOutput.writeInt(type);
136
137 if (extraInfo == null) {
138 objectOutput.writeUTF(StringPool.BLANK);
139 }
140 else {
141 objectOutput.writeUTF(extraInfo);
142 }
143
144 objectOutput.writeLong(expirationDate);
145 }
146
147 public long ticketId;
148 public long companyId;
149 public long createDate;
150 public long classNameId;
151 public long classPK;
152 public String key;
153 public int type;
154 public String extraInfo;
155 public long expirationDate;
156 }