1   /**
2    * Copyright (c) 2000-2009 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   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17   * SOFTWARE.
18   */
19  
20  package com.liferay.portal.model.impl;
21  
22  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23  import com.liferay.portal.kernel.util.GetterUtil;
24  import com.liferay.portal.kernel.util.HtmlUtil;
25  import com.liferay.portal.model.Portlet;
26  import com.liferay.portal.model.PortletSoap;
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 class is a model that represents the <code>Portlet</code> table
47   * in the database.
48   * </p>
49   *
50   * @author Brian Wing Shun Chan
51   *
52   * @see com.liferay.portal.model.Portlet
53   * @see com.liferay.portal.model.PortletModel
54   * @see com.liferay.portal.model.impl.PortletImpl
55   *
56   */
57  public class PortletModelImpl extends BaseModelImpl {
58      public static final String TABLE_NAME = "Portlet";
59      public static final Object[][] TABLE_COLUMNS = {
60              { "id_", new Integer(Types.BIGINT) },
61              
62  
63              { "companyId", new Integer(Types.BIGINT) },
64              
65  
66              { "portletId", new Integer(Types.VARCHAR) },
67              
68  
69              { "roles", new Integer(Types.VARCHAR) },
70              
71  
72              { "active_", new Integer(Types.BOOLEAN) }
73          };
74      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)";
75      public static final String TABLE_SQL_DROP = "drop table Portlet";
76      public static final String DATA_SOURCE = "liferayDataSource";
77      public static final String SESSION_FACTORY = "liferaySessionFactory";
78      public static final String TX_MANAGER = "liferayTransactionManager";
79      public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
80                  "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
81              true);
82  
83      public static Portlet toModel(PortletSoap soapModel) {
84          Portlet model = new PortletImpl();
85  
86          model.setId(soapModel.getId());
87          model.setCompanyId(soapModel.getCompanyId());
88          model.setPortletId(soapModel.getPortletId());
89          model.setRoles(soapModel.getRoles());
90          model.setActive(soapModel.getActive());
91  
92          return model;
93      }
94  
95      public static List<Portlet> toModels(PortletSoap[] soapModels) {
96          List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
97  
98          for (PortletSoap soapModel : soapModels) {
99              models.add(toModel(soapModel));
100         }
101 
102         return models;
103     }
104 
105     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
106                 "lock.expiration.time.com.liferay.portal.model.Portlet"));
107 
108     public PortletModelImpl() {
109     }
110 
111     public long getPrimaryKey() {
112         return _id;
113     }
114 
115     public void setPrimaryKey(long pk) {
116         setId(pk);
117     }
118 
119     public Serializable getPrimaryKeyObj() {
120         return new Long(_id);
121     }
122 
123     public long getId() {
124         return _id;
125     }
126 
127     public void setId(long id) {
128         if (id != _id) {
129             _id = id;
130         }
131     }
132 
133     public long getCompanyId() {
134         return _companyId;
135     }
136 
137     public void setCompanyId(long companyId) {
138         if (companyId != _companyId) {
139             _companyId = companyId;
140         }
141     }
142 
143     public String getPortletId() {
144         return GetterUtil.getString(_portletId);
145     }
146 
147     public void setPortletId(String portletId) {
148         if (((portletId == null) && (_portletId != null)) ||
149                 ((portletId != null) && (_portletId == null)) ||
150                 ((portletId != null) && (_portletId != null) &&
151                 !portletId.equals(_portletId))) {
152             _portletId = portletId;
153         }
154     }
155 
156     public String getRoles() {
157         return GetterUtil.getString(_roles);
158     }
159 
160     public void setRoles(String roles) {
161         if (((roles == null) && (_roles != null)) ||
162                 ((roles != null) && (_roles == null)) ||
163                 ((roles != null) && (_roles != null) && !roles.equals(_roles))) {
164             _roles = roles;
165         }
166     }
167 
168     public boolean getActive() {
169         return _active;
170     }
171 
172     public boolean isActive() {
173         return _active;
174     }
175 
176     public void setActive(boolean active) {
177         if (active != _active) {
178             _active = active;
179         }
180     }
181 
182     public Portlet toEscapedModel() {
183         if (isEscapedModel()) {
184             return (Portlet)this;
185         }
186         else {
187             Portlet model = new PortletImpl();
188 
189             model.setNew(isNew());
190             model.setEscapedModel(true);
191 
192             model.setId(getId());
193             model.setCompanyId(getCompanyId());
194             model.setPortletId(HtmlUtil.escape(getPortletId()));
195             model.setRoles(HtmlUtil.escape(getRoles()));
196             model.setActive(getActive());
197 
198             model = (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
199                     new Class[] { Portlet.class },
200                     new ReadOnlyBeanHandler(model));
201 
202             return model;
203         }
204     }
205 
206     public Object clone() {
207         PortletImpl clone = new PortletImpl();
208 
209         clone.setId(getId());
210         clone.setCompanyId(getCompanyId());
211         clone.setPortletId(getPortletId());
212         clone.setRoles(getRoles());
213         clone.setActive(getActive());
214 
215         return clone;
216     }
217 
218     public int compareTo(Object obj) {
219         if (obj == null) {
220             return -1;
221         }
222 
223         PortletImpl portlet = (PortletImpl)obj;
224 
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         PortletImpl portlet = null;
244 
245         try {
246             portlet = (PortletImpl)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     private long _id;
267     private long _companyId;
268     private String _portletId;
269     private String _roles;
270     private boolean _active;
271 }