001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
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.ResourceCode;
022    import com.liferay.portal.model.ResourceCodeModel;
023    import com.liferay.portal.service.ServiceContext;
024    
025    import com.liferay.portlet.expando.model.ExpandoBridge;
026    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
027    
028    import java.io.Serializable;
029    
030    import java.lang.reflect.Proxy;
031    
032    import java.sql.Types;
033    
034    /**
035     * The base model implementation for the ResourceCode service. Represents a row in the "ResourceCode" database table, with each column mapped to a property of this class.
036     *
037     * <p>
038     * This implementation and its corresponding interface {@link com.liferay.portal.model.ResourceCodeModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ResourceCodeImpl}.
039     * </p>
040     *
041     * <p>
042     * Never modify or reference this class directly. All methods that expect a resource code model instance should use the {@link com.liferay.portal.model.ResourceCode} interface instead.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ResourceCodeImpl
047     * @see com.liferay.portal.model.ResourceCode
048     * @see com.liferay.portal.model.ResourceCodeModel
049     * @generated
050     */
051    public class ResourceCodeModelImpl extends BaseModelImpl<ResourceCode>
052            implements ResourceCodeModel {
053            public static final String TABLE_NAME = "ResourceCode";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "codeId", new Integer(Types.BIGINT) },
056                            { "companyId", new Integer(Types.BIGINT) },
057                            { "name", new Integer(Types.VARCHAR) },
058                            { "scope", new Integer(Types.INTEGER) }
059                    };
060            public static final String TABLE_SQL_CREATE = "create table ResourceCode (codeId LONG not null primary key,companyId LONG,name VARCHAR(255) null,scope INTEGER)";
061            public static final String TABLE_SQL_DROP = "drop table ResourceCode";
062            public static final String DATA_SOURCE = "liferayDataSource";
063            public static final String SESSION_FACTORY = "liferaySessionFactory";
064            public static final String TX_MANAGER = "liferayTransactionManager";
065            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
066                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceCode"),
067                            true);
068            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceCode"),
070                            true);
071            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
072                                    "lock.expiration.time.com.liferay.portal.model.ResourceCode"));
073    
074            public ResourceCodeModelImpl() {
075            }
076    
077            public long getPrimaryKey() {
078                    return _codeId;
079            }
080    
081            public void setPrimaryKey(long pk) {
082                    setCodeId(pk);
083            }
084    
085            public Serializable getPrimaryKeyObj() {
086                    return new Long(_codeId);
087            }
088    
089            public long getCodeId() {
090                    return _codeId;
091            }
092    
093            public void setCodeId(long codeId) {
094                    _codeId = codeId;
095            }
096    
097            public long getCompanyId() {
098                    return _companyId;
099            }
100    
101            public void setCompanyId(long companyId) {
102                    _companyId = companyId;
103    
104                    if (!_setOriginalCompanyId) {
105                            _setOriginalCompanyId = true;
106    
107                            _originalCompanyId = companyId;
108                    }
109            }
110    
111            public long getOriginalCompanyId() {
112                    return _originalCompanyId;
113            }
114    
115            public String getName() {
116                    if (_name == null) {
117                            return StringPool.BLANK;
118                    }
119                    else {
120                            return _name;
121                    }
122            }
123    
124            public void setName(String name) {
125                    _name = name;
126    
127                    if (_originalName == null) {
128                            _originalName = name;
129                    }
130            }
131    
132            public String getOriginalName() {
133                    return GetterUtil.getString(_originalName);
134            }
135    
136            public int getScope() {
137                    return _scope;
138            }
139    
140            public void setScope(int scope) {
141                    _scope = scope;
142    
143                    if (!_setOriginalScope) {
144                            _setOriginalScope = true;
145    
146                            _originalScope = scope;
147                    }
148            }
149    
150            public int getOriginalScope() {
151                    return _originalScope;
152            }
153    
154            public ResourceCode toEscapedModel() {
155                    if (isEscapedModel()) {
156                            return (ResourceCode)this;
157                    }
158                    else {
159                            return (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
160                                    new Class[] { ResourceCode.class },
161                                    new AutoEscapeBeanHandler(this));
162                    }
163            }
164    
165            public ExpandoBridge getExpandoBridge() {
166                    if (_expandoBridge == null) {
167                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
168                                            ResourceCode.class.getName(), getPrimaryKey());
169                    }
170    
171                    return _expandoBridge;
172            }
173    
174            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
175                    getExpandoBridge().setAttributes(serviceContext);
176            }
177    
178            public Object clone() {
179                    ResourceCodeImpl clone = new ResourceCodeImpl();
180    
181                    clone.setCodeId(getCodeId());
182                    clone.setCompanyId(getCompanyId());
183                    clone.setName(getName());
184                    clone.setScope(getScope());
185    
186                    return clone;
187            }
188    
189            public int compareTo(ResourceCode resourceCode) {
190                    long pk = resourceCode.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                    ResourceCode resourceCode = null;
209    
210                    try {
211                            resourceCode = (ResourceCode)obj;
212                    }
213                    catch (ClassCastException cce) {
214                            return false;
215                    }
216    
217                    long pk = resourceCode.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            public String toString() {
232                    StringBundler sb = new StringBundler(9);
233    
234                    sb.append("{codeId=");
235                    sb.append(getCodeId());
236                    sb.append(", companyId=");
237                    sb.append(getCompanyId());
238                    sb.append(", name=");
239                    sb.append(getName());
240                    sb.append(", scope=");
241                    sb.append(getScope());
242                    sb.append("}");
243    
244                    return sb.toString();
245            }
246    
247            public String toXmlString() {
248                    StringBundler sb = new StringBundler(16);
249    
250                    sb.append("<model><model-name>");
251                    sb.append("com.liferay.portal.model.ResourceCode");
252                    sb.append("</model-name>");
253    
254                    sb.append(
255                            "<column><column-name>codeId</column-name><column-value><![CDATA[");
256                    sb.append(getCodeId());
257                    sb.append("]]></column-value></column>");
258                    sb.append(
259                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
260                    sb.append(getCompanyId());
261                    sb.append("]]></column-value></column>");
262                    sb.append(
263                            "<column><column-name>name</column-name><column-value><![CDATA[");
264                    sb.append(getName());
265                    sb.append("]]></column-value></column>");
266                    sb.append(
267                            "<column><column-name>scope</column-name><column-value><![CDATA[");
268                    sb.append(getScope());
269                    sb.append("]]></column-value></column>");
270    
271                    sb.append("</model>");
272    
273                    return sb.toString();
274            }
275    
276            private long _codeId;
277            private long _companyId;
278            private long _originalCompanyId;
279            private boolean _setOriginalCompanyId;
280            private String _name;
281            private String _originalName;
282            private int _scope;
283            private int _originalScope;
284            private boolean _setOriginalScope;
285            private transient ExpandoBridge _expandoBridge;
286    }