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