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