/**
* 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.SAuthor;
import com.jenginetest.builder.model.SAuthorModel;
import com.jenginetest.builder.model.SAuthorSoap;
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 SAuthor service. Represents a row in the "SB_SAuthor" database table, with each column mapped to a property of this class.
*
* <p>
* This implementation and its corresponding interface {@link com.jenginetest.builder.model.SAuthorModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link SAuthorImpl}.
* </p>
*
* @author Brian Wing Shun Chan
* @see SAuthorImpl
* @see com.jenginetest.builder.model.SAuthor
* @see com.jenginetest.builder.model.SAuthorModel
* @generated
*/
@JSON(strict = true)
public class SAuthorModelImpl extends BaseModelImpl<SAuthor>
implements SAuthorModel {
/*
* NOTE FOR DEVELOPERS:
*
* Never modify or reference this class directly. All methods that expect a s author model instance should use the {@link com.jenginetest.builder.model.SAuthor} interface instead.
*/
public static final String TABLE_NAME = "SB_SAuthor";
public static final Object[][] TABLE_COLUMNS = {
{ "authorId", Types.BIGINT },
{ "firstName", Types.VARCHAR },
{ "lastName", Types.VARCHAR }
};
public static final String TABLE_SQL_CREATE = "create table SB_SAuthor (authorId LONG not null primary key,firstName VARCHAR(75) null,lastName VARCHAR(75) null)";
public static final String TABLE_SQL_DROP = "drop table SB_SAuthor";
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.SAuthor"),
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.SAuthor"),
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 SAuthor toModel(SAuthorSoap soapModel) {
if (soapModel == null) {
return null;
}
SAuthor model = new SAuthorImpl();
model.setAuthorId(soapModel.getAuthorId());
model.setFirstName(soapModel.getFirstName());
model.setLastName(soapModel.getLastName());
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<SAuthor> toModels(SAuthorSoap[] soapModels) {
if (soapModels == null) {
return null;
}
List<SAuthor> models = new ArrayList<SAuthor>(soapModels.length);
for (SAuthorSoap 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.SAuthor"));
public SAuthorModelImpl() {
}
public long getPrimaryKey() {
return _authorId;
}
public void setPrimaryKey(long primaryKey) {
setAuthorId(primaryKey);
}
public Serializable getPrimaryKeyObj() {
return new Long(_authorId);
}
public void setPrimaryKeyObj(Serializable primaryKeyObj) {
setPrimaryKey(((Long)primaryKeyObj).longValue());
}
public Class<?> getModelClass() {
return SAuthor.class;
}
public String getModelClassName() {
return SAuthor.class.getName();
}
@Override
public Map<String, Object> getModelAttributes() {
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("authorId", getAuthorId());
attributes.put("firstName", getFirstName());
attributes.put("lastName", getLastName());
return attributes;
}
@Override
public void setModelAttributes(Map<String, Object> attributes) {
Long authorId = (Long)attributes.get("authorId");
if (authorId != null) {
setAuthorId(authorId);
}
String firstName = (String)attributes.get("firstName");
if (firstName != null) {
setFirstName(firstName);
}
String lastName = (String)attributes.get("lastName");
if (lastName != null) {
setLastName(lastName);
}
}
@JSON
public long getAuthorId() {
return _authorId;
}
public void setAuthorId(long authorId) {
_authorId = authorId;
}
@JSON
public String getFirstName() {
if (_firstName == null) {
return StringPool.BLANK;
}
else {
return _firstName;
}
}
public void setFirstName(String firstName) {
_firstName = firstName;
}
@JSON
public String getLastName() {
if (_lastName == null) {
return StringPool.BLANK;
}
else {
return _lastName;
}
}
public void setLastName(String lastName) {
_lastName = lastName;
}
@Override
public ExpandoBridge getExpandoBridge() {
return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
SAuthor.class.getName(), getPrimaryKey());
}
@Override
public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
ExpandoBridge expandoBridge = getExpandoBridge();
expandoBridge.setAttributes(serviceContext);
}
@Override
public SAuthor toEscapedModel() {
if (_escapedModelProxy == null) {
_escapedModelProxy = (SAuthor)ProxyUtil.newProxyInstance(_classLoader,
_escapedModelProxyInterfaces,
new AutoEscapeBeanHandler(this));
}
return _escapedModelProxy;
}
@Override
public Object clone() {
SAuthorImpl sAuthorImpl = new SAuthorImpl();
sAuthorImpl.setAuthorId(getAuthorId());
sAuthorImpl.setFirstName(getFirstName());
sAuthorImpl.setLastName(getLastName());
sAuthorImpl.resetOriginalValues();
return sAuthorImpl;
}
public int compareTo(SAuthor sAuthor) {
long primaryKey = sAuthor.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;
}
SAuthor sAuthor = null;
try {
sAuthor = (SAuthor)obj;
}
catch (ClassCastException cce) {
return false;
}
long primaryKey = sAuthor.getPrimaryKey();
if (getPrimaryKey() == primaryKey) {
return true;
}
else {
return false;
}
}
@Override
public int hashCode() {
return (int)getPrimaryKey();
}
@Override
public void resetOriginalValues() {
}
@Override
public CacheModel<SAuthor> toCacheModel() {
SAuthorCacheModel sAuthorCacheModel = new SAuthorCacheModel();
sAuthorCacheModel.authorId = getAuthorId();
sAuthorCacheModel.firstName = getFirstName();
String firstName = sAuthorCacheModel.firstName;
if ((firstName != null) && (firstName.length() == 0)) {
sAuthorCacheModel.firstName = null;
}
sAuthorCacheModel.lastName = getLastName();
String lastName = sAuthorCacheModel.lastName;
if ((lastName != null) && (lastName.length() == 0)) {
sAuthorCacheModel.lastName = null;
}
return sAuthorCacheModel;
}
@Override
public String toString() {
StringBundler sb = new StringBundler(7);
sb.append("{authorId=");
sb.append(getAuthorId());
sb.append(", firstName=");
sb.append(getFirstName());
sb.append(", lastName=");
sb.append(getLastName());
sb.append("}");
return sb.toString();
}
public String toXmlString() {
StringBundler sb = new StringBundler(13);
sb.append("<model><model-name>");
sb.append("com.jenginetest.builder.model.SAuthor");
sb.append("</model-name>");
sb.append(
"<column><column-name>authorId</column-name><column-value><![CDATA[");
sb.append(getAuthorId());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>firstName</column-name><column-value><![CDATA[");
sb.append(getFirstName());
sb.append("]]></column-value></column>");
sb.append(
"<column><column-name>lastName</column-name><column-value><![CDATA[");
sb.append(getLastName());
sb.append("]]></column-value></column>");
sb.append("</model>");
return sb.toString();
}
private static ClassLoader _classLoader = SAuthor.class.getClassLoader();
private static Class<?>[] _escapedModelProxyInterfaces = new Class[] {
SAuthor.class
};
private long _authorId;
private String _firstName;
private String _lastName;
private SAuthor _escapedModelProxy;
}