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