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            public long getPrimaryKey() {
090                    return _serviceComponentId;
091            }
092    
093            public void setPrimaryKey(long primaryKey) {
094                    setServiceComponentId(primaryKey);
095            }
096    
097            public Serializable getPrimaryKeyObj() {
098                    return new Long(_serviceComponentId);
099            }
100    
101            public void setPrimaryKeyObj(Serializable primaryKeyObj) {
102                    setPrimaryKey(((Long)primaryKeyObj).longValue());
103            }
104    
105            public Class<?> getModelClass() {
106                    return ServiceComponent.class;
107            }
108    
109            public String getModelClassName() {
110                    return ServiceComponent.class.getName();
111            }
112    
113            @Override
114            public Map<String, Object> getModelAttributes() {
115                    Map<String, Object> attributes = new HashMap<String, Object>();
116    
117                    attributes.put("serviceComponentId", getServiceComponentId());
118                    attributes.put("buildNamespace", getBuildNamespace());
119                    attributes.put("buildNumber", getBuildNumber());
120                    attributes.put("buildDate", getBuildDate());
121                    attributes.put("data", getData());
122    
123                    return attributes;
124            }
125    
126            @Override
127            public void setModelAttributes(Map<String, Object> attributes) {
128                    Long serviceComponentId = (Long)attributes.get("serviceComponentId");
129    
130                    if (serviceComponentId != null) {
131                            setServiceComponentId(serviceComponentId);
132                    }
133    
134                    String buildNamespace = (String)attributes.get("buildNamespace");
135    
136                    if (buildNamespace != null) {
137                            setBuildNamespace(buildNamespace);
138                    }
139    
140                    Long buildNumber = (Long)attributes.get("buildNumber");
141    
142                    if (buildNumber != null) {
143                            setBuildNumber(buildNumber);
144                    }
145    
146                    Long buildDate = (Long)attributes.get("buildDate");
147    
148                    if (buildDate != null) {
149                            setBuildDate(buildDate);
150                    }
151    
152                    String data = (String)attributes.get("data");
153    
154                    if (data != null) {
155                            setData(data);
156                    }
157            }
158    
159            public long getServiceComponentId() {
160                    return _serviceComponentId;
161            }
162    
163            public void setServiceComponentId(long serviceComponentId) {
164                    _serviceComponentId = serviceComponentId;
165            }
166    
167            public String getBuildNamespace() {
168                    if (_buildNamespace == null) {
169                            return StringPool.BLANK;
170                    }
171                    else {
172                            return _buildNamespace;
173                    }
174            }
175    
176            public void setBuildNamespace(String buildNamespace) {
177                    _columnBitmask = -1L;
178    
179                    if (_originalBuildNamespace == null) {
180                            _originalBuildNamespace = _buildNamespace;
181                    }
182    
183                    _buildNamespace = buildNamespace;
184            }
185    
186            public String getOriginalBuildNamespace() {
187                    return GetterUtil.getString(_originalBuildNamespace);
188            }
189    
190            public long getBuildNumber() {
191                    return _buildNumber;
192            }
193    
194            public void setBuildNumber(long buildNumber) {
195                    _columnBitmask = -1L;
196    
197                    if (!_setOriginalBuildNumber) {
198                            _setOriginalBuildNumber = true;
199    
200                            _originalBuildNumber = _buildNumber;
201                    }
202    
203                    _buildNumber = buildNumber;
204            }
205    
206            public long getOriginalBuildNumber() {
207                    return _originalBuildNumber;
208            }
209    
210            public long getBuildDate() {
211                    return _buildDate;
212            }
213    
214            public void setBuildDate(long buildDate) {
215                    _buildDate = buildDate;
216            }
217    
218            public String getData() {
219                    if (_data == null) {
220                            return StringPool.BLANK;
221                    }
222                    else {
223                            return _data;
224                    }
225            }
226    
227            public void setData(String data) {
228                    _data = data;
229            }
230    
231            public long getColumnBitmask() {
232                    return _columnBitmask;
233            }
234    
235            @Override
236            public ExpandoBridge getExpandoBridge() {
237                    return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
238                            ServiceComponent.class.getName(), getPrimaryKey());
239            }
240    
241            @Override
242            public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
243                    ExpandoBridge expandoBridge = getExpandoBridge();
244    
245                    expandoBridge.setAttributes(serviceContext);
246            }
247    
248            @Override
249            public ServiceComponent toEscapedModel() {
250                    if (_escapedModel == null) {
251                            _escapedModel = (ServiceComponent)ProxyUtil.newProxyInstance(_classLoader,
252                                            _escapedModelInterfaces, new AutoEscapeBeanHandler(this));
253                    }
254    
255                    return _escapedModel;
256            }
257    
258            public ServiceComponent toUnescapedModel() {
259                    return (ServiceComponent)this;
260            }
261    
262            @Override
263            public Object clone() {
264                    ServiceComponentImpl serviceComponentImpl = new ServiceComponentImpl();
265    
266                    serviceComponentImpl.setServiceComponentId(getServiceComponentId());
267                    serviceComponentImpl.setBuildNamespace(getBuildNamespace());
268                    serviceComponentImpl.setBuildNumber(getBuildNumber());
269                    serviceComponentImpl.setBuildDate(getBuildDate());
270                    serviceComponentImpl.setData(getData());
271    
272                    serviceComponentImpl.resetOriginalValues();
273    
274                    return serviceComponentImpl;
275            }
276    
277            public int compareTo(ServiceComponent serviceComponent) {
278                    int value = 0;
279    
280                    value = getBuildNamespace()
281                                            .compareTo(serviceComponent.getBuildNamespace());
282    
283                    value = value * -1;
284    
285                    if (value != 0) {
286                            return value;
287                    }
288    
289                    if (getBuildNumber() < serviceComponent.getBuildNumber()) {
290                            value = -1;
291                    }
292                    else if (getBuildNumber() > serviceComponent.getBuildNumber()) {
293                            value = 1;
294                    }
295                    else {
296                            value = 0;
297                    }
298    
299                    value = value * -1;
300    
301                    if (value != 0) {
302                            return value;
303                    }
304    
305                    return 0;
306            }
307    
308            @Override
309            public boolean equals(Object obj) {
310                    if (this == obj) {
311                            return true;
312                    }
313    
314                    if (!(obj instanceof ServiceComponent)) {
315                            return false;
316                    }
317    
318                    ServiceComponent serviceComponent = (ServiceComponent)obj;
319    
320                    long primaryKey = serviceComponent.getPrimaryKey();
321    
322                    if (getPrimaryKey() == primaryKey) {
323                            return true;
324                    }
325                    else {
326                            return false;
327                    }
328            }
329    
330            @Override
331            public int hashCode() {
332                    return (int)getPrimaryKey();
333            }
334    
335            @Override
336            public void resetOriginalValues() {
337                    ServiceComponentModelImpl serviceComponentModelImpl = this;
338    
339                    serviceComponentModelImpl._originalBuildNamespace = serviceComponentModelImpl._buildNamespace;
340    
341                    serviceComponentModelImpl._originalBuildNumber = serviceComponentModelImpl._buildNumber;
342    
343                    serviceComponentModelImpl._setOriginalBuildNumber = false;
344    
345                    serviceComponentModelImpl._columnBitmask = 0;
346            }
347    
348            @Override
349            public CacheModel<ServiceComponent> toCacheModel() {
350                    ServiceComponentCacheModel serviceComponentCacheModel = new ServiceComponentCacheModel();
351    
352                    serviceComponentCacheModel.serviceComponentId = getServiceComponentId();
353    
354                    serviceComponentCacheModel.buildNamespace = getBuildNamespace();
355    
356                    String buildNamespace = serviceComponentCacheModel.buildNamespace;
357    
358                    if ((buildNamespace != null) && (buildNamespace.length() == 0)) {
359                            serviceComponentCacheModel.buildNamespace = null;
360                    }
361    
362                    serviceComponentCacheModel.buildNumber = getBuildNumber();
363    
364                    serviceComponentCacheModel.buildDate = getBuildDate();
365    
366                    serviceComponentCacheModel.data = getData();
367    
368                    String data = serviceComponentCacheModel.data;
369    
370                    if ((data != null) && (data.length() == 0)) {
371                            serviceComponentCacheModel.data = null;
372                    }
373    
374                    return serviceComponentCacheModel;
375            }
376    
377            @Override
378            public String toString() {
379                    StringBundler sb = new StringBundler(11);
380    
381                    sb.append("{serviceComponentId=");
382                    sb.append(getServiceComponentId());
383                    sb.append(", buildNamespace=");
384                    sb.append(getBuildNamespace());
385                    sb.append(", buildNumber=");
386                    sb.append(getBuildNumber());
387                    sb.append(", buildDate=");
388                    sb.append(getBuildDate());
389                    sb.append(", data=");
390                    sb.append(getData());
391                    sb.append("}");
392    
393                    return sb.toString();
394            }
395    
396            public String toXmlString() {
397                    StringBundler sb = new StringBundler(19);
398    
399                    sb.append("<model><model-name>");
400                    sb.append("com.liferay.portal.model.ServiceComponent");
401                    sb.append("</model-name>");
402    
403                    sb.append(
404                            "<column><column-name>serviceComponentId</column-name><column-value><![CDATA[");
405                    sb.append(getServiceComponentId());
406                    sb.append("]]></column-value></column>");
407                    sb.append(
408                            "<column><column-name>buildNamespace</column-name><column-value><![CDATA[");
409                    sb.append(getBuildNamespace());
410                    sb.append("]]></column-value></column>");
411                    sb.append(
412                            "<column><column-name>buildNumber</column-name><column-value><![CDATA[");
413                    sb.append(getBuildNumber());
414                    sb.append("]]></column-value></column>");
415                    sb.append(
416                            "<column><column-name>buildDate</column-name><column-value><![CDATA[");
417                    sb.append(getBuildDate());
418                    sb.append("]]></column-value></column>");
419                    sb.append(
420                            "<column><column-name>data</column-name><column-value><![CDATA[");
421                    sb.append(getData());
422                    sb.append("]]></column-value></column>");
423    
424                    sb.append("</model>");
425    
426                    return sb.toString();
427            }
428    
429            private static ClassLoader _classLoader = ServiceComponent.class.getClassLoader();
430            private static Class<?>[] _escapedModelInterfaces = new Class[] {
431                            ServiceComponent.class
432                    };
433            private long _serviceComponentId;
434            private String _buildNamespace;
435            private String _originalBuildNamespace;
436            private long _buildNumber;
437            private long _originalBuildNumber;
438            private boolean _setOriginalBuildNumber;
439            private long _buildDate;
440            private String _data;
441            private long _columnBitmask;
442            private ServiceComponent _escapedModel;
443    }