1   /**
2    * Copyright (c) 2000-2007 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.util.GetterUtil;
26  import com.liferay.portal.model.impl.BaseModelImpl;
27  import com.liferay.portal.util.PropsUtil;
28  
29  import com.liferay.util.XSSUtil;
30  
31  import java.io.Serializable;
32  
33  import java.sql.Types;
34  
35  /**
36   * <a href="JournalArticleResourceModelImpl.java.html"><b><i>View Source</i></b></a>
37   *
38   * <p>
39   * ServiceBuilder generated this class. Modifications in this class will be overwritten
40   * the next time is generated.
41   * </p>
42   *
43   * <p>
44   * This class is a model that represents the <code>JournalArticleResource</code>
45   * table in the database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portlet.journal.service.model.JournalArticleResource
51   * @see com.liferay.portlet.journal.service.model.JournalArticleResourceModel
52   * @see com.liferay.portlet.journal.service.model.impl.JournalArticleResourceImpl
53   *
54   */
55  public class JournalArticleResourceModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "JournalArticleResource";
57      public static Object[][] TABLE_COLUMNS = {
58              { "resourcePrimKey", new Integer(Types.BIGINT) },
59              { "groupId", new Integer(Types.BIGINT) },
60              { "articleId", new Integer(Types.VARCHAR) }
61          };
62      public static String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
63      public static String TABLE_SQL_DROP = "drop table JournalArticleResource";
64      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
65                  "xss.allow.com.liferay.portlet.journal.model.JournalArticleResource"),
66              XSS_ALLOW);
67      public static boolean XSS_ALLOW_ARTICLEID = GetterUtil.getBoolean(PropsUtil.get(
68                  "xss.allow.com.liferay.portlet.journal.model.JournalArticleResource.articleId"),
69              XSS_ALLOW_BY_MODEL);
70      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
71                  "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResourceModel"));
72  
73      public JournalArticleResourceModelImpl() {
74      }
75  
76      public long getPrimaryKey() {
77          return _resourcePrimKey;
78      }
79  
80      public void setPrimaryKey(long pk) {
81          setResourcePrimKey(pk);
82      }
83  
84      public Serializable getPrimaryKeyObj() {
85          return new Long(_resourcePrimKey);
86      }
87  
88      public long getResourcePrimKey() {
89          return _resourcePrimKey;
90      }
91  
92      public void setResourcePrimKey(long resourcePrimKey) {
93          if (resourcePrimKey != _resourcePrimKey) {
94              _resourcePrimKey = resourcePrimKey;
95          }
96      }
97  
98      public long getGroupId() {
99          return _groupId;
100     }
101 
102     public void setGroupId(long groupId) {
103         if (groupId != _groupId) {
104             _groupId = groupId;
105         }
106     }
107 
108     public String getArticleId() {
109         return GetterUtil.getString(_articleId);
110     }
111 
112     public void setArticleId(String articleId) {
113         if (((articleId == null) && (_articleId != null)) ||
114                 ((articleId != null) && (_articleId == null)) ||
115                 ((articleId != null) && (_articleId != null) &&
116                 !articleId.equals(_articleId))) {
117             if (!XSS_ALLOW_ARTICLEID) {
118                 articleId = XSSUtil.strip(articleId);
119             }
120 
121             _articleId = articleId;
122         }
123     }
124 
125     public Object clone() {
126         JournalArticleResourceImpl clone = new JournalArticleResourceImpl();
127         clone.setResourcePrimKey(getResourcePrimKey());
128         clone.setGroupId(getGroupId());
129         clone.setArticleId(getArticleId());
130 
131         return clone;
132     }
133 
134     public int compareTo(Object obj) {
135         if (obj == null) {
136             return -1;
137         }
138 
139         JournalArticleResourceImpl journalArticleResource = (JournalArticleResourceImpl)obj;
140         long pk = journalArticleResource.getPrimaryKey();
141 
142         if (getPrimaryKey() < pk) {
143             return -1;
144         }
145         else if (getPrimaryKey() > pk) {
146             return 1;
147         }
148         else {
149             return 0;
150         }
151     }
152 
153     public boolean equals(Object obj) {
154         if (obj == null) {
155             return false;
156         }
157 
158         JournalArticleResourceImpl journalArticleResource = null;
159 
160         try {
161             journalArticleResource = (JournalArticleResourceImpl)obj;
162         }
163         catch (ClassCastException cce) {
164             return false;
165         }
166 
167         long pk = journalArticleResource.getPrimaryKey();
168 
169         if (getPrimaryKey() == pk) {
170             return true;
171         }
172         else {
173             return false;
174         }
175     }
176 
177     public int hashCode() {
178         return (int)getPrimaryKey();
179     }
180 
181     private long _resourcePrimKey;
182     private long _groupId;
183     private String _articleId;
184 }