1
14
15 package com.liferay.portal.model.impl;
16
17 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
18 import com.liferay.portal.kernel.util.GetterUtil;
19 import com.liferay.portal.kernel.util.StringBundler;
20 import com.liferay.portal.kernel.util.StringPool;
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
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 if (_regionCode == null) {
137 return StringPool.BLANK;
138 }
139 else {
140 return _regionCode;
141 }
142 }
143
144 public void setRegionCode(String regionCode) {
145 _regionCode = regionCode;
146 }
147
148 public String getName() {
149 if (_name == null) {
150 return StringPool.BLANK;
151 }
152 else {
153 return _name;
154 }
155 }
156
157 public void setName(String name) {
158 _name = name;
159 }
160
161 public boolean getActive() {
162 return _active;
163 }
164
165 public boolean isActive() {
166 return _active;
167 }
168
169 public void setActive(boolean active) {
170 _active = active;
171 }
172
173 public Region toEscapedModel() {
174 if (isEscapedModel()) {
175 return (Region)this;
176 }
177 else {
178 return (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
179 new Class[] { Region.class }, new AutoEscapeBeanHandler(this));
180 }
181 }
182
183 public ExpandoBridge getExpandoBridge() {
184 if (_expandoBridge == null) {
185 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(Region.class.getName(),
186 getPrimaryKey());
187 }
188
189 return _expandoBridge;
190 }
191
192 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
193 getExpandoBridge().setAttributes(serviceContext);
194 }
195
196 public Object clone() {
197 RegionImpl clone = new RegionImpl();
198
199 clone.setRegionId(getRegionId());
200 clone.setCountryId(getCountryId());
201 clone.setRegionCode(getRegionCode());
202 clone.setName(getName());
203 clone.setActive(getActive());
204
205 return clone;
206 }
207
208 public int compareTo(Region region) {
209 int value = 0;
210
211 value = getName().compareTo(region.getName());
212
213 if (value != 0) {
214 return value;
215 }
216
217 return 0;
218 }
219
220 public boolean equals(Object obj) {
221 if (obj == null) {
222 return false;
223 }
224
225 Region region = null;
226
227 try {
228 region = (Region)obj;
229 }
230 catch (ClassCastException cce) {
231 return false;
232 }
233
234 long pk = region.getPrimaryKey();
235
236 if (getPrimaryKey() == pk) {
237 return true;
238 }
239 else {
240 return false;
241 }
242 }
243
244 public int hashCode() {
245 return (int)getPrimaryKey();
246 }
247
248 public String toString() {
249 StringBundler sb = new StringBundler(11);
250
251 sb.append("{regionId=");
252 sb.append(getRegionId());
253 sb.append(", countryId=");
254 sb.append(getCountryId());
255 sb.append(", regionCode=");
256 sb.append(getRegionCode());
257 sb.append(", name=");
258 sb.append(getName());
259 sb.append(", active=");
260 sb.append(getActive());
261 sb.append("}");
262
263 return sb.toString();
264 }
265
266 public String toXmlString() {
267 StringBundler sb = new StringBundler(19);
268
269 sb.append("<model><model-name>");
270 sb.append("com.liferay.portal.model.Region");
271 sb.append("</model-name>");
272
273 sb.append(
274 "<column><column-name>regionId</column-name><column-value><![CDATA[");
275 sb.append(getRegionId());
276 sb.append("]]></column-value></column>");
277 sb.append(
278 "<column><column-name>countryId</column-name><column-value><![CDATA[");
279 sb.append(getCountryId());
280 sb.append("]]></column-value></column>");
281 sb.append(
282 "<column><column-name>regionCode</column-name><column-value><![CDATA[");
283 sb.append(getRegionCode());
284 sb.append("]]></column-value></column>");
285 sb.append(
286 "<column><column-name>name</column-name><column-value><![CDATA[");
287 sb.append(getName());
288 sb.append("]]></column-value></column>");
289 sb.append(
290 "<column><column-name>active</column-name><column-value><![CDATA[");
291 sb.append(getActive());
292 sb.append("]]></column-value></column>");
293
294 sb.append("</model>");
295
296 return sb.toString();
297 }
298
299 private long _regionId;
300 private long _countryId;
301 private String _regionCode;
302 private String _name;
303 private boolean _active;
304 private transient ExpandoBridge _expandoBridge;
305 }