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.portal.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="ResourceModelImpl.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>Resource_</code> table in the
45   * database.
46   * </p>
47   *
48   * @author Brian Wing Shun Chan
49   *
50   * @see com.liferay.portal.service.model.Resource
51   * @see com.liferay.portal.service.model.ResourceModel
52   * @see com.liferay.portal.service.model.impl.ResourceImpl
53   *
54   */
55  public class ResourceModelImpl extends BaseModelImpl {
56      public static String TABLE_NAME = "Resource_";
57      public static Object[][] TABLE_COLUMNS = {
58              { "resourceId", new Integer(Types.BIGINT) },
59              { "codeId", new Integer(Types.BIGINT) },
60              { "primKey", new Integer(Types.VARCHAR) }
61          };
62      public static String TABLE_SQL_CREATE = "create table Resource_ (resourceId LONG not null primary key,codeId LONG,primKey VARCHAR(300) null)";
63      public static String TABLE_SQL_DROP = "drop table Resource_";
64      public static boolean XSS_ALLOW_BY_MODEL = GetterUtil.getBoolean(PropsUtil.get(
65                  "xss.allow.com.liferay.portal.model.Resource"), XSS_ALLOW);
66      public static boolean XSS_ALLOW_PRIMKEY = GetterUtil.getBoolean(PropsUtil.get(
67                  "xss.allow.com.liferay.portal.model.Resource.primKey"),
68              XSS_ALLOW_BY_MODEL);
69      public static long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
70                  "lock.expiration.time.com.liferay.portal.model.ResourceModel"));
71  
72      public ResourceModelImpl() {
73      }
74  
75      public long getPrimaryKey() {
76          return _resourceId;
77      }
78  
79      public void setPrimaryKey(long pk) {
80          setResourceId(pk);
81      }
82  
83      public Serializable getPrimaryKeyObj() {
84          return new Long(_resourceId);
85      }
86  
87      public long getResourceId() {
88          return _resourceId;
89      }
90  
91      public void setResourceId(long resourceId) {
92          if (resourceId != _resourceId) {
93              _resourceId = resourceId;
94          }
95      }
96  
97      public long getCodeId() {
98          return _codeId;
99      }
100 
101     public void setCodeId(long codeId) {
102         if (codeId != _codeId) {
103             _codeId = codeId;
104         }
105     }
106 
107     public String getPrimKey() {
108         return GetterUtil.getString(_primKey);
109     }
110 
111     public void setPrimKey(String primKey) {
112         if (((primKey == null) && (_primKey != null)) ||
113                 ((primKey != null) && (_primKey == null)) ||
114                 ((primKey != null) && (_primKey != null) &&
115                 !primKey.equals(_primKey))) {
116             if (!XSS_ALLOW_PRIMKEY) {
117                 primKey = XSSUtil.strip(primKey);
118             }
119 
120             _primKey = primKey;
121         }
122     }
123 
124     public Object clone() {
125         ResourceImpl clone = new ResourceImpl();
126         clone.setResourceId(getResourceId());
127         clone.setCodeId(getCodeId());
128         clone.setPrimKey(getPrimKey());
129 
130         return clone;
131     }
132 
133     public int compareTo(Object obj) {
134         if (obj == null) {
135             return -1;
136         }
137 
138         ResourceImpl resource = (ResourceImpl)obj;
139         long pk = resource.getPrimaryKey();
140 
141         if (getPrimaryKey() < pk) {
142             return -1;
143         }
144         else if (getPrimaryKey() > pk) {
145             return 1;
146         }
147         else {
148             return 0;
149         }
150     }
151 
152     public boolean equals(Object obj) {
153         if (obj == null) {
154             return false;
155         }
156 
157         ResourceImpl resource = null;
158 
159         try {
160             resource = (ResourceImpl)obj;
161         }
162         catch (ClassCastException cce) {
163             return false;
164         }
165 
166         long pk = resource.getPrimaryKey();
167 
168         if (getPrimaryKey() == pk) {
169             return true;
170         }
171         else {
172             return false;
173         }
174     }
175 
176     public int hashCode() {
177         return (int)getPrimaryKey();
178     }
179 
180     private long _resourceId;
181     private long _codeId;
182     private String _primKey;
183 }