001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.model.impl;
016    
017    import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018    import com.liferay.portal.kernel.util.GetterUtil;
019    import com.liferay.portal.kernel.util.StringBundler;
020    import com.liferay.portal.kernel.util.StringPool;
021    import com.liferay.portal.model.Country;
022    import com.liferay.portal.model.CountryModel;
023    import com.liferay.portal.model.CountrySoap;
024    import com.liferay.portal.service.ServiceContext;
025    
026    import com.liferay.portlet.expando.model.ExpandoBridge;
027    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    import java.util.ArrayList;
036    import java.util.List;
037    
038    /**
039     * <p>
040     * This interface is a model that represents the Country table in the
041     * database.
042     * </p>
043     *
044     * @author    Brian Wing Shun Chan
045     * @see       CountryImpl
046     * @see       com.liferay.portal.model.Country
047     * @see       com.liferay.portal.model.CountryModel
048     * @generated
049     */
050    public class CountryModelImpl extends BaseModelImpl<Country>
051            implements CountryModel {
052            public static final String TABLE_NAME = "Country";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "countryId", new Integer(Types.BIGINT) },
055                            { "name", new Integer(Types.VARCHAR) },
056                            { "a2", new Integer(Types.VARCHAR) },
057                            { "a3", new Integer(Types.VARCHAR) },
058                            { "number_", new Integer(Types.VARCHAR) },
059                            { "idd_", new Integer(Types.VARCHAR) },
060                            { "active_", new Integer(Types.BOOLEAN) }
061                    };
062            public static final String TABLE_SQL_CREATE = "create table Country (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,active_ BOOLEAN)";
063            public static final String TABLE_SQL_DROP = "drop table Country";
064            public static final String ORDER_BY_JPQL = " ORDER BY country.name ASC";
065            public static final String ORDER_BY_SQL = " ORDER BY Country.name ASC";
066            public static final String DATA_SOURCE = "liferayDataSource";
067            public static final String SESSION_FACTORY = "liferaySessionFactory";
068            public static final String TX_MANAGER = "liferayTransactionManager";
069            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
070                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Country"),
071                            true);
072            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Country"),
074                            true);
075    
076            public static Country toModel(CountrySoap soapModel) {
077                    Country model = new CountryImpl();
078    
079                    model.setCountryId(soapModel.getCountryId());
080                    model.setName(soapModel.getName());
081                    model.setA2(soapModel.getA2());
082                    model.setA3(soapModel.getA3());
083                    model.setNumber(soapModel.getNumber());
084                    model.setIdd(soapModel.getIdd());
085                    model.setActive(soapModel.getActive());
086    
087                    return model;
088            }
089    
090            public static List<Country> toModels(CountrySoap[] soapModels) {
091                    List<Country> models = new ArrayList<Country>(soapModels.length);
092    
093                    for (CountrySoap soapModel : soapModels) {
094                            models.add(toModel(soapModel));
095                    }
096    
097                    return models;
098            }
099    
100            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
101                                    "lock.expiration.time.com.liferay.portal.model.Country"));
102    
103            public CountryModelImpl() {
104            }
105    
106            public long getPrimaryKey() {
107                    return _countryId;
108            }
109    
110            public void setPrimaryKey(long pk) {
111                    setCountryId(pk);
112            }
113    
114            public Serializable getPrimaryKeyObj() {
115                    return new Long(_countryId);
116            }
117    
118            public long getCountryId() {
119                    return _countryId;
120            }
121    
122            public void setCountryId(long countryId) {
123                    _countryId = countryId;
124            }
125    
126            public String getName() {
127                    if (_name == null) {
128                            return StringPool.BLANK;
129                    }
130                    else {
131                            return _name;
132                    }
133            }
134    
135            public void setName(String name) {
136                    _name = name;
137    
138                    if (_originalName == null) {
139                            _originalName = name;
140                    }
141            }
142    
143            public String getOriginalName() {
144                    return GetterUtil.getString(_originalName);
145            }
146    
147            public String getA2() {
148                    if (_a2 == null) {
149                            return StringPool.BLANK;
150                    }
151                    else {
152                            return _a2;
153                    }
154            }
155    
156            public void setA2(String a2) {
157                    _a2 = a2;
158    
159                    if (_originalA2 == null) {
160                            _originalA2 = a2;
161                    }
162            }
163    
164            public String getOriginalA2() {
165                    return GetterUtil.getString(_originalA2);
166            }
167    
168            public String getA3() {
169                    if (_a3 == null) {
170                            return StringPool.BLANK;
171                    }
172                    else {
173                            return _a3;
174                    }
175            }
176    
177            public void setA3(String a3) {
178                    _a3 = a3;
179    
180                    if (_originalA3 == null) {
181                            _originalA3 = a3;
182                    }
183            }
184    
185            public String getOriginalA3() {
186                    return GetterUtil.getString(_originalA3);
187            }
188    
189            public String getNumber() {
190                    if (_number == null) {
191                            return StringPool.BLANK;
192                    }
193                    else {
194                            return _number;
195                    }
196            }
197    
198            public void setNumber(String number) {
199                    _number = number;
200            }
201    
202            public String getIdd() {
203                    if (_idd == null) {
204                            return StringPool.BLANK;
205                    }
206                    else {
207                            return _idd;
208                    }
209            }
210    
211            public void setIdd(String idd) {
212                    _idd = idd;
213            }
214    
215            public boolean getActive() {
216                    return _active;
217            }
218    
219            public boolean isActive() {
220                    return _active;
221            }
222    
223            public void setActive(boolean active) {
224                    _active = active;
225            }
226    
227            public Country toEscapedModel() {
228                    if (isEscapedModel()) {
229                            return (Country)this;
230                    }
231                    else {
232                            return (Country)Proxy.newProxyInstance(Country.class.getClassLoader(),
233                                    new Class[] { Country.class }, new AutoEscapeBeanHandler(this));
234                    }
235            }
236    
237            public ExpandoBridge getExpandoBridge() {
238                    if (_expandoBridge == null) {
239                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
240                                            Country.class.getName(), getPrimaryKey());
241                    }
242    
243                    return _expandoBridge;
244            }
245    
246            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
247                    getExpandoBridge().setAttributes(serviceContext);
248            }
249    
250            public Object clone() {
251                    CountryImpl clone = new CountryImpl();
252    
253                    clone.setCountryId(getCountryId());
254                    clone.setName(getName());
255                    clone.setA2(getA2());
256                    clone.setA3(getA3());
257                    clone.setNumber(getNumber());
258                    clone.setIdd(getIdd());
259                    clone.setActive(getActive());
260    
261                    return clone;
262            }
263    
264            public int compareTo(Country country) {
265                    int value = 0;
266    
267                    value = getName().compareTo(country.getName());
268    
269                    if (value != 0) {
270                            return value;
271                    }
272    
273                    return 0;
274            }
275    
276            public boolean equals(Object obj) {
277                    if (obj == null) {
278                            return false;
279                    }
280    
281                    Country country = null;
282    
283                    try {
284                            country = (Country)obj;
285                    }
286                    catch (ClassCastException cce) {
287                            return false;
288                    }
289    
290                    long pk = country.getPrimaryKey();
291    
292                    if (getPrimaryKey() == pk) {
293                            return true;
294                    }
295                    else {
296                            return false;
297                    }
298            }
299    
300            public int hashCode() {
301                    return (int)getPrimaryKey();
302            }
303    
304            public String toString() {
305                    StringBundler sb = new StringBundler(15);
306    
307                    sb.append("{countryId=");
308                    sb.append(getCountryId());
309                    sb.append(", name=");
310                    sb.append(getName());
311                    sb.append(", a2=");
312                    sb.append(getA2());
313                    sb.append(", a3=");
314                    sb.append(getA3());
315                    sb.append(", number=");
316                    sb.append(getNumber());
317                    sb.append(", idd=");
318                    sb.append(getIdd());
319                    sb.append(", active=");
320                    sb.append(getActive());
321                    sb.append("}");
322    
323                    return sb.toString();
324            }
325    
326            public String toXmlString() {
327                    StringBundler sb = new StringBundler(25);
328    
329                    sb.append("<model><model-name>");
330                    sb.append("com.liferay.portal.model.Country");
331                    sb.append("</model-name>");
332    
333                    sb.append(
334                            "<column><column-name>countryId</column-name><column-value><![CDATA[");
335                    sb.append(getCountryId());
336                    sb.append("]]></column-value></column>");
337                    sb.append(
338                            "<column><column-name>name</column-name><column-value><![CDATA[");
339                    sb.append(getName());
340                    sb.append("]]></column-value></column>");
341                    sb.append(
342                            "<column><column-name>a2</column-name><column-value><![CDATA[");
343                    sb.append(getA2());
344                    sb.append("]]></column-value></column>");
345                    sb.append(
346                            "<column><column-name>a3</column-name><column-value><![CDATA[");
347                    sb.append(getA3());
348                    sb.append("]]></column-value></column>");
349                    sb.append(
350                            "<column><column-name>number</column-name><column-value><![CDATA[");
351                    sb.append(getNumber());
352                    sb.append("]]></column-value></column>");
353                    sb.append(
354                            "<column><column-name>idd</column-name><column-value><![CDATA[");
355                    sb.append(getIdd());
356                    sb.append("]]></column-value></column>");
357                    sb.append(
358                            "<column><column-name>active</column-name><column-value><![CDATA[");
359                    sb.append(getActive());
360                    sb.append("]]></column-value></column>");
361    
362                    sb.append("</model>");
363    
364                    return sb.toString();
365            }
366    
367            private long _countryId;
368            private String _name;
369            private String _originalName;
370            private String _a2;
371            private String _originalA2;
372            private String _a3;
373            private String _originalA3;
374            private String _number;
375            private String _idd;
376            private boolean _active;
377            private transient ExpandoBridge _expandoBridge;
378    }