001
014
015 package com.liferay.portlet.dynamicdatamapping.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.util.HashUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023
024 import com.liferay.portlet.dynamicdatamapping.model.DDMStructureLayout;
025
026 import java.io.Externalizable;
027 import java.io.IOException;
028 import java.io.ObjectInput;
029 import java.io.ObjectOutput;
030
031 import java.util.Date;
032
033
040 @ProviderType
041 public class DDMStructureLayoutCacheModel implements CacheModel<DDMStructureLayout>,
042 Externalizable {
043 @Override
044 public boolean equals(Object obj) {
045 if (this == obj) {
046 return true;
047 }
048
049 if (!(obj instanceof DDMStructureLayoutCacheModel)) {
050 return false;
051 }
052
053 DDMStructureLayoutCacheModel ddmStructureLayoutCacheModel = (DDMStructureLayoutCacheModel)obj;
054
055 if (structureLayoutId == ddmStructureLayoutCacheModel.structureLayoutId) {
056 return true;
057 }
058
059 return false;
060 }
061
062 @Override
063 public int hashCode() {
064 return HashUtil.hash(0, structureLayoutId);
065 }
066
067 @Override
068 public String toString() {
069 StringBundler sb = new StringBundler(21);
070
071 sb.append("{uuid=");
072 sb.append(uuid);
073 sb.append(", structureLayoutId=");
074 sb.append(structureLayoutId);
075 sb.append(", groupId=");
076 sb.append(groupId);
077 sb.append(", companyId=");
078 sb.append(companyId);
079 sb.append(", userId=");
080 sb.append(userId);
081 sb.append(", userName=");
082 sb.append(userName);
083 sb.append(", createDate=");
084 sb.append(createDate);
085 sb.append(", modifiedDate=");
086 sb.append(modifiedDate);
087 sb.append(", structureVersionId=");
088 sb.append(structureVersionId);
089 sb.append(", definition=");
090 sb.append(definition);
091 sb.append("}");
092
093 return sb.toString();
094 }
095
096 @Override
097 public DDMStructureLayout toEntityModel() {
098 DDMStructureLayoutImpl ddmStructureLayoutImpl = new DDMStructureLayoutImpl();
099
100 if (uuid == null) {
101 ddmStructureLayoutImpl.setUuid(StringPool.BLANK);
102 }
103 else {
104 ddmStructureLayoutImpl.setUuid(uuid);
105 }
106
107 ddmStructureLayoutImpl.setStructureLayoutId(structureLayoutId);
108 ddmStructureLayoutImpl.setGroupId(groupId);
109 ddmStructureLayoutImpl.setCompanyId(companyId);
110 ddmStructureLayoutImpl.setUserId(userId);
111
112 if (userName == null) {
113 ddmStructureLayoutImpl.setUserName(StringPool.BLANK);
114 }
115 else {
116 ddmStructureLayoutImpl.setUserName(userName);
117 }
118
119 if (createDate == Long.MIN_VALUE) {
120 ddmStructureLayoutImpl.setCreateDate(null);
121 }
122 else {
123 ddmStructureLayoutImpl.setCreateDate(new Date(createDate));
124 }
125
126 if (modifiedDate == Long.MIN_VALUE) {
127 ddmStructureLayoutImpl.setModifiedDate(null);
128 }
129 else {
130 ddmStructureLayoutImpl.setModifiedDate(new Date(modifiedDate));
131 }
132
133 ddmStructureLayoutImpl.setStructureVersionId(structureVersionId);
134
135 if (definition == null) {
136 ddmStructureLayoutImpl.setDefinition(StringPool.BLANK);
137 }
138 else {
139 ddmStructureLayoutImpl.setDefinition(definition);
140 }
141
142 ddmStructureLayoutImpl.resetOriginalValues();
143
144 ddmStructureLayoutImpl.setDDMFormLayout(_ddmFormLayout);
145
146 return ddmStructureLayoutImpl;
147 }
148
149 @Override
150 public void readExternal(ObjectInput objectInput)
151 throws ClassNotFoundException, IOException {
152 uuid = objectInput.readUTF();
153 structureLayoutId = objectInput.readLong();
154 groupId = objectInput.readLong();
155 companyId = objectInput.readLong();
156 userId = objectInput.readLong();
157 userName = objectInput.readUTF();
158 createDate = objectInput.readLong();
159 modifiedDate = objectInput.readLong();
160 structureVersionId = objectInput.readLong();
161 definition = objectInput.readUTF();
162
163 _ddmFormLayout = (com.liferay.portlet.dynamicdatamapping.model.DDMFormLayout)objectInput.readObject();
164 }
165
166 @Override
167 public void writeExternal(ObjectOutput objectOutput)
168 throws IOException {
169 if (uuid == null) {
170 objectOutput.writeUTF(StringPool.BLANK);
171 }
172 else {
173 objectOutput.writeUTF(uuid);
174 }
175
176 objectOutput.writeLong(structureLayoutId);
177 objectOutput.writeLong(groupId);
178 objectOutput.writeLong(companyId);
179 objectOutput.writeLong(userId);
180
181 if (userName == null) {
182 objectOutput.writeUTF(StringPool.BLANK);
183 }
184 else {
185 objectOutput.writeUTF(userName);
186 }
187
188 objectOutput.writeLong(createDate);
189 objectOutput.writeLong(modifiedDate);
190 objectOutput.writeLong(structureVersionId);
191
192 if (definition == null) {
193 objectOutput.writeUTF(StringPool.BLANK);
194 }
195 else {
196 objectOutput.writeUTF(definition);
197 }
198
199 objectOutput.writeObject(_ddmFormLayout);
200 }
201
202 public String uuid;
203 public long structureLayoutId;
204 public long groupId;
205 public long companyId;
206 public long userId;
207 public String userName;
208 public long createDate;
209 public long modifiedDate;
210 public long structureVersionId;
211 public String definition;
212 public com.liferay.portlet.dynamicdatamapping.model.DDMFormLayout _ddmFormLayout;
213 }