1
19
20 package com.liferay.portal.model.impl;
21
22 import com.liferay.portal.kernel.bean.ReadOnlyBeanHandler;
23 import com.liferay.portal.kernel.util.GetterUtil;
24 import com.liferay.portal.kernel.util.HtmlUtil;
25 import com.liferay.portal.model.Resource;
26 import com.liferay.portal.model.ResourceSoap;
27
28 import java.io.Serializable;
29
30 import java.lang.reflect.Proxy;
31
32 import java.sql.Types;
33
34 import java.util.ArrayList;
35 import java.util.List;
36
37
57 public class ResourceModelImpl extends BaseModelImpl {
58 public static final String TABLE_NAME = "Resource_";
59 public static final Object[][] TABLE_COLUMNS = {
60 { "resourceId", new Integer(Types.BIGINT) },
61
62
63 { "codeId", new Integer(Types.BIGINT) },
64
65
66 { "primKey", new Integer(Types.VARCHAR) }
67 };
68 public static final String TABLE_SQL_CREATE = "create table Resource_ (resourceId LONG not null primary key,codeId LONG,primKey VARCHAR(300) null)";
69 public static final String TABLE_SQL_DROP = "drop table Resource_";
70 public static final String DATA_SOURCE = "liferayDataSource";
71 public static final String SESSION_FACTORY = "liferaySessionFactory";
72 public static final String TX_MANAGER = "liferayTransactionManager";
73 public static final boolean CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
74 "value.object.finder.cache.enabled.com.liferay.portal.model.Resource"),
75 true);
76
77 public static Resource toModel(ResourceSoap soapModel) {
78 Resource model = new ResourceImpl();
79
80 model.setResourceId(soapModel.getResourceId());
81 model.setCodeId(soapModel.getCodeId());
82 model.setPrimKey(soapModel.getPrimKey());
83
84 return model;
85 }
86
87 public static List<Resource> toModels(ResourceSoap[] soapModels) {
88 List<Resource> models = new ArrayList<Resource>(soapModels.length);
89
90 for (ResourceSoap soapModel : soapModels) {
91 models.add(toModel(soapModel));
92 }
93
94 return models;
95 }
96
97 public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
98 "lock.expiration.time.com.liferay.portal.model.Resource"));
99
100 public ResourceModelImpl() {
101 }
102
103 public long getPrimaryKey() {
104 return _resourceId;
105 }
106
107 public void setPrimaryKey(long pk) {
108 setResourceId(pk);
109 }
110
111 public Serializable getPrimaryKeyObj() {
112 return new Long(_resourceId);
113 }
114
115 public long getResourceId() {
116 return _resourceId;
117 }
118
119 public void setResourceId(long resourceId) {
120 if (resourceId != _resourceId) {
121 _resourceId = resourceId;
122 }
123 }
124
125 public long getCodeId() {
126 return _codeId;
127 }
128
129 public void setCodeId(long codeId) {
130 if (codeId != _codeId) {
131 _codeId = codeId;
132 }
133 }
134
135 public String getPrimKey() {
136 return GetterUtil.getString(_primKey);
137 }
138
139 public void setPrimKey(String primKey) {
140 if (((primKey == null) && (_primKey != null)) ||
141 ((primKey != null) && (_primKey == null)) ||
142 ((primKey != null) && (_primKey != null) &&
143 !primKey.equals(_primKey))) {
144 _primKey = primKey;
145 }
146 }
147
148 public Resource toEscapedModel() {
149 if (isEscapedModel()) {
150 return (Resource)this;
151 }
152 else {
153 Resource model = new ResourceImpl();
154
155 model.setNew(isNew());
156 model.setEscapedModel(true);
157
158 model.setResourceId(getResourceId());
159 model.setCodeId(getCodeId());
160 model.setPrimKey(HtmlUtil.escape(getPrimKey()));
161
162 model = (Resource)Proxy.newProxyInstance(Resource.class.getClassLoader(),
163 new Class[] { Resource.class },
164 new ReadOnlyBeanHandler(model));
165
166 return model;
167 }
168 }
169
170 public Object clone() {
171 ResourceImpl clone = new ResourceImpl();
172
173 clone.setResourceId(getResourceId());
174 clone.setCodeId(getCodeId());
175 clone.setPrimKey(getPrimKey());
176
177 return clone;
178 }
179
180 public int compareTo(Object obj) {
181 if (obj == null) {
182 return -1;
183 }
184
185 ResourceImpl resource = (ResourceImpl)obj;
186
187 long pk = resource.getPrimaryKey();
188
189 if (getPrimaryKey() < pk) {
190 return -1;
191 }
192 else if (getPrimaryKey() > pk) {
193 return 1;
194 }
195 else {
196 return 0;
197 }
198 }
199
200 public boolean equals(Object obj) {
201 if (obj == null) {
202 return false;
203 }
204
205 ResourceImpl resource = null;
206
207 try {
208 resource = (ResourceImpl)obj;
209 }
210 catch (ClassCastException cce) {
211 return false;
212 }
213
214 long pk = resource.getPrimaryKey();
215
216 if (getPrimaryKey() == pk) {
217 return true;
218 }
219 else {
220 return false;
221 }
222 }
223
224 public int hashCode() {
225 return (int)getPrimaryKey();
226 }
227
228 private long _resourceId;
229 private long _codeId;
230 private String _primKey;
231 }