001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portlet.documentlibrary.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.impl.BaseModelImpl;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.portlet.documentlibrary.model.DLFileVersion;
029:
030: import com.liferay.util.Html;
031:
032: import java.io.Serializable;
033:
034: import java.lang.reflect.Proxy;
035:
036: import java.sql.Types;
037:
038: import java.util.Date;
039:
040: /**
041: * <a href="DLFileVersionModelImpl.java.html"><b><i>View Source</i></b></a>
042: *
043: * <p>
044: * ServiceBuilder generated this class. Modifications in this class will be
045: * overwritten the next time is generated.
046: * </p>
047: *
048: * <p>
049: * This class is a model that represents the <code>DLFileVersion</code> table
050: * in the database.
051: * </p>
052: *
053: * @author Brian Wing Shun Chan
054: *
055: * @see com.liferay.portlet.documentlibrary.service.model.DLFileVersion
056: * @see com.liferay.portlet.documentlibrary.service.model.DLFileVersionModel
057: * @see com.liferay.portlet.documentlibrary.service.model.impl.DLFileVersionImpl
058: *
059: */
060: public class DLFileVersionModelImpl extends BaseModelImpl {
061: public static final String TABLE_NAME = "DLFileVersion";
062: public static final Object[][] TABLE_COLUMNS = {
063: { "fileVersionId", new Integer(Types.BIGINT) },
064:
065: { "companyId", new Integer(Types.BIGINT) },
066:
067: { "userId", new Integer(Types.BIGINT) },
068:
069: { "userName", new Integer(Types.VARCHAR) },
070:
071: { "createDate", new Integer(Types.TIMESTAMP) },
072:
073: { "folderId", new Integer(Types.BIGINT) },
074:
075: { "name", new Integer(Types.VARCHAR) },
076:
077: { "version", new Integer(Types.DOUBLE) },
078:
079: { "size_", new Integer(Types.INTEGER) } };
080: public static final String TABLE_SQL_CREATE = "create table DLFileVersion (fileVersionId LONG not null primary key,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,folderId LONG,name VARCHAR(300) null,version DOUBLE,size_ INTEGER)";
081: public static final String TABLE_SQL_DROP = "drop table DLFileVersion";
082: public static final boolean CACHE_ENABLED = GetterUtil
083: .getBoolean(
084: PropsUtil
085: .get("value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFileVersion"),
086: true);
087: public static final long LOCK_EXPIRATION_TIME = GetterUtil
088: .getLong(PropsUtil
089: .get("lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFileVersion"));
090:
091: public DLFileVersionModelImpl() {
092: }
093:
094: public long getPrimaryKey() {
095: return _fileVersionId;
096: }
097:
098: public void setPrimaryKey(long pk) {
099: setFileVersionId(pk);
100: }
101:
102: public Serializable getPrimaryKeyObj() {
103: return new Long(_fileVersionId);
104: }
105:
106: public long getFileVersionId() {
107: return _fileVersionId;
108: }
109:
110: public void setFileVersionId(long fileVersionId) {
111: if (fileVersionId != _fileVersionId) {
112: _fileVersionId = fileVersionId;
113: }
114: }
115:
116: public long getCompanyId() {
117: return _companyId;
118: }
119:
120: public void setCompanyId(long companyId) {
121: if (companyId != _companyId) {
122: _companyId = companyId;
123: }
124: }
125:
126: public long getUserId() {
127: return _userId;
128: }
129:
130: public void setUserId(long userId) {
131: if (userId != _userId) {
132: _userId = userId;
133: }
134: }
135:
136: public String getUserName() {
137: return GetterUtil.getString(_userName);
138: }
139:
140: public void setUserName(String userName) {
141: if (((userName == null) && (_userName != null))
142: || ((userName != null) && (_userName == null))
143: || ((userName != null) && (_userName != null) && !userName
144: .equals(_userName))) {
145: _userName = userName;
146: }
147: }
148:
149: public Date getCreateDate() {
150: return _createDate;
151: }
152:
153: public void setCreateDate(Date createDate) {
154: if (((createDate == null) && (_createDate != null))
155: || ((createDate != null) && (_createDate == null))
156: || ((createDate != null) && (_createDate != null) && !createDate
157: .equals(_createDate))) {
158: _createDate = createDate;
159: }
160: }
161:
162: public long getFolderId() {
163: return _folderId;
164: }
165:
166: public void setFolderId(long folderId) {
167: if (folderId != _folderId) {
168: _folderId = folderId;
169: }
170: }
171:
172: public String getName() {
173: return GetterUtil.getString(_name);
174: }
175:
176: public void setName(String name) {
177: if (((name == null) && (_name != null))
178: || ((name != null) && (_name == null))
179: || ((name != null) && (_name != null) && !name
180: .equals(_name))) {
181: _name = name;
182: }
183: }
184:
185: public double getVersion() {
186: return _version;
187: }
188:
189: public void setVersion(double version) {
190: if (version != _version) {
191: _version = version;
192: }
193: }
194:
195: public int getSize() {
196: return _size;
197: }
198:
199: public void setSize(int size) {
200: if (size != _size) {
201: _size = size;
202: }
203: }
204:
205: public DLFileVersion toEscapedModel() {
206: if (isEscapedModel()) {
207: return (DLFileVersion) this ;
208: } else {
209: DLFileVersion model = new DLFileVersionImpl();
210:
211: model.setEscapedModel(true);
212:
213: model.setFileVersionId(getFileVersionId());
214: model.setCompanyId(getCompanyId());
215: model.setUserId(getUserId());
216: model.setUserName(Html.escape(getUserName()));
217: model.setCreateDate(getCreateDate());
218: model.setFolderId(getFolderId());
219: model.setName(Html.escape(getName()));
220: model.setVersion(getVersion());
221: model.setSize(getSize());
222:
223: model = (DLFileVersion) Proxy.newProxyInstance(
224: DLFileVersion.class.getClassLoader(),
225: new Class[] { DLFileVersion.class },
226: new ReadOnlyBeanHandler(model));
227:
228: return model;
229: }
230: }
231:
232: public Object clone() {
233: DLFileVersionImpl clone = new DLFileVersionImpl();
234:
235: clone.setFileVersionId(getFileVersionId());
236: clone.setCompanyId(getCompanyId());
237: clone.setUserId(getUserId());
238: clone.setUserName(getUserName());
239: clone.setCreateDate(getCreateDate());
240: clone.setFolderId(getFolderId());
241: clone.setName(getName());
242: clone.setVersion(getVersion());
243: clone.setSize(getSize());
244:
245: return clone;
246: }
247:
248: public int compareTo(Object obj) {
249: if (obj == null) {
250: return -1;
251: }
252:
253: DLFileVersionImpl dlFileVersion = (DLFileVersionImpl) obj;
254:
255: int value = 0;
256:
257: if (getFolderId() < dlFileVersion.getFolderId()) {
258: value = -1;
259: } else if (getFolderId() > dlFileVersion.getFolderId()) {
260: value = 1;
261: } else {
262: value = 0;
263: }
264:
265: value = value * -1;
266:
267: if (value != 0) {
268: return value;
269: }
270:
271: value = getName().compareTo(dlFileVersion.getName());
272:
273: value = value * -1;
274:
275: if (value != 0) {
276: return value;
277: }
278:
279: if (getVersion() < dlFileVersion.getVersion()) {
280: value = -1;
281: } else if (getVersion() > dlFileVersion.getVersion()) {
282: value = 1;
283: } else {
284: value = 0;
285: }
286:
287: value = value * -1;
288:
289: if (value != 0) {
290: return value;
291: }
292:
293: return 0;
294: }
295:
296: public boolean equals(Object obj) {
297: if (obj == null) {
298: return false;
299: }
300:
301: DLFileVersionImpl dlFileVersion = null;
302:
303: try {
304: dlFileVersion = (DLFileVersionImpl) obj;
305: } catch (ClassCastException cce) {
306: return false;
307: }
308:
309: long pk = dlFileVersion.getPrimaryKey();
310:
311: if (getPrimaryKey() == pk) {
312: return true;
313: } else {
314: return false;
315: }
316: }
317:
318: public int hashCode() {
319: return (int) getPrimaryKey();
320: }
321:
322: private long _fileVersionId;
323: private long _companyId;
324: private long _userId;
325: private String _userName;
326: private Date _createDate;
327: private long _folderId;
328: private String _name;
329: private double _version;
330: private int _size;
331: }
|