1
19
20 package com.liferay.portal.model.impl;
21
22 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23 import com.liferay.portal.kernel.util.GetterUtil;
24 import com.liferay.portal.kernel.util.HtmlUtil;
25 import com.liferay.portal.model.Region;
26 import com.liferay.portal.model.RegionSoap;
27
28 import com.liferay.portlet.expando.model.ExpandoBridge;
29 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
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
60 public class RegionModelImpl extends BaseModelImpl<Region> {
61 public static final String TABLE_NAME = "Region";
62 public static final Object[][] TABLE_COLUMNS = {
63 { "regionId", new Integer(Types.BIGINT) },
64
65
66 { "countryId", new Integer(Types.BIGINT) },
67
68
69 { "regionCode", new Integer(Types.VARCHAR) },
70
71
72 { "name", new Integer(Types.VARCHAR) },
73
74
75 { "active_", new Integer(Types.BOOLEAN) }
76 };
77 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)";
78 public static final String TABLE_SQL_DROP = "drop table Region";
79 public static final String DATA_SOURCE = "liferayDataSource";
80 public static final String SESSION_FACTORY = "liferaySessionFactory";
81 public static final String TX_MANAGER = "liferayTransactionManager";
82 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
83 "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
84 true);
85 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
86 "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
87 true);
88
89 public static Region toModel(RegionSoap soapModel) {
90 Region model = new RegionImpl();
91
92 model.setRegionId(soapModel.getRegionId());
93 model.setCountryId(soapModel.getCountryId());
94 model.setRegionCode(soapModel.getRegionCode());
95 model.setName(soapModel.getName());
96 model.setActive(soapModel.getActive());
97
98 return model;
99 }
100
101 public static List<Region> toModels(RegionSoap[] soapModels) {
102 List<Region> models = new ArrayList<Region>(soapModels.length);
103
104 for (RegionSoap soapModel : soapModels) {
105 models.add(toModel(soapModel));
106 }
107
108 return models;
109 }
110
111 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
112 "lock.expiration.time.com.liferay.portal.model.Region"));
113
114 public RegionModelImpl() {
115 }
116
117 public long getPrimaryKey() {
118 return _regionId;
119 }
120
121 public void setPrimaryKey(long pk) {
122 setRegionId(pk);
123 }
124
125 public Serializable getPrimaryKeyObj() {
126 return new Long(_regionId);
127 }
128
129 public long getRegionId() {
130 return _regionId;
131 }
132
133 public void setRegionId(long regionId) {
134 _regionId = regionId;
135 }
136
137 public long getCountryId() {
138 return _countryId;
139 }
140
141 public void setCountryId(long countryId) {
142 _countryId = countryId;
143 }
144
145 public String getRegionCode() {
146 return GetterUtil.getString(_regionCode);
147 }
148
149 public void setRegionCode(String regionCode) {
150 _regionCode = regionCode;
151 }
152
153 public String getName() {
154 return GetterUtil.getString(_name);
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 Region model = new RegionImpl();
179
180 model.setNew(isNew());
181 model.setEscapedModel(true);
182
183 model.setRegionId(getRegionId());
184 model.setCountryId(getCountryId());
185 model.setRegionCode(HtmlUtil.escape(getRegionCode()));
186 model.setName(HtmlUtil.escape(getName()));
187 model.setActive(getActive());
188
189 model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
190 new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
191
192 return model;
193 }
194 }
195
196 public ExpandoBridge getExpandoBridge() {
197 if (_expandoBridge == null) {
198 _expandoBridge = new ExpandoBridgeImpl(Region.class.getName(),
199 getPrimaryKey());
200 }
201
202 return _expandoBridge;
203 }
204
205 public Object clone() {
206 RegionImpl clone = new RegionImpl();
207
208 clone.setRegionId(getRegionId());
209 clone.setCountryId(getCountryId());
210 clone.setRegionCode(getRegionCode());
211 clone.setName(getName());
212 clone.setActive(getActive());
213
214 return clone;
215 }
216
217 public int compareTo(Region region) {
218 int value = 0;
219
220 value = getName().compareTo(region.getName());
221
222 if (value != 0) {
223 return value;
224 }
225
226 return 0;
227 }
228
229 public boolean equals(Object obj) {
230 if (obj == null) {
231 return false;
232 }
233
234 Region region = null;
235
236 try {
237 region = (Region)obj;
238 }
239 catch (ClassCastException cce) {
240 return false;
241 }
242
243 long pk = region.getPrimaryKey();
244
245 if (getPrimaryKey() == pk) {
246 return true;
247 }
248 else {
249 return false;
250 }
251 }
252
253 public int hashCode() {
254 return (int)getPrimaryKey();
255 }
256
257 public String toString() {
258 StringBuilder sb = new StringBuilder();
259
260 sb.append("{regionId=");
261 sb.append(getRegionId());
262 sb.append(", countryId=");
263 sb.append(getCountryId());
264 sb.append(", regionCode=");
265 sb.append(getRegionCode());
266 sb.append(", name=");
267 sb.append(getName());
268 sb.append(", active=");
269 sb.append(getActive());
270 sb.append("}");
271
272 return sb.toString();
273 }
274
275 public String toXmlString() {
276 StringBuilder sb = new StringBuilder();
277
278 sb.append("<model><model-name>");
279 sb.append("com.liferay.portal.model.Region");
280 sb.append("</model-name>");
281
282 sb.append(
283 "<column><column-name>regionId</column-name><column-value><![CDATA[");
284 sb.append(getRegionId());
285 sb.append("]]></column-value></column>");
286 sb.append(
287 "<column><column-name>countryId</column-name><column-value><![CDATA[");
288 sb.append(getCountryId());
289 sb.append("]]></column-value></column>");
290 sb.append(
291 "<column><column-name>regionCode</column-name><column-value><![CDATA[");
292 sb.append(getRegionCode());
293 sb.append("]]></column-value></column>");
294 sb.append(
295 "<column><column-name>name</column-name><column-value><![CDATA[");
296 sb.append(getName());
297 sb.append("]]></column-value></column>");
298 sb.append(
299 "<column><column-name>active</column-name><column-value><![CDATA[");
300 sb.append(getActive());
301 sb.append("]]></column-value></column>");
302
303 sb.append("</model>");
304
305 return sb.toString();
306 }
307
308 private long _regionId;
309 private long _countryId;
310 private String _regionCode;
311 private String _name;
312 private boolean _active;
313 private transient ExpandoBridge _expandoBridge;
314 }