001
014
015 package com.liferay.portlet.journal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.ProxyUtil;
020 import com.liferay.portal.kernel.util.StringBundler;
021 import com.liferay.portal.kernel.util.StringPool;
022 import com.liferay.portal.model.CacheModel;
023 import com.liferay.portal.model.impl.BaseModelImpl;
024 import com.liferay.portal.service.ServiceContext;
025
026 import com.liferay.portlet.expando.model.ExpandoBridge;
027 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028 import com.liferay.portlet.journal.model.JournalArticleResource;
029 import com.liferay.portlet.journal.model.JournalArticleResourceModel;
030
031 import java.io.Serializable;
032
033 import java.sql.Types;
034
035 import java.util.HashMap;
036 import java.util.Map;
037
038
051 public class JournalArticleResourceModelImpl extends BaseModelImpl<JournalArticleResource>
052 implements JournalArticleResourceModel {
053
058 public static final String TABLE_NAME = "JournalArticleResource";
059 public static final Object[][] TABLE_COLUMNS = {
060 { "uuid_", Types.VARCHAR },
061 { "resourcePrimKey", Types.BIGINT },
062 { "groupId", Types.BIGINT },
063 { "articleId", Types.VARCHAR }
064 };
065 public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (uuid_ VARCHAR(75) null,resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
066 public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
067 public static final String DATA_SOURCE = "liferayDataSource";
068 public static final String SESSION_FACTORY = "liferaySessionFactory";
069 public static final String TX_MANAGER = "liferayTransactionManager";
070 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071 "value.object.entity.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
072 true);
073 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
074 "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
075 true);
076 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
077 "value.object.column.bitmask.enabled.com.liferay.portlet.journal.model.JournalArticleResource"),
078 true);
079 public static long ARTICLEID_COLUMN_BITMASK = 1L;
080 public static long GROUPID_COLUMN_BITMASK = 2L;
081 public static long UUID_COLUMN_BITMASK = 4L;
082 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
083 "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
084
085 public JournalArticleResourceModelImpl() {
086 }
087
088 public long getPrimaryKey() {
089 return _resourcePrimKey;
090 }
091
092 public void setPrimaryKey(long primaryKey) {
093 setResourcePrimKey(primaryKey);
094 }
095
096 public Serializable getPrimaryKeyObj() {
097 return new Long(_resourcePrimKey);
098 }
099
100 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
101 setPrimaryKey(((Long)primaryKeyObj).longValue());
102 }
103
104 public Class<?> getModelClass() {
105 return JournalArticleResource.class;
106 }
107
108 public String getModelClassName() {
109 return JournalArticleResource.class.getName();
110 }
111
112 @Override
113 public Map<String, Object> getModelAttributes() {
114 Map<String, Object> attributes = new HashMap<String, Object>();
115
116 attributes.put("uuid", getUuid());
117 attributes.put("resourcePrimKey", getResourcePrimKey());
118 attributes.put("groupId", getGroupId());
119 attributes.put("articleId", getArticleId());
120
121 return attributes;
122 }
123
124 @Override
125 public void setModelAttributes(Map<String, Object> attributes) {
126 String uuid = (String)attributes.get("uuid");
127
128 if (uuid != null) {
129 setUuid(uuid);
130 }
131
132 Long resourcePrimKey = (Long)attributes.get("resourcePrimKey");
133
134 if (resourcePrimKey != null) {
135 setResourcePrimKey(resourcePrimKey);
136 }
137
138 Long groupId = (Long)attributes.get("groupId");
139
140 if (groupId != null) {
141 setGroupId(groupId);
142 }
143
144 String articleId = (String)attributes.get("articleId");
145
146 if (articleId != null) {
147 setArticleId(articleId);
148 }
149 }
150
151 public String getUuid() {
152 if (_uuid == null) {
153 return StringPool.BLANK;
154 }
155 else {
156 return _uuid;
157 }
158 }
159
160 public void setUuid(String uuid) {
161 if (_originalUuid == null) {
162 _originalUuid = _uuid;
163 }
164
165 _uuid = uuid;
166 }
167
168 public String getOriginalUuid() {
169 return GetterUtil.getString(_originalUuid);
170 }
171
172 public long getResourcePrimKey() {
173 return _resourcePrimKey;
174 }
175
176 public void setResourcePrimKey(long resourcePrimKey) {
177 _resourcePrimKey = resourcePrimKey;
178 }
179
180 public long getGroupId() {
181 return _groupId;
182 }
183
184 public void setGroupId(long groupId) {
185 _columnBitmask |= GROUPID_COLUMN_BITMASK;
186
187 if (!_setOriginalGroupId) {
188 _setOriginalGroupId = true;
189
190 _originalGroupId = _groupId;
191 }
192
193 _groupId = groupId;
194 }
195
196 public long getOriginalGroupId() {
197 return _originalGroupId;
198 }
199
200 public String getArticleId() {
201 if (_articleId == null) {
202 return StringPool.BLANK;
203 }
204 else {
205 return _articleId;
206 }
207 }
208
209 public void setArticleId(String articleId) {
210 _columnBitmask |= ARTICLEID_COLUMN_BITMASK;
211
212 if (_originalArticleId == null) {
213 _originalArticleId = _articleId;
214 }
215
216 _articleId = articleId;
217 }
218
219 public String getOriginalArticleId() {
220 return GetterUtil.getString(_originalArticleId);
221 }
222
223 public long getColumnBitmask() {
224 return _columnBitmask;
225 }
226
227 @Override
228 public ExpandoBridge getExpandoBridge() {
229 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
230 JournalArticleResource.class.getName(), getPrimaryKey());
231 }
232
233 @Override
234 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
235 ExpandoBridge expandoBridge = getExpandoBridge();
236
237 expandoBridge.setAttributes(serviceContext);
238 }
239
240 @Override
241 public JournalArticleResource toEscapedModel() {
242 if (_escapedModel == null) {
243 _escapedModel = (JournalArticleResource)ProxyUtil.newProxyInstance(_classLoader,
244 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
245 }
246
247 return _escapedModel;
248 }
249
250 public JournalArticleResource toUnescapedModel() {
251 return (JournalArticleResource)this;
252 }
253
254 @Override
255 public Object clone() {
256 JournalArticleResourceImpl journalArticleResourceImpl = new JournalArticleResourceImpl();
257
258 journalArticleResourceImpl.setUuid(getUuid());
259 journalArticleResourceImpl.setResourcePrimKey(getResourcePrimKey());
260 journalArticleResourceImpl.setGroupId(getGroupId());
261 journalArticleResourceImpl.setArticleId(getArticleId());
262
263 journalArticleResourceImpl.resetOriginalValues();
264
265 return journalArticleResourceImpl;
266 }
267
268 public int compareTo(JournalArticleResource journalArticleResource) {
269 long primaryKey = journalArticleResource.getPrimaryKey();
270
271 if (getPrimaryKey() < primaryKey) {
272 return -1;
273 }
274 else if (getPrimaryKey() > primaryKey) {
275 return 1;
276 }
277 else {
278 return 0;
279 }
280 }
281
282 @Override
283 public boolean equals(Object obj) {
284 if (this == obj) {
285 return true;
286 }
287
288 if (!(obj instanceof JournalArticleResource)) {
289 return false;
290 }
291
292 JournalArticleResource journalArticleResource = (JournalArticleResource)obj;
293
294 long primaryKey = journalArticleResource.getPrimaryKey();
295
296 if (getPrimaryKey() == primaryKey) {
297 return true;
298 }
299 else {
300 return false;
301 }
302 }
303
304 @Override
305 public int hashCode() {
306 return (int)getPrimaryKey();
307 }
308
309 @Override
310 public void resetOriginalValues() {
311 JournalArticleResourceModelImpl journalArticleResourceModelImpl = this;
312
313 journalArticleResourceModelImpl._originalUuid = journalArticleResourceModelImpl._uuid;
314
315 journalArticleResourceModelImpl._originalGroupId = journalArticleResourceModelImpl._groupId;
316
317 journalArticleResourceModelImpl._setOriginalGroupId = false;
318
319 journalArticleResourceModelImpl._originalArticleId = journalArticleResourceModelImpl._articleId;
320
321 journalArticleResourceModelImpl._columnBitmask = 0;
322 }
323
324 @Override
325 public CacheModel<JournalArticleResource> toCacheModel() {
326 JournalArticleResourceCacheModel journalArticleResourceCacheModel = new JournalArticleResourceCacheModel();
327
328 journalArticleResourceCacheModel.uuid = getUuid();
329
330 String uuid = journalArticleResourceCacheModel.uuid;
331
332 if ((uuid != null) && (uuid.length() == 0)) {
333 journalArticleResourceCacheModel.uuid = null;
334 }
335
336 journalArticleResourceCacheModel.resourcePrimKey = getResourcePrimKey();
337
338 journalArticleResourceCacheModel.groupId = getGroupId();
339
340 journalArticleResourceCacheModel.articleId = getArticleId();
341
342 String articleId = journalArticleResourceCacheModel.articleId;
343
344 if ((articleId != null) && (articleId.length() == 0)) {
345 journalArticleResourceCacheModel.articleId = null;
346 }
347
348 return journalArticleResourceCacheModel;
349 }
350
351 @Override
352 public String toString() {
353 StringBundler sb = new StringBundler(9);
354
355 sb.append("{uuid=");
356 sb.append(getUuid());
357 sb.append(", resourcePrimKey=");
358 sb.append(getResourcePrimKey());
359 sb.append(", groupId=");
360 sb.append(getGroupId());
361 sb.append(", articleId=");
362 sb.append(getArticleId());
363 sb.append("}");
364
365 return sb.toString();
366 }
367
368 public String toXmlString() {
369 StringBundler sb = new StringBundler(16);
370
371 sb.append("<model><model-name>");
372 sb.append("com.liferay.portlet.journal.model.JournalArticleResource");
373 sb.append("</model-name>");
374
375 sb.append(
376 "<column><column-name>uuid</column-name><column-value><![CDATA[");
377 sb.append(getUuid());
378 sb.append("]]></column-value></column>");
379 sb.append(
380 "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
381 sb.append(getResourcePrimKey());
382 sb.append("]]></column-value></column>");
383 sb.append(
384 "<column><column-name>groupId</column-name><column-value><![CDATA[");
385 sb.append(getGroupId());
386 sb.append("]]></column-value></column>");
387 sb.append(
388 "<column><column-name>articleId</column-name><column-value><![CDATA[");
389 sb.append(getArticleId());
390 sb.append("]]></column-value></column>");
391
392 sb.append("</model>");
393
394 return sb.toString();
395 }
396
397 private static ClassLoader _classLoader = JournalArticleResource.class.getClassLoader();
398 private static Class<?>[] _escapedModelInterfaces = new Class[] {
399 JournalArticleResource.class
400 };
401 private String _uuid;
402 private String _originalUuid;
403 private long _resourcePrimKey;
404 private long _groupId;
405 private long _originalGroupId;
406 private boolean _setOriginalGroupId;
407 private String _articleId;
408 private String _originalArticleId;
409 private long _columnBitmask;
410 private JournalArticleResource _escapedModel;
411 }