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.Region;
022    import com.liferay.portal.model.RegionModel;
023    import com.liferay.portal.model.RegionSoap;
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 Region table in the
041     * database.
042     * </p>
043     *
044     * @author    Brian Wing Shun Chan
045     * @see       RegionImpl
046     * @see       com.liferay.portal.model.Region
047     * @see       com.liferay.portal.model.RegionModel
048     * @generated
049     */
050    public class RegionModelImpl extends BaseModelImpl<Region>
051            implements RegionModel {
052            public static final String TABLE_NAME = "Region";
053            public static final Object[][] TABLE_COLUMNS = {
054                            { "regionId", new Integer(Types.BIGINT) },
055                            { "countryId", new Integer(Types.BIGINT) },
056                            { "regionCode", new Integer(Types.VARCHAR) },
057                            { "name", new Integer(Types.VARCHAR) },
058                            { "active_", new Integer(Types.BOOLEAN) }
059                    };
060            public static final String TABLE_SQL_CREATE = "create table Region (regionId LONG not null primary key,countryId LONG,regionCode VARCHAR(75) null,name VARCHAR(75) null,active_ BOOLEAN)";
061            public static final String TABLE_SQL_DROP = "drop table Region";
062            public static final String ORDER_BY_JPQL = " ORDER BY region.name ASC";
063            public static final String ORDER_BY_SQL = " ORDER BY Region.name ASC";
064            public static final String DATA_SOURCE = "liferayDataSource";
065            public static final String SESSION_FACTORY = "liferaySessionFactory";
066            public static final String TX_MANAGER = "liferayTransactionManager";
067            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
068                                    "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
069                            true);
070            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
071                                    "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
072                            true);
073    
074            public static Region toModel(RegionSoap soapModel) {
075                    Region model = new RegionImpl();
076    
077                    model.setRegionId(soapModel.getRegionId());
078                    model.setCountryId(soapModel.getCountryId());
079                    model.setRegionCode(soapModel.getRegionCode());
080                    model.setName(soapModel.getName());
081                    model.setActive(soapModel.getActive());
082    
083                    return model;
084            }
085    
086            public static List<Region> toModels(RegionSoap[] soapModels) {
087                    List<Region> models = new ArrayList<Region>(soapModels.length);
088    
089                    for (RegionSoap soapModel : soapModels) {
090                            models.add(toModel(soapModel));
091                    }
092    
093                    return models;
094            }
095    
096            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
097                                    "lock.expiration.time.com.liferay.portal.model.Region"));
098    
099            public RegionModelImpl() {
100            }
101    
102            public long getPrimaryKey() {
103                    return _regionId;
104            }
105    
106            public void setPrimaryKey(long pk) {
107                    setRegionId(pk);
108            }
109    
110            public Serializable getPrimaryKeyObj() {
111                    return new Long(_regionId);
112            }
113    
114            public long getRegionId() {
115                    return _regionId;
116            }
117    
118            public void setRegionId(long regionId) {
119                    _regionId = regionId;
120            }
121    
122            public long getCountryId() {
123                    return _countryId;
124            }
125    
126            public void setCountryId(long countryId) {
127                    _countryId = countryId;
128            }
129    
130            public String getRegionCode() {
131                    if (_regionCode == null) {
132                            return StringPool.BLANK;
133                    }
134                    else {
135                            return _regionCode;
136                    }
137            }
138    
139            public void setRegionCode(String regionCode) {
140                    _regionCode = regionCode;
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 void setName(String name) {
153                    _name = name;
154            }
155    
156            public boolean getActive() {
157                    return _active;
158            }
159    
160            public boolean isActive() {
161                    return _active;
162            }
163    
164            public void setActive(boolean active) {
165                    _active = active;
166            }
167    
168            public Region toEscapedModel() {
169                    if (isEscapedModel()) {
170                            return (Region)this;
171                    }
172                    else {
173                            return (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
174                                    new Class[] { Region.class }, new AutoEscapeBeanHandler(this));
175                    }
176            }
177    
178            public ExpandoBridge getExpandoBridge() {
179                    if (_expandoBridge == null) {
180                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
181                                            Region.class.getName(), getPrimaryKey());
182                    }
183    
184                    return _expandoBridge;
185            }
186    
187            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
188                    getExpandoBridge().setAttributes(serviceContext);
189            }
190    
191            public Object clone() {
192                    RegionImpl clone = new RegionImpl();
193    
194                    clone.setRegionId(getRegionId());
195                    clone.setCountryId(getCountryId());
196                    clone.setRegionCode(getRegionCode());
197                    clone.setName(getName());
198                    clone.setActive(getActive());
199    
200                    return clone;
201            }
202    
203            public int compareTo(Region region) {
204                    int value = 0;
205    
206                    value = getName().compareTo(region.getName());
207    
208                    if (value != 0) {
209                            return value;
210                    }
211    
212                    return 0;
213            }
214    
215            public boolean equals(Object obj) {
216                    if (obj == null) {
217                            return false;
218                    }
219    
220                    Region region = null;
221    
222                    try {
223                            region = (Region)obj;
224                    }
225                    catch (ClassCastException cce) {
226                            return false;
227                    }
228    
229                    long pk = region.getPrimaryKey();
230    
231                    if (getPrimaryKey() == pk) {
232                            return true;
233                    }
234                    else {
235                            return false;
236                    }
237            }
238    
239            public int hashCode() {
240                    return (int)getPrimaryKey();
241            }
242    
243            public String toString() {
244                    StringBundler sb = new StringBundler(11);
245    
246                    sb.append("{regionId=");
247                    sb.append(getRegionId());
248                    sb.append(", countryId=");
249                    sb.append(getCountryId());
250                    sb.append(", regionCode=");
251                    sb.append(getRegionCode());
252                    sb.append(", name=");
253                    sb.append(getName());
254                    sb.append(", active=");
255                    sb.append(getActive());
256                    sb.append("}");
257    
258                    return sb.toString();
259            }
260    
261            public String toXmlString() {
262                    StringBundler sb = new StringBundler(19);
263    
264                    sb.append("<model><model-name>");
265                    sb.append("com.liferay.portal.model.Region");
266                    sb.append("</model-name>");
267    
268                    sb.append(
269                            "<column><column-name>regionId</column-name><column-value><![CDATA[");
270                    sb.append(getRegionId());
271                    sb.append("]]></column-value></column>");
272                    sb.append(
273                            "<column><column-name>countryId</column-name><column-value><![CDATA[");
274                    sb.append(getCountryId());
275                    sb.append("]]></column-value></column>");
276                    sb.append(
277                            "<column><column-name>regionCode</column-name><column-value><![CDATA[");
278                    sb.append(getRegionCode());
279                    sb.append("]]></column-value></column>");
280                    sb.append(
281                            "<column><column-name>name</column-name><column-value><![CDATA[");
282                    sb.append(getName());
283                    sb.append("]]></column-value></column>");
284                    sb.append(
285                            "<column><column-name>active</column-name><column-value><![CDATA[");
286                    sb.append(getActive());
287                    sb.append("]]></column-value></column>");
288    
289                    sb.append("</model>");
290    
291                    return sb.toString();
292            }
293    
294            private long _regionId;
295            private long _countryId;
296            private String _regionCode;
297            private String _name;
298            private boolean _active;
299            private transient ExpandoBridge _expandoBridge;
300    }