001
014
015 package com.liferay.portal.model.impl;
016
017 import aQute.bnd.annotation.ProviderType;
018
019 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
020 import com.liferay.portal.kernel.json.JSON;
021 import com.liferay.portal.kernel.util.GetterUtil;
022 import com.liferay.portal.kernel.util.ProxyUtil;
023 import com.liferay.portal.kernel.util.StringBundler;
024 import com.liferay.portal.kernel.util.StringPool;
025 import com.liferay.portal.model.CacheModel;
026 import com.liferay.portal.model.Country;
027 import com.liferay.portal.model.CountryModel;
028 import com.liferay.portal.model.CountrySoap;
029 import com.liferay.portal.service.ServiceContext;
030
031 import com.liferay.portlet.expando.model.ExpandoBridge;
032 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
033
034 import java.io.Serializable;
035
036 import java.sql.Types;
037
038 import java.util.ArrayList;
039 import java.util.HashMap;
040 import java.util.List;
041 import java.util.Map;
042
043
056 @JSON(strict = true)
057 @ProviderType
058 public class CountryModelImpl extends BaseModelImpl<Country>
059 implements CountryModel {
060
065 public static final String TABLE_NAME = "Country";
066 public static final Object[][] TABLE_COLUMNS = {
067 { "mvccVersion", Types.BIGINT },
068 { "countryId", Types.BIGINT },
069 { "name", Types.VARCHAR },
070 { "a2", Types.VARCHAR },
071 { "a3", Types.VARCHAR },
072 { "number_", Types.VARCHAR },
073 { "idd_", Types.VARCHAR },
074 { "zipRequired", Types.BOOLEAN },
075 { "active_", Types.BOOLEAN }
076 };
077 public static final String TABLE_SQL_CREATE = "create table Country (mvccVersion LONG default 0,countryId LONG not null primary key,name VARCHAR(75) null,a2 VARCHAR(75) null,a3 VARCHAR(75) null,number_ VARCHAR(75) null,idd_ VARCHAR(75) null,zipRequired BOOLEAN,active_ BOOLEAN)";
078 public static final String TABLE_SQL_DROP = "drop table Country";
079 public static final String ORDER_BY_JPQL = " ORDER BY country.name ASC";
080 public static final String ORDER_BY_SQL = " ORDER BY Country.name ASC";
081 public static final String DATA_SOURCE = "liferayDataSource";
082 public static final String SESSION_FACTORY = "liferaySessionFactory";
083 public static final String TX_MANAGER = "liferayTransactionManager";
084 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
085 "value.object.entity.cache.enabled.com.liferay.portal.model.Country"),
086 true);
087 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
088 "value.object.finder.cache.enabled.com.liferay.portal.model.Country"),
089 true);
090 public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
091 "value.object.column.bitmask.enabled.com.liferay.portal.model.Country"),
092 true);
093 public static final long A2_COLUMN_BITMASK = 1L;
094 public static final long A3_COLUMN_BITMASK = 2L;
095 public static final long ACTIVE_COLUMN_BITMASK = 4L;
096 public static final long NAME_COLUMN_BITMASK = 8L;
097
098
104 public static Country toModel(CountrySoap soapModel) {
105 if (soapModel == null) {
106 return null;
107 }
108
109 Country model = new CountryImpl();
110
111 model.setMvccVersion(soapModel.getMvccVersion());
112 model.setCountryId(soapModel.getCountryId());
113 model.setName(soapModel.getName());
114 model.setA2(soapModel.getA2());
115 model.setA3(soapModel.getA3());
116 model.setNumber(soapModel.getNumber());
117 model.setIdd(soapModel.getIdd());
118 model.setZipRequired(soapModel.getZipRequired());
119 model.setActive(soapModel.getActive());
120
121 return model;
122 }
123
124
130 public static List<Country> toModels(CountrySoap[] soapModels) {
131 if (soapModels == null) {
132 return null;
133 }
134
135 List<Country> models = new ArrayList<Country>(soapModels.length);
136
137 for (CountrySoap soapModel : soapModels) {
138 models.add(toModel(soapModel));
139 }
140
141 return models;
142 }
143
144 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
145 "lock.expiration.time.com.liferay.portal.model.Country"));
146
147 public CountryModelImpl() {
148 }
149
150 @Override
151 public long getPrimaryKey() {
152 return _countryId;
153 }
154
155 @Override
156 public void setPrimaryKey(long primaryKey) {
157 setCountryId(primaryKey);
158 }
159
160 @Override
161 public Serializable getPrimaryKeyObj() {
162 return _countryId;
163 }
164
165 @Override
166 public void setPrimaryKeyObj(Serializable primaryKeyObj) {
167 setPrimaryKey(((Long)primaryKeyObj).longValue());
168 }
169
170 @Override
171 public Class<?> getModelClass() {
172 return Country.class;
173 }
174
175 @Override
176 public String getModelClassName() {
177 return Country.class.getName();
178 }
179
180 @Override
181 public Map<String, Object> getModelAttributes() {
182 Map<String, Object> attributes = new HashMap<String, Object>();
183
184 attributes.put("mvccVersion", getMvccVersion());
185 attributes.put("countryId", getCountryId());
186 attributes.put("name", getName());
187 attributes.put("a2", getA2());
188 attributes.put("a3", getA3());
189 attributes.put("number", getNumber());
190 attributes.put("idd", getIdd());
191 attributes.put("zipRequired", getZipRequired());
192 attributes.put("active", getActive());
193
194 attributes.put("entityCacheEnabled", isEntityCacheEnabled());
195 attributes.put("finderCacheEnabled", isFinderCacheEnabled());
196
197 return attributes;
198 }
199
200 @Override
201 public void setModelAttributes(Map<String, Object> attributes) {
202 Long mvccVersion = (Long)attributes.get("mvccVersion");
203
204 if (mvccVersion != null) {
205 setMvccVersion(mvccVersion);
206 }
207
208 Long countryId = (Long)attributes.get("countryId");
209
210 if (countryId != null) {
211 setCountryId(countryId);
212 }
213
214 String name = (String)attributes.get("name");
215
216 if (name != null) {
217 setName(name);
218 }
219
220 String a2 = (String)attributes.get("a2");
221
222 if (a2 != null) {
223 setA2(a2);
224 }
225
226 String a3 = (String)attributes.get("a3");
227
228 if (a3 != null) {
229 setA3(a3);
230 }
231
232 String number = (String)attributes.get("number");
233
234 if (number != null) {
235 setNumber(number);
236 }
237
238 String idd = (String)attributes.get("idd");
239
240 if (idd != null) {
241 setIdd(idd);
242 }
243
244 Boolean zipRequired = (Boolean)attributes.get("zipRequired");
245
246 if (zipRequired != null) {
247 setZipRequired(zipRequired);
248 }
249
250 Boolean active = (Boolean)attributes.get("active");
251
252 if (active != null) {
253 setActive(active);
254 }
255 }
256
257 @JSON
258 @Override
259 public long getMvccVersion() {
260 return _mvccVersion;
261 }
262
263 @Override
264 public void setMvccVersion(long mvccVersion) {
265 _mvccVersion = mvccVersion;
266 }
267
268 @JSON
269 @Override
270 public long getCountryId() {
271 return _countryId;
272 }
273
274 @Override
275 public void setCountryId(long countryId) {
276 _countryId = countryId;
277 }
278
279 @JSON
280 @Override
281 public String getName() {
282 if (_name == null) {
283 return StringPool.BLANK;
284 }
285 else {
286 return _name;
287 }
288 }
289
290 @Override
291 public void setName(String name) {
292 _columnBitmask = -1L;
293
294 if (_originalName == null) {
295 _originalName = _name;
296 }
297
298 _name = name;
299 }
300
301 public String getOriginalName() {
302 return GetterUtil.getString(_originalName);
303 }
304
305 @JSON
306 @Override
307 public String getA2() {
308 if (_a2 == null) {
309 return StringPool.BLANK;
310 }
311 else {
312 return _a2;
313 }
314 }
315
316 @Override
317 public void setA2(String a2) {
318 _columnBitmask |= A2_COLUMN_BITMASK;
319
320 if (_originalA2 == null) {
321 _originalA2 = _a2;
322 }
323
324 _a2 = a2;
325 }
326
327 public String getOriginalA2() {
328 return GetterUtil.getString(_originalA2);
329 }
330
331 @JSON
332 @Override
333 public String getA3() {
334 if (_a3 == null) {
335 return StringPool.BLANK;
336 }
337 else {
338 return _a3;
339 }
340 }
341
342 @Override
343 public void setA3(String a3) {
344 _columnBitmask |= A3_COLUMN_BITMASK;
345
346 if (_originalA3 == null) {
347 _originalA3 = _a3;
348 }
349
350 _a3 = a3;
351 }
352
353 public String getOriginalA3() {
354 return GetterUtil.getString(_originalA3);
355 }
356
357 @JSON
358 @Override
359 public String getNumber() {
360 if (_number == null) {
361 return StringPool.BLANK;
362 }
363 else {
364 return _number;
365 }
366 }
367
368 @Override
369 public void setNumber(String number) {
370 _number = number;
371 }
372
373 @JSON
374 @Override
375 public String getIdd() {
376 if (_idd == null) {
377 return StringPool.BLANK;
378 }
379 else {
380 return _idd;
381 }
382 }
383
384 @Override
385 public void setIdd(String idd) {
386 _idd = idd;
387 }
388
389 @JSON
390 @Override
391 public boolean getZipRequired() {
392 return _zipRequired;
393 }
394
395 @Override
396 public boolean isZipRequired() {
397 return _zipRequired;
398 }
399
400 @Override
401 public void setZipRequired(boolean zipRequired) {
402 _zipRequired = zipRequired;
403 }
404
405 @JSON
406 @Override
407 public boolean getActive() {
408 return _active;
409 }
410
411 @Override
412 public boolean isActive() {
413 return _active;
414 }
415
416 @Override
417 public void setActive(boolean active) {
418 _columnBitmask |= ACTIVE_COLUMN_BITMASK;
419
420 if (!_setOriginalActive) {
421 _setOriginalActive = true;
422
423 _originalActive = _active;
424 }
425
426 _active = active;
427 }
428
429 public boolean getOriginalActive() {
430 return _originalActive;
431 }
432
433 public long getColumnBitmask() {
434 return _columnBitmask;
435 }
436
437 @Override
438 public ExpandoBridge getExpandoBridge() {
439 return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
440 Country.class.getName(), getPrimaryKey());
441 }
442
443 @Override
444 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
445 ExpandoBridge expandoBridge = getExpandoBridge();
446
447 expandoBridge.setAttributes(serviceContext);
448 }
449
450 @Override
451 public Country toEscapedModel() {
452 if (_escapedModel == null) {
453 _escapedModel = (Country)ProxyUtil.newProxyInstance(_classLoader,
454 _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
455 }
456
457 return _escapedModel;
458 }
459
460 @Override
461 public Object clone() {
462 CountryImpl countryImpl = new CountryImpl();
463
464 countryImpl.setMvccVersion(getMvccVersion());
465 countryImpl.setCountryId(getCountryId());
466 countryImpl.setName(getName());
467 countryImpl.setA2(getA2());
468 countryImpl.setA3(getA3());
469 countryImpl.setNumber(getNumber());
470 countryImpl.setIdd(getIdd());
471 countryImpl.setZipRequired(getZipRequired());
472 countryImpl.setActive(getActive());
473
474 countryImpl.resetOriginalValues();
475
476 return countryImpl;
477 }
478
479 @Override
480 public int compareTo(Country country) {
481 int value = 0;
482
483 value = getName().compareTo(country.getName());
484
485 if (value != 0) {
486 return value;
487 }
488
489 return 0;
490 }
491
492 @Override
493 public boolean equals(Object obj) {
494 if (this == obj) {
495 return true;
496 }
497
498 if (!(obj instanceof Country)) {
499 return false;
500 }
501
502 Country country = (Country)obj;
503
504 long primaryKey = country.getPrimaryKey();
505
506 if (getPrimaryKey() == primaryKey) {
507 return true;
508 }
509 else {
510 return false;
511 }
512 }
513
514 @Override
515 public int hashCode() {
516 return (int)getPrimaryKey();
517 }
518
519 @Override
520 public boolean isEntityCacheEnabled() {
521 return ENTITY_CACHE_ENABLED;
522 }
523
524 @Override
525 public boolean isFinderCacheEnabled() {
526 return FINDER_CACHE_ENABLED;
527 }
528
529 @Override
530 public void resetOriginalValues() {
531 CountryModelImpl countryModelImpl = this;
532
533 countryModelImpl._originalName = countryModelImpl._name;
534
535 countryModelImpl._originalA2 = countryModelImpl._a2;
536
537 countryModelImpl._originalA3 = countryModelImpl._a3;
538
539 countryModelImpl._originalActive = countryModelImpl._active;
540
541 countryModelImpl._setOriginalActive = false;
542
543 countryModelImpl._columnBitmask = 0;
544 }
545
546 @Override
547 public CacheModel<Country> toCacheModel() {
548 CountryCacheModel countryCacheModel = new CountryCacheModel();
549
550 countryCacheModel.mvccVersion = getMvccVersion();
551
552 countryCacheModel.countryId = getCountryId();
553
554 countryCacheModel.name = getName();
555
556 String name = countryCacheModel.name;
557
558 if ((name != null) && (name.length() == 0)) {
559 countryCacheModel.name = null;
560 }
561
562 countryCacheModel.a2 = getA2();
563
564 String a2 = countryCacheModel.a2;
565
566 if ((a2 != null) && (a2.length() == 0)) {
567 countryCacheModel.a2 = null;
568 }
569
570 countryCacheModel.a3 = getA3();
571
572 String a3 = countryCacheModel.a3;
573
574 if ((a3 != null) && (a3.length() == 0)) {
575 countryCacheModel.a3 = null;
576 }
577
578 countryCacheModel.number = getNumber();
579
580 String number = countryCacheModel.number;
581
582 if ((number != null) && (number.length() == 0)) {
583 countryCacheModel.number = null;
584 }
585
586 countryCacheModel.idd = getIdd();
587
588 String idd = countryCacheModel.idd;
589
590 if ((idd != null) && (idd.length() == 0)) {
591 countryCacheModel.idd = null;
592 }
593
594 countryCacheModel.zipRequired = getZipRequired();
595
596 countryCacheModel.active = getActive();
597
598 return countryCacheModel;
599 }
600
601 @Override
602 public String toString() {
603 StringBundler sb = new StringBundler(19);
604
605 sb.append("{mvccVersion=");
606 sb.append(getMvccVersion());
607 sb.append(", countryId=");
608 sb.append(getCountryId());
609 sb.append(", name=");
610 sb.append(getName());
611 sb.append(", a2=");
612 sb.append(getA2());
613 sb.append(", a3=");
614 sb.append(getA3());
615 sb.append(", number=");
616 sb.append(getNumber());
617 sb.append(", idd=");
618 sb.append(getIdd());
619 sb.append(", zipRequired=");
620 sb.append(getZipRequired());
621 sb.append(", active=");
622 sb.append(getActive());
623 sb.append("}");
624
625 return sb.toString();
626 }
627
628 @Override
629 public String toXmlString() {
630 StringBundler sb = new StringBundler(31);
631
632 sb.append("<model><model-name>");
633 sb.append("com.liferay.portal.model.Country");
634 sb.append("</model-name>");
635
636 sb.append(
637 "<column><column-name>mvccVersion</column-name><column-value><![CDATA[");
638 sb.append(getMvccVersion());
639 sb.append("]]></column-value></column>");
640 sb.append(
641 "<column><column-name>countryId</column-name><column-value><![CDATA[");
642 sb.append(getCountryId());
643 sb.append("]]></column-value></column>");
644 sb.append(
645 "<column><column-name>name</column-name><column-value><![CDATA[");
646 sb.append(getName());
647 sb.append("]]></column-value></column>");
648 sb.append(
649 "<column><column-name>a2</column-name><column-value><![CDATA[");
650 sb.append(getA2());
651 sb.append("]]></column-value></column>");
652 sb.append(
653 "<column><column-name>a3</column-name><column-value><![CDATA[");
654 sb.append(getA3());
655 sb.append("]]></column-value></column>");
656 sb.append(
657 "<column><column-name>number</column-name><column-value><![CDATA[");
658 sb.append(getNumber());
659 sb.append("]]></column-value></column>");
660 sb.append(
661 "<column><column-name>idd</column-name><column-value><![CDATA[");
662 sb.append(getIdd());
663 sb.append("]]></column-value></column>");
664 sb.append(
665 "<column><column-name>zipRequired</column-name><column-value><![CDATA[");
666 sb.append(getZipRequired());
667 sb.append("]]></column-value></column>");
668 sb.append(
669 "<column><column-name>active</column-name><column-value><![CDATA[");
670 sb.append(getActive());
671 sb.append("]]></column-value></column>");
672
673 sb.append("</model>");
674
675 return sb.toString();
676 }
677
678 private static final ClassLoader _classLoader = Country.class.getClassLoader();
679 private static final Class<?>[] _escapedModelInterfaces = new Class[] {
680 Country.class
681 };
682 private long _mvccVersion;
683 private long _countryId;
684 private String _name;
685 private String _originalName;
686 private String _a2;
687 private String _originalA2;
688 private String _a3;
689 private String _originalA3;
690 private String _number;
691 private String _idd;
692 private boolean _zipRequired;
693 private boolean _active;
694 private boolean _originalActive;
695 private boolean _setOriginalActive;
696 private long _columnBitmask;
697 private Country _escapedModel;
698 }