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.portlet.journal.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.impl.BaseModelImpl;
022    import com.liferay.portal.service.ServiceContext;
023    
024    import com.liferay.portlet.expando.model.ExpandoBridge;
025    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
026    import com.liferay.portlet.journal.model.JournalArticleResource;
027    import com.liferay.portlet.journal.model.JournalArticleResourceModel;
028    
029    import java.io.Serializable;
030    
031    import java.lang.reflect.Proxy;
032    
033    import java.sql.Types;
034    
035    /**
036     * The base model implementation for the JournalArticleResource service. Represents a row in the "JournalArticleResource" database table, with each column mapped to a property of this class.
037     *
038     * <p>
039     * This implementation and its corresponding interface {@link com.liferay.portlet.journal.model.JournalArticleResourceModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link JournalArticleResourceImpl}.
040     * </p>
041     *
042     * <p>
043     * Never modify or reference this class directly. All methods that expect a journal article resource model instance should use the {@link com.liferay.portlet.journal.model.JournalArticleResource} interface instead.
044     * </p>
045     *
046     * @author Brian Wing Shun Chan
047     * @see JournalArticleResourceImpl
048     * @see com.liferay.portlet.journal.model.JournalArticleResource
049     * @see com.liferay.portlet.journal.model.JournalArticleResourceModel
050     * @generated
051     */
052    public class JournalArticleResourceModelImpl extends BaseModelImpl<JournalArticleResource>
053            implements JournalArticleResourceModel {
054            public static final String TABLE_NAME = "JournalArticleResource";
055            public static final Object[][] TABLE_COLUMNS = {
056                            { "resourcePrimKey", new Integer(Types.BIGINT) },
057                            { "groupId", new Integer(Types.BIGINT) },
058                            { "articleId", new Integer(Types.VARCHAR) }
059                    };
060            public static final String TABLE_SQL_CREATE = "create table JournalArticleResource (resourcePrimKey LONG not null primary key,groupId LONG,articleId VARCHAR(75) null)";
061            public static final String TABLE_SQL_DROP = "drop table JournalArticleResource";
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.portlet.journal.model.JournalArticleResource"),
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.portlet.journal.model.JournalArticleResource"),
070                            true);
071            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
072                                    "lock.expiration.time.com.liferay.portlet.journal.model.JournalArticleResource"));
073    
074            public JournalArticleResourceModelImpl() {
075            }
076    
077            public long getPrimaryKey() {
078                    return _resourcePrimKey;
079            }
080    
081            public void setPrimaryKey(long pk) {
082                    setResourcePrimKey(pk);
083            }
084    
085            public Serializable getPrimaryKeyObj() {
086                    return new Long(_resourcePrimKey);
087            }
088    
089            public long getResourcePrimKey() {
090                    return _resourcePrimKey;
091            }
092    
093            public void setResourcePrimKey(long resourcePrimKey) {
094                    _resourcePrimKey = resourcePrimKey;
095            }
096    
097            public long getGroupId() {
098                    return _groupId;
099            }
100    
101            public void setGroupId(long groupId) {
102                    _groupId = groupId;
103    
104                    if (!_setOriginalGroupId) {
105                            _setOriginalGroupId = true;
106    
107                            _originalGroupId = groupId;
108                    }
109            }
110    
111            public long getOriginalGroupId() {
112                    return _originalGroupId;
113            }
114    
115            public String getArticleId() {
116                    if (_articleId == null) {
117                            return StringPool.BLANK;
118                    }
119                    else {
120                            return _articleId;
121                    }
122            }
123    
124            public void setArticleId(String articleId) {
125                    _articleId = articleId;
126    
127                    if (_originalArticleId == null) {
128                            _originalArticleId = articleId;
129                    }
130            }
131    
132            public String getOriginalArticleId() {
133                    return GetterUtil.getString(_originalArticleId);
134            }
135    
136            public JournalArticleResource toEscapedModel() {
137                    if (isEscapedModel()) {
138                            return (JournalArticleResource)this;
139                    }
140                    else {
141                            return (JournalArticleResource)Proxy.newProxyInstance(JournalArticleResource.class.getClassLoader(),
142                                    new Class[] { JournalArticleResource.class },
143                                    new AutoEscapeBeanHandler(this));
144                    }
145            }
146    
147            public ExpandoBridge getExpandoBridge() {
148                    if (_expandoBridge == null) {
149                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
150                                            JournalArticleResource.class.getName(), getPrimaryKey());
151                    }
152    
153                    return _expandoBridge;
154            }
155    
156            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
157                    getExpandoBridge().setAttributes(serviceContext);
158            }
159    
160            public Object clone() {
161                    JournalArticleResourceImpl clone = new JournalArticleResourceImpl();
162    
163                    clone.setResourcePrimKey(getResourcePrimKey());
164                    clone.setGroupId(getGroupId());
165                    clone.setArticleId(getArticleId());
166    
167                    return clone;
168            }
169    
170            public int compareTo(JournalArticleResource journalArticleResource) {
171                    long pk = journalArticleResource.getPrimaryKey();
172    
173                    if (getPrimaryKey() < pk) {
174                            return -1;
175                    }
176                    else if (getPrimaryKey() > pk) {
177                            return 1;
178                    }
179                    else {
180                            return 0;
181                    }
182            }
183    
184            public boolean equals(Object obj) {
185                    if (obj == null) {
186                            return false;
187                    }
188    
189                    JournalArticleResource journalArticleResource = null;
190    
191                    try {
192                            journalArticleResource = (JournalArticleResource)obj;
193                    }
194                    catch (ClassCastException cce) {
195                            return false;
196                    }
197    
198                    long pk = journalArticleResource.getPrimaryKey();
199    
200                    if (getPrimaryKey() == pk) {
201                            return true;
202                    }
203                    else {
204                            return false;
205                    }
206            }
207    
208            public int hashCode() {
209                    return (int)getPrimaryKey();
210            }
211    
212            public String toString() {
213                    StringBundler sb = new StringBundler(7);
214    
215                    sb.append("{resourcePrimKey=");
216                    sb.append(getResourcePrimKey());
217                    sb.append(", groupId=");
218                    sb.append(getGroupId());
219                    sb.append(", articleId=");
220                    sb.append(getArticleId());
221                    sb.append("}");
222    
223                    return sb.toString();
224            }
225    
226            public String toXmlString() {
227                    StringBundler sb = new StringBundler(13);
228    
229                    sb.append("<model><model-name>");
230                    sb.append("com.liferay.portlet.journal.model.JournalArticleResource");
231                    sb.append("</model-name>");
232    
233                    sb.append(
234                            "<column><column-name>resourcePrimKey</column-name><column-value><![CDATA[");
235                    sb.append(getResourcePrimKey());
236                    sb.append("]]></column-value></column>");
237                    sb.append(
238                            "<column><column-name>groupId</column-name><column-value><![CDATA[");
239                    sb.append(getGroupId());
240                    sb.append("]]></column-value></column>");
241                    sb.append(
242                            "<column><column-name>articleId</column-name><column-value><![CDATA[");
243                    sb.append(getArticleId());
244                    sb.append("]]></column-value></column>");
245    
246                    sb.append("</model>");
247    
248                    return sb.toString();
249            }
250    
251            private long _resourcePrimKey;
252            private long _groupId;
253            private long _originalGroupId;
254            private boolean _setOriginalGroupId;
255            private String _articleId;
256            private String _originalArticleId;
257            private transient ExpandoBridge _expandoBridge;
258    }