1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portlet.documentlibrary.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.impl.BaseModelImpl;
26  
27  import com.liferay.portlet.documentlibrary.model.DLFolder;
28  import com.liferay.portlet.documentlibrary.model.DLFolderSoap;
29  
30  import java.io.Serializable;
31  
32  import java.lang.reflect.Proxy;
33  
34  import java.sql.Types;
35  
36  import java.util.ArrayList;
37  import java.util.Date;
38  import java.util.List;
39  
40  /**
41   * <a href="DLFolderModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This class is a model that represents the <code>DLFolder</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.documentlibrary.model.DLFolder
56   * @see com.liferay.portlet.documentlibrary.model.DLFolderModel
57   * @see com.liferay.portlet.documentlibrary.model.impl.DLFolderImpl
58   *
59   */
60  public class DLFolderModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "DLFolder";
62      public static final Object[][] TABLE_COLUMNS = {
63              { "uuid_", new Integer(Types.VARCHAR) },
64              
65  
66              { "folderId", new Integer(Types.BIGINT) },
67              
68  
69              { "groupId", new Integer(Types.BIGINT) },
70              
71  
72              { "companyId", new Integer(Types.BIGINT) },
73              
74  
75              { "userId", new Integer(Types.BIGINT) },
76              
77  
78              { "userName", new Integer(Types.VARCHAR) },
79              
80  
81              { "createDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "modifiedDate", new Integer(Types.TIMESTAMP) },
85              
86  
87              { "parentFolderId", new Integer(Types.BIGINT) },
88              
89  
90              { "name", new Integer(Types.VARCHAR) },
91              
92  
93              { "description", new Integer(Types.VARCHAR) },
94              
95  
96              { "lastPostDate", new Integer(Types.TIMESTAMP) }
97          };
98      public static final String TABLE_SQL_CREATE = "create table DLFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,userName VARCHAR(75) null,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(100) null,description STRING null,lastPostDate DATE null)";
99      public static final String TABLE_SQL_DROP = "drop table DLFolder";
100     public static final String DATA_SOURCE = "liferayDataSource";
101     public static final String SESSION_FACTORY = "liferaySessionFactory";
102     public static final String TX_MANAGER = "liferayTransactionManager";
103     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
104                 "value.object.finder.cache.enabled.com.liferay.portlet.documentlibrary.model.DLFolder"),
105             true);
106 
107     public static DLFolder toModel(DLFolderSoap soapModel) {
108         DLFolder model = new DLFolderImpl();
109 
110         model.setUuid(soapModel.getUuid());
111         model.setFolderId(soapModel.getFolderId());
112         model.setGroupId(soapModel.getGroupId());
113         model.setCompanyId(soapModel.getCompanyId());
114         model.setUserId(soapModel.getUserId());
115         model.setUserName(soapModel.getUserName());
116         model.setCreateDate(soapModel.getCreateDate());
117         model.setModifiedDate(soapModel.getModifiedDate());
118         model.setParentFolderId(soapModel.getParentFolderId());
119         model.setName(soapModel.getName());
120         model.setDescription(soapModel.getDescription());
121         model.setLastPostDate(soapModel.getLastPostDate());
122 
123         return model;
124     }
125 
126     public static List<DLFolder> toModels(DLFolderSoap[] soapModels) {
127         List<DLFolder> models = new ArrayList<DLFolder>(soapModels.length);
128 
129         for (DLFolderSoap soapModel : soapModels) {
130             models.add(toModel(soapModel));
131         }
132 
133         return models;
134     }
135 
136     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
137                 "lock.expiration.time.com.liferay.portlet.documentlibrary.model.DLFolder"));
138 
139     public DLFolderModelImpl() {
140     }
141 
142     public long getPrimaryKey() {
143         return _folderId;
144     }
145 
146     public void setPrimaryKey(long pk) {
147         setFolderId(pk);
148     }
149 
150     public Serializable getPrimaryKeyObj() {
151         return new Long(_folderId);
152     }
153 
154     public String getUuid() {
155         return GetterUtil.getString(_uuid);
156     }
157 
158     public void setUuid(String uuid) {
159         if ((uuid != null) && (uuid != _uuid)) {
160             _uuid = uuid;
161         }
162     }
163 
164     public long getFolderId() {
165         return _folderId;
166     }
167 
168     public void setFolderId(long folderId) {
169         if (folderId != _folderId) {
170             _folderId = folderId;
171         }
172     }
173 
174     public long getGroupId() {
175         return _groupId;
176     }
177 
178     public void setGroupId(long groupId) {
179         if (groupId != _groupId) {
180             _groupId = groupId;
181         }
182     }
183 
184     public long getCompanyId() {
185         return _companyId;
186     }
187 
188     public void setCompanyId(long companyId) {
189         if (companyId != _companyId) {
190             _companyId = companyId;
191         }
192     }
193 
194     public long getUserId() {
195         return _userId;
196     }
197 
198     public void setUserId(long userId) {
199         if (userId != _userId) {
200             _userId = userId;
201         }
202     }
203 
204     public String getUserName() {
205         return GetterUtil.getString(_userName);
206     }
207 
208     public void setUserName(String userName) {
209         if (((userName == null) && (_userName != null)) ||
210                 ((userName != null) && (_userName == null)) ||
211                 ((userName != null) && (_userName != null) &&
212                 !userName.equals(_userName))) {
213             _userName = userName;
214         }
215     }
216 
217     public Date getCreateDate() {
218         return _createDate;
219     }
220 
221     public void setCreateDate(Date createDate) {
222         if (((createDate == null) && (_createDate != null)) ||
223                 ((createDate != null) && (_createDate == null)) ||
224                 ((createDate != null) && (_createDate != null) &&
225                 !createDate.equals(_createDate))) {
226             _createDate = createDate;
227         }
228     }
229 
230     public Date getModifiedDate() {
231         return _modifiedDate;
232     }
233 
234     public void setModifiedDate(Date modifiedDate) {
235         if (((modifiedDate == null) && (_modifiedDate != null)) ||
236                 ((modifiedDate != null) && (_modifiedDate == null)) ||
237                 ((modifiedDate != null) && (_modifiedDate != null) &&
238                 !modifiedDate.equals(_modifiedDate))) {
239             _modifiedDate = modifiedDate;
240         }
241     }
242 
243     public long getParentFolderId() {
244         return _parentFolderId;
245     }
246 
247     public void setParentFolderId(long parentFolderId) {
248         if (parentFolderId != _parentFolderId) {
249             _parentFolderId = parentFolderId;
250         }
251     }
252 
253     public String getName() {
254         return GetterUtil.getString(_name);
255     }
256 
257     public void setName(String name) {
258         if (((name == null) && (_name != null)) ||
259                 ((name != null) && (_name == null)) ||
260                 ((name != null) && (_name != null) && !name.equals(_name))) {
261             _name = name;
262         }
263     }
264 
265     public String getDescription() {
266         return GetterUtil.getString(_description);
267     }
268 
269     public void setDescription(String description) {
270         if (((description == null) && (_description != null)) ||
271                 ((description != null) && (_description == null)) ||
272                 ((description != null) && (_description != null) &&
273                 !description.equals(_description))) {
274             _description = description;
275         }
276     }
277 
278     public Date getLastPostDate() {
279         return _lastPostDate;
280     }
281 
282     public void setLastPostDate(Date lastPostDate) {
283         if (((lastPostDate == null) && (_lastPostDate != null)) ||
284                 ((lastPostDate != null) && (_lastPostDate == null)) ||
285                 ((lastPostDate != null) && (_lastPostDate != null) &&
286                 !lastPostDate.equals(_lastPostDate))) {
287             _lastPostDate = lastPostDate;
288         }
289     }
290 
291     public DLFolder toEscapedModel() {
292         if (isEscapedModel()) {
293             return (DLFolder)this;
294         }
295         else {
296             DLFolder model = new DLFolderImpl();
297 
298             model.setNew(isNew());
299             model.setEscapedModel(true);
300 
301             model.setUuid(HtmlUtil.escape(getUuid()));
302             model.setFolderId(getFolderId());
303             model.setGroupId(getGroupId());
304             model.setCompanyId(getCompanyId());
305             model.setUserId(getUserId());
306             model.setUserName(HtmlUtil.escape(getUserName()));
307             model.setCreateDate(getCreateDate());
308             model.setModifiedDate(getModifiedDate());
309             model.setParentFolderId(getParentFolderId());
310             model.setName(HtmlUtil.escape(getName()));
311             model.setDescription(HtmlUtil.escape(getDescription()));
312             model.setLastPostDate(getLastPostDate());
313 
314             model = (DLFolder)Proxy.newProxyInstance(DLFolder.class.getClassLoader(),
315                     new Class[] { DLFolder.class },
316                     new ReadOnlyBeanHandler(model));
317 
318             return model;
319         }
320     }
321 
322     public Object clone() {
323         DLFolderImpl clone = new DLFolderImpl();
324 
325         clone.setUuid(getUuid());
326         clone.setFolderId(getFolderId());
327         clone.setGroupId(getGroupId());
328         clone.setCompanyId(getCompanyId());
329         clone.setUserId(getUserId());
330         clone.setUserName(getUserName());
331         clone.setCreateDate(getCreateDate());
332         clone.setModifiedDate(getModifiedDate());
333         clone.setParentFolderId(getParentFolderId());
334         clone.setName(getName());
335         clone.setDescription(getDescription());
336         clone.setLastPostDate(getLastPostDate());
337 
338         return clone;
339     }
340 
341     public int compareTo(Object obj) {
342         if (obj == null) {
343             return -1;
344         }
345 
346         DLFolderImpl dlFolder = (DLFolderImpl)obj;
347 
348         int value = 0;
349 
350         if (getParentFolderId() < dlFolder.getParentFolderId()) {
351             value = -1;
352         }
353         else if (getParentFolderId() > dlFolder.getParentFolderId()) {
354             value = 1;
355         }
356         else {
357             value = 0;
358         }
359 
360         if (value != 0) {
361             return value;
362         }
363 
364         value = getName().toLowerCase()
365                     .compareTo(dlFolder.getName().toLowerCase());
366 
367         if (value != 0) {
368             return value;
369         }
370 
371         return 0;
372     }
373 
374     public boolean equals(Object obj) {
375         if (obj == null) {
376             return false;
377         }
378 
379         DLFolderImpl dlFolder = null;
380 
381         try {
382             dlFolder = (DLFolderImpl)obj;
383         }
384         catch (ClassCastException cce) {
385             return false;
386         }
387 
388         long pk = dlFolder.getPrimaryKey();
389 
390         if (getPrimaryKey() == pk) {
391             return true;
392         }
393         else {
394             return false;
395         }
396     }
397 
398     public int hashCode() {
399         return (int)getPrimaryKey();
400     }
401 
402     private String _uuid;
403     private long _folderId;
404     private long _groupId;
405     private long _companyId;
406     private long _userId;
407     private String _userName;
408     private Date _createDate;
409     private Date _modifiedDate;
410     private long _parentFolderId;
411     private String _name;
412     private String _description;
413     private Date _lastPostDate;
414 }