001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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     * <p>
036     * This interface is a model that represents the ResourceCode table in the
037     * database.
038     * </p>
039     *
040     * @author    Brian Wing Shun Chan
041     * @see       ResourceCodeImpl
042     * @see       com.liferay.portal.model.ResourceCode
043     * @see       com.liferay.portal.model.ResourceCodeModel
044     * @generated
045     */
046    public class ResourceCodeModelImpl extends BaseModelImpl<ResourceCode>
047            implements ResourceCodeModel {
048            public static final String TABLE_NAME = "ResourceCode";
049            public static final Object[][] TABLE_COLUMNS = {
050                            { "codeId", new Integer(Types.BIGINT) },
051                            { "companyId", new Integer(Types.BIGINT) },
052                            { "name", new Integer(Types.VARCHAR) },
053                            { "scope", new Integer(Types.INTEGER) }
054                    };
055            public static final String TABLE_SQL_CREATE = "create table ResourceCode (codeId LONG not null primary key,companyId LONG,name VARCHAR(255) null,scope INTEGER)";
056            public static final String TABLE_SQL_DROP = "drop table ResourceCode";
057            public static final String DATA_SOURCE = "liferayDataSource";
058            public static final String SESSION_FACTORY = "liferaySessionFactory";
059            public static final String TX_MANAGER = "liferayTransactionManager";
060            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
061                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ResourceCode"),
062                            true);
063            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
064                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ResourceCode"),
065                            true);
066            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
067                                    "lock.expiration.time.com.liferay.portal.model.ResourceCode"));
068    
069            public ResourceCodeModelImpl() {
070            }
071    
072            public long getPrimaryKey() {
073                    return _codeId;
074            }
075    
076            public void setPrimaryKey(long pk) {
077                    setCodeId(pk);
078            }
079    
080            public Serializable getPrimaryKeyObj() {
081                    return new Long(_codeId);
082            }
083    
084            public long getCodeId() {
085                    return _codeId;
086            }
087    
088            public void setCodeId(long codeId) {
089                    _codeId = codeId;
090            }
091    
092            public long getCompanyId() {
093                    return _companyId;
094            }
095    
096            public void setCompanyId(long companyId) {
097                    _companyId = companyId;
098    
099                    if (!_setOriginalCompanyId) {
100                            _setOriginalCompanyId = true;
101    
102                            _originalCompanyId = companyId;
103                    }
104            }
105    
106            public long getOriginalCompanyId() {
107                    return _originalCompanyId;
108            }
109    
110            public String getName() {
111                    if (_name == null) {
112                            return StringPool.BLANK;
113                    }
114                    else {
115                            return _name;
116                    }
117            }
118    
119            public void setName(String name) {
120                    _name = name;
121    
122                    if (_originalName == null) {
123                            _originalName = name;
124                    }
125            }
126    
127            public String getOriginalName() {
128                    return GetterUtil.getString(_originalName);
129            }
130    
131            public int getScope() {
132                    return _scope;
133            }
134    
135            public void setScope(int scope) {
136                    _scope = scope;
137    
138                    if (!_setOriginalScope) {
139                            _setOriginalScope = true;
140    
141                            _originalScope = scope;
142                    }
143            }
144    
145            public int getOriginalScope() {
146                    return _originalScope;
147            }
148    
149            public ResourceCode toEscapedModel() {
150                    if (isEscapedModel()) {
151                            return (ResourceCode)this;
152                    }
153                    else {
154                            return (ResourceCode)Proxy.newProxyInstance(ResourceCode.class.getClassLoader(),
155                                    new Class[] { ResourceCode.class },
156                                    new AutoEscapeBeanHandler(this));
157                    }
158            }
159    
160            public ExpandoBridge getExpandoBridge() {
161                    if (_expandoBridge == null) {
162                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(getCompanyId(),
163                                            ResourceCode.class.getName(), getPrimaryKey());
164                    }
165    
166                    return _expandoBridge;
167            }
168    
169            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
170                    getExpandoBridge().setAttributes(serviceContext);
171            }
172    
173            public Object clone() {
174                    ResourceCodeImpl clone = new ResourceCodeImpl();
175    
176                    clone.setCodeId(getCodeId());
177                    clone.setCompanyId(getCompanyId());
178                    clone.setName(getName());
179                    clone.setScope(getScope());
180    
181                    return clone;
182            }
183    
184            public int compareTo(ResourceCode resourceCode) {
185                    long pk = resourceCode.getPrimaryKey();
186    
187                    if (getPrimaryKey() < pk) {
188                            return -1;
189                    }
190                    else if (getPrimaryKey() > pk) {
191                            return 1;
192                    }
193                    else {
194                            return 0;
195                    }
196            }
197    
198            public boolean equals(Object obj) {
199                    if (obj == null) {
200                            return false;
201                    }
202    
203                    ResourceCode resourceCode = null;
204    
205                    try {
206                            resourceCode = (ResourceCode)obj;
207                    }
208                    catch (ClassCastException cce) {
209                            return false;
210                    }
211    
212                    long pk = resourceCode.getPrimaryKey();
213    
214                    if (getPrimaryKey() == pk) {
215                            return true;
216                    }
217                    else {
218                            return false;
219                    }
220            }
221    
222            public int hashCode() {
223                    return (int)getPrimaryKey();
224            }
225    
226            public String toString() {
227                    StringBundler sb = new StringBundler(9);
228    
229                    sb.append("{codeId=");
230                    sb.append(getCodeId());
231                    sb.append(", companyId=");
232                    sb.append(getCompanyId());
233                    sb.append(", name=");
234                    sb.append(getName());
235                    sb.append(", scope=");
236                    sb.append(getScope());
237                    sb.append("}");
238    
239                    return sb.toString();
240            }
241    
242            public String toXmlString() {
243                    StringBundler sb = new StringBundler(16);
244    
245                    sb.append("<model><model-name>");
246                    sb.append("com.liferay.portal.model.ResourceCode");
247                    sb.append("</model-name>");
248    
249                    sb.append(
250                            "<column><column-name>codeId</column-name><column-value><![CDATA[");
251                    sb.append(getCodeId());
252                    sb.append("]]></column-value></column>");
253                    sb.append(
254                            "<column><column-name>companyId</column-name><column-value><![CDATA[");
255                    sb.append(getCompanyId());
256                    sb.append("]]></column-value></column>");
257                    sb.append(
258                            "<column><column-name>name</column-name><column-value><![CDATA[");
259                    sb.append(getName());
260                    sb.append("]]></column-value></column>");
261                    sb.append(
262                            "<column><column-name>scope</column-name><column-value><![CDATA[");
263                    sb.append(getScope());
264                    sb.append("]]></column-value></column>");
265    
266                    sb.append("</model>");
267    
268                    return sb.toString();
269            }
270    
271            private long _codeId;
272            private long _companyId;
273            private long _originalCompanyId;
274            private boolean _setOriginalCompanyId;
275            private String _name;
276            private String _originalName;
277            private int _scope;
278            private int _originalScope;
279            private boolean _setOriginalScope;
280            private transient ExpandoBridge _expandoBridge;
281    }