1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.model.impl;
24  
25  import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
26  import com.liferay.portal.kernel.util.GetterUtil;
27  import com.liferay.portal.kernel.util.HtmlUtil;
28  import com.liferay.portal.model.Region;
29  import com.liferay.portal.model.RegionSoap;
30  
31  import java.io.Serializable;
32  
33  import java.lang.reflect.Proxy;
34  
35  import java.sql.Types;
36  
37  import java.util.ArrayList;
38  import java.util.List;
39  
40  /**
41   * <a href="RegionModelImpl.java.html"><b><i>View Source</i></b></a>
42   *
43   * <p>
44   * ServiceBuilder generated this class. Modifications in this class will be
45   * overwritten the next time is generated.
46   * </p>
47   *
48   * <p>
49   * This interface is a model that represents the Region table in the
50   * database.
51   * </p>
52   *
53   * @author    Brian Wing Shun Chan
54   * @see       RegionImpl
55   * @see       com.liferay.portal.model.Region
56   * @see       com.liferay.portal.model.RegionModel
57   * @generated
58   */
59  public class RegionModelImpl extends BaseModelImpl<Region> {
60      public static final String TABLE_NAME = "Region";
61      public static final Object[][] TABLE_COLUMNS = {
62              { "regionId", new Integer(Types.BIGINT) },
63              { "countryId", new Integer(Types.BIGINT) },
64              { "regionCode", new Integer(Types.VARCHAR) },
65              { "name", new Integer(Types.VARCHAR) },
66              { "active_", new Integer(Types.BOOLEAN) }
67          };
68      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)";
69      public static final String TABLE_SQL_DROP = "drop table Region";
70      public static final String DATA_SOURCE = "liferayDataSource";
71      public static final String SESSION_FACTORY = "liferaySessionFactory";
72      public static final String TX_MANAGER = "liferayTransactionManager";
73      public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74                  "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
75              true);
76      public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
77                  "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
78              true);
79  
80      public static Region toModel(RegionSoap soapModel) {
81          Region model = new RegionImpl();
82  
83          model.setRegionId(soapModel.getRegionId());
84          model.setCountryId(soapModel.getCountryId());
85          model.setRegionCode(soapModel.getRegionCode());
86          model.setName(soapModel.getName());
87          model.setActive(soapModel.getActive());
88  
89          return model;
90      }
91  
92      public static List<Region> toModels(RegionSoap[] soapModels) {
93          List<Region> models = new ArrayList<Region>(soapModels.length);
94  
95          for (RegionSoap soapModel : soapModels) {
96              models.add(toModel(soapModel));
97          }
98  
99          return models;
100     }
101 
102     public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
103                 "lock.expiration.time.com.liferay.portal.model.Region"));
104 
105     public RegionModelImpl() {
106     }
107 
108     public long getPrimaryKey() {
109         return _regionId;
110     }
111 
112     public void setPrimaryKey(long pk) {
113         setRegionId(pk);
114     }
115 
116     public Serializable getPrimaryKeyObj() {
117         return new Long(_regionId);
118     }
119 
120     public long getRegionId() {
121         return _regionId;
122     }
123 
124     public void setRegionId(long regionId) {
125         _regionId = regionId;
126     }
127 
128     public long getCountryId() {
129         return _countryId;
130     }
131 
132     public void setCountryId(long countryId) {
133         _countryId = countryId;
134     }
135 
136     public String getRegionCode() {
137         return GetterUtil.getString(_regionCode);
138     }
139 
140     public void setRegionCode(String regionCode) {
141         _regionCode = regionCode;
142     }
143 
144     public String getName() {
145         return GetterUtil.getString(_name);
146     }
147 
148     public void setName(String name) {
149         _name = name;
150     }
151 
152     public boolean getActive() {
153         return _active;
154     }
155 
156     public boolean isActive() {
157         return _active;
158     }
159 
160     public void setActive(boolean active) {
161         _active = active;
162     }
163 
164     public Region toEscapedModel() {
165         if (isEscapedModel()) {
166             return (Region)this;
167         }
168         else {
169             Region model = new RegionImpl();
170 
171             model.setNew(isNew());
172             model.setEscapedModel(true);
173 
174             model.setRegionId(getRegionId());
175             model.setCountryId(getCountryId());
176             model.setRegionCode(HtmlUtil.escape(getRegionCode()));
177             model.setName(HtmlUtil.escape(getName()));
178             model.setActive(getActive());
179 
180             model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
181                     new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
182 
183             return model;
184         }
185     }
186 
187     public Object clone() {
188         RegionImpl clone = new RegionImpl();
189 
190         clone.setRegionId(getRegionId());
191         clone.setCountryId(getCountryId());
192         clone.setRegionCode(getRegionCode());
193         clone.setName(getName());
194         clone.setActive(getActive());
195 
196         return clone;
197     }
198 
199     public int compareTo(Region region) {
200         int value = 0;
201 
202         value = getName().compareTo(region.getName());
203 
204         if (value != 0) {
205             return value;
206         }
207 
208         return 0;
209     }
210 
211     public boolean equals(Object obj) {
212         if (obj == null) {
213             return false;
214         }
215 
216         Region region = null;
217 
218         try {
219             region = (Region)obj;
220         }
221         catch (ClassCastException cce) {
222             return false;
223         }
224 
225         long pk = region.getPrimaryKey();
226 
227         if (getPrimaryKey() == pk) {
228             return true;
229         }
230         else {
231             return false;
232         }
233     }
234 
235     public int hashCode() {
236         return (int)getPrimaryKey();
237     }
238 
239     public String toString() {
240         StringBuilder sb = new StringBuilder();
241 
242         sb.append("{regionId=");
243         sb.append(getRegionId());
244         sb.append(", countryId=");
245         sb.append(getCountryId());
246         sb.append(", regionCode=");
247         sb.append(getRegionCode());
248         sb.append(", name=");
249         sb.append(getName());
250         sb.append(", active=");
251         sb.append(getActive());
252         sb.append("}");
253 
254         return sb.toString();
255     }
256 
257     public String toXmlString() {
258         StringBuilder sb = new StringBuilder();
259 
260         sb.append("<model><model-name>");
261         sb.append("com.liferay.portal.model.Region");
262         sb.append("</model-name>");
263 
264         sb.append(
265             "<column><column-name>regionId</column-name><column-value><![CDATA[");
266         sb.append(getRegionId());
267         sb.append("]]></column-value></column>");
268         sb.append(
269             "<column><column-name>countryId</column-name><column-value><![CDATA[");
270         sb.append(getCountryId());
271         sb.append("]]></column-value></column>");
272         sb.append(
273             "<column><column-name>regionCode</column-name><column-value><![CDATA[");
274         sb.append(getRegionCode());
275         sb.append("]]></column-value></column>");
276         sb.append(
277             "<column><column-name>name</column-name><column-value><![CDATA[");
278         sb.append(getName());
279         sb.append("]]></column-value></column>");
280         sb.append(
281             "<column><column-name>active</column-name><column-value><![CDATA[");
282         sb.append(getActive());
283         sb.append("]]></column-value></column>");
284 
285         sb.append("</model>");
286 
287         return sb.toString();
288     }
289 
290     private long _regionId;
291     private long _countryId;
292     private String _regionCode;
293     private String _name;
294     private boolean _active;
295 }