1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18 import com.liferay.portal.kernel.language.LanguageUtil;
19 import com.liferay.portal.kernel.util.GetterUtil;
20 import com.liferay.portal.kernel.util.HtmlUtil;
21 import com.liferay.portal.kernel.util.LocaleUtil;
22 import com.liferay.portal.kernel.util.StringBundler;
23 import com.liferay.portal.kernel.util.Validator;
24 import com.liferay.portal.model.LayoutPrototype;
25 import com.liferay.portal.model.LayoutPrototypeSoap;
26 import com.liferay.portal.service.ServiceContext;
27
28 import com.liferay.portlet.expando.model.ExpandoBridge;
29 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
30
31 import com.liferay.util.LocalizationUtil;
32
33 import java.io.Serializable;
34
35 import java.lang.reflect.Proxy;
36
37 import java.sql.Types;
38
39 import java.util.ArrayList;
40 import java.util.List;
41 import java.util.Locale;
42 import java.util.Map;
43
44
63 public class LayoutPrototypeModelImpl extends BaseModelImpl<LayoutPrototype> {
64 public static final String TABLE_NAME = "LayoutPrototype";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "layoutPrototypeId", new Integer(Types.BIGINT) },
67 { "companyId", new Integer(Types.BIGINT) },
68 { "name", new Integer(Types.VARCHAR) },
69 { "description", new Integer(Types.VARCHAR) },
70 { "settings_", new Integer(Types.VARCHAR) },
71 { "active_", new Integer(Types.BOOLEAN) }
72 };
73 public static final String TABLE_SQL_CREATE = "create table LayoutPrototype (layoutPrototypeId LONG not null primary key,companyId LONG,name STRING null,description STRING null,settings_ STRING null,active_ BOOLEAN)";
74 public static final String TABLE_SQL_DROP = "drop table LayoutPrototype";
75 public static final String DATA_SOURCE = "liferayDataSource";
76 public static final String SESSION_FACTORY = "liferaySessionFactory";
77 public static final String TX_MANAGER = "liferayTransactionManager";
78 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
79 "value.object.entity.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
80 true);
81 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
82 "value.object.finder.cache.enabled.com.liferay.portal.model.LayoutPrototype"),
83 true);
84
85 public static LayoutPrototype toModel(LayoutPrototypeSoap soapModel) {
86 LayoutPrototype model = new LayoutPrototypeImpl();
87
88 model.setLayoutPrototypeId(soapModel.getLayoutPrototypeId());
89 model.setCompanyId(soapModel.getCompanyId());
90 model.setName(soapModel.getName());
91 model.setDescription(soapModel.getDescription());
92 model.setSettings(soapModel.getSettings());
93 model.setActive(soapModel.getActive());
94
95 return model;
96 }
97
98 public static List<LayoutPrototype> toModels(
99 LayoutPrototypeSoap[] soapModels) {
100 List<LayoutPrototype> models = new ArrayList<LayoutPrototype>(soapModels.length);
101
102 for (LayoutPrototypeSoap soapModel : soapModels) {
103 models.add(toModel(soapModel));
104 }
105
106 return models;
107 }
108
109 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
110 "lock.expiration.time.com.liferay.portal.model.LayoutPrototype"));
111
112 public LayoutPrototypeModelImpl() {
113 }
114
115 public long getPrimaryKey() {
116 return _layoutPrototypeId;
117 }
118
119 public void setPrimaryKey(long pk) {
120 setLayoutPrototypeId(pk);
121 }
122
123 public Serializable getPrimaryKeyObj() {
124 return new Long(_layoutPrototypeId);
125 }
126
127 public long getLayoutPrototypeId() {
128 return _layoutPrototypeId;
129 }
130
131 public void setLayoutPrototypeId(long layoutPrototypeId) {
132 _layoutPrototypeId = layoutPrototypeId;
133 }
134
135 public long getCompanyId() {
136 return _companyId;
137 }
138
139 public void setCompanyId(long companyId) {
140 _companyId = companyId;
141 }
142
143 public String getName() {
144 return GetterUtil.getString(_name);
145 }
146
147 public String getName(Locale locale) {
148 String languageId = LocaleUtil.toLanguageId(locale);
149
150 return getName(languageId);
151 }
152
153 public String getName(Locale locale, boolean useDefault) {
154 String languageId = LocaleUtil.toLanguageId(locale);
155
156 return getName(languageId, useDefault);
157 }
158
159 public String getName(String languageId) {
160 String value = LocalizationUtil.getLocalization(getName(), languageId);
161
162 if (isEscapedModel()) {
163 return HtmlUtil.escape(value);
164 }
165 else {
166 return value;
167 }
168 }
169
170 public String getName(String languageId, boolean useDefault) {
171 String value = LocalizationUtil.getLocalization(getName(), languageId,
172 useDefault);
173
174 if (isEscapedModel()) {
175 return HtmlUtil.escape(value);
176 }
177 else {
178 return value;
179 }
180 }
181
182 public Map<Locale, String> getNameMap() {
183 return LocalizationUtil.getLocalizationMap(getName());
184 }
185
186 public void setName(String name) {
187 _name = name;
188 }
189
190 public void setName(Locale locale, String name) {
191 String languageId = LocaleUtil.toLanguageId(locale);
192
193 if (Validator.isNotNull(name)) {
194 setName(LocalizationUtil.updateLocalization(getName(), "Name",
195 name, languageId));
196 }
197 else {
198 setName(LocalizationUtil.removeLocalization(getName(), "Name",
199 languageId));
200 }
201 }
202
203 public void setNameMap(Map<Locale, String> nameMap) {
204 if (nameMap == null) {
205 return;
206 }
207
208 Locale[] locales = LanguageUtil.getAvailableLocales();
209
210 for (Locale locale : locales) {
211 String name = nameMap.get(locale);
212
213 setName(locale, name);
214 }
215 }
216
217 public String getDescription() {
218 return GetterUtil.getString(_description);
219 }
220
221 public void setDescription(String description) {
222 _description = description;
223 }
224
225 public String getSettings() {
226 return GetterUtil.getString(_settings);
227 }
228
229 public void setSettings(String settings) {
230 _settings = settings;
231 }
232
233 public boolean getActive() {
234 return _active;
235 }
236
237 public boolean isActive() {
238 return _active;
239 }
240
241 public void setActive(boolean active) {
242 _active = active;
243 }
244
245 public LayoutPrototype toEscapedModel() {
246 if (isEscapedModel()) {
247 return (LayoutPrototype)this;
248 }
249 else {
250 LayoutPrototype model = new LayoutPrototypeImpl();
251
252 model.setNew(isNew());
253 model.setEscapedModel(true);
254
255 model.setLayoutPrototypeId(getLayoutPrototypeId());
256 model.setCompanyId(getCompanyId());
257 model.setName(getName());
258 model.setDescription(HtmlUtil.escape(getDescription()));
259 model.setSettings(HtmlUtil.escape(getSettings()));
260 model.setActive(getActive());
261
262 model = (LayoutPrototype)Proxy.newProxyInstance(LayoutPrototype.class.getClassLoader(),
263 new Class[] { LayoutPrototype.class },
264 new ReadOnlyBeanHandler(model));
265
266 return model;
267 }
268 }
269
270 public ExpandoBridge getExpandoBridge() {
271 if (_expandoBridge == null) {
272 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
273 LayoutPrototype.class.getName(), getPrimaryKey());
274 }
275
276 return _expandoBridge;
277 }
278
279 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
280 getExpandoBridge().setAttributes(serviceContext);
281 }
282
283 public Object clone() {
284 LayoutPrototypeImpl clone = new LayoutPrototypeImpl();
285
286 clone.setLayoutPrototypeId(getLayoutPrototypeId());
287 clone.setCompanyId(getCompanyId());
288 clone.setName(getName());
289 clone.setDescription(getDescription());
290 clone.setSettings(getSettings());
291 clone.setActive(getActive());
292
293 return clone;
294 }
295
296 public int compareTo(LayoutPrototype layoutPrototype) {
297 long pk = layoutPrototype.getPrimaryKey();
298
299 if (getPrimaryKey() < pk) {
300 return -1;
301 }
302 else if (getPrimaryKey() > pk) {
303 return 1;
304 }
305 else {
306 return 0;
307 }
308 }
309
310 public boolean equals(Object obj) {
311 if (obj == null) {
312 return false;
313 }
314
315 LayoutPrototype layoutPrototype = null;
316
317 try {
318 layoutPrototype = (LayoutPrototype)obj;
319 }
320 catch (ClassCastException cce) {
321 return false;
322 }
323
324 long pk = layoutPrototype.getPrimaryKey();
325
326 if (getPrimaryKey() == pk) {
327 return true;
328 }
329 else {
330 return false;
331 }
332 }
333
334 public int hashCode() {
335 return (int)getPrimaryKey();
336 }
337
338 public String toString() {
339 StringBundler sb = new StringBundler(13);
340
341 sb.append("{layoutPrototypeId=");
342 sb.append(getLayoutPrototypeId());
343 sb.append(", companyId=");
344 sb.append(getCompanyId());
345 sb.append(", name=");
346 sb.append(getName());
347 sb.append(", description=");
348 sb.append(getDescription());
349 sb.append(", settings=");
350 sb.append(getSettings());
351 sb.append(", active=");
352 sb.append(getActive());
353 sb.append("}");
354
355 return sb.toString();
356 }
357
358 public String toXmlString() {
359 StringBundler sb = new StringBundler(22);
360
361 sb.append("<model><model-name>");
362 sb.append("com.liferay.portal.model.LayoutPrototype");
363 sb.append("</model-name>");
364
365 sb.append(
366 "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
367 sb.append(getLayoutPrototypeId());
368 sb.append("]]></column-value></column>");
369 sb.append(
370 "<column><column-name>companyId</column-name><column-value><![CDATA[");
371 sb.append(getCompanyId());
372 sb.append("]]></column-value></column>");
373 sb.append(
374 "<column><column-name>name</column-name><column-value><![CDATA[");
375 sb.append(getName());
376 sb.append("]]></column-value></column>");
377 sb.append(
378 "<column><column-name>description</column-name><column-value><![CDATA[");
379 sb.append(getDescription());
380 sb.append("]]></column-value></column>");
381 sb.append(
382 "<column><column-name>settings</column-name><column-value><![CDATA[");
383 sb.append(getSettings());
384 sb.append("]]></column-value></column>");
385 sb.append(
386 "<column><column-name>active</column-name><column-value><![CDATA[");
387 sb.append(getActive());
388 sb.append("]]></column-value></column>");
389
390 sb.append("</model>");
391
392 return sb.toString();
393 }
394
395 private long _layoutPrototypeId;
396 private long _companyId;
397 private String _name;
398 private String _description;
399 private String _settings;
400 private boolean _active;
401 private transient ExpandoBridge _expandoBridge;
402 }