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.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.HtmlUtil;
28  import com.liferay.portal.model.PluginSetting;
29  import com.liferay.portal.model.PluginSettingSoap;
30  import com.liferay.portal.util.PropsUtil;
31  
32  import java.io.Serializable;
33  
34  import java.lang.reflect.Proxy;
35  
36  import java.sql.Types;
37  
38  import java.util.ArrayList;
39  import java.util.List;
40  
41  /**
42   * <a href="PluginSettingModelImpl.java.html"><b><i>View Source</i></b></a>
43   *
44   * <p>
45   * ServiceBuilder generated this class. Modifications in this class will be
46   * overwritten the next time is generated.
47   * </p>
48   *
49   * <p>
50   * This class is a model that represents the <code>PluginSetting</code> table
51   * in the database.
52   * </p>
53   *
54   * @author Brian Wing Shun Chan
55   *
56   * @see com.liferay.portal.service.model.PluginSetting
57   * @see com.liferay.portal.service.model.PluginSettingModel
58   * @see com.liferay.portal.service.model.impl.PluginSettingImpl
59   *
60   */
61  public class PluginSettingModelImpl extends BaseModelImpl {
62      public static final String TABLE_NAME = "PluginSetting";
63      public static final Object[][] TABLE_COLUMNS = {
64              { "pluginSettingId", new Integer(Types.BIGINT) },
65              
66  
67              { "companyId", new Integer(Types.BIGINT) },
68              
69  
70              { "pluginId", new Integer(Types.VARCHAR) },
71              
72  
73              { "pluginType", new Integer(Types.VARCHAR) },
74              
75  
76              { "roles", new Integer(Types.VARCHAR) },
77              
78  
79              { "active_", new Integer(Types.BOOLEAN) }
80          };
81      public static final String TABLE_SQL_CREATE = "create table PluginSetting (pluginSettingId LONG not null primary key,companyId LONG,pluginId VARCHAR(75) null,pluginType VARCHAR(75) null,roles STRING null,active_ BOOLEAN)";
82      public static final String TABLE_SQL_DROP = "drop table PluginSetting";
83      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(PropsUtil.get(
84                  "value.object.finder.cache.enabled.com.liferay.portal.model.PluginSetting"),
85              true);
86  
87      public static PluginSetting toModel(PluginSettingSoap soapModel) {
88          PluginSetting model = new PluginSettingImpl();
89  
90          model.setPluginSettingId(soapModel.getPluginSettingId());
91          model.setCompanyId(soapModel.getCompanyId());
92          model.setPluginId(soapModel.getPluginId());
93          model.setPluginType(soapModel.getPluginType());
94          model.setRoles(soapModel.getRoles());
95          model.setActive(soapModel.getActive());
96  
97          return model;
98      }
99  
100     public static List<PluginSetting> toModels(PluginSettingSoap[] soapModels) {
101         List<PluginSetting> models = new ArrayList<PluginSetting>(soapModels.length);
102 
103         for (PluginSettingSoap soapModel : soapModels) {
104             models.add(toModel(soapModel));
105         }
106 
107         return models;
108     }
109 
110     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(PropsUtil.get(
111                 "lock.expiration.time.com.liferay.portal.model.PluginSetting"));
112 
113     public PluginSettingModelImpl() {
114     }
115 
116     public long getPrimaryKey() {
117         return _pluginSettingId;
118     }
119 
120     public void setPrimaryKey(long pk) {
121         setPluginSettingId(pk);
122     }
123 
124     public Serializable getPrimaryKeyObj() {
125         return new Long(_pluginSettingId);
126     }
127 
128     public long getPluginSettingId() {
129         return _pluginSettingId;
130     }
131 
132     public void setPluginSettingId(long pluginSettingId) {
133         if (pluginSettingId != _pluginSettingId) {
134             _pluginSettingId = pluginSettingId;
135         }
136     }
137 
138     public long getCompanyId() {
139         return _companyId;
140     }
141 
142     public void setCompanyId(long companyId) {
143         if (companyId != _companyId) {
144             _companyId = companyId;
145         }
146     }
147 
148     public String getPluginId() {
149         return GetterUtil.getString(_pluginId);
150     }
151 
152     public void setPluginId(String pluginId) {
153         if (((pluginId == null) && (_pluginId != null)) ||
154                 ((pluginId != null) && (_pluginId == null)) ||
155                 ((pluginId != null) && (_pluginId != null) &&
156                 !pluginId.equals(_pluginId))) {
157             _pluginId = pluginId;
158         }
159     }
160 
161     public String getPluginType() {
162         return GetterUtil.getString(_pluginType);
163     }
164 
165     public void setPluginType(String pluginType) {
166         if (((pluginType == null) && (_pluginType != null)) ||
167                 ((pluginType != null) && (_pluginType == null)) ||
168                 ((pluginType != null) && (_pluginType != null) &&
169                 !pluginType.equals(_pluginType))) {
170             _pluginType = pluginType;
171         }
172     }
173 
174     public String getRoles() {
175         return GetterUtil.getString(_roles);
176     }
177 
178     public void setRoles(String roles) {
179         if (((roles == null) && (_roles != null)) ||
180                 ((roles != null) && (_roles == null)) ||
181                 ((roles != null) && (_roles != null) && !roles.equals(_roles))) {
182             _roles = roles;
183         }
184     }
185 
186     public boolean getActive() {
187         return _active;
188     }
189 
190     public boolean isActive() {
191         return _active;
192     }
193 
194     public void setActive(boolean active) {
195         if (active != _active) {
196             _active = active;
197         }
198     }
199 
200     public PluginSetting toEscapedModel() {
201         if (isEscapedModel()) {
202             return (PluginSetting)this;
203         }
204         else {
205             PluginSetting model = new PluginSettingImpl();
206 
207             model.setEscapedModel(true);
208 
209             model.setPluginSettingId(getPluginSettingId());
210             model.setCompanyId(getCompanyId());
211             model.setPluginId(HtmlUtil.escape(getPluginId()));
212             model.setPluginType(HtmlUtil.escape(getPluginType()));
213             model.setRoles(HtmlUtil.escape(getRoles()));
214             model.setActive(getActive());
215 
216             model = (PluginSetting)Proxy.newProxyInstance(PluginSetting.class.getClassLoader(),
217                     new Class[] { PluginSetting.class },
218                     new ReadOnlyBeanHandler(model));
219 
220             return model;
221         }
222     }
223 
224     public Object clone() {
225         PluginSettingImpl clone = new PluginSettingImpl();
226 
227         clone.setPluginSettingId(getPluginSettingId());
228         clone.setCompanyId(getCompanyId());
229         clone.setPluginId(getPluginId());
230         clone.setPluginType(getPluginType());
231         clone.setRoles(getRoles());
232         clone.setActive(getActive());
233 
234         return clone;
235     }
236 
237     public int compareTo(Object obj) {
238         if (obj == null) {
239             return -1;
240         }
241 
242         PluginSettingImpl pluginSetting = (PluginSettingImpl)obj;
243 
244         long pk = pluginSetting.getPrimaryKey();
245 
246         if (getPrimaryKey() < pk) {
247             return -1;
248         }
249         else if (getPrimaryKey() > pk) {
250             return 1;
251         }
252         else {
253             return 0;
254         }
255     }
256 
257     public boolean equals(Object obj) {
258         if (obj == null) {
259             return false;
260         }
261 
262         PluginSettingImpl pluginSetting = null;
263 
264         try {
265             pluginSetting = (PluginSettingImpl)obj;
266         }
267         catch (ClassCastException cce) {
268             return false;
269         }
270 
271         long pk = pluginSetting.getPrimaryKey();
272 
273         if (getPrimaryKey() == pk) {
274             return true;
275         }
276         else {
277             return false;
278         }
279     }
280 
281     public int hashCode() {
282         return (int)getPrimaryKey();
283     }
284 
285     private long _pluginSettingId;
286     private long _companyId;
287     private String _pluginId;
288     private String _pluginType;
289     private String _roles;
290     private boolean _active;
291 }