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.imagegallery.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.imagegallery.model.IGFolder;
28  import com.liferay.portlet.imagegallery.model.IGFolderSoap;
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="IGFolderModelImpl.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>IGFolder</code> table
50   * in the database.
51   * </p>
52   *
53   * @author Brian Wing Shun Chan
54   *
55   * @see com.liferay.portlet.imagegallery.model.IGFolder
56   * @see com.liferay.portlet.imagegallery.model.IGFolderModel
57   * @see com.liferay.portlet.imagegallery.model.impl.IGFolderImpl
58   *
59   */
60  public class IGFolderModelImpl extends BaseModelImpl {
61      public static final String TABLE_NAME = "IGFolder";
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              { "createDate", new Integer(Types.TIMESTAMP) },
79              
80  
81              { "modifiedDate", new Integer(Types.TIMESTAMP) },
82              
83  
84              { "parentFolderId", new Integer(Types.BIGINT) },
85              
86  
87              { "name", new Integer(Types.VARCHAR) },
88              
89  
90              { "description", new Integer(Types.VARCHAR) }
91          };
92      public static final String TABLE_SQL_CREATE = "create table IGFolder (uuid_ VARCHAR(75) null,folderId LONG not null primary key,groupId LONG,companyId LONG,userId LONG,createDate DATE null,modifiedDate DATE null,parentFolderId LONG,name VARCHAR(75) null,description STRING null)";
93      public static final String TABLE_SQL_DROP = "drop table IGFolder";
94      public static final String DATA_SOURCE = "liferayDataSource";
95      public static final String SESSION_FACTORY = "liferaySessionFactory";
96      public static final String TX_MANAGER = "liferayTransactionManager";
97      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
98                  "value.object.finder.cache.enabled.com.liferay.portlet.imagegallery.model.IGFolder"),
99              true);
100 
101     public static IGFolder toModel(IGFolderSoap soapModel) {
102         IGFolder model = new IGFolderImpl();
103 
104         model.setUuid(soapModel.getUuid());
105         model.setFolderId(soapModel.getFolderId());
106         model.setGroupId(soapModel.getGroupId());
107         model.setCompanyId(soapModel.getCompanyId());
108         model.setUserId(soapModel.getUserId());
109         model.setCreateDate(soapModel.getCreateDate());
110         model.setModifiedDate(soapModel.getModifiedDate());
111         model.setParentFolderId(soapModel.getParentFolderId());
112         model.setName(soapModel.getName());
113         model.setDescription(soapModel.getDescription());
114 
115         return model;
116     }
117 
118     public static List<IGFolder> toModels(IGFolderSoap[] soapModels) {
119         List<IGFolder> models = new ArrayList<IGFolder>(soapModels.length);
120 
121         for (IGFolderSoap soapModel : soapModels) {
122             models.add(toModel(soapModel));
123         }
124 
125         return models;
126     }
127 
128     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
129                 "lock.expiration.time.com.liferay.portlet.imagegallery.model.IGFolder"));
130 
131     public IGFolderModelImpl() {
132     }
133 
134     public long getPrimaryKey() {
135         return _folderId;
136     }
137 
138     public void setPrimaryKey(long pk) {
139         setFolderId(pk);
140     }
141 
142     public Serializable getPrimaryKeyObj() {
143         return new Long(_folderId);
144     }
145 
146     public String getUuid() {
147         return GetterUtil.getString(_uuid);
148     }
149 
150     public void setUuid(String uuid) {
151         if ((uuid != null) && (uuid != _uuid)) {
152             _uuid = uuid;
153         }
154     }
155 
156     public long getFolderId() {
157         return _folderId;
158     }
159 
160     public void setFolderId(long folderId) {
161         if (folderId != _folderId) {
162             _folderId = folderId;
163         }
164     }
165 
166     public long getGroupId() {
167         return _groupId;
168     }
169 
170     public void setGroupId(long groupId) {
171         if (groupId != _groupId) {
172             _groupId = groupId;
173         }
174     }
175 
176     public long getCompanyId() {
177         return _companyId;
178     }
179 
180     public void setCompanyId(long companyId) {
181         if (companyId != _companyId) {
182             _companyId = companyId;
183         }
184     }
185 
186     public long getUserId() {
187         return _userId;
188     }
189 
190     public void setUserId(long userId) {
191         if (userId != _userId) {
192             _userId = userId;
193         }
194     }
195 
196     public Date getCreateDate() {
197         return _createDate;
198     }
199 
200     public void setCreateDate(Date createDate) {
201         if (((createDate == null) && (_createDate != null)) ||
202                 ((createDate != null) && (_createDate == null)) ||
203                 ((createDate != null) && (_createDate != null) &&
204                 !createDate.equals(_createDate))) {
205             _createDate = createDate;
206         }
207     }
208 
209     public Date getModifiedDate() {
210         return _modifiedDate;
211     }
212 
213     public void setModifiedDate(Date modifiedDate) {
214         if (((modifiedDate == null) && (_modifiedDate != null)) ||
215                 ((modifiedDate != null) && (_modifiedDate == null)) ||
216                 ((modifiedDate != null) && (_modifiedDate != null) &&
217                 !modifiedDate.equals(_modifiedDate))) {
218             _modifiedDate = modifiedDate;
219         }
220     }
221 
222     public long getParentFolderId() {
223         return _parentFolderId;
224     }
225 
226     public void setParentFolderId(long parentFolderId) {
227         if (parentFolderId != _parentFolderId) {
228             _parentFolderId = parentFolderId;
229         }
230     }
231 
232     public String getName() {
233         return GetterUtil.getString(_name);
234     }
235 
236     public void setName(String name) {
237         if (((name == null) && (_name != null)) ||
238                 ((name != null) && (_name == null)) ||
239                 ((name != null) && (_name != null) && !name.equals(_name))) {
240             _name = name;
241         }
242     }
243 
244     public String getDescription() {
245         return GetterUtil.getString(_description);
246     }
247 
248     public void setDescription(String description) {
249         if (((description == null) && (_description != null)) ||
250                 ((description != null) && (_description == null)) ||
251                 ((description != null) && (_description != null) &&
252                 !description.equals(_description))) {
253             _description = description;
254         }
255     }
256 
257     public IGFolder toEscapedModel() {
258         if (isEscapedModel()) {
259             return (IGFolder)this;
260         }
261         else {
262             IGFolder model = new IGFolderImpl();
263 
264             model.setNew(isNew());
265             model.setEscapedModel(true);
266 
267             model.setUuid(HtmlUtil.escape(getUuid()));
268             model.setFolderId(getFolderId());
269             model.setGroupId(getGroupId());
270             model.setCompanyId(getCompanyId());
271             model.setUserId(getUserId());
272             model.setCreateDate(getCreateDate());
273             model.setModifiedDate(getModifiedDate());
274             model.setParentFolderId(getParentFolderId());
275             model.setName(HtmlUtil.escape(getName()));
276             model.setDescription(HtmlUtil.escape(getDescription()));
277 
278             model = (IGFolder)Proxy.newProxyInstance(IGFolder.class.getClassLoader(),
279                     new Class[] { IGFolder.class },
280                     new ReadOnlyBeanHandler(model));
281 
282             return model;
283         }
284     }
285 
286     public Object clone() {
287         IGFolderImpl clone = new IGFolderImpl();
288 
289         clone.setUuid(getUuid());
290         clone.setFolderId(getFolderId());
291         clone.setGroupId(getGroupId());
292         clone.setCompanyId(getCompanyId());
293         clone.setUserId(getUserId());
294         clone.setCreateDate(getCreateDate());
295         clone.setModifiedDate(getModifiedDate());
296         clone.setParentFolderId(getParentFolderId());
297         clone.setName(getName());
298         clone.setDescription(getDescription());
299 
300         return clone;
301     }
302 
303     public int compareTo(Object obj) {
304         if (obj == null) {
305             return -1;
306         }
307 
308         IGFolderImpl igFolder = (IGFolderImpl)obj;
309 
310         int value = 0;
311 
312         if (getFolderId() < igFolder.getFolderId()) {
313             value = -1;
314         }
315         else if (getFolderId() > igFolder.getFolderId()) {
316             value = 1;
317         }
318         else {
319             value = 0;
320         }
321 
322         if (value != 0) {
323             return value;
324         }
325 
326         value = getName().toLowerCase()
327                     .compareTo(igFolder.getName().toLowerCase());
328 
329         if (value != 0) {
330             return value;
331         }
332 
333         return 0;
334     }
335 
336     public boolean equals(Object obj) {
337         if (obj == null) {
338             return false;
339         }
340 
341         IGFolderImpl igFolder = null;
342 
343         try {
344             igFolder = (IGFolderImpl)obj;
345         }
346         catch (ClassCastException cce) {
347             return false;
348         }
349 
350         long pk = igFolder.getPrimaryKey();
351 
352         if (getPrimaryKey() == pk) {
353             return true;
354         }
355         else {
356             return false;
357         }
358     }
359 
360     public int hashCode() {
361         return (int)getPrimaryKey();
362     }
363 
364     private String _uuid;
365     private long _folderId;
366     private long _groupId;
367     private long _companyId;
368     private long _userId;
369     private Date _createDate;
370     private Date _modifiedDate;
371     private long _parentFolderId;
372     private String _name;
373     private String _description;
374 }