001: /**
002: * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003: *
004: * Permission is hereby granted, free of charge, to any person obtaining a copy
005: * of this software and associated documentation files (the "Software"), to deal
006: * in the Software without restriction, including without limitation the rights
007: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008: * copies of the Software, and to permit persons to whom the Software is
009: * furnished to do so, subject to the following conditions:
010: *
011: * The above copyright notice and this permission notice shall be included in
012: * all copies or substantial portions of the Software.
013: *
014: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017: * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020: * SOFTWARE.
021: */package com.liferay.portal.model.impl;
022:
023: import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
024: import com.liferay.portal.kernel.util.GetterUtil;
025: import com.liferay.portal.model.Portlet;
026: import com.liferay.portal.util.PropsUtil;
027:
028: import com.liferay.util.Html;
029:
030: import java.io.Serializable;
031:
032: import java.lang.reflect.Proxy;
033:
034: import java.sql.Types;
035:
036: /**
037: * <a href="PortletModelImpl.java.html"><b><i>View Source</i></b></a>
038: *
039: * <p>
040: * ServiceBuilder generated this class. Modifications in this class will be
041: * overwritten the next time is generated.
042: * </p>
043: *
044: * <p>
045: * This class is a model that represents the <code>Portlet</code> table
046: * in the database.
047: * </p>
048: *
049: * @author Brian Wing Shun Chan
050: *
051: * @see com.liferay.portal.service.model.Portlet
052: * @see com.liferay.portal.service.model.PortletModel
053: * @see com.liferay.portal.service.model.impl.PortletImpl
054: *
055: */
056: public class PortletModelImpl extends BaseModelImpl {
057: public static final String TABLE_NAME = "Portlet";
058: public static final Object[][] TABLE_COLUMNS = {
059: { "id_", new Integer(Types.BIGINT) },
060:
061: { "companyId", new Integer(Types.BIGINT) },
062:
063: { "portletId", new Integer(Types.VARCHAR) },
064:
065: { "roles", new Integer(Types.VARCHAR) },
066:
067: { "active_", new Integer(Types.BOOLEAN) } };
068: 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)";
069: public static final String TABLE_SQL_DROP = "drop table Portlet";
070: public static final boolean CACHE_ENABLED = GetterUtil
071: .getBoolean(
072: PropsUtil
073: .get("value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
074: true);
075: public static final long LOCK_EXPIRATION_TIME = GetterUtil
076: .getLong(PropsUtil
077: .get("lock.expiration.time.com.liferay.portal.model.Portlet"));
078:
079: public PortletModelImpl() {
080: }
081:
082: public long getPrimaryKey() {
083: return _id;
084: }
085:
086: public void setPrimaryKey(long pk) {
087: setId(pk);
088: }
089:
090: public Serializable getPrimaryKeyObj() {
091: return new Long(_id);
092: }
093:
094: public long getId() {
095: return _id;
096: }
097:
098: public void setId(long id) {
099: if (id != _id) {
100: _id = id;
101: }
102: }
103:
104: public long getCompanyId() {
105: return _companyId;
106: }
107:
108: public void setCompanyId(long companyId) {
109: if (companyId != _companyId) {
110: _companyId = companyId;
111: }
112: }
113:
114: public String getPortletId() {
115: return GetterUtil.getString(_portletId);
116: }
117:
118: public void setPortletId(String portletId) {
119: if (((portletId == null) && (_portletId != null))
120: || ((portletId != null) && (_portletId == null))
121: || ((portletId != null) && (_portletId != null) && !portletId
122: .equals(_portletId))) {
123: _portletId = portletId;
124: }
125: }
126:
127: public String getRoles() {
128: return GetterUtil.getString(_roles);
129: }
130:
131: public void setRoles(String roles) {
132: if (((roles == null) && (_roles != null))
133: || ((roles != null) && (_roles == null))
134: || ((roles != null) && (_roles != null) && !roles
135: .equals(_roles))) {
136: _roles = roles;
137: }
138: }
139:
140: public boolean getActive() {
141: return _active;
142: }
143:
144: public boolean isActive() {
145: return _active;
146: }
147:
148: public void setActive(boolean active) {
149: if (active != _active) {
150: _active = active;
151: }
152: }
153:
154: public Portlet toEscapedModel() {
155: if (isEscapedModel()) {
156: return (Portlet) this ;
157: } else {
158: Portlet model = new PortletImpl();
159:
160: model.setEscapedModel(true);
161:
162: model.setId(getId());
163: model.setCompanyId(getCompanyId());
164: model.setPortletId(Html.escape(getPortletId()));
165: model.setRoles(Html.escape(getRoles()));
166: model.setActive(getActive());
167:
168: model = (Portlet) Proxy.newProxyInstance(Portlet.class
169: .getClassLoader(), new Class[] { Portlet.class },
170: new ReadOnlyBeanHandler(model));
171:
172: return model;
173: }
174: }
175:
176: public Object clone() {
177: PortletImpl clone = new PortletImpl();
178:
179: clone.setId(getId());
180: clone.setCompanyId(getCompanyId());
181: clone.setPortletId(getPortletId());
182: clone.setRoles(getRoles());
183: clone.setActive(getActive());
184:
185: return clone;
186: }
187:
188: public int compareTo(Object obj) {
189: if (obj == null) {
190: return -1;
191: }
192:
193: PortletImpl portlet = (PortletImpl) obj;
194:
195: long pk = portlet.getPrimaryKey();
196:
197: if (getPrimaryKey() < pk) {
198: return -1;
199: } else if (getPrimaryKey() > pk) {
200: return 1;
201: } else {
202: return 0;
203: }
204: }
205:
206: public boolean equals(Object obj) {
207: if (obj == null) {
208: return false;
209: }
210:
211: PortletImpl portlet = null;
212:
213: try {
214: portlet = (PortletImpl) obj;
215: } catch (ClassCastException cce) {
216: return false;
217: }
218:
219: long pk = portlet.getPrimaryKey();
220:
221: if (getPrimaryKey() == pk) {
222: return true;
223: } else {
224: return false;
225: }
226: }
227:
228: public int hashCode() {
229: return (int) getPrimaryKey();
230: }
231:
232: private long _id;
233: private long _companyId;
234: private String _portletId;
235: private String _roles;
236: private boolean _active;
237: }
|