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