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.setNew(isNew());
159 model.setEscapedModel(true);
160
161 model.setResourceId(getResourceId());
162 model.setCodeId(getCodeId());
163 model.setPrimKey(HtmlUtil.escape(getPrimKey()));
164
165 model = (Resource)Proxy.newProxyInstance(Resource.class.getClassLoader(),
166 new Class[] { Resource.class },
167 new ReadOnlyBeanHandler(model));
168
169 return model;
170 }
171 }
172
173 public Object clone() {
174 ResourceImpl clone = new ResourceImpl();
175
176 clone.setResourceId(getResourceId());
177 clone.setCodeId(getCodeId());
178 clone.setPrimKey(getPrimKey());
179
180 return clone;
181 }
182
183 public int compareTo(Object obj) {
184 if (obj == null) {
185 return -1;
186 }
187
188 ResourceImpl resource = (ResourceImpl)obj;
189
190 long pk = resource.getPrimaryKey();
191
192 if (getPrimaryKey() < pk) {
193 return -1;
194 }
195 else if (getPrimaryKey() > pk) {
196 return 1;
197 }
198 else {
199 return 0;
200 }
201 }
202
203 public boolean equals(Object obj) {
204 if (obj == null) {
205 return false;
206 }
207
208 ResourceImpl resource = null;
209
210 try {
211 resource = (ResourceImpl)obj;
212 }
213 catch (ClassCastException cce) {
214 return false;
215 }
216
217 long pk = resource.getPrimaryKey();
218
219 if (getPrimaryKey() == pk) {
220 return true;
221 }
222 else {
223 return false;
224 }
225 }
226
227 public int hashCode() {
228 return (int)getPrimaryKey();
229 }
230
231 private long _resourceId;
232 private long _codeId;
233 private String _primKey;
234 }