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.hmmc.liferay.portlet.puch.model.impl; import at.graz.hmmc.liferay.portlet.puch.model.Person; import at.graz.hmmc.liferay.portlet.puch.model.PersonModel; import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler; import com.liferay.portal.kernel.exception.SystemException; 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.Date; import java.util.HashMap; import java.util.Map; /** * The base model implementation for the Person service. Represents a row in the "puchmuseum.person" database table, with each column mapped to a property of this class. * * <p> * This implementation and its corresponding interface {@link at.graz.hmmc.liferay.portlet.puch.model.PersonModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PersonImpl}. * </p> * * @author reihsr * @see PersonImpl * @see at.graz.hmmc.liferay.portlet.puch.model.Person * @see at.graz.hmmc.liferay.portlet.puch.model.PersonModel * @generated */ public class PersonModelImpl extends BaseModelImpl<Person> implements PersonModel { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. All methods that expect a person model instance should use the {@link at.graz.hmmc.liferay.portlet.puch.model.Person} interface instead. */ public static final String TABLE_NAME = "puchmuseum.person"; public static final Object[][] TABLE_COLUMNS = { { "personId", Types.BIGINT }, { "createrUserId", Types.BIGINT }, { "createDate", Types.TIMESTAMP }, { "modifiedUserId", Types.BIGINT }, { "modifiedDate", Types.TIMESTAMP }, { "vorname", Types.VARCHAR } }; public static final String TABLE_SQL_CREATE = "create table puchmuseum.person (personId LONG not null primary key,createrUserId LONG,createDate DATE null,modifiedUserId LONG,modifiedDate DATE null,vorname VARCHAR(75) null)"; public static final String TABLE_SQL_DROP = "drop table puchmuseum.person"; public static final String ORDER_BY_JPQL = " ORDER BY person.personId ASC"; public static final String ORDER_BY_SQL = " ORDER BY puchmuseum.person.personId 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.hmmc.liferay.portlet.puch.model.Person"), true); public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.finder.cache.enabled.at.graz.hmmc.liferay.portlet.puch.model.Person"), true); public static final boolean COLUMN_BITMASK_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.column.bitmask.enabled.at.graz.hmmc.liferay.portlet.puch.model.Person"), true); public static long VORNAME_COLUMN_BITMASK = 1L; public static long PERSONID_COLUMN_BITMASK = 2L; public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps .get("lock.expiration.time.at.graz.hmmc.liferay.portlet.puch.model.Person")); public PersonModelImpl() { } @Override public long getPrimaryKey() { return _personId; } @Override public void setPrimaryKey(long primaryKey) { setPersonId(primaryKey); } @Override public Serializable getPrimaryKeyObj() { return _personId; } @Override public void setPrimaryKeyObj(Serializable primaryKeyObj) { setPrimaryKey(((Long) primaryKeyObj).longValue()); } @Override public Class<?> getModelClass() { return Person.class; } @Override public String getModelClassName() { return Person.class.getName(); } @Override public Map<String, Object> getModelAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("personId", getPersonId()); attributes.put("createrUserId", getCreaterUserId()); attributes.put("createDate", getCreateDate()); attributes.put("modifiedUserId", getModifiedUserId()); attributes.put("modifiedDate", getModifiedDate()); attributes.put("vorname", getVorname()); return attributes; } @Override public void setModelAttributes(Map<String, Object> attributes) { Long personId = (Long) attributes.get("personId"); if (personId != null) { setPersonId(personId); } Long createrUserId = (Long) attributes.get("createrUserId"); if (createrUserId != null) { setCreaterUserId(createrUserId); } Date createDate = (Date) attributes.get("createDate"); if (createDate != null) { setCreateDate(createDate); } Long modifiedUserId = (Long) attributes.get("modifiedUserId"); if (modifiedUserId != null) { setModifiedUserId(modifiedUserId); } Date modifiedDate = (Date) attributes.get("modifiedDate"); if (modifiedDate != null) { setModifiedDate(modifiedDate); } String vorname = (String) attributes.get("vorname"); if (vorname != null) { setVorname(vorname); } } @Override public long getPersonId() { return _personId; } @Override public void setPersonId(long personId) { _personId = personId; } @Override public long getCreaterUserId() { return _createrUserId; } @Override public void setCreaterUserId(long createrUserId) { _createrUserId = createrUserId; } @Override public String getCreaterUserUuid() throws SystemException { return PortalUtil.getUserValue(getCreaterUserId(), "uuid", _createrUserUuid); } @Override public void setCreaterUserUuid(String createrUserUuid) { _createrUserUuid = createrUserUuid; } @Override public Date getCreateDate() { return _createDate; } @Override public void setCreateDate(Date createDate) { _createDate = createDate; } @Override public long getModifiedUserId() { return _modifiedUserId; } @Override public void setModifiedUserId(long modifiedUserId) { _modifiedUserId = modifiedUserId; } @Override public String getModifiedUserUuid() throws SystemException { return PortalUtil.getUserValue(getModifiedUserId(), "uuid", _modifiedUserUuid); } @Override public void setModifiedUserUuid(String modifiedUserUuid) { _modifiedUserUuid = modifiedUserUuid; } @Override public Date getModifiedDate() { return _modifiedDate; } @Override public void setModifiedDate(Date modifiedDate) { _modifiedDate = modifiedDate; } @Override public String getVorname() { if (_vorname == null) { return StringPool.BLANK; } else { return _vorname; } } @Override public void setVorname(String vorname) { _columnBitmask |= VORNAME_COLUMN_BITMASK; if (_originalVorname == null) { _originalVorname = _vorname; } _vorname = vorname; } public String getOriginalVorname() { return GetterUtil.getString(_originalVorname); } public long getColumnBitmask() { return _columnBitmask; } @Override public ExpandoBridge getExpandoBridge() { return ExpandoBridgeFactoryUtil.getExpandoBridge(0, Person.class.getName(), getPrimaryKey()); } @Override public void setExpandoBridgeAttributes(ServiceContext serviceContext) { ExpandoBridge expandoBridge = getExpandoBridge(); expandoBridge.setAttributes(serviceContext); } @Override public Person toEscapedModel() { if (_escapedModel == null) { _escapedModel = (Person) ProxyUtil.newProxyInstance(_classLoader, _escapedModelInterfaces, new AutoEscapeBeanHandler(this)); } return _escapedModel; } @Override public Object clone() { PersonImpl personImpl = new PersonImpl(); personImpl.setPersonId(getPersonId()); personImpl.setCreaterUserId(getCreaterUserId()); personImpl.setCreateDate(getCreateDate()); personImpl.setModifiedUserId(getModifiedUserId()); personImpl.setModifiedDate(getModifiedDate()); personImpl.setVorname(getVorname()); personImpl.resetOriginalValues(); return personImpl; } @Override public int compareTo(Person person) { long primaryKey = person.getPrimaryKey(); if (getPrimaryKey() < primaryKey) { return -1; } else if (getPrimaryKey() > primaryKey) { return 1; } else { return 0; } } @Override public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Person)) { return false; } Person person = (Person) obj; long primaryKey = person.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } } @Override public int hashCode() { return (int) getPrimaryKey(); } @Override public void resetOriginalValues() { PersonModelImpl personModelImpl = this; personModelImpl._originalVorname = personModelImpl._vorname; personModelImpl._columnBitmask = 0; } @Override public CacheModel<Person> toCacheModel() { PersonCacheModel personCacheModel = new PersonCacheModel(); personCacheModel.personId = getPersonId(); personCacheModel.createrUserId = getCreaterUserId(); Date createDate = getCreateDate(); if (createDate != null) { personCacheModel.createDate = createDate.getTime(); } else { personCacheModel.createDate = Long.MIN_VALUE; } personCacheModel.modifiedUserId = getModifiedUserId(); Date modifiedDate = getModifiedDate(); if (modifiedDate != null) { personCacheModel.modifiedDate = modifiedDate.getTime(); } else { personCacheModel.modifiedDate = Long.MIN_VALUE; } personCacheModel.vorname = getVorname(); String vorname = personCacheModel.vorname; if ((vorname != null) && (vorname.length() == 0)) { personCacheModel.vorname = null; } return personCacheModel; } @Override public String toString() { StringBundler sb = new StringBundler(13); sb.append("{personId="); sb.append(getPersonId()); sb.append(", createrUserId="); sb.append(getCreaterUserId()); sb.append(", createDate="); sb.append(getCreateDate()); sb.append(", modifiedUserId="); sb.append(getModifiedUserId()); sb.append(", modifiedDate="); sb.append(getModifiedDate()); sb.append(", vorname="); sb.append(getVorname()); sb.append("}"); return sb.toString(); } @Override public String toXmlString() { StringBundler sb = new StringBundler(22); sb.append("<model><model-name>"); sb.append("at.graz.hmmc.liferay.portlet.puch.model.Person"); sb.append("</model-name>"); sb.append("<column><column-name>personId</column-name><column-value><![CDATA["); sb.append(getPersonId()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>createrUserId</column-name><column-value><![CDATA["); sb.append(getCreaterUserId()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>createDate</column-name><column-value><![CDATA["); sb.append(getCreateDate()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>modifiedUserId</column-name><column-value><![CDATA["); sb.append(getModifiedUserId()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>modifiedDate</column-name><column-value><![CDATA["); sb.append(getModifiedDate()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>vorname</column-name><column-value><![CDATA["); sb.append(getVorname()); sb.append("]]></column-value></column>"); sb.append("</model>"); return sb.toString(); } private static ClassLoader _classLoader = Person.class.getClassLoader(); private static Class<?>[] _escapedModelInterfaces = new Class[] { Person.class }; private long _personId; private long _createrUserId; private String _createrUserUuid; private Date _createDate; private long _modifiedUserId; private String _modifiedUserUuid; private Date _modifiedDate; private String _vorname; private String _originalVorname; private long _columnBitmask; private Person _escapedModel; }