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.AutoEscapeBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.StringBundler;
20  import com.liferay.portal.kernel.util.StringPool;
21  import com.liferay.portal.model.Portlet;
22  import com.liferay.portal.model.PortletSoap;
23  import com.liferay.portal.service.ServiceContext;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="PortletModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the Portlet table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       PortletImpl
52   * @see       com.liferay.portal.model.Portlet
53   * @see       com.liferay.portal.model.PortletModel
54   * @generated
55   */
56  public class PortletModelImpl extends BaseModelImpl<Portlet> {
57      public static final String TABLE_NAME = "Portlet";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "id_", new Integer(Types.BIGINT) },
60              { "companyId", new Integer(Types.BIGINT) },
61              { "portletId", new Integer(Types.VARCHAR) },
62              { "roles", new Integer(Types.VARCHAR) },
63              { "active_", new Integer(Types.BOOLEAN) }
64          };
65      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)";
66      public static final String TABLE_SQL_DROP = "drop table Portlet";
67      public static final String DATA_SOURCE = "liferayDataSource";
68      public static final String SESSION_FACTORY = "liferaySessionFactory";
69      public static final String TX_MANAGER = "liferayTransactionManager";
70      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
71                  "value.object.entity.cache.enabled.com.liferay.portal.model.Portlet"),
72              true);
73      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
75              true);
76  
77      public static Portlet toModel(PortletSoap soapModel) {
78          Portlet model = new PortletImpl();
79  
80          model.setId(soapModel.getId());
81          model.setCompanyId(soapModel.getCompanyId());
82          model.setPortletId(soapModel.getPortletId());
83          model.setRoles(soapModel.getRoles());
84          model.setActive(soapModel.getActive());
85  
86          return model;
87      }
88  
89      public static List<Portlet> toModels(PortletSoap[] soapModels) {
90          List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
91  
92          for (PortletSoap soapModel : soapModels) {
93              models.add(toModel(soapModel));
94          }
95  
96          return models;
97      }
98  
99      public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
100                 "lock.expiration.time.com.liferay.portal.model.Portlet"));
101 
102     public PortletModelImpl() {
103     }
104 
105     public long getPrimaryKey() {
106         return _id;
107     }
108 
109     public void setPrimaryKey(long pk) {
110         setId(pk);
111     }
112 
113     public Serializable getPrimaryKeyObj() {
114         return new Long(_id);
115     }
116 
117     public long getId() {
118         return _id;
119     }
120 
121     public void setId(long id) {
122         _id = id;
123     }
124 
125     public long getCompanyId() {
126         return _companyId;
127     }
128 
129     public void setCompanyId(long companyId) {
130         _companyId = companyId;
131 
132         if (!_setOriginalCompanyId) {
133             _setOriginalCompanyId = true;
134 
135             _originalCompanyId = companyId;
136         }
137     }
138 
139     public long getOriginalCompanyId() {
140         return _originalCompanyId;
141     }
142 
143     public String getPortletId() {
144         if (_portletId == null) {
145             return StringPool.BLANK;
146         }
147         else {
148             return _portletId;
149         }
150     }
151 
152     public void setPortletId(String portletId) {
153         _portletId = portletId;
154 
155         if (_originalPortletId == null) {
156             _originalPortletId = portletId;
157         }
158     }
159 
160     public String getOriginalPortletId() {
161         return GetterUtil.getString(_originalPortletId);
162     }
163 
164     public String getRoles() {
165         if (_roles == null) {
166             return StringPool.BLANK;
167         }
168         else {
169             return _roles;
170         }
171     }
172 
173     public void setRoles(String roles) {
174         _roles = roles;
175     }
176 
177     public boolean getActive() {
178         return _active;
179     }
180 
181     public boolean isActive() {
182         return _active;
183     }
184 
185     public void setActive(boolean active) {
186         _active = active;
187     }
188 
189     public Portlet toEscapedModel() {
190         if (isEscapedModel()) {
191             return (Portlet)this;
192         }
193         else {
194             return (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
195                 new Class[] { Portlet.class }, new AutoEscapeBeanHandler(this));
196         }
197     }
198 
199     public ExpandoBridge getExpandoBridge() {
200         if (_expandoBridge == null) {
201             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Portlet.class.getName(),
202                     getPrimaryKey());
203         }
204 
205         return _expandoBridge;
206     }
207 
208     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
209         getExpandoBridge().setAttributes(serviceContext);
210     }
211 
212     public Object clone() {
213         PortletImpl clone = new PortletImpl();
214 
215         clone.setId(getId());
216         clone.setCompanyId(getCompanyId());
217         clone.setPortletId(getPortletId());
218         clone.setRoles(getRoles());
219         clone.setActive(getActive());
220 
221         return clone;
222     }
223 
224     public int compareTo(Portlet portlet) {
225         long pk = portlet.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         Portlet portlet = null;
244 
245         try {
246             portlet = (Portlet)obj;
247         }
248         catch (ClassCastException cce) {
249             return false;
250         }
251 
252         long pk = portlet.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     public String toString() {
267         StringBundler sb = new StringBundler(11);
268 
269         sb.append("{id=");
270         sb.append(getId());
271         sb.append(", companyId=");
272         sb.append(getCompanyId());
273         sb.append(", portletId=");
274         sb.append(getPortletId());
275         sb.append(", roles=");
276         sb.append(getRoles());
277         sb.append(", active=");
278         sb.append(getActive());
279         sb.append("}");
280 
281         return sb.toString();
282     }
283 
284     public String toXmlString() {
285         StringBundler sb = new StringBundler(19);
286 
287         sb.append("<model><model-name>");
288         sb.append("com.liferay.portal.model.Portlet");
289         sb.append("</model-name>");
290 
291         sb.append(
292             "<column><column-name>id</column-name><column-value><![CDATA[");
293         sb.append(getId());
294         sb.append("]]></column-value></column>");
295         sb.append(
296             "<column><column-name>companyId</column-name><column-value><![CDATA[");
297         sb.append(getCompanyId());
298         sb.append("]]></column-value></column>");
299         sb.append(
300             "<column><column-name>portletId</column-name><column-value><![CDATA[");
301         sb.append(getPortletId());
302         sb.append("]]></column-value></column>");
303         sb.append(
304             "<column><column-name>roles</column-name><column-value><![CDATA[");
305         sb.append(getRoles());
306         sb.append("]]></column-value></column>");
307         sb.append(
308             "<column><column-name>active</column-name><column-value><![CDATA[");
309         sb.append(getActive());
310         sb.append("]]></column-value></column>");
311 
312         sb.append("</model>");
313 
314         return sb.toString();
315     }
316 
317     private long _id;
318     private long _companyId;
319     private long _originalCompanyId;
320     private boolean _setOriginalCompanyId;
321     private String _portletId;
322     private String _originalPortletId;
323     private String _roles;
324     private boolean _active;
325     private transient ExpandoBridge _expandoBridge;
326 }