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 clone = new RegionImpl();
210
211 clone.setRegionId(getRegionId());
212 clone.setCountryId(getCountryId());
213 clone.setRegionCode(getRegionCode());
214 clone.setName(getName());
215 clone.setActive(getActive());
216
217 return clone;
218 }
219
220 public int compareTo(Region region) {
221 int value = 0;
222
223 value = getName().compareTo(region.getName());
224
225 if (value != 0) {
226 return value;
227 }
228
229 return 0;
230 }
231
232 public boolean equals(Object obj) {
233 if (obj == null) {
234 return false;
235 }
236
237 Region region = null;
238
239 try {
240 region = (Region)obj;
241 }
242 catch (ClassCastException cce) {
243 return false;
244 }
245
246 long pk = region.getPrimaryKey();
247
248 if (getPrimaryKey() == pk) {
249 return true;
250 }
251 else {
252 return false;
253 }
254 }
255
256 public int hashCode() {
257 return (int)getPrimaryKey();
258 }
259
260 public String toString() {
261 StringBundler sb = new StringBundler(11);
262
263 sb.append("{regionId=");
264 sb.append(getRegionId());
265 sb.append(", countryId=");
266 sb.append(getCountryId());
267 sb.append(", regionCode=");
268 sb.append(getRegionCode());
269 sb.append(", name=");
270 sb.append(getName());
271 sb.append(", active=");
272 sb.append(getActive());
273 sb.append("}");
274
275 return sb.toString();
276 }
277
278 public String toXmlString() {
279 StringBundler sb = new StringBundler(19);
280
281 sb.append("<model><model-name>");
282 sb.append("com.liferay.portal.model.Region");
283 sb.append("</model-name>");
284
285 sb.append(
286 "<column><column-name>regionId</column-name><column-value><![CDATA[");
287 sb.append(getRegionId());
288 sb.append("]]></column-value></column>");
289 sb.append(
290 "<column><column-name>countryId</column-name><column-value><![CDATA[");
291 sb.append(getCountryId());
292 sb.append("]]></column-value></column>");
293 sb.append(
294 "<column><column-name>regionCode</column-name><column-value><![CDATA[");
295 sb.append(getRegionCode());
296 sb.append("]]></column-value></column>");
297 sb.append(
298 "<column><column-name>name</column-name><column-value><![CDATA[");
299 sb.append(getName());
300 sb.append("]]></column-value></column>");
301 sb.append(
302 "<column><column-name>active</column-name><column-value><![CDATA[");
303 sb.append(getActive());
304 sb.append("]]></column-value></column>");
305
306 sb.append("</model>");
307
308 return sb.toString();
309 }
310
311 private long _regionId;
312 private long _countryId;
313 private String _regionCode;
314 private String _name;
315 private boolean _active;
316 private transient ExpandoBridge _expandoBridge;
317 }