1   /**
2    * Copyright (c) 2000-2008 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  import com.liferay.portal.util.PropsUtil;
30  
31  import com.liferay.portlet.journal.model.JournalStructure;
32  import com.liferay.portlet.journal.model.JournalStructureSoap;
33  
34  import java.io.Serializable;
35  
36  import java.lang.reflect.Proxy;
37  
38  import java.sql.Types;
39  
40  import java.util.ArrayList;
41  import java.util.Date;
42  import java.util.List;
43  
44  /**
45   * <a href="JournalStructureModelImpl.java.html"><b><i>View Source</i></b></a>
46   *
47   * <p>
48   * ServiceBuilder generated this class. Modifications in this class will be
49   * overwritten the next time is generated.
50   * </p>
51   *
52   * <p>
53   * This class is a model that represents the <code>JournalStructure</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portlet.journal.service.model.JournalStructure
60   * @see com.liferay.portlet.journal.service.model.JournalStructureModel
61   * @see com.liferay.portlet.journal.service.model.impl.JournalStructureImpl
62   *
63   */
64  public class JournalStructureModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "JournalStructure";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "uuid_", new Integer(Types.VARCHAR) },
68              
69  
70              { "id_", new Integer(Types.BIGINT) },
71              
72  
73              { "groupId", new Integer(Types.BIGINT) },
74              
75  
76              { "companyId", new Integer(Types.BIGINT) },
77              
78  
79              { "userId", new Integer(Types.BIGINT) },
80              
81  
82              { "userName", new Integer(Types.VARCHAR) },
83              
84  
85              { "createDate", new Integer(Types.TIMESTAMP) },
86              
87  
88              { "modifiedDate", new Integer(Types.TIMESTAMP) },
89              
90  
91              { "structureId", new Integer(Types.VARCHAR) },
92              
93  
94              { "name", new Integer(Types.VARCHAR) },
95              
96  
97              { "description", new Integer(Types.VARCHAR) },
98              
99  
100             { "xsd", new Integer(Types.CLOB) }
101         };
102     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,name VARCHAR(75) null,description STRING null,xsd TEXT null)";
103     public static final String TABLE_SQL_DROP = "drop table JournalStructure";
104     public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
105                 "value.object.finder.cache.enabled.com.liferay.portlet.journal.model.JournalStructure"),
106             true);
107 
108     public static JournalStructure toModel(JournalStructureSoap soapModel) {
109         JournalStructure model = new JournalStructureImpl();
110 
111         model.setUuid(soapModel.getUuid());
112         model.setId(soapModel.getId());
113         model.setGroupId(soapModel.getGroupId());
114         model.setCompanyId(soapModel.getCompanyId());
115         model.setUserId(soapModel.getUserId());
116         model.setUserName(soapModel.getUserName());
117         model.setCreateDate(soapModel.getCreateDate());
118         model.setModifiedDate(soapModel.getModifiedDate());
119         model.setStructureId(soapModel.getStructureId());
120         model.setName(soapModel.getName());
121         model.setDescription(soapModel.getDescription());
122         model.setXsd(soapModel.getXsd());
123 
124         return model;
125     }
126 
127     public static List<JournalStructure> toModels(
128         JournalStructureSoap[] soapModels) {
129         List<JournalStructure> models = new ArrayList<JournalStructure>(soapModels.length);
130 
131         for (JournalStructureSoap soapModel : soapModels) {
132             models.add(toModel(soapModel));
133         }
134 
135         return models;
136     }
137 
138     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
139                 "lock.expiration.time.com.liferay.portlet.journal.model.JournalStructure"));
140 
141     public JournalStructureModelImpl() {
142     }
143 
144     public long getPrimaryKey() {
145         return _id;
146     }
147 
148     public void setPrimaryKey(long pk) {
149         setId(pk);
150     }
151 
152     public Serializable getPrimaryKeyObj() {
153         return new Long(_id);
154     }
155 
156     public String getUuid() {
157         return GetterUtil.getString(_uuid);
158     }
159 
160     public void setUuid(String uuid) {
161         if ((uuid != null) && (uuid != _uuid)) {
162             _uuid = uuid;
163         }
164     }
165 
166     public long getId() {
167         return _id;
168     }
169 
170     public void setId(long id) {
171         if (id != _id) {
172             _id = id;
173         }
174     }
175 
176     public long getGroupId() {
177         return _groupId;
178     }
179 
180     public void setGroupId(long groupId) {
181         if (groupId != _groupId) {
182             _groupId = groupId;
183         }
184     }
185 
186     public long getCompanyId() {
187         return _companyId;
188     }
189 
190     public void setCompanyId(long companyId) {
191         if (companyId != _companyId) {
192             _companyId = companyId;
193         }
194     }
195 
196     public long getUserId() {
197         return _userId;
198     }
199 
200     public void setUserId(long userId) {
201         if (userId != _userId) {
202             _userId = userId;
203         }
204     }
205 
206     public String getUserName() {
207         return GetterUtil.getString(_userName);
208     }
209 
210     public void setUserName(String userName) {
211         if (((userName == null) && (_userName != null)) ||
212                 ((userName != null) && (_userName == null)) ||
213                 ((userName != null) && (_userName != null) &&
214                 !userName.equals(_userName))) {
215             _userName = userName;
216         }
217     }
218 
219     public Date getCreateDate() {
220         return _createDate;
221     }
222 
223     public void setCreateDate(Date createDate) {
224         if (((createDate == null) && (_createDate != null)) ||
225                 ((createDate != null) && (_createDate == null)) ||
226                 ((createDate != null) && (_createDate != null) &&
227                 !createDate.equals(_createDate))) {
228             _createDate = createDate;
229         }
230     }
231 
232     public Date getModifiedDate() {
233         return _modifiedDate;
234     }
235 
236     public void setModifiedDate(Date modifiedDate) {
237         if (((modifiedDate == null) && (_modifiedDate != null)) ||
238                 ((modifiedDate != null) && (_modifiedDate == null)) ||
239                 ((modifiedDate != null) && (_modifiedDate != null) &&
240                 !modifiedDate.equals(_modifiedDate))) {
241             _modifiedDate = modifiedDate;
242         }
243     }
244 
245     public String getStructureId() {
246         return GetterUtil.getString(_structureId);
247     }
248 
249     public void setStructureId(String structureId) {
250         if (((structureId == null) && (_structureId != null)) ||
251                 ((structureId != null) && (_structureId == null)) ||
252                 ((structureId != null) && (_structureId != null) &&
253                 !structureId.equals(_structureId))) {
254             _structureId = structureId;
255         }
256     }
257 
258     public String getName() {
259         return GetterUtil.getString(_name);
260     }
261 
262     public void setName(String name) {
263         if (((name == null) && (_name != null)) ||
264                 ((name != null) && (_name == null)) ||
265                 ((name != null) && (_name != null) && !name.equals(_name))) {
266             _name = name;
267         }
268     }
269 
270     public String getDescription() {
271         return GetterUtil.getString(_description);
272     }
273 
274     public void setDescription(String description) {
275         if (((description == null) && (_description != null)) ||
276                 ((description != null) && (_description == null)) ||
277                 ((description != null) && (_description != null) &&
278                 !description.equals(_description))) {
279             _description = description;
280         }
281     }
282 
283     public String getXsd() {
284         return GetterUtil.getString(_xsd);
285     }
286 
287     public void setXsd(String xsd) {
288         if (((xsd == null) && (_xsd != null)) ||
289                 ((xsd != null) && (_xsd == null)) ||
290                 ((xsd != null) && (_xsd != null) && !xsd.equals(_xsd))) {
291             _xsd = xsd;
292         }
293     }
294 
295     public JournalStructure toEscapedModel() {
296         if (isEscapedModel()) {
297             return (JournalStructure)this;
298         }
299         else {
300             JournalStructure model = new JournalStructureImpl();
301 
302             model.setEscapedModel(true);
303 
304             model.setUuid(HtmlUtil.escape(getUuid()));
305             model.setId(getId());
306             model.setGroupId(getGroupId());
307             model.setCompanyId(getCompanyId());
308             model.setUserId(getUserId());
309             model.setUserName(HtmlUtil.escape(getUserName()));
310             model.setCreateDate(getCreateDate());
311             model.setModifiedDate(getModifiedDate());
312             model.setStructureId(getStructureId());
313             model.setName(HtmlUtil.escape(getName()));
314             model.setDescription(HtmlUtil.escape(getDescription()));
315             model.setXsd(HtmlUtil.escape(getXsd()));
316 
317             model = (JournalStructure)Proxy.newProxyInstance(JournalStructure.class.getClassLoader(),
318                     new Class[] { JournalStructure.class },
319                     new ReadOnlyBeanHandler(model));
320 
321             return model;
322         }
323     }
324 
325     public Object clone() {
326         JournalStructureImpl clone = new JournalStructureImpl();
327 
328         clone.setUuid(getUuid());
329         clone.setId(getId());
330         clone.setGroupId(getGroupId());
331         clone.setCompanyId(getCompanyId());
332         clone.setUserId(getUserId());
333         clone.setUserName(getUserName());
334         clone.setCreateDate(getCreateDate());
335         clone.setModifiedDate(getModifiedDate());
336         clone.setStructureId(getStructureId());
337         clone.setName(getName());
338         clone.setDescription(getDescription());
339         clone.setXsd(getXsd());
340 
341         return clone;
342     }
343 
344     public int compareTo(Object obj) {
345         if (obj == null) {
346             return -1;
347         }
348 
349         JournalStructureImpl journalStructure = (JournalStructureImpl)obj;
350 
351         int value = 0;
352 
353         value = getStructureId().compareTo(journalStructure.getStructureId());
354 
355         if (value != 0) {
356             return value;
357         }
358 
359         return 0;
360     }
361 
362     public boolean equals(Object obj) {
363         if (obj == null) {
364             return false;
365         }
366 
367         JournalStructureImpl journalStructure = null;
368 
369         try {
370             journalStructure = (JournalStructureImpl)obj;
371         }
372         catch (ClassCastException cce) {
373             return false;
374         }
375 
376         long pk = journalStructure.getPrimaryKey();
377 
378         if (getPrimaryKey() == pk) {
379             return true;
380         }
381         else {
382             return false;
383         }
384     }
385 
386     public int hashCode() {
387         return (int)getPrimaryKey();
388     }
389 
390     private String _uuid;
391     private long _id;
392     private long _groupId;
393     private long _companyId;
394     private long _userId;
395     private String _userName;
396     private Date _createDate;
397     private Date _modifiedDate;
398     private String _structureId;
399     private String _name;
400     private String _description;
401     private String _xsd;
402 }