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.meduni.graz.patho.haybaeck.model.impl; import at.meduni.graz.patho.haybaeck.model.Patient; import at.meduni.graz.patho.haybaeck.model.PatientModel; import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler; 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.Date; import java.util.HashMap; import java.util.Map; /** * The base model implementation for the Patient service. Represents a row in the "haybaeck.patient" database table, with each column mapped to a property of this class. * * <p> * This implementation and its corresponding interface {@link at.meduni.graz.patho.haybaeck.model.PatientModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link PatientImpl}. * </p> * * @author reihsr * @see PatientImpl * @see at.meduni.graz.patho.haybaeck.model.Patient * @see at.meduni.graz.patho.haybaeck.model.PatientModel * @generated */ public class PatientModelImpl extends BaseModelImpl<Patient> implements PatientModel { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. All methods that expect a patient model instance should use the {@link at.meduni.graz.patho.haybaeck.model.Patient} interface instead. */ public static final String TABLE_NAME = "haybaeck.patient"; public static final Object[][] TABLE_COLUMNS = { { "id", Types.BIGINT }, { "identifier", Types.VARCHAR }, { "cohort", Types.VARCHAR }, { "first_name", Types.VARCHAR }, { "last_name", Types.VARCHAR }, { "date_of_birth", Types.TIMESTAMP }, { "date_of_death", Types.TIMESTAMP }, { "couse_of_death", Types.VARCHAR }, { "gender", Types.VARCHAR } }; public static final String TABLE_SQL_CREATE = "create table haybaeck.patient (id LONG not null primary key,identifier VARCHAR(255) null,cohort VARCHAR(255) null,first_name VARCHAR(255) null,last_name VARCHAR(255) null,date_of_birth DATE null,date_of_death DATE null,couse_of_death VARCHAR(255) null,gender VARCHAR(1) null)"; public static final String TABLE_SQL_DROP = "drop table haybaeck.patient"; public static final String ORDER_BY_JPQL = " ORDER BY patient.patient_Id ASC"; public static final String ORDER_BY_SQL = " ORDER BY haybaeck.patient.id ASC"; public static final String DATA_SOURCE = "haybaeckDataSource"; public static final String SESSION_FACTORY = "haybaeckSessionFactory"; public static final String TX_MANAGER = "haybaeckTransactionManager"; public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.entity.cache.enabled.at.meduni.graz.patho.haybaeck.model.Patient"), true); public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps .get("value.object.finder.cache.enabled.at.meduni.graz.patho.haybaeck.model.Patient"), true); public static final boolean COLUMN_BITMASK_ENABLED = false; public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps .get("lock.expiration.time.at.meduni.graz.patho.haybaeck.model.Patient")); public PatientModelImpl() { } @Override public long getPrimaryKey() { return _patient_Id; } @Override public void setPrimaryKey(long primaryKey) { setPatient_Id(primaryKey); } @Override public Serializable getPrimaryKeyObj() { return _patient_Id; } @Override public void setPrimaryKeyObj(Serializable primaryKeyObj) { setPrimaryKey(((Long) primaryKeyObj).longValue()); } @Override public Class<?> getModelClass() { return Patient.class; } @Override public String getModelClassName() { return Patient.class.getName(); } @Override public Map<String, Object> getModelAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put("patient_Id", getPatient_Id()); attributes.put("identifier", getIdentifier()); attributes.put("cohort", getCohort()); attributes.put("first_name", getFirst_name()); attributes.put("last_name", getLast_name()); attributes.put("date_of_birth", getDate_of_birth()); attributes.put("date_of_death", getDate_of_death()); attributes.put("couse_of_death", getCouse_of_death()); attributes.put("gender", getGender()); return attributes; } @Override public void setModelAttributes(Map<String, Object> attributes) { Long patient_Id = (Long) attributes.get("patient_Id"); if (patient_Id != null) { setPatient_Id(patient_Id); } String identifier = (String) attributes.get("identifier"); if (identifier != null) { setIdentifier(identifier); } String cohort = (String) attributes.get("cohort"); if (cohort != null) { setCohort(cohort); } String first_name = (String) attributes.get("first_name"); if (first_name != null) { setFirst_name(first_name); } String last_name = (String) attributes.get("last_name"); if (last_name != null) { setLast_name(last_name); } Date date_of_birth = (Date) attributes.get("date_of_birth"); if (date_of_birth != null) { setDate_of_birth(date_of_birth); } Date date_of_death = (Date) attributes.get("date_of_death"); if (date_of_death != null) { setDate_of_death(date_of_death); } String couse_of_death = (String) attributes.get("couse_of_death"); if (couse_of_death != null) { setCouse_of_death(couse_of_death); } String gender = (String) attributes.get("gender"); if (gender != null) { setGender(gender); } } @Override public long getPatient_Id() { return _patient_Id; } @Override public void setPatient_Id(long patient_Id) { _patient_Id = patient_Id; } @Override public String getIdentifier() { if (_identifier == null) { return StringPool.BLANK; } else { return _identifier; } } @Override public void setIdentifier(String identifier) { _identifier = identifier; } @Override public String getCohort() { if (_cohort == null) { return StringPool.BLANK; } else { return _cohort; } } @Override public void setCohort(String cohort) { _cohort = cohort; } @Override public String getFirst_name() { if (_first_name == null) { return StringPool.BLANK; } else { return _first_name; } } @Override public void setFirst_name(String first_name) { _first_name = first_name; } @Override public String getLast_name() { if (_last_name == null) { return StringPool.BLANK; } else { return _last_name; } } @Override public void setLast_name(String last_name) { _last_name = last_name; } @Override public Date getDate_of_birth() { return _date_of_birth; } @Override public void setDate_of_birth(Date date_of_birth) { _date_of_birth = date_of_birth; } @Override public Date getDate_of_death() { return _date_of_death; } @Override public void setDate_of_death(Date date_of_death) { _date_of_death = date_of_death; } @Override public String getCouse_of_death() { if (_couse_of_death == null) { return StringPool.BLANK; } else { return _couse_of_death; } } @Override public void setCouse_of_death(String couse_of_death) { _couse_of_death = couse_of_death; } @Override public String getGender() { if (_gender == null) { return StringPool.BLANK; } else { return _gender; } } @Override public void setGender(String gender) { _gender = gender; } @Override public ExpandoBridge getExpandoBridge() { return ExpandoBridgeFactoryUtil.getExpandoBridge(0, Patient.class.getName(), getPrimaryKey()); } @Override public void setExpandoBridgeAttributes(ServiceContext serviceContext) { ExpandoBridge expandoBridge = getExpandoBridge(); expandoBridge.setAttributes(serviceContext); } @Override public Patient toEscapedModel() { if (_escapedModel == null) { _escapedModel = (Patient) ProxyUtil.newProxyInstance(_classLoader, _escapedModelInterfaces, new AutoEscapeBeanHandler(this)); } return _escapedModel; } @Override public Object clone() { PatientImpl patientImpl = new PatientImpl(); patientImpl.setPatient_Id(getPatient_Id()); patientImpl.setIdentifier(getIdentifier()); patientImpl.setCohort(getCohort()); patientImpl.setFirst_name(getFirst_name()); patientImpl.setLast_name(getLast_name()); patientImpl.setDate_of_birth(getDate_of_birth()); patientImpl.setDate_of_death(getDate_of_death()); patientImpl.setCouse_of_death(getCouse_of_death()); patientImpl.setGender(getGender()); patientImpl.resetOriginalValues(); return patientImpl; } @Override public int compareTo(Patient patient) { long primaryKey = patient.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 Patient)) { return false; } Patient patient = (Patient) obj; long primaryKey = patient.getPrimaryKey(); if (getPrimaryKey() == primaryKey) { return true; } else { return false; } } @Override public int hashCode() { return (int) getPrimaryKey(); } @Override public void resetOriginalValues() { } @Override public CacheModel<Patient> toCacheModel() { PatientCacheModel patientCacheModel = new PatientCacheModel(); patientCacheModel.patient_Id = getPatient_Id(); patientCacheModel.identifier = getIdentifier(); String identifier = patientCacheModel.identifier; if ((identifier != null) && (identifier.length() == 0)) { patientCacheModel.identifier = null; } patientCacheModel.cohort = getCohort(); String cohort = patientCacheModel.cohort; if ((cohort != null) && (cohort.length() == 0)) { patientCacheModel.cohort = null; } patientCacheModel.first_name = getFirst_name(); String first_name = patientCacheModel.first_name; if ((first_name != null) && (first_name.length() == 0)) { patientCacheModel.first_name = null; } patientCacheModel.last_name = getLast_name(); String last_name = patientCacheModel.last_name; if ((last_name != null) && (last_name.length() == 0)) { patientCacheModel.last_name = null; } Date date_of_birth = getDate_of_birth(); if (date_of_birth != null) { patientCacheModel.date_of_birth = date_of_birth.getTime(); } else { patientCacheModel.date_of_birth = Long.MIN_VALUE; } Date date_of_death = getDate_of_death(); if (date_of_death != null) { patientCacheModel.date_of_death = date_of_death.getTime(); } else { patientCacheModel.date_of_death = Long.MIN_VALUE; } patientCacheModel.couse_of_death = getCouse_of_death(); String couse_of_death = patientCacheModel.couse_of_death; if ((couse_of_death != null) && (couse_of_death.length() == 0)) { patientCacheModel.couse_of_death = null; } patientCacheModel.gender = getGender(); String gender = patientCacheModel.gender; if ((gender != null) && (gender.length() == 0)) { patientCacheModel.gender = null; } return patientCacheModel; } @Override public String toString() { StringBundler sb = new StringBundler(19); sb.append("{patient_Id="); sb.append(getPatient_Id()); sb.append(", identifier="); sb.append(getIdentifier()); sb.append(", cohort="); sb.append(getCohort()); sb.append(", first_name="); sb.append(getFirst_name()); sb.append(", last_name="); sb.append(getLast_name()); sb.append(", date_of_birth="); sb.append(getDate_of_birth()); sb.append(", date_of_death="); sb.append(getDate_of_death()); sb.append(", couse_of_death="); sb.append(getCouse_of_death()); sb.append(", gender="); sb.append(getGender()); sb.append("}"); return sb.toString(); } @Override public String toXmlString() { StringBundler sb = new StringBundler(31); sb.append("<model><model-name>"); sb.append("at.meduni.graz.patho.haybaeck.model.Patient"); sb.append("</model-name>"); sb.append("<column><column-name>patient_Id</column-name><column-value><![CDATA["); sb.append(getPatient_Id()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>identifier</column-name><column-value><![CDATA["); sb.append(getIdentifier()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>cohort</column-name><column-value><![CDATA["); sb.append(getCohort()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>first_name</column-name><column-value><![CDATA["); sb.append(getFirst_name()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>last_name</column-name><column-value><![CDATA["); sb.append(getLast_name()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>date_of_birth</column-name><column-value><![CDATA["); sb.append(getDate_of_birth()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>date_of_death</column-name><column-value><![CDATA["); sb.append(getDate_of_death()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>couse_of_death</column-name><column-value><![CDATA["); sb.append(getCouse_of_death()); sb.append("]]></column-value></column>"); sb.append("<column><column-name>gender</column-name><column-value><![CDATA["); sb.append(getGender()); sb.append("]]></column-value></column>"); sb.append("</model>"); return sb.toString(); } private static ClassLoader _classLoader = Patient.class.getClassLoader(); private static Class<?>[] _escapedModelInterfaces = new Class[] { Patient.class }; private long _patient_Id; private String _identifier; private String _cohort; private String _first_name; private String _last_name; private Date _date_of_birth; private Date _date_of_death; private String _couse_of_death; private String _gender; private Patient _escapedModel; }