1
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
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 }