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