001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Portlet;
022    import com.liferay.portal.model.PortletModel;
023    import com.liferay.portal.model.PortletSoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.List;
037    
038    /**
039     * <p>
040     * This interface is a model that represents the Portlet table in the
041     * database.
042     * </p>
043     *
044     * @author    Brian Wing Shun Chan
045     * @see       PortletImpl
046     * @see       com.liferay.portal.model.Portlet
047     * @see       com.liferay.portal.model.PortletModel
048     * @generated
049     */
050    public class PortletModelImpl extends BaseModelImpl<Portlet>
051            implements PortletModel {
052            public static final String TABLE_NAME = "Portlet";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "id_", new Integer(Types.BIGINT) },
055                            { "companyId", new Integer(Types.BIGINT) },
056                            { "portletId", new Integer(Types.VARCHAR) },
057                            { "roles", new Integer(Types.VARCHAR) },
058                            { "active_", new Integer(Types.BOOLEAN) }
059                    };
060            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)";
061            public static final String TABLE_SQL_DROP = "drop table Portlet";
062            public static final String DATA_SOURCE = "liferayDataSource";
063            public static final String SESSION_FACTORY = "liferaySessionFactory";
064            public static final String TX_MANAGER = "liferayTransactionManager";
065            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
066                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Portlet"),
067                            true);
068            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
070                            true);
071    
072            public static Portlet toModel(PortletSoap soapModel) {
073                    Portlet model = new PortletImpl();
074    
075                    model.setId(soapModel.getId());
076                    model.setCompanyId(soapModel.getCompanyId());
077                    model.setPortletId(soapModel.getPortletId());
078                    model.setRoles(soapModel.getRoles());
079                    model.setActive(soapModel.getActive());
080    
081                    return model;
082            }
083    
084            public static List<Portlet> toModels(PortletSoap[] soapModels) {
085                    List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
086    
087                    for (PortletSoap soapModel : soapModels) {
088                            models.add(toModel(soapModel));
089                    }
090    
091                    return models;
092            }
093    
094            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
095                                    "lock.expiration.time.com.liferay.portal.model.Portlet"));
096    
097            public PortletModelImpl() {
098            }
099    
100            public long getPrimaryKey() {
101                    return _id;
102            }
103    
104            public void setPrimaryKey(long pk) {
105                    setId(pk);
106            }
107    
108            public Serializable getPrimaryKeyObj() {
109                    return new Long(_id);
110            }
111    
112            public long getId() {
113                    return _id;
114            }
115    
116            public void setId(long id) {
117                    _id = id;
118            }
119    
120            public long getCompanyId() {
121                    return _companyId;
122            }
123    
124            public void setCompanyId(long companyId) {
125                    _companyId = companyId;
126    
127                    if (!_setOriginalCompanyId) {
128                            _setOriginalCompanyId = true;
129    
130                            _originalCompanyId = companyId;
131                    }
132            }
133    
134            public long getOriginalCompanyId() {
135                    return _originalCompanyId;
136            }
137    
138            public String getPortletId() {
139                    if (_portletId == null) {
140                            return StringPool.BLANK;
141                    }
142                    else {
143                            return _portletId;
144                    }
145            }
146    
147            public void setPortletId(String portletId) {
148                    _portletId = portletId;
149    
150                    if (_originalPortletId == null) {
151                            _originalPortletId = portletId;
152                    }
153            }
154    
155            public String getOriginalPortletId() {
156                    return GetterUtil.getString(_originalPortletId);
157            }
158    
159            public String getRoles() {
160                    if (_roles == null) {
161                            return StringPool.BLANK;
162                    }
163                    else {
164                            return _roles;
165                    }
166            }
167    
168            public void setRoles(String roles) {
169                    _roles = roles;
170            }
171    
172            public boolean getActive() {
173                    return _active;
174            }
175    
176            public boolean isActive() {
177                    return _active;
178            }
179    
180            public void setActive(boolean active) {
181                    _active = active;
182            }
183    
184            public Portlet toEscapedModel() {
185                    if (isEscapedModel()) {
186                            return (Portlet)this;
187                    }
188                    else {
189                            return (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
190                                    new Class[] { Portlet.class }, new AutoEscapeBeanHandler(this));
191                    }
192            }
193    
194            public ExpandoBridge getExpandoBridge() {
195                    if (_expandoBridge == null) {
196                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
197                                            Portlet.class.getName(), getPrimaryKey());
198                    }
199    
200                    return _expandoBridge;
201            }
202    
203            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
204                    getExpandoBridge().setAttributes(serviceContext);
205            }
206    
207            public Object clone() {
208                    PortletImpl clone = new PortletImpl();
209    
210                    clone.setId(getId());
211                    clone.setCompanyId(getCompanyId());
212                    clone.setPortletId(getPortletId());
213                    clone.setRoles(getRoles());
214                    clone.setActive(getActive());
215    
216                    return clone;
217            }
218    
219            public int compareTo(Portlet portlet) {
220                    long pk = portlet.getPrimaryKey();
221    
222                    if (getPrimaryKey() < pk) {
223                            return -1;
224                    }
225                    else if (getPrimaryKey() > pk) {
226                            return 1;
227                    }
228                    else {
229                            return 0;
230                    }
231            }
232    
233            public boolean equals(Object obj) {
234                    if (obj == null) {
235                            return false;
236                    }
237    
238                    Portlet portlet = null;
239    
240                    try {
241                            portlet = (Portlet)obj;
242                    }
243                    catch (ClassCastException cce) {
244                            return false;
245                    }
246    
247                    long pk = portlet.getPrimaryKey();
248    
249                    if (getPrimaryKey() == pk) {
250                            return true;
251                    }
252                    else {
253                            return false;
254                    }
255            }
256    
257            public int hashCode() {
258                    return (int)getPrimaryKey();
259            }
260    
261            public String toString() {
262                    StringBundler sb = new StringBundler(11);
263    
264                    sb.append("{id=");
265                    sb.append(getId());
266                    sb.append(", companyId=");
267                    sb.append(getCompanyId());
268                    sb.append(", portletId=");
269                    sb.append(getPortletId());
270                    sb.append(", roles=");
271                    sb.append(getRoles());
272                    sb.append(", active=");
273                    sb.append(getActive());
274                    sb.append("}");
275    
276                    return sb.toString();
277            }
278    
279            public String toXmlString() {
280                    StringBundler sb = new StringBundler(19);
281    
282                    sb.append("<model><model-name>");
283                    sb.append("com.liferay.portal.model.Portlet");
284                    sb.append("</model-name>");
285    
286                    sb.append(
287                            "<column><column-name>id</column-name><column-value><![CDATA[");
288                    sb.append(getId());
289                    sb.append("]]></column-value></column>");
290                    sb.append(
291                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
292                    sb.append(getCompanyId());
293                    sb.append("]]></column-value></column>");
294                    sb.append(
295                            "<column><column-name>portletId</column-name><column-value><![CDATA[");
296                    sb.append(getPortletId());
297                    sb.append("]]></column-value></column>");
298                    sb.append(
299                            "<column><column-name>roles</column-name><column-value><![CDATA[");
300                    sb.append(getRoles());
301                    sb.append("]]></column-value></column>");
302                    sb.append(
303                            "<column><column-name>active</column-name><column-value><![CDATA[");
304                    sb.append(getActive());
305                    sb.append("]]></column-value></column>");
306    
307                    sb.append("</model>");
308    
309                    return sb.toString();
310            }
311    
312            private long _id;
313            private long _companyId;
314            private long _originalCompanyId;
315            private boolean _setOriginalCompanyId;
316            private String _portletId;
317            private String _originalPortletId;
318            private String _roles;
319            private boolean _active;
320            private transient ExpandoBridge _expandoBridge;
321    }