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