001    /**
002     * Copyright (c) 2000-2013 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.ProxyUtil;
020    import com.liferay.portal.kernel.util.StringBundler;
021    import com.liferay.portal.kernel.util.StringPool;
022    import com.liferay.portal.model.CacheModel;
023    import com.liferay.portal.model.ServiceComponent;
024    import com.liferay.portal.model.ServiceComponentModel;
025    import com.liferay.portal.service.ServiceContext;
026    
027    import com.liferay.portlet.expando.model.ExpandoBridge;
028    import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
029    
030    import java.io.Serializable;
031    
032    import java.sql.Types;
033    
034    import java.util.HashMap;
035    import java.util.Map;
036    
037    /**
038     * 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.
039     *
040     * <p>
041     * 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}.
042     * </p>
043     *
044     * @author Brian Wing Shun Chan
045     * @see ServiceComponentImpl
046     * @see com.liferay.portal.model.ServiceComponent
047     * @see com.liferay.portal.model.ServiceComponentModel
048     * @generated
049     */
050    public class ServiceComponentModelImpl extends BaseModelImpl<ServiceComponent>
051            implements ServiceComponentModel {
052            /*
053             * NOTE FOR DEVELOPERS:
054             *
055             * 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.
056             */
057            public static final String TABLE_NAME = "ServiceComponent";
058            public static final Object[][] TABLE_COLUMNS = {
059                            { "serviceComponentId", Types.BIGINT },
060                            { "buildNamespace", Types.VARCHAR },
061                            { "buildNumber", Types.BIGINT },
062                            { "buildDate", Types.BIGINT },
063                            { "data_", Types.CLOB }
064                    };
065            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)";
066            public static final String TABLE_SQL_DROP = "drop table ServiceComponent";
067            public static final String ORDER_BY_JPQL = " ORDER BY serviceComponent.buildNamespace DESC, serviceComponent.buildNumber DESC";
068            public static final String ORDER_BY_SQL = " ORDER BY ServiceComponent.buildNamespace DESC, ServiceComponent.buildNumber DESC";
069            public static final String DATA_SOURCE = "liferayDataSource";
070            public static final String SESSION_FACTORY = "liferaySessionFactory";
071            public static final String TX_MANAGER = "liferayTransactionManager";
072            public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
073                                    "value.object.entity.cache.enabled.com.liferay.portal.model.ServiceComponent"),
074                            true);
075            public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
076                                    "value.object.finder.cache.enabled.com.liferay.portal.model.ServiceComponent"),
077                            true);
078            public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.portal.util.PropsUtil.get(
079                                    "value.object.column.bitmask.enabled.com.liferay.portal.model.ServiceComponent"),
080                            true);
081            public static long BUILDNAMESPACE_COLUMN_BITMASK = 1L;
082            public static long BUILDNUMBER_COLUMN_BITMASK = 2L;
083            public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.portal.util.PropsUtil.get(
084                                    "lock.expiration.time.com.liferay.portal.model.ServiceComponent"));
085    
086            public ServiceComponentModelImpl() {
087            }
088    
089            @Override
090            public long getPrimaryKey() {
091                    return _serviceComponentId;
092            }
093    
094            @Override
095            public void setPrimaryKey(long primaryKey) {
096                    setServiceComponentId(primaryKey);
097            }
098    
099            @Override
100            public Serializable getPrimaryKeyObj() {
101                    return _serviceComponentId;
102            }
103    
104            @Override
105            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
106                    setPrimaryKey(((Long)primaryKeyObj).longValue());
107            }
108    
109            @Override
110            public Class<?> getModelClass() {
111                    return ServiceComponent.class;
112            }
113    
114            @Override
115            public String getModelClassName() {
116                    return ServiceComponent.class.getName();
117            }
118    
119            @Override
120            public Map<String, Object> getModelAttributes() {
121                    Map<String, Object> attributes = new HashMap<String, Object>();
122    
123                    attributes.put("serviceComponentId", getServiceComponentId());
124                    attributes.put("buildNamespace", getBuildNamespace());
125                    attributes.put("buildNumber", getBuildNumber());
126                    attributes.put("buildDate", getBuildDate());
127                    attributes.put("data", getData());
128    
129                    return attributes;
130            }
131    
132            @Override
133            public void setModelAttributes(Map<String, Object> attributes) {
134                    Long serviceComponentId = (Long)attributes.get("serviceComponentId");
135    
136                    if (serviceComponentId != null) {
137                            setServiceComponentId(serviceComponentId);
138                    }
139    
140                    String buildNamespace = (String)attributes.get("buildNamespace");
141    
142                    if (buildNamespace != null) {
143                            setBuildNamespace(buildNamespace);
144                    }
145    
146                    Long buildNumber = (Long)attributes.get("buildNumber");
147    
148                    if (buildNumber != null) {
149                            setBuildNumber(buildNumber);
150                    }
151    
152                    Long buildDate = (Long)attributes.get("buildDate");
153    
154                    if (buildDate != null) {
155                            setBuildDate(buildDate);
156                    }
157    
158                    String data = (String)attributes.get("data");
159    
160                    if (data != null) {
161                            setData(data);
162                    }
163            }
164    
165            @Override
166            public long getServiceComponentId() {
167                    return _serviceComponentId;
168            }
169    
170            @Override
171            public void setServiceComponentId(long serviceComponentId) {
172                    _serviceComponentId = serviceComponentId;
173            }
174    
175            @Override
176            public String getBuildNamespace() {
177                    if (_buildNamespace == null) {
178                            return StringPool.BLANK;
179                    }
180                    else {
181                            return _buildNamespace;
182                    }
183            }
184    
185            @Override
186            public void setBuildNamespace(String buildNamespace) {
187                    _columnBitmask = -1L;
188    
189                    if (_originalBuildNamespace == null) {
190                            _originalBuildNamespace = _buildNamespace;
191                    }
192    
193                    _buildNamespace = buildNamespace;
194            }
195    
196            public String getOriginalBuildNamespace() {
197                    return GetterUtil.getString(_originalBuildNamespace);
198            }
199    
200            @Override
201            public long getBuildNumber() {
202                    return _buildNumber;
203            }
204    
205            @Override
206            public void setBuildNumber(long buildNumber) {
207                    _columnBitmask = -1L;
208    
209                    if (!_setOriginalBuildNumber) {
210                            _setOriginalBuildNumber = true;
211    
212                            _originalBuildNumber = _buildNumber;
213                    }
214    
215                    _buildNumber = buildNumber;
216            }
217    
218            public long getOriginalBuildNumber() {
219                    return _originalBuildNumber;
220            }
221    
222            @Override
223            public long getBuildDate() {
224                    return _buildDate;
225            }
226    
227            @Override
228            public void setBuildDate(long buildDate) {
229                    _buildDate = buildDate;
230            }
231    
232            @Override
233            public String getData() {
234                    if (_data == null) {
235                            return StringPool.BLANK;
236                    }
237                    else {
238                            return _data;
239                    }
240            }
241    
242            @Override
243            public void setData(String data) {
244                    _data = data;
245            }
246    
247            public long getColumnBitmask() {
248                    return _columnBitmask;
249            }
250    
251            @Override
252            public ExpandoBridge getExpandoBridge() {
253                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
254                            ServiceComponent.class.getName(), getPrimaryKey());
255            }
256    
257            @Override
258            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
259                    ExpandoBridge expandoBridge = getExpandoBridge();
260    
261                    expandoBridge.setAttributes(serviceContext);
262            }
263    
264            @Override
265            public ServiceComponent toEscapedModel() {
266                    if (_escapedModel == null) {
267                            _escapedModel = (ServiceComponent)ProxyUtil.newProxyInstance(_classLoader,
268                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
269                    }
270    
271                    return _escapedModel;
272            }
273    
274            @Override
275            public Object clone() {
276                    ServiceComponentImpl serviceComponentImpl = new ServiceComponentImpl();
277    
278                    serviceComponentImpl.setServiceComponentId(getServiceComponentId());
279                    serviceComponentImpl.setBuildNamespace(getBuildNamespace());
280                    serviceComponentImpl.setBuildNumber(getBuildNumber());
281                    serviceComponentImpl.setBuildDate(getBuildDate());
282                    serviceComponentImpl.setData(getData());
283    
284                    serviceComponentImpl.resetOriginalValues();
285    
286                    return serviceComponentImpl;
287            }
288    
289            @Override
290            public int compareTo(ServiceComponent serviceComponent) {
291                    int value = 0;
292    
293                    value = getBuildNamespace()
294                                            .compareTo(serviceComponent.getBuildNamespace());
295    
296                    value = value * -1;
297    
298                    if (value != 0) {
299                            return value;
300                    }
301    
302                    if (getBuildNumber() < serviceComponent.getBuildNumber()) {
303                            value = -1;
304                    }
305                    else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
306                            value = 1;
307                    }
308                    else {
309                            value = 0;
310                    }
311    
312                    value = value * -1;
313    
314                    if (value != 0) {
315                            return value;
316                    }
317    
318                    return 0;
319            }
320    
321            @Override
322            public boolean equals(Object obj) {
323                    if (this == obj) {
324                            return true;
325                    }
326    
327                    if (!(obj instanceof ServiceComponent)) {
328                            return false;
329                    }
330    
331                    ServiceComponent serviceComponent = (ServiceComponent)obj;
332    
333                    long primaryKey = serviceComponent.getPrimaryKey();
334    
335                    if (getPrimaryKey() == primaryKey) {
336                            return true;
337                    }
338                    else {
339                            return false;
340                    }
341            }
342    
343            @Override
344            public int hashCode() {
345                    return (int)getPrimaryKey();
346            }
347    
348            @Override
349            public void resetOriginalValues() {
350                    ServiceComponentModelImpl serviceComponentModelImpl = this;
351    
352                    serviceComponentModelImpl._originalBuildNamespace = serviceComponentModelImpl._buildNamespace;
353    
354                    serviceComponentModelImpl._originalBuildNumber = serviceComponentModelImpl._buildNumber;
355    
356                    serviceComponentModelImpl._setOriginalBuildNumber = false;
357    
358                    serviceComponentModelImpl._columnBitmask = 0;
359            }
360    
361            @Override
362            public CacheModel<ServiceComponent> toCacheModel() {
363                    ServiceComponentCacheModel serviceComponentCacheModel = new ServiceComponentCacheModel();
364    
365                    serviceComponentCacheModel.serviceComponentId = getServiceComponentId();
366    
367                    serviceComponentCacheModel.buildNamespace = getBuildNamespace();
368    
369                    String buildNamespace = serviceComponentCacheModel.buildNamespace;
370    
371                    if ((buildNamespace != null) && (buildNamespace.length() == 0)) {
372                            serviceComponentCacheModel.buildNamespace = null;
373                    }
374    
375                    serviceComponentCacheModel.buildNumber = getBuildNumber();
376    
377                    serviceComponentCacheModel.buildDate = getBuildDate();
378    
379                    serviceComponentCacheModel.data = getData();
380    
381                    String data = serviceComponentCacheModel.data;
382    
383                    if ((data != null) && (data.length() == 0)) {
384                            serviceComponentCacheModel.data = null;
385                    }
386    
387                    return serviceComponentCacheModel;
388            }
389    
390            @Override
391            public String toString() {
392                    StringBundler sb = new StringBundler(11);
393    
394                    sb.append("{serviceComponentId=");
395                    sb.append(getServiceComponentId());
396                    sb.append(", buildNamespace=");
397                    sb.append(getBuildNamespace());
398                    sb.append(", buildNumber=");
399                    sb.append(getBuildNumber());
400                    sb.append(", buildDate=");
401                    sb.append(getBuildDate());
402                    sb.append(", data=");
403                    sb.append(getData());
404                    sb.append("}");
405    
406                    return sb.toString();
407            }
408    
409            @Override
410            public String toXmlString() {
411                    StringBundler sb = new StringBundler(19);
412    
413                    sb.append("<model><model-name>");
414                    sb.append("com.liferay.portal.model.ServiceComponent");
415                    sb.append("</model-name>");
416    
417                    sb.append(
418                            "<column><column-name>serviceComponentId</column-name><column-value><![CDATA[");
419                    sb.append(getServiceComponentId());
420                    sb.append("]]></column-value></column>");
421                    sb.append(
422                            "<column><column-name>buildNamespace</column-name><column-value><![CDATA[");
423                    sb.append(getBuildNamespace());
424                    sb.append("]]></column-value></column>");
425                    sb.append(
426                            "<column><column-name>buildNumber</column-name><column-value><![CDATA[");
427                    sb.append(getBuildNumber());
428                    sb.append("]]></column-value></column>");
429                    sb.append(
430                            "<column><column-name>buildDate</column-name><column-value><![CDATA[");
431                    sb.append(getBuildDate());
432                    sb.append("]]></column-value></column>");
433                    sb.append(
434                            "<column><column-name>data</column-name><column-value><![CDATA[");
435                    sb.append(getData());
436                    sb.append("]]></column-value></column>");
437    
438                    sb.append("</model>");
439    
440                    return sb.toString();
441            }
442    
443            private static ClassLoader _classLoader = ServiceComponent.class.getClassLoader();
444            private static Class<?>[] _escapedModelInterfaces = new Class[] {
445                            ServiceComponent.class
446                    };
447            private long _serviceComponentId;
448            private String _buildNamespace;
449            private String _originalBuildNamespace;
450            private long _buildNumber;
451            private long _originalBuildNumber;
452            private boolean _setOriginalBuildNumber;
453            private long _buildDate;
454            private String _data;
455            private long _columnBitmask;
456            private ServiceComponent _escapedModel;
457    }