001
014
015 package com.liferay.portal.model.impl;
016
017 import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.StringBundler;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.model.Region;
022 import com.liferay.portal.model.RegionModel;
023 import com.liferay.portal.model.RegionSoap;
024 import com.liferay.portal.service.ServiceContext;
025
026 import com.liferay.portlet.expando.model.ExpandoBridge;
027 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
028
029 import java.io.Serializable;
030
031 import java.lang.reflect.Proxy;
032
033 import java.sql.Types;
034
035 import java.util.ArrayList;
036 import java.util.List;
037
038
055 public class RegionModelImpl extends BaseModelImpl<Region>
056 implements RegionModel {
057 public static final String TABLE_NAME = "Region";
058 public static final Object[][] TABLE_COLUMNS = {
059 { "regionId", new Integer(Types.BIGINT) },
060 { "countryId", new Integer(Types.BIGINT) },
061 { "regionCode", new Integer(Types.VARCHAR) },
062 { "name", new Integer(Types.VARCHAR) },
063 { "active_", new Integer(Types.BOOLEAN) }
064 };
065 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)";
066 public static final String TABLE_SQL_DROP = "drop table Region";
067 public static final String ORDER_BY_JPQL = " ORDER BY region.name ASC";
068 public static final String ORDER_BY_SQL = " ORDER BY Region.name ASC";
069 public static final String DATA_SOURCE = "liferayDataSource";
070 public static final String SESSION_FACTORY = "liferaySessionFactory";
071 public static final String TX_MANAGER = "liferayTransactionManager";
072 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073 "value.object.entity.cache.enabled.com.liferay.portal.model.Region"),
074 true);
075 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076 "value.object.finder.cache.enabled.com.liferay.portal.model.Region"),
077 true);
078
079
085 public static Region toModel(RegionSoap soapModel) {
086 Region model = new RegionImpl();
087
088 model.setRegionId(soapModel.getRegionId());
089 model.setCountryId(soapModel.getCountryId());
090 model.setRegionCode(soapModel.getRegionCode());
091 model.setName(soapModel.getName());
092 model.setActive(soapModel.getActive());
093
094 return model;
095 }
096
097
103 public static List<Region> toModels(RegionSoap[] soapModels) {
104 List<Region> models = new ArrayList<Region>(soapModels.length);
105
106 for (RegionSoap soapModel : soapModels) {
107 models.add(toModel(soapModel));
108 }
109
110 return models;
111 }
112
113 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
114 "lock.expiration.time.com.liferay.portal.model.Region"));
115
116 public RegionModelImpl() {
117 }
118
119 public long getPrimaryKey() {
120 return _regionId;
121 }
122
123 public void setPrimaryKey(long pk) {
124 setRegionId(pk);
125 }
126
127 public Serializable getPrimaryKeyObj() {
128 return new Long(_regionId);
129 }
130
131 public long getRegionId() {
132 return _regionId;
133 }
134
135 public void setRegionId(long regionId) {
136 _regionId = regionId;
137 }
138
139 public long getCountryId() {
140 return _countryId;
141 }
142
143 public void setCountryId(long countryId) {
144 _countryId = countryId;
145 }
146
147 public String getRegionCode() {
148 if (_regionCode == null) {
149 return StringPool.BLANK;
150 }
151 else {
152 return _regionCode;
153 }
154 }
155
156 public void setRegionCode(String regionCode) {
157 _regionCode = regionCode;
158 }
159
160 public String getName() {
161 if (_name == null) {
162 return StringPool.BLANK;
163 }
164 else {
165 return _name;
166 }
167 }
168
169 public void setName(String name) {
170 _name = name;
171 }
172
173 public boolean getActive() {
174 return _active;
175 }
176
177 public boolean isActive() {
178 return _active;
179 }
180
181 public void setActive(boolean active) {
182 _active = active;
183 }
184
185 public Region toEscapedModel() {
186 if (isEscapedModel()) {
187 return (Region)this;
188 }
189 else {
190 return (Region)Proxy.newProxyInstance(Region.class.getClassLoader(),
191 new Class[] { Region.class }, new AutoEscapeBeanHandler(this));
192 }
193 }
194
195 public ExpandoBridge getExpandoBridge() {
196 if (_expandoBridge == null) {
197 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
198 Region.class.getName(), getPrimaryKey());
199 }
200
201 return _expandoBridge;
202 }
203
204 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
205 getExpandoBridge().setAttributes(serviceContext);
206 }
207
208 public Object clone() {
209 RegionImpl regionImpl = new RegionImpl();
210
211 regionImpl.setRegionId(getRegionId());
212
213 regionImpl.setCountryId(getCountryId());
214
215 regionImpl.setRegionCode(getRegionCode());
216
217 regionImpl.setName(getName());
218
219 regionImpl.setActive(getActive());
220
221 return regionImpl;
222 }
223
224 public int compareTo(Region region) {
225 int value = 0;
226
227 value = getName().compareTo(region.getName());
228
229 if (value != 0) {
230 return value;
231 }
232
233 return 0;
234 }
235
236 public boolean equals(Object obj) {
237 if (obj == null) {
238 return false;
239 }
240
241 Region region = null;
242
243 try {
244 region = (Region)obj;
245 }
246 catch (ClassCastException cce) {
247 return false;
248 }
249
250 long pk = region.getPrimaryKey();
251
252 if (getPrimaryKey() == pk) {
253 return true;
254 }
255 else {
256 return false;
257 }
258 }
259
260 public int hashCode() {
261 return (int)getPrimaryKey();
262 }
263
264 public String toString() {
265 StringBundler sb = new StringBundler(11);
266
267 sb.append("{regionId=");
268 sb.append(getRegionId());
269 sb.append(", countryId=");
270 sb.append(getCountryId());
271 sb.append(", regionCode=");
272 sb.append(getRegionCode());
273 sb.append(", name=");
274 sb.append(getName());
275 sb.append(", active=");
276 sb.append(getActive());
277 sb.append("}");
278
279 return sb.toString();
280 }
281
282 public String toXmlString() {
283 StringBundler sb = new StringBundler(19);
284
285 sb.append("<model><model-name>");
286 sb.append("com.liferay.portal.model.Region");
287 sb.append("</model-name>");
288
289 sb.append(
290 "<column><column-name>regionId</column-name><column-value><![CDATA[");
291 sb.append(getRegionId());
292 sb.append("]]></column-value></column>");
293 sb.append(
294 "<column><column-name>countryId</column-name><column-value><![CDATA[");
295 sb.append(getCountryId());
296 sb.append("]]></column-value></column>");
297 sb.append(
298 "<column><column-name>regionCode</column-name><column-value><![CDATA[");
299 sb.append(getRegionCode());
300 sb.append("]]></column-value></column>");
301 sb.append(
302 "<column><column-name>name</column-name><column-value><![CDATA[");
303 sb.append(getName());
304 sb.append("]]></column-value></column>");
305 sb.append(
306 "<column><column-name>active</column-name><column-value><![CDATA[");
307 sb.append(getActive());
308 sb.append("]]></column-value></column>");
309
310 sb.append("</model>");
311
312 return sb.toString();
313 }
314
315 private long _regionId;
316 private long _countryId;
317 private String _regionCode;
318 private String _name;
319 private boolean _active;
320 private transient ExpandoBridge _expandoBridge;
321 }