1
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
24 import java.io.Serializable;
25
26 import java.lang.reflect.Proxy;
27
28 import java.sql.Types;
29
30 import java.util.ArrayList;
31 import java.util.List;
32
33
52 public class RegionModelImpl extends BaseModelImpl<Region> {
53 public static final String TABLE_NAME = "Region";
54 public static final Object[][] TABLE_COLUMNS = {
55 { "regionId", new Integer(Types.BIGINT) },
56 { "countryId", new Integer(Types.BIGINT) },
57 { "regionCode", new Integer(Types.VARCHAR) },
58 { "name", new Integer(Types.VARCHAR) },
59 { "active_", new Integer(Types.BOOLEAN) }
60 };
61 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)";
62 public static final String TABLE_SQL_DROP = "drop table Region";
63 public static final String ORDER_BY_JPQL = " ORDER BY region.name ASC";
64 public static final String ORDER_BY_SQL = " ORDER BY Region.name ASC";
65 public static final String DATA_SOURCE = "liferayDataSource";
66 public static final String SESSION_FACTORY = "liferaySessionFactory";
67 public static final String TX_MANAGER = "liferayTransactionManager";
68 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
69 "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
70 true);
71 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
72 "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
73 true);
74
75 public static Region toModel(RegionSoap soapModel) {
76 Region model = new RegionImpl();
77
78 model.setRegionId(soapModel.getRegionId());
79 model.setCountryId(soapModel.getCountryId());
80 model.setRegionCode(soapModel.getRegionCode());
81 model.setName(soapModel.getName());
82 model.setActive(soapModel.getActive());
83
84 return model;
85 }
86
87 public static List<Region> toModels(RegionSoap[] soapModels) {
88 List<Region> models = new ArrayList<Region>(soapModels.length);
89
90 for (RegionSoap soapModel : soapModels) {
91 models.add(toModel(soapModel));
92 }
93
94 return models;
95 }
96
97 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
98 "lock.expiration.time.com.liferay.portal.model.Region"));
99
100 public RegionModelImpl() {
101 }
102
103 public long getPrimaryKey() {
104 return _regionId;
105 }
106
107 public void setPrimaryKey(long pk) {
108 setRegionId(pk);
109 }
110
111 public Serializable getPrimaryKeyObj() {
112 return new Long(_regionId);
113 }
114
115 public long getRegionId() {
116 return _regionId;
117 }
118
119 public void setRegionId(long regionId) {
120 _regionId = regionId;
121 }
122
123 public long getCountryId() {
124 return _countryId;
125 }
126
127 public void setCountryId(long countryId) {
128 _countryId = countryId;
129 }
130
131 public String getRegionCode() {
132 return GetterUtil.getString(_regionCode);
133 }
134
135 public void setRegionCode(String regionCode) {
136 _regionCode = regionCode;
137 }
138
139 public String getName() {
140 return GetterUtil.getString(_name);
141 }
142
143 public void setName(String name) {
144 _name = name;
145 }
146
147 public boolean getActive() {
148 return _active;
149 }
150
151 public boolean isActive() {
152 return _active;
153 }
154
155 public void setActive(boolean active) {
156 _active = active;
157 }
158
159 public Region toEscapedModel() {
160 if (isEscapedModel()) {
161 return (Region)this;
162 }
163 else {
164 Region model = new RegionImpl();
165
166 model.setNew(isNew());
167 model.setEscapedModel(true);
168
169 model.setRegionId(getRegionId());
170 model.setCountryId(getCountryId());
171 model.setRegionCode(HtmlUtil.escape(getRegionCode()));
172 model.setName(HtmlUtil.escape(getName()));
173 model.setActive(getActive());
174
175 model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
176 new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
177
178 return model;
179 }
180 }
181
182 public Object clone() {
183 RegionImpl clone = new RegionImpl();
184
185 clone.setRegionId(getRegionId());
186 clone.setCountryId(getCountryId());
187 clone.setRegionCode(getRegionCode());
188 clone.setName(getName());
189 clone.setActive(getActive());
190
191 return clone;
192 }
193
194 public int compareTo(Region region) {
195 int value = 0;
196
197 value = getName().compareTo(region.getName());
198
199 if (value != 0) {
200 return value;
201 }
202
203 return 0;
204 }
205
206 public boolean equals(Object obj) {
207 if (obj == null) {
208 return false;
209 }
210
211 Region region = null;
212
213 try {
214 region = (Region)obj;
215 }
216 catch (ClassCastException cce) {
217 return false;
218 }
219
220 long pk = region.getPrimaryKey();
221
222 if (getPrimaryKey() == pk) {
223 return true;
224 }
225 else {
226 return false;
227 }
228 }
229
230 public int hashCode() {
231 return (int)getPrimaryKey();
232 }
233
234 public String toString() {
235 StringBundler sb = new StringBundler(11);
236
237 sb.append("{regionId=");
238 sb.append(getRegionId());
239 sb.append(", countryId=");
240 sb.append(getCountryId());
241 sb.append(", regionCode=");
242 sb.append(getRegionCode());
243 sb.append(", name=");
244 sb.append(getName());
245 sb.append(", active=");
246 sb.append(getActive());
247 sb.append("}");
248
249 return sb.toString();
250 }
251
252 public String toXmlString() {
253 StringBundler sb = new StringBundler(19);
254
255 sb.append("<model><model-name>");
256 sb.append("com.liferay.portal.model.Region");
257 sb.append("</model-name>");
258
259 sb.append(
260 "<column><column-name>regionId</column-name><column-value><![CDATA[");
261 sb.append(getRegionId());
262 sb.append("]]></column-value></column>");
263 sb.append(
264 "<column><column-name>countryId</column-name><column-value><![CDATA[");
265 sb.append(getCountryId());
266 sb.append("]]></column-value></column>");
267 sb.append(
268 "<column><column-name>regionCode</column-name><column-value><![CDATA[");
269 sb.append(getRegionCode());
270 sb.append("]]></column-value></column>");
271 sb.append(
272 "<column><column-name>name</column-name><column-value><![CDATA[");
273 sb.append(getName());
274 sb.append("]]></column-value></column>");
275 sb.append(
276 "<column><column-name>active</column-name><column-value><![CDATA[");
277 sb.append(getActive());
278 sb.append("]]></column-value></column>");
279
280 sb.append("</model>");
281
282 return sb.toString();
283 }
284
285 private long _regionId;
286 private long _countryId;
287 private String _regionCode;
288 private String _name;
289 private boolean _active;
290 }