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