1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.Portlet;
22  import com.liferay.portal.model.PortletSoap;
23  
24  import java.io.Serializable;
25  
26  import java.lang.reflect.Proxy;
27  
28  import java.sql.Types;
29  
30  import java.util.ArrayList;
31  import java.util.List;
32  
33  /**
34   * <a href="PortletModelImpl.java.html"><b><i>View Source</i></b></a>
35   *
36   * <p>
37   * ServiceBuilder generated this class. Modifications in this class will be
38   * overwritten the next time is generated.
39   * </p>
40   *
41   * <p>
42   * This interface is a model that represents the Portlet table in the
43   * database.
44   * </p>
45   *
46   * @author    Brian Wing Shun Chan
47   * @see       PortletImpl
48   * @see       com.liferay.portal.model.Portlet
49   * @see       com.liferay.portal.model.PortletModel
50   * @generated
51   */
52  public class PortletModelImpl extends BaseModelImpl<Portlet> {
53      public static final String TABLE_NAME = "Portlet";
54      public static final Object[][] TABLE_COLUMNS = {
55              { "id_", new Integer(Types.BIGINT) },
56              { "companyId", new Integer(Types.BIGINT) },
57              { "portletId", new Integer(Types.VARCHAR) },
58              { "roles", new Integer(Types.VARCHAR) },
59              { "active_", new Integer(Types.BOOLEAN) }
60          };
61      public static final String TABLE_SQL_CREATE = "create table Portlet (id_ LONG not null primary key,companyId LONG,portletId VARCHAR(200) null,roles STRING null,active_ BOOLEAN)";
62      public static final String TABLE_SQL_DROP = "drop table Portlet";
63      public static final String DATA_SOURCE = "liferayDataSource";
64      public static final String SESSION_FACTORY = "liferaySessionFactory";
65      public static final String TX_MANAGER = "liferayTransactionManager";
66      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
67                  "value.object.entity.cache.enabled.com.liferay.portal.model.Portlet"),
68              true);
69      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
70                  "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
71              true);
72  
73      public static Portlet toModel(PortletSoap soapModel) {
74          Portlet model = new PortletImpl();
75  
76          model.setId(soapModel.getId());
77          model.setCompanyId(soapModel.getCompanyId());
78          model.setPortletId(soapModel.getPortletId());
79          model.setRoles(soapModel.getRoles());
80          model.setActive(soapModel.getActive());
81  
82          return model;
83      }
84  
85      public static List<Portlet> toModels(PortletSoap[] soapModels) {
86          List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
87  
88          for (PortletSoap soapModel : soapModels) {
89              models.add(toModel(soapModel));
90          }
91  
92          return models;
93      }
94  
95      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
96                  "lock.expiration.time.com.liferay.portal.model.Portlet"));
97  
98      public PortletModelImpl() {
99      }
100 
101     public long getPrimaryKey() {
102         return _id;
103     }
104 
105     public void setPrimaryKey(long pk) {
106         setId(pk);
107     }
108 
109     public Serializable getPrimaryKeyObj() {
110         return new Long(_id);
111     }
112 
113     public long getId() {
114         return _id;
115     }
116 
117     public void setId(long id) {
118         _id = id;
119     }
120 
121     public long getCompanyId() {
122         return _companyId;
123     }
124 
125     public void setCompanyId(long companyId) {
126         _companyId = companyId;
127 
128         if (!_setOriginalCompanyId) {
129             _setOriginalCompanyId = true;
130 
131             _originalCompanyId = companyId;
132         }
133     }
134 
135     public long getOriginalCompanyId() {
136         return _originalCompanyId;
137     }
138 
139     public String getPortletId() {
140         return GetterUtil.getString(_portletId);
141     }
142 
143     public void setPortletId(String portletId) {
144         _portletId = portletId;
145 
146         if (_originalPortletId == null) {
147             _originalPortletId = portletId;
148         }
149     }
150 
151     public String getOriginalPortletId() {
152         return GetterUtil.getString(_originalPortletId);
153     }
154 
155     public String getRoles() {
156         return GetterUtil.getString(_roles);
157     }
158 
159     public void setRoles(String roles) {
160         _roles = roles;
161     }
162 
163     public boolean getActive() {
164         return _active;
165     }
166 
167     public boolean isActive() {
168         return _active;
169     }
170 
171     public void setActive(boolean active) {
172         _active = active;
173     }
174 
175     public Portlet toEscapedModel() {
176         if (isEscapedModel()) {
177             return (Portlet)this;
178         }
179         else {
180             Portlet model = new PortletImpl();
181 
182             model.setNew(isNew());
183             model.setEscapedModel(true);
184 
185             model.setId(getId());
186             model.setCompanyId(getCompanyId());
187             model.setPortletId(HtmlUtil.escape(getPortletId()));
188             model.setRoles(HtmlUtil.escape(getRoles()));
189             model.setActive(getActive());
190 
191             model = (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
192                     new Class[] { Portlet.class },
193                     new ReadOnlyBeanHandler(model));
194 
195             return model;
196         }
197     }
198 
199     public Object clone() {
200         PortletImpl clone = new PortletImpl();
201 
202         clone.setId(getId());
203         clone.setCompanyId(getCompanyId());
204         clone.setPortletId(getPortletId());
205         clone.setRoles(getRoles());
206         clone.setActive(getActive());
207 
208         return clone;
209     }
210 
211     public int compareTo(Portlet portlet) {
212         long pk = portlet.getPrimaryKey();
213 
214         if (getPrimaryKey() < pk) {
215             return -1;
216         }
217         else if (getPrimaryKey() > pk) {
218             return 1;
219         }
220         else {
221             return 0;
222         }
223     }
224 
225     public boolean equals(Object obj) {
226         if (obj == null) {
227             return false;
228         }
229 
230         Portlet portlet = null;
231 
232         try {
233             portlet = (Portlet)obj;
234         }
235         catch (ClassCastException cce) {
236             return false;
237         }
238 
239         long pk = portlet.getPrimaryKey();
240 
241         if (getPrimaryKey() == pk) {
242             return true;
243         }
244         else {
245             return false;
246         }
247     }
248 
249     public int hashCode() {
250         return (int)getPrimaryKey();
251     }
252 
253     public String toString() {
254         StringBundler sb = new StringBundler(11);
255 
256         sb.append("{id=");
257         sb.append(getId());
258         sb.append(", companyId=");
259         sb.append(getCompanyId());
260         sb.append(", portletId=");
261         sb.append(getPortletId());
262         sb.append(", roles=");
263         sb.append(getRoles());
264         sb.append(", active=");
265         sb.append(getActive());
266         sb.append("}");
267 
268         return sb.toString();
269     }
270 
271     public String toXmlString() {
272         StringBundler sb = new StringBundler(19);
273 
274         sb.append("<model><model-name>");
275         sb.append("com.liferay.portal.model.Portlet");
276         sb.append("</model-name>");
277 
278         sb.append(
279             "<column><column-name>id</column-name><column-value><![CDATA[");
280         sb.append(getId());
281         sb.append("]]></column-value></column>");
282         sb.append(
283             "<column><column-name>companyId</column-name><column-value><![CDATA[");
284         sb.append(getCompanyId());
285         sb.append("]]></column-value></column>");
286         sb.append(
287             "<column><column-name>portletId</column-name><column-value><![CDATA[");
288         sb.append(getPortletId());
289         sb.append("]]></column-value></column>");
290         sb.append(
291             "<column><column-name>roles</column-name><column-value><![CDATA[");
292         sb.append(getRoles());
293         sb.append("]]></column-value></column>");
294         sb.append(
295             "<column><column-name>active</column-name><column-value><![CDATA[");
296         sb.append(getActive());
297         sb.append("]]></column-value></column>");
298 
299         sb.append("</model>");
300 
301         return sb.toString();
302     }
303 
304     private long _id;
305     private long _companyId;
306     private long _originalCompanyId;
307     private boolean _setOriginalCompanyId;
308     private String _portletId;
309     private String _originalPortletId;
310     private String _roles;
311     private boolean _active;
312 }