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.ServiceComponent;
022    import com.liferay.portal.model.ServiceComponentModel;
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 ServiceComponent service. Represents a row in the "ServiceComponent" 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.ServiceComponentModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link ServiceComponentImpl}.
039     * </p>
040     *
041     * <p>
042     * Never modify or reference this class directly. All methods that expect a service component model instance should use the {@link com.liferay.portal.model.ServiceComponent} interface instead.
043     * </p>
044     *
045     * @author Brian Wing Shun Chan
046     * @see ServiceComponentImpl
047     * @see com.liferay.portal.model.ServiceComponent
048     * @see com.liferay.portal.model.ServiceComponentModel
049     * @generated
050     */
051    public class ServiceComponentModelImpl extends BaseModelImpl<ServiceComponent>
052            implements ServiceComponentModel {
053            public static final String TABLE_NAME = "ServiceComponent";
054            public static final Object[][] TABLE_COLUMNS = {
055                            { "serviceComponentId", new Integer(Types.BIGINT) },
056                            { "buildNamespace", new Integer(Types.VARCHAR) },
057                            { "buildNumber", new Integer(Types.BIGINT) },
058                            { "buildDate", new Integer(Types.BIGINT) },
059                            { "data_", new Integer(Types.CLOB) }
060                    };
061            public static final String TABLE_SQL_CREATE = "create table ServiceComponent (serviceComponentId LONG not null primary key,buildNamespace VARCHAR(75) null,buildNumber LONG,buildDate LONG,data_ TEXT null)";
062            public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
063            public static final String ORDER_BY_JPQL = " ORDER BY serviceComponent.buildNamespace DESC, serviceComponent.buildNumber DESC";
064            public static final String ORDER_BY_SQL = " ORDER BY ServiceComponent.buildNamespace DESC, ServiceComponent.buildNumber DESC";
065            public static final String DATA_SOURCE = "liferayDataSource";
066            public static final String SESSION_FACTORY = "liferaySessionFactory";
067            public static final String TX_MANAGER = "liferayTransactionManager";
068            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
069                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ServiceComponent"),
070                            true);
071            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
072                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
073                            true);
074            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
075                                    "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
076    
077            public ServiceComponentModelImpl() {
078            }
079    
080            public long getPrimaryKey() {
081                    return _serviceComponentId;
082            }
083    
084            public void setPrimaryKey(long pk) {
085                    setServiceComponentId(pk);
086            }
087    
088            public Serializable getPrimaryKeyObj() {
089                    return new Long(_serviceComponentId);
090            }
091    
092            public long getServiceComponentId() {
093                    return _serviceComponentId;
094            }
095    
096            public void setServiceComponentId(long serviceComponentId) {
097                    _serviceComponentId = serviceComponentId;
098            }
099    
100            public String getBuildNamespace() {
101                    if (_buildNamespace == null) {
102                            return StringPool.BLANK;
103                    }
104                    else {
105                            return _buildNamespace;
106                    }
107            }
108    
109            public void setBuildNamespace(String buildNamespace) {
110                    _buildNamespace = buildNamespace;
111    
112                    if (_originalBuildNamespace == null) {
113                            _originalBuildNamespace = buildNamespace;
114                    }
115            }
116    
117            public String getOriginalBuildNamespace() {
118                    return GetterUtil.getString(_originalBuildNamespace);
119            }
120    
121            public long getBuildNumber() {
122                    return _buildNumber;
123            }
124    
125            public void setBuildNumber(long buildNumber) {
126                    _buildNumber = buildNumber;
127    
128                    if (!_setOriginalBuildNumber) {
129                            _setOriginalBuildNumber = true;
130    
131                            _originalBuildNumber = buildNumber;
132                    }
133            }
134    
135            public long getOriginalBuildNumber() {
136                    return _originalBuildNumber;
137            }
138    
139            public long getBuildDate() {
140                    return _buildDate;
141            }
142    
143            public void setBuildDate(long buildDate) {
144                    _buildDate = buildDate;
145            }
146    
147            public String getData() {
148                    if (_data == null) {
149                            return StringPool.BLANK;
150                    }
151                    else {
152                            return _data;
153                    }
154            }
155    
156            public void setData(String data) {
157                    _data = data;
158            }
159    
160            public ServiceComponent toEscapedModel() {
161                    if (isEscapedModel()) {
162                            return (ServiceComponent)this;
163                    }
164                    else {
165                            return (ServiceComponent)Proxy.newProxyInstance(ServiceComponent.class.getClassLoader(),
166                                    new Class[] { ServiceComponent.class },
167                                    new AutoEscapeBeanHandler(this));
168                    }
169            }
170    
171            public ExpandoBridge getExpandoBridge() {
172                    if (_expandoBridge == null) {
173                            _expandoBridge = ExpandoBridgeFactoryUtil.getExpandoBridge(0,
174                                            ServiceComponent.class.getName(), getPrimaryKey());
175                    }
176    
177                    return _expandoBridge;
178            }
179    
180            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
181                    getExpandoBridge().setAttributes(serviceContext);
182            }
183    
184            public Object clone() {
185                    ServiceComponentImpl clone = new ServiceComponentImpl();
186    
187                    clone.setServiceComponentId(getServiceComponentId());
188                    clone.setBuildNamespace(getBuildNamespace());
189                    clone.setBuildNumber(getBuildNumber());
190                    clone.setBuildDate(getBuildDate());
191                    clone.setData(getData());
192    
193                    return clone;
194            }
195    
196            public int compareTo(ServiceComponent serviceComponent) {
197                    int value = 0;
198    
199                    value = getBuildNamespace()
200                                            .compareTo(serviceComponent.getBuildNamespace());
201    
202                    value = value * -1;
203    
204                    if (value != 0) {
205                            return value;
206                    }
207    
208                    if (getBuildNumber() < serviceComponent.getBuildNumber()) {
209                            value = -1;
210                    }
211                    else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
212                            value = 1;
213                    }
214                    else {
215                            value = 0;
216                    }
217    
218                    value = value * -1;
219    
220                    if (value != 0) {
221                            return value;
222                    }
223    
224                    return 0;
225            }
226    
227            public boolean equals(Object obj) {
228                    if (obj == null) {
229                            return false;
230                    }
231    
232                    ServiceComponent serviceComponent = null;
233    
234                    try {
235                            serviceComponent = (ServiceComponent)obj;
236                    }
237                    catch (ClassCastException cce) {
238                            return false;
239                    }
240    
241                    long pk = serviceComponent.getPrimaryKey();
242    
243                    if (getPrimaryKey() == pk) {
244                            return true;
245                    }
246                    else {
247                            return false;
248                    }
249            }
250    
251            public int hashCode() {
252                    return (int)getPrimaryKey();
253            }
254    
255            public String toString() {
256                    StringBundler sb = new StringBundler(11);
257    
258                    sb.append("{serviceComponentId=");
259                    sb.append(getServiceComponentId());
260                    sb.append(", buildNamespace=");
261                    sb.append(getBuildNamespace());
262                    sb.append(", buildNumber=");
263                    sb.append(getBuildNumber());
264                    sb.append(", buildDate=");
265                    sb.append(getBuildDate());
266                    sb.append(", data=");
267                    sb.append(getData());
268                    sb.append("}");
269    
270                    return sb.toString();
271            }
272    
273            public String toXmlString() {
274                    StringBundler sb = new StringBundler(19);
275    
276                    sb.append("<model><model-name>");
277                    sb.append("com.liferay.portal.model.ServiceComponent");
278                    sb.append("</model-name>");
279    
280                    sb.append(
281                            "<column><column-name>serviceComponentId</column-name><column-value><![CDATA[");
282                    sb.append(getServiceComponentId());
283                    sb.append("]]></column-value></column>");
284                    sb.append(
285                            "<column><column-name>buildNamespace</column-name><column-value><![CDATA[");
286                    sb.append(getBuildNamespace());
287                    sb.append("]]></column-value></column>");
288                    sb.append(
289                            "<column><column-name>buildNumber</column-name><column-value><![CDATA[");
290                    sb.append(getBuildNumber());
291                    sb.append("]]></column-value></column>");
292                    sb.append(
293                            "<column><column-name>buildDate</column-name><column-value><![CDATA[");
294                    sb.append(getBuildDate());
295                    sb.append("]]></column-value></column>");
296                    sb.append(
297                            "<column><column-name>data</column-name><column-value><![CDATA[");
298                    sb.append(getData());
299                    sb.append("]]></column-value></column>");
300    
301                    sb.append("</model>");
302    
303                    return sb.toString();
304            }
305    
306            private long _serviceComponentId;
307            private String _buildNamespace;
308            private String _originalBuildNamespace;
309            private long _buildNumber;
310            private long _originalBuildNumber;
311            private boolean _setOriginalBuildNumber;
312            private long _buildDate;
313            private String _data;
314            private transient ExpandoBridge _expandoBridge;
315    }