/**
* Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.jenginetest.builder.model.impl;
import com.jenginetest.builder.model.SBook;
import com.jenginetest.builder.model.SBookModel;
import com.jenginetest.builder.model.SBookSoap;
import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;
import java.io.Serializable;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* The base model implementation for the SBook service. Represents a row in the "SB_SBook" database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.jenginetest.builder.model.SBookModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SBookImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see SBookImpl
* @see com.jenginetest.builder.model.SBook
* @see com.jenginetest.builder.model.SBookModel
* @generated
*/
@JSON(strict = true)
public class SBookModelImpl extends BaseModelImpl<SBook> implements SBookModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a s book model instance should use the {@link com.jenginetest.builder.model.SBook} interface instead.
*/
public static final String TABLE_NAME = "SB_SBook";
public static final Object[][] TABLE_COLUMNS = {
{ "bookId", Types.BIGINT },
{ "libraryId", Types.BIGINT },
{ "title", Types.VARCHAR }
};
public static final String TABLE_SQL_CREATE = "create table SB_SBook (bookId LONG not null primary key,libraryId LONG,title VARCHAR(75) null)";
public static final String TABLE_SQL_DROP = "drop table SB_SBook";
public static final String DATA_SOURCE = "liferayDataSource";
public static final String SESSION_FACTORY = "liferaySessionFactory";
public static final String TX_MANAGER = "liferayTransactionManager";
public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.entity.cache.enabled.com.jenginetest.builder.model.SBook"),
true);
public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
"value.object.finder.cache.enabled.com.jenginetest.builder.model.SBook"),
true);
public static final boolean COLUMN_BITMASK_ENABLED = false;
/**
* Converts the soap model instance into a normal model instance.
*
* @param soapModel the soap model instance to convert
* @return the normal model instance
*/
public static SBook toModel(SBookSoap soapModel) {
if (soapModel == null) {
return null;
}
SBook model = new SBookImpl();
model.setBookId(soapModel.getBookId());
model.setLibraryId(soapModel.getLibraryId());
model.setTitle(soapModel.getTitle());
return model;
}
/**
* Converts the soap model instances into normal model instances.
*
* @param soapModels the soap model instances to convert
* @return the normal model instances
*/
public static List<SBook> toModels(SBookSoap[] soapModels) {
if (soapModels == null) {
return null;
}
List<SBook> models = new ArrayList<SBook>(soapModels.length);
for (SBookSoap soapModel : soapModels) {
models.add(toModel(soapModel));
}
return models;
}
public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
"lock.expiration.time.com.jenginetest.builder.model.SBook"));
public SBookModelImpl() {
}
public long getPrimaryKey() {
return _bookId;
}
public void setPrimaryKey(long primaryKey) {
setBookId(primaryKey);
}
public Serializable getPrimaryKeyObj() {
return new Long(_bookId);
}
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
public Class<?> getModelClass() {
return SBook.class;
}
public String getModelClassName() {
return SBook.class.getName();
}
@Override
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("bookId", getBookId());
attributes.put("libraryId", getLibraryId());
attributes.put("title", getTitle());
return attributes;
}
@Override
public void setModelAttributes(Map<String, Object> attributes) {
Long bookId = (Long)attributes.get("bookId");
if (bookId != null) {
setBookId(bookId);
}
Long libraryId = (Long)attributes.get("libraryId");
if (libraryId != null) {
setLibraryId(libraryId);
}
String title = (String)attributes.get("title");
if (title != null) {
setTitle(title);
}
}
@JSON
public long getBookId() {
return _bookId;
}
public void setBookId(long bookId) {
_bookId = bookId;
}
@JSON
public long getLibraryId() {
return _libraryId;
}
public void setLibraryId(long libraryId) {
_libraryId = libraryId;
}
@JSON
public String getTitle() {
if (_title == null) {
return StringPool.BLANK;
}
else {
return _title;
}
}
public void setTitle(String title) {
_title = title;
}
@Override
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
SBook.class.getName(), getPrimaryKey());
}
@Override
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
@Override
public SBook toEscapedModel() {
if (_escapedModelProxy == null) {
_escapedModelProxy = (SBook)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelProxyInterfaces,
new AutoEscapeBeanHandler(this));
}
return _escapedModelProxy;
}
@Override
public Object clone() {
SBookImpl sBookImpl = new SBookImpl();
sBookImpl.setBookId(getBookId());
sBookImpl.setLibraryId(getLibraryId());
sBookImpl.setTitle(getTitle());
sBookImpl.resetOriginalValues();
return sBookImpl;
}
public int compareTo(SBook sBook) {
long primaryKey = sBook.getPrimaryKey();
if (getPrimaryKey() < primaryKey) {
return -1;
}
else if (getPrimaryKey() > primaryKey) {
return 1;
}
else {
return 0;
}
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
SBook sBook = null;
try {
sBook = (SBook)obj;
}
catch (ClassCastException cce) {
return false;
}
long primaryKey = sBook.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
@Override
public int hashCode() {
return (int)getPrimaryKey();
}
@Override
public void resetOriginalValues() {
}
@Override
public CacheModel<SBook> toCacheModel() {
SBookCacheModel sBookCacheModel = new SBookCacheModel();
sBookCacheModel.bookId = getBookId();
sBookCacheModel.libraryId = getLibraryId();
sBookCacheModel.title = getTitle();
String title = sBookCacheModel.title;
if ((title != null) && (title.length() == 0)) {
sBookCacheModel.title = null;
}
return sBookCacheModel;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(7);
sb.append("{bookId=");
sb.append(getBookId());
sb.append(", libraryId=");
sb.append(getLibraryId());
sb.append(", title=");
sb.append(getTitle());
sb.append("}");
return sb.toString();
}
public String toXmlString() {
StringBundler sb = new StringBundler(13);
sb.append("<model><model-name>");
sb.append("com.jenginetest.builder.model.SBook");
sb.append("</model-name>");
sb.append(
"<column><column-name>bookId</column-name><column-value><![CDATA[");
sb.append(getBookId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>libraryId</column-name><column-value><![CDATA[");
sb.append(getLibraryId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>title</column-name><column-value><![CDATA[");
sb.append(getTitle());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = SBook.class.getClassLoader();
private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
SBook.class
};
private long _bookId;
private long _libraryId;
private String _title;
private SBook _escapedModelProxy;
}