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.portal.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.StringPool;
28  import com.liferay.portal.model.PasswordPolicyRel;
29  import com.liferay.portal.model.PasswordPolicyRelSoap;
30  import com.liferay.portal.util.PortalUtil;
31  
32  import com.liferay.portlet.expando.model.ExpandoBridge;
33  import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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.List;
43  
44  /**
45   * <a href="PasswordPolicyRelModelImpl.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>PasswordPolicyRel</code> table
54   * in the database.
55   * </p>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   * @see com.liferay.portal.model.PasswordPolicyRel
60   * @see com.liferay.portal.model.PasswordPolicyRelModel
61   * @see com.liferay.portal.model.impl.PasswordPolicyRelImpl
62   *
63   */
64  public class PasswordPolicyRelModelImpl extends BaseModelImpl {
65      public static final String TABLE_NAME = "PasswordPolicyRel";
66      public static final Object[][] TABLE_COLUMNS = {
67              { "passwordPolicyRelId", new Integer(Types.BIGINT) },
68              
69  
70              { "passwordPolicyId", new Integer(Types.BIGINT) },
71              
72  
73              { "classNameId", new Integer(Types.BIGINT) },
74              
75  
76              { "classPK", new Integer(Types.BIGINT) }
77          };
78      public static final String TABLE_SQL_CREATE = "create table PasswordPolicyRel (passwordPolicyRelId LONG not null primary key,passwordPolicyId LONG,classNameId LONG,classPK LONG)";
79      public static final String TABLE_SQL_DROP = "drop table PasswordPolicyRel";
80      public static final String DATA_SOURCE = "liferayDataSource";
81      public static final String SESSION_FACTORY = "liferaySessionFactory";
82      public static final String TX_MANAGER = "liferayTransactionManager";
83      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portal.model.PasswordPolicyRel"),
85              true);
86  
87      public static PasswordPolicyRel toModel(PasswordPolicyRelSoap soapModel) {
88          PasswordPolicyRel model = new PasswordPolicyRelImpl();
89  
90          model.setPasswordPolicyRelId(soapModel.getPasswordPolicyRelId());
91          model.setPasswordPolicyId(soapModel.getPasswordPolicyId());
92          model.setClassNameId(soapModel.getClassNameId());
93          model.setClassPK(soapModel.getClassPK());
94  
95          return model;
96      }
97  
98      public static List<PasswordPolicyRel> toModels(
99          PasswordPolicyRelSoap[] soapModels) {
100         List<PasswordPolicyRel> models = new ArrayList<PasswordPolicyRel>(soapModels.length);
101 
102         for (PasswordPolicyRelSoap soapModel : soapModels) {
103             models.add(toModel(soapModel));
104         }
105 
106         return models;
107     }
108 
109     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
110                 "lock.expiration.time.com.liferay.portal.model.PasswordPolicyRel"));
111 
112     public PasswordPolicyRelModelImpl() {
113     }
114 
115     public long getPrimaryKey() {
116         return _passwordPolicyRelId;
117     }
118 
119     public void setPrimaryKey(long pk) {
120         setPasswordPolicyRelId(pk);
121     }
122 
123     public Serializable getPrimaryKeyObj() {
124         return new Long(_passwordPolicyRelId);
125     }
126 
127     public long getPasswordPolicyRelId() {
128         return _passwordPolicyRelId;
129     }
130 
131     public void setPasswordPolicyRelId(long passwordPolicyRelId) {
132         if (passwordPolicyRelId != _passwordPolicyRelId) {
133             _passwordPolicyRelId = passwordPolicyRelId;
134         }
135     }
136 
137     public long getPasswordPolicyId() {
138         return _passwordPolicyId;
139     }
140 
141     public void setPasswordPolicyId(long passwordPolicyId) {
142         if (passwordPolicyId != _passwordPolicyId) {
143             _passwordPolicyId = passwordPolicyId;
144         }
145     }
146 
147     public String getClassName() {
148         if (getClassNameId() <= 0) {
149             return StringPool.BLANK;
150         }
151 
152         return PortalUtil.getClassName(getClassNameId());
153     }
154 
155     public long getClassNameId() {
156         return _classNameId;
157     }
158 
159     public void setClassNameId(long classNameId) {
160         if (classNameId != _classNameId) {
161             _classNameId = classNameId;
162         }
163     }
164 
165     public long getClassPK() {
166         return _classPK;
167     }
168 
169     public void setClassPK(long classPK) {
170         if (classPK != _classPK) {
171             _classPK = classPK;
172         }
173     }
174 
175     public PasswordPolicyRel toEscapedModel() {
176         if (isEscapedModel()) {
177             return (PasswordPolicyRel)this;
178         }
179         else {
180             PasswordPolicyRel model = new PasswordPolicyRelImpl();
181 
182             model.setNew(isNew());
183             model.setEscapedModel(true);
184 
185             model.setPasswordPolicyRelId(getPasswordPolicyRelId());
186             model.setPasswordPolicyId(getPasswordPolicyId());
187             model.setClassNameId(getClassNameId());
188             model.setClassPK(getClassPK());
189 
190             model = (PasswordPolicyRel)Proxy.newProxyInstance(PasswordPolicyRel.class.getClassLoader(),
191                     new Class[] { PasswordPolicyRel.class },
192                     new ReadOnlyBeanHandler(model));
193 
194             return model;
195         }
196     }
197 
198     public ExpandoBridge getExpandoBridge() {
199         if (_expandoBridge == null) {
200             _expandoBridge = new ExpandoBridgeImpl(PasswordPolicyRel.class.getName(),
201                     getPrimaryKey());
202         }
203 
204         return _expandoBridge;
205     }
206 
207     public Object clone() {
208         PasswordPolicyRelImpl clone = new PasswordPolicyRelImpl();
209 
210         clone.setPasswordPolicyRelId(getPasswordPolicyRelId());
211         clone.setPasswordPolicyId(getPasswordPolicyId());
212         clone.setClassNameId(getClassNameId());
213         clone.setClassPK(getClassPK());
214 
215         return clone;
216     }
217 
218     public int compareTo(Object obj) {
219         if (obj == null) {
220             return -1;
221         }
222 
223         PasswordPolicyRelImpl passwordPolicyRel = (PasswordPolicyRelImpl)obj;
224 
225         long pk = passwordPolicyRel.getPrimaryKey();
226 
227         if (getPrimaryKey() < pk) {
228             return -1;
229         }
230         else if (getPrimaryKey() > pk) {
231             return 1;
232         }
233         else {
234             return 0;
235         }
236     }
237 
238     public boolean equals(Object obj) {
239         if (obj == null) {
240             return false;
241         }
242 
243         PasswordPolicyRelImpl passwordPolicyRel = null;
244 
245         try {
246             passwordPolicyRel = (PasswordPolicyRelImpl)obj;
247         }
248         catch (ClassCastException cce) {
249             return false;
250         }
251 
252         long pk = passwordPolicyRel.getPrimaryKey();
253 
254         if (getPrimaryKey() == pk) {
255             return true;
256         }
257         else {
258             return false;
259         }
260     }
261 
262     public int hashCode() {
263         return (int)getPrimaryKey();
264     }
265 
266     private long _passwordPolicyRelId;
267     private long _passwordPolicyId;
268     private long _classNameId;
269     private long _classPK;
270     private transient ExpandoBridge _expandoBridge;
271 }