1
22
23 package com.liferay.portal.model.impl;
24
25 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26 import com.liferay.portal.kernel.util.GetterUtil;
27 import com.liferay.portal.kernel.util.HtmlUtil;
28 import com.liferay.portal.model.Portlet;
29 import com.liferay.portal.model.PortletSoap;
30
31 import java.io.Serializable;
32
33 import java.lang.reflect.Proxy;
34
35 import java.sql.Types;
36
37 import java.util.ArrayList;
38 import java.util.List;
39
40
60 public class PortletModelImpl extends BaseModelImpl {
61 public static final String TABLE_NAME = "Portlet";
62 public static final Object[][] TABLE_COLUMNS = {
63 { "id_", new Integer(Types.BIGINT) },
64
65
66 { "companyId", new Integer(Types.BIGINT) },
67
68
69 { "portletId", new Integer(Types.VARCHAR) },
70
71
72 { "roles", new Integer(Types.VARCHAR) },
73
74
75 { "active_", new Integer(Types.BOOLEAN) }
76 };
77 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)";
78 public static final String TABLE_SQL_DROP = "drop table Portlet";
79 public static final String DATA_SOURCE = "liferayDataSource";
80 public static final String SESSION_FACTORY = "liferaySessionFactory";
81 public static final String TX_MANAGER = "liferayTransactionManager";
82 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83 "value.object.finder.cache.enabled.com.liferay.portal.model.Portlet"),
84 true);
85
86 public static Portlet toModel(PortletSoap soapModel) {
87 Portlet model = new PortletImpl();
88
89 model.setId(soapModel.getId());
90 model.setCompanyId(soapModel.getCompanyId());
91 model.setPortletId(soapModel.getPortletId());
92 model.setRoles(soapModel.getRoles());
93 model.setActive(soapModel.getActive());
94
95 return model;
96 }
97
98 public static List<Portlet> toModels(PortletSoap[] soapModels) {
99 List<Portlet> models = new ArrayList<Portlet>(soapModels.length);
100
101 for (PortletSoap soapModel : soapModels) {
102 models.add(toModel(soapModel));
103 }
104
105 return models;
106 }
107
108 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
109 "lock.expiration.time.com.liferay.portal.model.Portlet"));
110
111 public PortletModelImpl() {
112 }
113
114 public long getPrimaryKey() {
115 return _id;
116 }
117
118 public void setPrimaryKey(long pk) {
119 setId(pk);
120 }
121
122 public Serializable getPrimaryKeyObj() {
123 return new Long(_id);
124 }
125
126 public long getId() {
127 return _id;
128 }
129
130 public void setId(long id) {
131 if (id != _id) {
132 _id = id;
133 }
134 }
135
136 public long getCompanyId() {
137 return _companyId;
138 }
139
140 public void setCompanyId(long companyId) {
141 if (companyId != _companyId) {
142 _companyId = companyId;
143 }
144 }
145
146 public String getPortletId() {
147 return GetterUtil.getString(_portletId);
148 }
149
150 public void setPortletId(String portletId) {
151 if (((portletId == null) && (_portletId != null)) ||
152 ((portletId != null) && (_portletId == null)) ||
153 ((portletId != null) && (_portletId != null) &&
154 !portletId.equals(_portletId))) {
155 _portletId = portletId;
156 }
157 }
158
159 public String getRoles() {
160 return GetterUtil.getString(_roles);
161 }
162
163 public void setRoles(String roles) {
164 if (((roles == null) && (_roles != null)) ||
165 ((roles != null) && (_roles == null)) ||
166 ((roles != null) && (_roles != null) && !roles.equals(_roles))) {
167 _roles = roles;
168 }
169 }
170
171 public boolean getActive() {
172 return _active;
173 }
174
175 public boolean isActive() {
176 return _active;
177 }
178
179 public void setActive(boolean active) {
180 if (active != _active) {
181 _active = active;
182 }
183 }
184
185 public Portlet toEscapedModel() {
186 if (isEscapedModel()) {
187 return (Portlet)this;
188 }
189 else {
190 Portlet model = new PortletImpl();
191
192 model.setEscapedModel(true);
193
194 model.setId(getId());
195 model.setCompanyId(getCompanyId());
196 model.setPortletId(HtmlUtil.escape(getPortletId()));
197 model.setRoles(HtmlUtil.escape(getRoles()));
198 model.setActive(getActive());
199
200 model = (Portlet)Proxy.newProxyInstance(Portlet.class.getClassLoader(),
201 new Class[] { Portlet.class },
202 new ReadOnlyBeanHandler(model));
203
204 return model;
205 }
206 }
207
208 public Object clone() {
209 PortletImpl clone = new PortletImpl();
210
211 clone.setId(getId());
212 clone.setCompanyId(getCompanyId());
213 clone.setPortletId(getPortletId());
214 clone.setRoles(getRoles());
215 clone.setActive(getActive());
216
217 return clone;
218 }
219
220 public int compareTo(Object obj) {
221 if (obj == null) {
222 return -1;
223 }
224
225 PortletImpl portlet = (PortletImpl)obj;
226
227 long pk = portlet.getPrimaryKey();
228
229 if (getPrimaryKey() < pk) {
230 return -1;
231 }
232 else if (getPrimaryKey() > pk) {
233 return 1;
234 }
235 else {
236 return 0;
237 }
238 }
239
240 public boolean equals(Object obj) {
241 if (obj == null) {
242 return false;
243 }
244
245 PortletImpl portlet = null;
246
247 try {
248 portlet = (PortletImpl)obj;
249 }
250 catch (ClassCastException cce) {
251 return false;
252 }
253
254 long pk = portlet.getPrimaryKey();
255
256 if (getPrimaryKey() == pk) {
257 return true;
258 }
259 else {
260 return false;
261 }
262 }
263
264 public int hashCode() {
265 return (int)getPrimaryKey();
266 }
267
268 private long _id;
269 private long _companyId;
270 private String _portletId;
271 private String _roles;
272 private boolean _active;
273 }