1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.model.impl;
16  
17  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
18  import com.liferay.portal.kernel.util.GetterUtil;
19  import com.liferay.portal.kernel.util.HtmlUtil;
20  import com.liferay.portal.kernel.util.StringBundler;
21  import com.liferay.portal.model.Region;
22  import com.liferay.portal.model.RegionSoap;
23  import com.liferay.portal.service.ServiceContext;
24  
25  import com.liferay.portlet.expando.model.ExpandoBridge;
26  import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
27  
28  import java.io.Serializable;
29  
30  import java.lang.reflect.Proxy;
31  
32  import java.sql.Types;
33  
34  import java.util.ArrayList;
35  import java.util.List;
36  
37  /**
38   * <a href="RegionModelImpl.java.html"><b><i>View Source</i></b></a>
39   *
40   * <p>
41   * ServiceBuilder generated this class. Modifications in this class will be
42   * overwritten the next time is generated.
43   * </p>
44   *
45   * <p>
46   * This interface is a model that represents the Region table in the
47   * database.
48   * </p>
49   *
50   * @author    Brian Wing Shun Chan
51   * @see       RegionImpl
52   * @see       com.liferay.portal.model.Region
53   * @see       com.liferay.portal.model.RegionModel
54   * @generated
55   */
56  public class RegionModelImpl extends BaseModelImpl<Region> {
57      public static final String TABLE_NAME = "Region";
58      public static final Object[][] TABLE_COLUMNS = {
59              { "regionId", new Integer(Types.BIGINT) },
60              { "countryId", new Integer(Types.BIGINT) },
61              { "regionCode", new Integer(Types.VARCHAR) },
62              { "name", new Integer(Types.VARCHAR) },
63              { "active_", new Integer(Types.BOOLEAN) }
64          };
65      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)";
66      public static final String TABLE_SQL_DROP = "drop table Region";
67      public static final String ORDER_BY_JPQL = " ORDER BY region.name ASC";
68      public static final String ORDER_BY_SQL = " ORDER BY Region.name ASC";
69      public static final String DATA_SOURCE = "liferayDataSource";
70      public static final String SESSION_FACTORY = "liferaySessionFactory";
71      public static final String TX_MANAGER = "liferayTransactionManager";
72      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
73                  "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
74              true);
75      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
76                  "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
77              true);
78  
79      public static Region toModel(RegionSoap soapModel) {
80          Region model = new RegionImpl();
81  
82          model.setRegionId(soapModel.getRegionId());
83          model.setCountryId(soapModel.getCountryId());
84          model.setRegionCode(soapModel.getRegionCode());
85          model.setName(soapModel.getName());
86          model.setActive(soapModel.getActive());
87  
88          return model;
89      }
90  
91      public static List<Region> toModels(RegionSoap[] soapModels) {
92          List<Region> models = new ArrayList<Region>(soapModels.length);
93  
94          for (RegionSoap soapModel : soapModels) {
95              models.add(toModel(soapModel));
96          }
97  
98          return models;
99      }
100 
101     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
102                 "lock.expiration.time.com.liferay.portal.model.Region"));
103 
104     public RegionModelImpl() {
105     }
106 
107     public long getPrimaryKey() {
108         return _regionId;
109     }
110 
111     public void setPrimaryKey(long pk) {
112         setRegionId(pk);
113     }
114 
115     public Serializable getPrimaryKeyObj() {
116         return new Long(_regionId);
117     }
118 
119     public long getRegionId() {
120         return _regionId;
121     }
122 
123     public void setRegionId(long regionId) {
124         _regionId = regionId;
125     }
126 
127     public long getCountryId() {
128         return _countryId;
129     }
130 
131     public void setCountryId(long countryId) {
132         _countryId = countryId;
133     }
134 
135     public String getRegionCode() {
136         return GetterUtil.getString(_regionCode);
137     }
138 
139     public void setRegionCode(String regionCode) {
140         _regionCode = regionCode;
141     }
142 
143     public String getName() {
144         return GetterUtil.getString(_name);
145     }
146 
147     public void setName(String name) {
148         _name = name;
149     }
150 
151     public boolean getActive() {
152         return _active;
153     }
154 
155     public boolean isActive() {
156         return _active;
157     }
158 
159     public void setActive(boolean active) {
160         _active = active;
161     }
162 
163     public Region toEscapedModel() {
164         if (isEscapedModel()) {
165             return (Region)this;
166         }
167         else {
168             Region model = new RegionImpl();
169 
170             model.setNew(isNew());
171             model.setEscapedModel(true);
172 
173             model.setRegionId(getRegionId());
174             model.setCountryId(getCountryId());
175             model.setRegionCode(HtmlUtil.escape(getRegionCode()));
176             model.setName(HtmlUtil.escape(getName()));
177             model.setActive(getActive());
178 
179             model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
180                     new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
181 
182             return model;
183         }
184     }
185 
186     public ExpandoBridge getExpandoBridge() {
187         if (_expandoBridge == null) {
188             _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
189                     Region.class.getName(), getPrimaryKey());
190         }
191 
192         return _expandoBridge;
193     }
194 
195     public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
196         getExpandoBridge().setAttributes(serviceContext);
197     }
198 
199     public Object clone() {
200         RegionImpl clone = new RegionImpl();
201 
202         clone.setRegionId(getRegionId());
203         clone.setCountryId(getCountryId());
204         clone.setRegionCode(getRegionCode());
205         clone.setName(getName());
206         clone.setActive(getActive());
207 
208         return clone;
209     }
210 
211     public int compareTo(Region region) {
212         int value = 0;
213 
214         value = getName().compareTo(region.getName());
215 
216         if (value != 0) {
217             return value;
218         }
219 
220         return 0;
221     }
222 
223     public boolean equals(Object obj) {
224         if (obj == null) {
225             return false;
226         }
227 
228         Region region = null;
229 
230         try {
231             region = (Region)obj;
232         }
233         catch (ClassCastException cce) {
234             return false;
235         }
236 
237         long pk = region.getPrimaryKey();
238 
239         if (getPrimaryKey() == pk) {
240             return true;
241         }
242         else {
243             return false;
244         }
245     }
246 
247     public int hashCode() {
248         return (int)getPrimaryKey();
249     }
250 
251     public String toString() {
252         StringBundler sb = new StringBundler(11);
253 
254         sb.append("{regionId=");
255         sb.append(getRegionId());
256         sb.append(", countryId=");
257         sb.append(getCountryId());
258         sb.append(", regionCode=");
259         sb.append(getRegionCode());
260         sb.append(", name=");
261         sb.append(getName());
262         sb.append(", active=");
263         sb.append(getActive());
264         sb.append("}");
265 
266         return sb.toString();
267     }
268 
269     public String toXmlString() {
270         StringBundler sb = new StringBundler(19);
271 
272         sb.append("<model><model-name>");
273         sb.append("com.liferay.portal.model.Region");
274         sb.append("</model-name>");
275 
276         sb.append(
277             "<column><column-name>regionId</column-name><column-value><![CDATA[");
278         sb.append(getRegionId());
279         sb.append("]]></column-value></column>");
280         sb.append(
281             "<column><column-name>countryId</column-name><column-value><![CDATA[");
282         sb.append(getCountryId());
283         sb.append("]]></column-value></column>");
284         sb.append(
285             "<column><column-name>regionCode</column-name><column-value><![CDATA[");
286         sb.append(getRegionCode());
287         sb.append("]]></column-value></column>");
288         sb.append(
289             "<column><column-name>name</column-name><column-value><![CDATA[");
290         sb.append(getName());
291         sb.append("]]></column-value></column>");
292         sb.append(
293             "<column><column-name>active</column-name><column-value><![CDATA[");
294         sb.append(getActive());
295         sb.append("]]></column-value></column>");
296 
297         sb.append("</model>");
298 
299         return sb.toString();
300     }
301 
302     private long _regionId;
303     private long _countryId;
304     private String _regionCode;
305     private String _name;
306     private boolean _active;
307     private transient ExpandoBridge _expandoBridge;
308 }