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.ClassName;
022 import com.liferay.portal.model.ClassNameModel;
023 import com.liferay.portal.model.ClassNameSoap;
024 import com.liferay.portal.service.ServiceContext;
025 import com.liferay.portal.util.PortalUtil;
026
027 import com.liferay.portlet.expando.model.ExpandoBridge;
028 import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029
030 import java.io.Serializable;
031
032 import java.lang.reflect.Proxy;
033
034 import java.sql.Types;
035
036 import java.util.ArrayList;
037 import java.util.List;
038
039
056 public class ClassNameModelImpl extends BaseModelImpl<ClassName>
057 implements ClassNameModel {
058 public static final String TABLE_NAME = "ClassName_";
059 public static final Object[][] TABLE_COLUMNS = {
060 { "classNameId", new Integer(Types.BIGINT) },
061 { "value", new Integer(Types.VARCHAR) }
062 };
063 public static final String TABLE_SQL_CREATE = "create table ClassName_ (classNameId LONG not null primary key,value VARCHAR(200) null)";
064 public static final String TABLE_SQL_DROP = "drop table ClassName_";
065 public static final String DATA_SOURCE = "liferayDataSource";
066 public static final String SESSION_FACTORY = "liferaySessionFactory";
067 public static final String TX_MANAGER = "liferayTransactionManager";
068 public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069 "value.object.entity.cache.enabled.com.liferay.portal.model.ClassName"),
070 true);
071 public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072 "value.object.finder.cache.enabled.com.liferay.portal.model.ClassName"),
073 true);
074
075
081 public static ClassName toModel(ClassNameSoap soapModel) {
082 ClassName model = new ClassNameImpl();
083
084 model.setClassNameId(soapModel.getClassNameId());
085 model.setValue(soapModel.getValue());
086
087 return model;
088 }
089
090
096 public static List<ClassName> toModels(ClassNameSoap[] soapModels) {
097 List<ClassName> models = new ArrayList<ClassName>(soapModels.length);
098
099 for (ClassNameSoap 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.ClassName"));
108
109 public ClassNameModelImpl() {
110 }
111
112 public long getPrimaryKey() {
113 return _classNameId;
114 }
115
116 public void setPrimaryKey(long pk) {
117 setClassNameId(pk);
118 }
119
120 public Serializable getPrimaryKeyObj() {
121 return new Long(_classNameId);
122 }
123
124 public String getClassName() {
125 if (getClassNameId() <= 0) {
126 return StringPool.BLANK;
127 }
128
129 return PortalUtil.getClassName(getClassNameId());
130 }
131
132 public long getClassNameId() {
133 return _classNameId;
134 }
135
136 public void setClassNameId(long classNameId) {
137 _classNameId = classNameId;
138 }
139
140 public String getValue() {
141 if (_value == null) {
142 return StringPool.BLANK;
143 }
144 else {
145 return _value;
146 }
147 }
148
149 public void setValue(String value) {
150 _value = value;
151
152 if (_originalValue == null) {
153 _originalValue = value;
154 }
155 }
156
157 public String getOriginalValue() {
158 return GetterUtil.getString(_originalValue);
159 }
160
161 public ClassName toEscapedModel() {
162 if (isEscapedModel()) {
163 return (ClassName)this;
164 }
165 else {
166 return (ClassName)Proxy.newProxyInstance(ClassName.class.getClassLoader(),
167 new Class[] { ClassName.class }, new AutoEscapeBeanHandler(this));
168 }
169 }
170
171 public ExpandoBridge getExpandoBridge() {
172 if (_expandoBridge == null) {
173 _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
174 ClassName.class.getName(), getPrimaryKey());
175 }
176
177 return _expandoBridge;
178 }
179
180 public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
181 getExpandoBridge().setAttributes(serviceContext);
182 }
183
184 public Object clone() {
185 ClassNameImpl clone = new ClassNameImpl();
186
187 clone.setClassNameId(getClassNameId());
188 clone.setValue(getValue());
189
190 return clone;
191 }
192
193 public int compareTo(ClassName className) {
194 long pk = className.getPrimaryKey();
195
196 if (getPrimaryKey() < pk) {
197 return -1;
198 }
199 else if (getPrimaryKey() > pk) {
200 return 1;
201 }
202 else {
203 return 0;
204 }
205 }
206
207 public boolean equals(Object obj) {
208 if (obj == null) {
209 return false;
210 }
211
212 ClassName className = null;
213
214 try {
215 className = (ClassName)obj;
216 }
217 catch (ClassCastException cce) {
218 return false;
219 }
220
221 long pk = className.getPrimaryKey();
222
223 if (getPrimaryKey() == pk) {
224 return true;
225 }
226 else {
227 return false;
228 }
229 }
230
231 public int hashCode() {
232 return (int)getPrimaryKey();
233 }
234
235 public String toString() {
236 StringBundler sb = new StringBundler(5);
237
238 sb.append("{classNameId=");
239 sb.append(getClassNameId());
240 sb.append(", value=");
241 sb.append(getValue());
242 sb.append("}");
243
244 return sb.toString();
245 }
246
247 public String toXmlString() {
248 StringBundler sb = new StringBundler(10);
249
250 sb.append("<model><model-name>");
251 sb.append("com.liferay.portal.model.ClassName");
252 sb.append("</model-name>");
253
254 sb.append(
255 "<column><column-name>classNameId</column-name><column-value><![CDATA[");
256 sb.append(getClassNameId());
257 sb.append("]]></column-value></column>");
258 sb.append(
259 "<column><column-name>value</column-name><column-value><![CDATA[");
260 sb.append(getValue());
261 sb.append("]]></column-value></column>");
262
263 sb.append("</model>");
264
265 return sb.toString();
266 }
267
268 private long _classNameId;
269 private String _value;
270 private String _originalValue;
271 private transient ExpandoBridge _expandoBridge;
272 }