1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
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.LocalizationUtil;
23 import com.liferay.portal.kernel.util.StringBundler;
24 import com.liferay.portal.kernel.util.StringPool;
25 import com.liferay.portal.kernel.util.Validator;
26 import com.liferay.portal.model.LayoutPrototype;
27 import com.liferay.portal.model.LayoutPrototypeSoap;
28 import com.liferay.portal.service.ServiceContext;
29
30 import com.liferay.portlet.expando.model.ExpandoBridge;
31 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
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 if (_name == null) {
145 return StringPool.BLANK;
146 }
147 else {
148 return _name;
149 }
150 }
151
152 public String getName(Locale locale) {
153 String languageId = LocaleUtil.toLanguageId(locale);
154
155 return getName(languageId);
156 }
157
158 public String getName(Locale locale, boolean useDefault) {
159 String languageId = LocaleUtil.toLanguageId(locale);
160
161 return getName(languageId, useDefault);
162 }
163
164 public String getName(String languageId) {
165 String value = LocalizationUtil.getLocalization(getName(), languageId);
166
167 if (isEscapedModel()) {
168 return HtmlUtil.escape(value);
169 }
170 else {
171 return value;
172 }
173 }
174
175 public String getName(String languageId, boolean useDefault) {
176 String value = LocalizationUtil.getLocalization(getName(), languageId,
177 useDefault);
178
179 if (isEscapedModel()) {
180 return HtmlUtil.escape(value);
181 }
182 else {
183 return value;
184 }
185 }
186
187 public Map<Locale, String> getNameMap() {
188 return LocalizationUtil.getLocalizationMap(getName());
189 }
190
191 public void setName(String name) {
192 _name = name;
193 }
194
195 public void setName(Locale locale, String name) {
196 String languageId = LocaleUtil.toLanguageId(locale);
197
198 if (Validator.isNotNull(name)) {
199 setName(LocalizationUtil.updateLocalization(getName(), "Name",
200 name, languageId));
201 }
202 else {
203 setName(LocalizationUtil.removeLocalization(getName(), "Name",
204 languageId));
205 }
206 }
207
208 public void setNameMap(Map<Locale, String> nameMap) {
209 if (nameMap == null) {
210 return;
211 }
212
213 Locale[] locales = LanguageUtil.getAvailableLocales();
214
215 for (Locale locale : locales) {
216 String name = nameMap.get(locale);
217
218 setName(locale, name);
219 }
220 }
221
222 public String getDescription() {
223 if (_description == null) {
224 return StringPool.BLANK;
225 }
226 else {
227 return _description;
228 }
229 }
230
231 public void setDescription(String description) {
232 _description = description;
233 }
234
235 public String getSettings() {
236 if (_settings == null) {
237 return StringPool.BLANK;
238 }
239 else {
240 return _settings;
241 }
242 }
243
244 public void setSettings(String settings) {
245 _settings = settings;
246 }
247
248 public boolean getActive() {
249 return _active;
250 }
251
252 public boolean isActive() {
253 return _active;
254 }
255
256 public void setActive(boolean active) {
257 _active = active;
258 }
259
260 public LayoutPrototype toEscapedModel() {
261 if (isEscapedModel()) {
262 return (LayoutPrototype)this;
263 }
264 else {
265 return (LayoutPrototype)Proxy.newProxyInstance(LayoutPrototype.class.getClassLoader(),
266 new Class[] { LayoutPrototype.class },
267 new AutoEscapeBeanHandler(this));
268 }
269 }
270
271 public ExpandoBridge getExpandoBridge() {
272 if (_expandoBridge == null) {
273 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
274 LayoutPrototype.class.getName(), getPrimaryKey());
275 }
276
277 return _expandoBridge;
278 }
279
280 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
281 getExpandoBridge().setAttributes(serviceContext);
282 }
283
284 public Object clone() {
285 LayoutPrototypeImpl clone = new LayoutPrototypeImpl();
286
287 clone.setLayoutPrototypeId(getLayoutPrototypeId());
288 clone.setCompanyId(getCompanyId());
289 clone.setName(getName());
290 clone.setDescription(getDescription());
291 clone.setSettings(getSettings());
292 clone.setActive(getActive());
293
294 return clone;
295 }
296
297 public int compareTo(LayoutPrototype layoutPrototype) {
298 long pk = layoutPrototype.getPrimaryKey();
299
300 if (getPrimaryKey() < pk) {
301 return -1;
302 }
303 else if (getPrimaryKey() > pk) {
304 return 1;
305 }
306 else {
307 return 0;
308 }
309 }
310
311 public boolean equals(Object obj) {
312 if (obj == null) {
313 return false;
314 }
315
316 LayoutPrototype layoutPrototype = null;
317
318 try {
319 layoutPrototype = (LayoutPrototype)obj;
320 }
321 catch (ClassCastException cce) {
322 return false;
323 }
324
325 long pk = layoutPrototype.getPrimaryKey();
326
327 if (getPrimaryKey() == pk) {
328 return true;
329 }
330 else {
331 return false;
332 }
333 }
334
335 public int hashCode() {
336 return (int)getPrimaryKey();
337 }
338
339 public String toString() {
340 StringBundler sb = new StringBundler(13);
341
342 sb.append("{layoutPrototypeId=");
343 sb.append(getLayoutPrototypeId());
344 sb.append(", companyId=");
345 sb.append(getCompanyId());
346 sb.append(", name=");
347 sb.append(getName());
348 sb.append(", description=");
349 sb.append(getDescription());
350 sb.append(", settings=");
351 sb.append(getSettings());
352 sb.append(", active=");
353 sb.append(getActive());
354 sb.append("}");
355
356 return sb.toString();
357 }
358
359 public String toXmlString() {
360 StringBundler sb = new StringBundler(22);
361
362 sb.append("<model><model-name>");
363 sb.append("com.liferay.portal.model.LayoutPrototype");
364 sb.append("</model-name>");
365
366 sb.append(
367 "<column><column-name>layoutPrototypeId</column-name><column-value><![CDATA[");
368 sb.append(getLayoutPrototypeId());
369 sb.append("]]></column-value></column>");
370 sb.append(
371 "<column><column-name>companyId</column-name><column-value><![CDATA[");
372 sb.append(getCompanyId());
373 sb.append("]]></column-value></column>");
374 sb.append(
375 "<column><column-name>name</column-name><column-value><![CDATA[");
376 sb.append(getName());
377 sb.append("]]></column-value></column>");
378 sb.append(
379 "<column><column-name>description</column-name><column-value><![CDATA[");
380 sb.append(getDescription());
381 sb.append("]]></column-value></column>");
382 sb.append(
383 "<column><column-name>settings</column-name><column-value><![CDATA[");
384 sb.append(getSettings());
385 sb.append("]]></column-value></column>");
386 sb.append(
387 "<column><column-name>active</column-name><column-value><![CDATA[");
388 sb.append(getActive());
389 sb.append("]]></column-value></column>");
390
391 sb.append("</model>");
392
393 return sb.toString();
394 }
395
396 private long _layoutPrototypeId;
397 private long _companyId;
398 private String _name;
399 private String _description;
400 private String _settings;
401 private boolean _active;
402 private transient ExpandoBridge _expandoBridge;
403 }