/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/core/vo/HomeLeaveVo.java
//#############################################################################
//#                                                                           #
//#  Copyright (C) <2015>  <IMS MAXIMS>                                       #
//#                                                                           #
//#  This program is free software: you can redistribute it and/or modify     #
//#  it under the terms of the GNU Affero General Public License as           #
//#  published by the Free Software Foundation, either version 3 of the       #
//#  License, or (at your option) any later version.                          # 
//#                                                                           #
//#  This program 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 Affero General Public License for more details.                      #
//#                                                                           #
//#  You should have received a copy of the GNU Affero General Public License #
//#  along with this program.  If not, see <http://www.gnu.org/licenses/>.    #
//#                                                                           #
//#  IMS MAXIMS provides absolutely NO GUARANTEE OF THE CLINICAL SAFTEY of    #
//#  this program.  Users of this software do so entirely at their own risk.  #
//#  IMS MAXIMS only ensures the Clinical Safety of unaltered run-time        #
//#  software that it builds, deploys and maintains.                          #
//#                                                                           #
//#############################################################################
//#EOH
// This code was generated by Barbara Worwood using IMS Development Environment (version 1.80 build 5589.25814)
// Copyright (C) 1995-2015 IMS MAXIMS. All rights reserved.
// WARNING: DO NOT MODIFY the content of this file

package ims.core.vo;

/**
 * Linked to core.admin.pas.HomeLeave business object (ID: 1014100017).
 */
public class HomeLeaveVo extends ims.core.admin.pas.vo.HomeLeaveRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public HomeLeaveVo()
	{
	}
	public HomeLeaveVo(Integer id, int version)
	{
		super(id, version);
	}
	public HomeLeaveVo(ims.core.vo.beans.HomeLeaveVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.dateonhomeleave = bean.getDateOnHomeLeave() == null ? null : bean.getDateOnHomeLeave().buildDate();
		this.timeonhomeleave = bean.getTimeOnHomeLeave() == null ? null : bean.getTimeOnHomeLeave().buildTime();
		this.expecteddateofreturn = bean.getExpectedDateOfReturn() == null ? null : bean.getExpectedDateOfReturn().buildDate();
		this.expectedtimeofreturn = bean.getExpectedTimeOfReturn() == null ? null : bean.getExpectedTimeOfReturn().buildTime();
		this.datereturnedfromhomeleave = bean.getDateReturnedFromHomeLeave() == null ? null : bean.getDateReturnedFromHomeLeave().buildDate();
		this.timereturnedfromhomeleave = bean.getTimeReturnedFromHomeLeave() == null ? null : bean.getTimeReturnedFromHomeLeave().buildTime();
		this.vacatedbednumber = bean.getVacatedBedNumber();
		this.bedretained = bean.getBedRetained();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.HomeLeaveVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.dateonhomeleave = bean.getDateOnHomeLeave() == null ? null : bean.getDateOnHomeLeave().buildDate();
		this.timeonhomeleave = bean.getTimeOnHomeLeave() == null ? null : bean.getTimeOnHomeLeave().buildTime();
		this.expecteddateofreturn = bean.getExpectedDateOfReturn() == null ? null : bean.getExpectedDateOfReturn().buildDate();
		this.expectedtimeofreturn = bean.getExpectedTimeOfReturn() == null ? null : bean.getExpectedTimeOfReturn().buildTime();
		this.datereturnedfromhomeleave = bean.getDateReturnedFromHomeLeave() == null ? null : bean.getDateReturnedFromHomeLeave().buildDate();
		this.timereturnedfromhomeleave = bean.getTimeReturnedFromHomeLeave() == null ? null : bean.getTimeReturnedFromHomeLeave().buildTime();
		this.vacatedbednumber = bean.getVacatedBedNumber();
		this.bedretained = bean.getBedRetained();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.HomeLeaveVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.HomeLeaveVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.HomeLeaveVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public Object getFieldValueByFieldName(String fieldName)
	{
		if(fieldName == null)
			throw new ims.framework.exceptions.CodingRuntimeException("Invalid field name");
		fieldName = fieldName.toUpperCase();
		if(fieldName.equals("DATEONHOMELEAVE"))
			return getDateOnHomeLeave();
		if(fieldName.equals("TIMEONHOMELEAVE"))
			return getTimeOnHomeLeave();
		if(fieldName.equals("EXPECTEDDATEOFRETURN"))
			return getExpectedDateOfReturn();
		if(fieldName.equals("EXPECTEDTIMEOFRETURN"))
			return getExpectedTimeOfReturn();
		if(fieldName.equals("DATERETURNEDFROMHOMELEAVE"))
			return getDateReturnedFromHomeLeave();
		if(fieldName.equals("TIMERETURNEDFROMHOMELEAVE"))
			return getTimeReturnedFromHomeLeave();
		if(fieldName.equals("VACATEDBEDNUMBER"))
			return getVacatedBedNumber();
		if(fieldName.equals("BEDRETAINED"))
			return getBedRetained();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getDateOnHomeLeaveIsNotNull()
	{
		return this.dateonhomeleave != null;
	}
	public ims.framework.utils.Date getDateOnHomeLeave()
	{
		return this.dateonhomeleave;
	}
	public void setDateOnHomeLeave(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.dateonhomeleave = value;
	}
	public boolean getTimeOnHomeLeaveIsNotNull()
	{
		return this.timeonhomeleave != null;
	}
	public ims.framework.utils.Time getTimeOnHomeLeave()
	{
		return this.timeonhomeleave;
	}
	public void setTimeOnHomeLeave(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.timeonhomeleave = value;
	}
	public boolean getExpectedDateOfReturnIsNotNull()
	{
		return this.expecteddateofreturn != null;
	}
	public ims.framework.utils.Date getExpectedDateOfReturn()
	{
		return this.expecteddateofreturn;
	}
	public void setExpectedDateOfReturn(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.expecteddateofreturn = value;
	}
	public boolean getExpectedTimeOfReturnIsNotNull()
	{
		return this.expectedtimeofreturn != null;
	}
	public ims.framework.utils.Time getExpectedTimeOfReturn()
	{
		return this.expectedtimeofreturn;
	}
	public void setExpectedTimeOfReturn(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.expectedtimeofreturn = value;
	}
	public boolean getDateReturnedFromHomeLeaveIsNotNull()
	{
		return this.datereturnedfromhomeleave != null;
	}
	public ims.framework.utils.Date getDateReturnedFromHomeLeave()
	{
		return this.datereturnedfromhomeleave;
	}
	public void setDateReturnedFromHomeLeave(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datereturnedfromhomeleave = value;
	}
	public boolean getTimeReturnedFromHomeLeaveIsNotNull()
	{
		return this.timereturnedfromhomeleave != null;
	}
	public ims.framework.utils.Time getTimeReturnedFromHomeLeave()
	{
		return this.timereturnedfromhomeleave;
	}
	public void setTimeReturnedFromHomeLeave(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.timereturnedfromhomeleave = value;
	}
	public boolean getVacatedBedNumberIsNotNull()
	{
		return this.vacatedbednumber != null;
	}
	public String getVacatedBedNumber()
	{
		return this.vacatedbednumber;
	}
	public static int getVacatedBedNumberMaxLength()
	{
		return 255;
	}
	public void setVacatedBedNumber(String value)
	{
		this.isValidated = false;
		this.vacatedbednumber = value;
	}
	public boolean getBedRetainedIsNotNull()
	{
		return this.bedretained != null;
	}
	public Boolean getBedRetained()
	{
		return this.bedretained;
	}
	public void setBedRetained(Boolean value)
	{
		this.isValidated = false;
		this.bedretained = value;
	}
	/**
	* HomeLeaveVoDateOnHomeLeaveComparator  (class definition)
	*/
	public static class HomeLeaveVoDateOnHomeLeaveComparator  implements java.util.Comparator
	{
			private int direction = 1;
			public HomeLeaveVoDateOnHomeLeaveComparator ()
			{
				this(ims.framework.enumerations.SortOrder.ASCENDING);
			}
			public HomeLeaveVoDateOnHomeLeaveComparator (ims.framework.enumerations.SortOrder order)
			{
				if (order == ims.framework.enumerations.SortOrder.DESCENDING)
				{
					direction = -1;
				}
			}
			public int compare(Object obj1, Object obj2)
			{
				HomeLeaveVo voObj1 = (HomeLeaveVo)obj1;
				HomeLeaveVo voObj2 = (HomeLeaveVo)obj2;
				if (voObj1.getDateOnHomeLeaveIsNotNull()
					&& voObj2.getDateOnHomeLeaveIsNotNull())
				{	
					if (voObj1.getTimeOnHomeLeave() == null)
						return -1;
					if (voObj2.getTimeOnHomeLeave() == null)
						return 1;			
					if (voObj1.getDateOnHomeLeave().equals(voObj2.getDateOnHomeLeave()) && voObj1.getTimeOnHomeLeave() != null && voObj2.getTimeOnHomeLeave() != null)
					{
						return direction*(voObj1.getTimeOnHomeLeave().compareTo(voObj2.getTimeOnHomeLeave()));
					}
					return direction*(voObj1.getDateOnHomeLeave().compareTo(voObj2.getDateOnHomeLeave()));
				}
				else if (voObj1.getDateOnHomeLeaveIsNotNull()
						&& !voObj2.getDateOnHomeLeaveIsNotNull())
				{
					return -1 * direction;
				}
				else if (!voObj1.getDateOnHomeLeaveIsNotNull()
						&& voObj2.getDateOnHomeLeaveIsNotNull())
				{
					return direction;
				}
				else
				{
					return direction;
				}
					
			}
			public boolean equals(Object obj)
			{
				return false;
			}	
	
	}
	/**
	* getDateOnHomeLeaveComparator -  retrieves a new instance of static class HomeLeaveVoDateOnHomeLeaveComparator  
	*/
	public static HomeLeaveVoDateOnHomeLeaveComparator getDateOnHomeLeaveComparator(ims.framework.enumerations.SortOrder sortOrder)
	{
		return new HomeLeaveVo.HomeLeaveVoDateOnHomeLeaveComparator(sortOrder);
	}
	
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		this.isBusy = false;
		return true;
	}
	public String[] validate()
	{
		return validate(null);
	}
	public String[] validate(String[] existingErrors)
	{
		if(this.isBusy)
			return null;
		this.isBusy = true;
	
		java.util.ArrayList<String> listOfErrors = new java.util.ArrayList<String>();
		if(existingErrors != null)
		{
			for(int x = 0; x < existingErrors.length; x++)
			{
				listOfErrors.add(existingErrors[x]);
			}
		}
		if(this.vacatedbednumber != null)
			if(this.vacatedbednumber.length() > 255)
				listOfErrors.add("The length of the field [vacatedbednumber] in the value object [ims.core.vo.HomeLeaveVo] is too big. It should be less or equal to 255");
		int errorCount = listOfErrors.size();
		if(errorCount == 0)
		{
			this.isBusy = false;
			this.isValidated = true;
			return null;
		}
		String[] result = new String[errorCount];
		for(int x = 0; x < errorCount; x++)
			result[x] = (String)listOfErrors.get(x);
		this.isBusy = false;
		this.isValidated = false;
		return result;
	}
	public void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		HomeLeaveVo clone = new HomeLeaveVo(this.id, this.version);
		
		if(this.dateonhomeleave == null)
			clone.dateonhomeleave = null;
		else
			clone.dateonhomeleave = (ims.framework.utils.Date)this.dateonhomeleave.clone();
		if(this.timeonhomeleave == null)
			clone.timeonhomeleave = null;
		else
			clone.timeonhomeleave = (ims.framework.utils.Time)this.timeonhomeleave.clone();
		if(this.expecteddateofreturn == null)
			clone.expecteddateofreturn = null;
		else
			clone.expecteddateofreturn = (ims.framework.utils.Date)this.expecteddateofreturn.clone();
		if(this.expectedtimeofreturn == null)
			clone.expectedtimeofreturn = null;
		else
			clone.expectedtimeofreturn = (ims.framework.utils.Time)this.expectedtimeofreturn.clone();
		if(this.datereturnedfromhomeleave == null)
			clone.datereturnedfromhomeleave = null;
		else
			clone.datereturnedfromhomeleave = (ims.framework.utils.Date)this.datereturnedfromhomeleave.clone();
		if(this.timereturnedfromhomeleave == null)
			clone.timereturnedfromhomeleave = null;
		else
			clone.timereturnedfromhomeleave = (ims.framework.utils.Time)this.timereturnedfromhomeleave.clone();
		clone.vacatedbednumber = this.vacatedbednumber;
		clone.bedretained = this.bedretained;
		clone.isValidated = this.isValidated;
		
		this.isBusy = false;
		return clone;
	}
	public int compareTo(Object obj)
	{
		return compareTo(obj, true);
	}
	public int compareTo(Object obj, boolean caseInsensitive)
	{
		if (obj == null)
		{
			return -1;
		}
		if(caseInsensitive); // this is to avoid eclipse warning only.
		if (!(HomeLeaveVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A HomeLeaveVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((HomeLeaveVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((HomeLeaveVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.dateonhomeleave != null)
			count++;
		if(this.timeonhomeleave != null)
			count++;
		if(this.expecteddateofreturn != null)
			count++;
		if(this.expectedtimeofreturn != null)
			count++;
		if(this.datereturnedfromhomeleave != null)
			count++;
		if(this.timereturnedfromhomeleave != null)
			count++;
		if(this.vacatedbednumber != null)
			count++;
		if(this.bedretained != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.framework.utils.Date dateonhomeleave;
	protected ims.framework.utils.Time timeonhomeleave;
	protected ims.framework.utils.Date expecteddateofreturn;
	protected ims.framework.utils.Time expectedtimeofreturn;
	protected ims.framework.utils.Date datereturnedfromhomeleave;
	protected ims.framework.utils.Time timereturnedfromhomeleave;
	protected String vacatedbednumber;
	protected Boolean bedretained;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
