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
31 import com.liferay.portlet.expando.model.ExpandoBridge;
32 import com.liferay.portlet.expando.model.impl.ExpandoBridgeImpl;
33
34 import java.io.Serializable;
35
36 import java.lang.reflect.Proxy;
37
38 import java.sql.Types;
39
40 import java.util.ArrayList;
41 import java.util.List;
42
43
63 public class RegionModelImpl extends BaseModelImpl {
64 public static final String TABLE_NAME = "Region";
65 public static final Object[][] TABLE_COLUMNS = {
66 { "regionId", new Integer(Types.BIGINT) },
67
68
69 { "countryId", new Integer(Types.BIGINT) },
70
71
72 { "regionCode", new Integer(Types.VARCHAR) },
73
74
75 { "name", new Integer(Types.VARCHAR) },
76
77
78 { "active_", new Integer(Types.BOOLEAN) }
79 };
80 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)";
81 public static final String TABLE_SQL_DROP = "drop table Region";
82 public static final String DATA_SOURCE = "liferayDataSource";
83 public static final String SESSION_FACTORY = "liferaySessionFactory";
84 public static final String TX_MANAGER = "liferayTransactionManager";
85 public static final boolean 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 if (regionId != _regionId) {
135 _regionId = regionId;
136 }
137 }
138
139 public long getCountryId() {
140 return _countryId;
141 }
142
143 public void setCountryId(long countryId) {
144 if (countryId != _countryId) {
145 _countryId = countryId;
146 }
147 }
148
149 public String getRegionCode() {
150 return GetterUtil.getString(_regionCode);
151 }
152
153 public void setRegionCode(String regionCode) {
154 if (((regionCode == null) && (_regionCode != null)) ||
155 ((regionCode != null) && (_regionCode == null)) ||
156 ((regionCode != null) && (_regionCode != null) &&
157 !regionCode.equals(_regionCode))) {
158 _regionCode = regionCode;
159 }
160 }
161
162 public String getName() {
163 return GetterUtil.getString(_name);
164 }
165
166 public void setName(String name) {
167 if (((name == null) && (_name != null)) ||
168 ((name != null) && (_name == null)) ||
169 ((name != null) && (_name != null) && !name.equals(_name))) {
170 _name = name;
171 }
172 }
173
174 public boolean getActive() {
175 return _active;
176 }
177
178 public boolean isActive() {
179 return _active;
180 }
181
182 public void setActive(boolean active) {
183 if (active != _active) {
184 _active = active;
185 }
186 }
187
188 public Region toEscapedModel() {
189 if (isEscapedModel()) {
190 return (Region)this;
191 }
192 else {
193 Region model = new RegionImpl();
194
195 model.setNew(isNew());
196 model.setEscapedModel(true);
197
198 model.setRegionId(getRegionId());
199 model.setCountryId(getCountryId());
200 model.setRegionCode(HtmlUtil.escape(getRegionCode()));
201 model.setName(HtmlUtil.escape(getName()));
202 model.setActive(getActive());
203
204 model = (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
205 new Class[] { Region.class }, new ReadOnlyBeanHandler(model));
206
207 return model;
208 }
209 }
210
211 public ExpandoBridge getExpandoBridge() {
212 if (_expandoBridge == null) {
213 _expandoBridge = new ExpandoBridgeImpl(Region.class.getName(),
214 getPrimaryKey());
215 }
216
217 return _expandoBridge;
218 }
219
220 public Object clone() {
221 RegionImpl clone = new RegionImpl();
222
223 clone.setRegionId(getRegionId());
224 clone.setCountryId(getCountryId());
225 clone.setRegionCode(getRegionCode());
226 clone.setName(getName());
227 clone.setActive(getActive());
228
229 return clone;
230 }
231
232 public int compareTo(Object obj) {
233 if (obj == null) {
234 return -1;
235 }
236
237 RegionImpl region = (RegionImpl)obj;
238
239 int value = 0;
240
241 value = getName().compareTo(region.getName());
242
243 if (value != 0) {
244 return value;
245 }
246
247 return 0;
248 }
249
250 public boolean equals(Object obj) {
251 if (obj == null) {
252 return false;
253 }
254
255 RegionImpl region = null;
256
257 try {
258 region = (RegionImpl)obj;
259 }
260 catch (ClassCastException cce) {
261 return false;
262 }
263
264 long pk = region.getPrimaryKey();
265
266 if (getPrimaryKey() == pk) {
267 return true;
268 }
269 else {
270 return false;
271 }
272 }
273
274 public int hashCode() {
275 return (int)getPrimaryKey();
276 }
277
278 private long _regionId;
279 private long _countryId;
280 private String _regionCode;
281 private String _name;
282 private boolean _active;
283 private transient ExpandoBridge _expandoBridge;
284 }