Java tutorial
/** * Copyright (c) 2000-2013 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 at.graz.meduni.liferay.api.model.impl; import at.graz.meduni.liferay.api.model.rdconnect; import at.graz.meduni.liferay.api.model.rdconnectModel; import at.graz.meduni.liferay.api.model.rdconnectSoap; import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler; import com.liferay.portal.kernel.exception.SystemException; import com.liferay.portal.kernel.json.JSON; import com.liferay.portal.kernel.util.DateUtil; 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.portal.util.PortalUtil; 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.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * The base model implementation for the rdconnect service. Represents a row in the "rdconnect.idcardapilog" database table, with each column mapped to a property of this class. * * <p> * This implementation and its corresponding interface {@link at.graz.meduni.liferay.api.model.rdconnectModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link rdconnectImpl}. * </p> * * @author reihsr * @see rdconnectImpl * @see at.graz.meduni.liferay.api.model.rdconnect * @see at.graz.meduni.liferay.api.model.rdconnectModel * @generated */ @JSON(strict = true) public class rdconnectModelImpl extends BaseModelImpl<rdconnect> implements rdconnectModel { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. All methods that expect a rdconnect model instance should use the {@link at.graz.meduni.liferay.api.model.rdconnect} interface instead. */ public static final String TABLE_NAME = "rdconnect.idcardapilog"; public static final Object[][] TABLE_COLUMNS = { { "idcardapilogId", Types.BIGINT }, { "userId", Types.BIGINT }, { "ipaddress", Types.VARCHAR }, { "accessDate", Types.TIMESTAMP }, { "requestparameter", Types.VARCHAR } }; public static final String TABLE_SQL_CREATE = "create table rdconnect.idcardapilog (idcardapilogId LONG not null primary key,userId LONG,ipaddress VARCHAR(75) null,accessDate DATE null,requestparameter VARCHAR(75) null)"; public static final String TABLE_SQL_DROP = "drop table rdconnect.idcardapilog"; public static final String ORDER_BY_JPQL = " ORDER BY rdconnect.accessDate ASC"; public static final String ORDER_BY_SQL = " ORDER BY rdconnect.idcardapilog.accessDate ASC"; 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.at.graz.meduni.liferay.api.model.rdconnect"), true); public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.finder.cache.enabled.at.graz.meduni.liferay.api.model.rdconnect"), true); public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.column.bitmask.enabled.at.graz.meduni.liferay.api.model.rdconnect"), true); public static long USERID_COLUMN_BITMASK = 1L; public static long ACCESSDATE_COLUMN_BITMASK = 2L; /** * 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 rdconnect toModel(rdconnectSoap soapModel) { if (soapModel == null) { return null; } rdconnect model = new rdconnectImpl(); model.setIdcardapilogId(soapModel.getIdcardapilogId()); model.setUserId(soapModel.getUserId()); model.setIpaddress(soapModel.getIpaddress()); model.setAccessDate(soapModel.getAccessDate()); model.setRequestparameter(soapModel.getRequestparameter()); 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<rdconnect> toModels(rdconnectSoap[] soapModels) { if (soapModels == null) { return null; } List<rdconnect> models = new ArrayList<rdconnect>(soapModels.length); for (rdconnectSoap 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.at.graz.meduni.liferay.api.model.rdconnect")); public rdconnectModelImpl() { } @Override public long getPrimaryKey() { return _idcardapilogId; } @Override public void setPrimaryKey(long primaryKey) { setIdcardapilogId(primaryKey); } @Override public Serializable getPrimaryKeyObj() { return _idcardapilogId; } @Override public void setPrimaryKeyObj(Serializable primaryKeyObj) { setPrimaryKey(((Long) primaryKeyObj).longValue()); } @Override public Class<?> getModelClass() { return rdconnect.class; } @Override public String getModelClassName() { return rdconnect.class.getName(); } @Override public Map<String, Object> getModelAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("idcardapilogId", getIdcardapilogId()); attributes.put("userId", getUserId()); attributes.put("ipaddress", getIpaddress()); attributes.put("accessDate", getAccessDate()); attributes.put("requestparameter", getRequestparameter()); return attributes; } @Override public void setModelAttributes(Map<String, Object> attributes) { Long idcardapilogId = (Long) attributes.get("idcardapilogId"); if (idcardapilogId != null) { setIdcardapilogId(idcardapilogId); } Long userId = (Long) attributes.get("userId"); if (userId != null) { setUserId(userId); } String ipaddress = (String) attributes.get("ipaddress"); if (ipaddress != null) { setIpaddress(ipaddress); } Date accessDate = (Date) attributes.get("accessDate"); if (accessDate != null) { setAccessDate(accessDate); } String requestparameter = (String) attributes.get("requestparameter"); if (requestparameter != null) { setRequestparameter(requestparameter); } } @JSON @Override public long getIdcardapilogId() { return _idcardapilogId; } @Override public void setIdcardapilogId(long idcardapilogId) { _idcardapilogId = idcardapilogId; } @JSON @Override public long getUserId() { return _userId; } @Override public void setUserId(long userId) { _columnBitmask |= USERID_COLUMN_BITMASK; if (!_setOriginalUserId) { _setOriginalUserId = true; _originalUserId = _userId; } _userId = userId; } @Override public String getUserUuid() throws SystemException { return PortalUtil.getUserValue(getUserId(), "uuid", _userUuid); } @Override public void setUserUuid(String userUuid) { _userUuid = userUuid; } public long getOriginalUserId() { return _originalUserId; } @JSON @Override public String getIpaddress() { if (_ipaddress == null) { return StringPool.BLANK; } else { return _ipaddress; } } @Override public void setIpaddress(String ipaddress) { _ipaddress = ipaddress; } @JSON @Override public Date getAccessDate() { return _accessDate; } @Override public void setAccessDate(Date accessDate) { _columnBitmask = -1L; _accessDate = accessDate; } @JSON @Override public String getRequestparameter() { if (_requestparameter == null) { return StringPool.BLANK; } else { return _requestparameter; } } @Override public void setRequestparameter(String requestparameter) { _requestparameter = requestparameter; } public long getColumnBitmask() { return _columnBitmask; } @Override public ExpandoBridge getExpandoBridge() { return ExpandoBridgeFactoryUtil.getExpandoBridge(0, rdconnect.class.getName(), getPrimaryKey()); } @Override public void setExpandoBridgeAttributes(ServiceContext serviceContext) { ExpandoBridge expandoBridge = getExpandoBridge(); expandoBridge.setAttributes(serviceContext); } @Override public rdconnect toEscapedModel() { if (_escapedModel == null) { _escapedModel = (rdconnect) ProxyUtil.newProxyInstance(_classLoader, _escapedModelInterfaces, new AutoEscapeBeanHandler(this)); } return _escapedModel; } @Override public Object clone() { rdconnectImpl rdconnectImpl = new rdconnectImpl(); rdconnectImpl.setIdcardapilogId(getIdcardapilogId()); rdconnectImpl.setUserId(getUserId()); rdconnectImpl.setIpaddress(getIpaddress()); rdconnectImpl.setAccessDate(getAccessDate()); rdconnectImpl.setRequestparameter(getRequestparameter()); rdconnectImpl.resetOriginalValues(); return rdconnectImpl; } @Override public int compareTo(rdconnect rdconnect) { int value = 0; value = DateUtil.compareTo(getAccessDate(), rdconnect.getAccessDate()); if (value != 0) { return value; } return 0; } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof rdconnect)) { return false; } rdconnect rdconnect = (rdconnect) obj; long primaryKey = rdconnect.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } } @Override public int hashCode() { return (int) getPrimaryKey(); } @Override public void resetOriginalValues() { rdconnectModelImpl rdconnectModelImpl = this; rdconnectModelImpl._originalUserId = rdconnectModelImpl._userId; rdconnectModelImpl._setOriginalUserId = false; rdconnectModelImpl._columnBitmask = 0; } @Override public CacheModel<rdconnect> toCacheModel() { rdconnectCacheModel rdconnectCacheModel = new rdconnectCacheModel(); rdconnectCacheModel.idcardapilogId = getIdcardapilogId(); rdconnectCacheModel.userId = getUserId(); rdconnectCacheModel.ipaddress = getIpaddress(); String ipaddress = rdconnectCacheModel.ipaddress; if ((ipaddress != null) && (ipaddress.length() == 0)) { rdconnectCacheModel.ipaddress = null; } Date accessDate = getAccessDate(); if (accessDate != null) { rdconnectCacheModel.accessDate = accessDate.getTime(); } else { rdconnectCacheModel.accessDate = Long.MIN_VALUE; } rdconnectCacheModel.requestparameter = getRequestparameter(); String requestparameter = rdconnectCacheModel.requestparameter; if ((requestparameter != null) && (requestparameter.length() == 0)) { rdconnectCacheModel.requestparameter = null; } return rdconnectCacheModel; } @Override public String toString() { StringBundler sb = new StringBundler(11); sb.append("{idcardapilogId="); sb.append(getIdcardapilogId()); sb.append(", userId="); sb.append(getUserId()); sb.append(", ipaddress="); sb.append(getIpaddress()); sb.append(", accessDate="); sb.append(getAccessDate()); sb.append(", requestparameter="); sb.append(getRequestparameter()); sb.append("}"); return sb.toString(); } @Override public String toXmlString() { StringBundler sb = new StringBundler(19); sb.append("<model><model-name>"); sb.append("at.graz.meduni.liferay.api.model.rdconnect"); sb.append("</model-name>"); sb.append("<column><column-name>idcardapilogId</column-name><column-value><![CDATA["); sb.append(getIdcardapilogId()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>userId</column-name><column-value><![CDATA["); sb.append(getUserId()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>ipaddress</column-name><column-value><![CDATA["); sb.append(getIpaddress()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>accessDate</column-name><column-value><![CDATA["); sb.append(getAccessDate()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>requestparameter</column-name><column-value><![CDATA["); sb.append(getRequestparameter()); sb.append("]]></column-value></column>"); sb.append("</model>"); return sb.toString(); } private static ClassLoader _classLoader = rdconnect.class.getClassLoader(); private static Class<?>[] _escapedModelInterfaces = new Class[] { rdconnect.class }; private long _idcardapilogId; private long _userId; private String _userUuid; private long _originalUserId; private boolean _setOriginalUserId; private String _ipaddress; private Date _accessDate; private String _requestparameter; private long _columnBitmask; private rdconnect _escapedModel; }