/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/ccosched/vo/BookingDetailsVo.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.ccosched.vo;


public class BookingDetailsVo extends ims.vo.ValueObject implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public BookingDetailsVo()
	{
	}
	public BookingDetailsVo(ims.ccosched.vo.beans.BookingDetailsVoBean bean)
	{
		this.startdate = bean.getStartDate();
		this.enddate = bean.getEndDate();
		this.defaultappttime = bean.getDefaultApptTime();
		this.numberofconflicts = bean.getNumberOfConflicts();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ccosched.vo.beans.BookingDetailsVoBean bean)
	{
		this.startdate = bean.getStartDate();
		this.enddate = bean.getEndDate();
		this.defaultappttime = bean.getDefaultApptTime();
		this.numberofconflicts = bean.getNumberOfConflicts();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ccosched.vo.beans.BookingDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.ccosched.vo.beans.BookingDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ccosched.vo.beans.BookingDetailsVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getStartDateIsNotNull()
	{
		return this.startdate != null;
	}
	public String getStartDate()
	{
		return this.startdate;
	}
	public static int getStartDateMaxLength()
	{
		return 255;
	}
	public void setStartDate(String value)
	{
		this.isValidated = false;
		this.startdate = value;
	}
	public boolean getEndDateIsNotNull()
	{
		return this.enddate != null;
	}
	public String getEndDate()
	{
		return this.enddate;
	}
	public static int getEndDateMaxLength()
	{
		return 255;
	}
	public void setEndDate(String value)
	{
		this.isValidated = false;
		this.enddate = value;
	}
	public boolean getDefaultApptTimeIsNotNull()
	{
		return this.defaultappttime != null;
	}
	public String getDefaultApptTime()
	{
		return this.defaultappttime;
	}
	public static int getDefaultApptTimeMaxLength()
	{
		return 255;
	}
	public void setDefaultApptTime(String value)
	{
		this.isValidated = false;
		this.defaultappttime = value;
	}
	public boolean getNumberOfConflictsIsNotNull()
	{
		return this.numberofconflicts != null;
	}
	public String getNumberOfConflicts()
	{
		return this.numberofconflicts;
	}
	public static int getNumberOfConflictsMaxLength()
	{
		return 255;
	}
	public void setNumberOfConflicts(String value)
	{
		this.isValidated = false;
		this.numberofconflicts = value;
	}
	public final String getIItemText()
	{
		return toString();
	}
	public final Integer getBoId() 
	{
		return null;
	}
	public final String getBoClassName()
	{
		return null;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof BookingDetailsVo))
			return false;
		BookingDetailsVo compareObj = (BookingDetailsVo)obj;
		if(this.getStartDate() == null && compareObj.getStartDate() != null)
			return false;
		if(this.getStartDate() != null && compareObj.getStartDate() == null)
			return false;
		if(this.getStartDate() != null && compareObj.getStartDate() != null)
			if(!this.getStartDate().equals(compareObj.getStartDate()))
				return false;
		if(this.getEndDate() == null && compareObj.getEndDate() != null)
			return false;
		if(this.getEndDate() != null && compareObj.getEndDate() == null)
			return false;
		if(this.getEndDate() != null && compareObj.getEndDate() != null)
			if(!this.getEndDate().equals(compareObj.getEndDate()))
				return false;
		if(this.getDefaultApptTime() == null && compareObj.getDefaultApptTime() != null)
			return false;
		if(this.getDefaultApptTime() != null && compareObj.getDefaultApptTime() == null)
			return false;
		if(this.getDefaultApptTime() != null && compareObj.getDefaultApptTime() != null)
			if(!this.getDefaultApptTime().equals(compareObj.getDefaultApptTime()))
				return false;
		if(this.getNumberOfConflicts() == null && compareObj.getNumberOfConflicts() != null)
			return false;
		if(this.getNumberOfConflicts() != null && compareObj.getNumberOfConflicts() == null)
			return false;
		if(this.getNumberOfConflicts() != null && compareObj.getNumberOfConflicts() != null)
			return this.getNumberOfConflicts().equals(compareObj.getNumberOfConflicts());
		return super.equals(obj);
	}
	/**
	* toHtml() method
	*/
	public String toHtml()
	{
		StringBuffer sb = new StringBuffer();
	
		if(this.getStartDateIsNotNull() && this.getStartDate().length() > 0)
		{
			sb.append("*Start Date:* ");
			sb.append(this.getStartDate());
		}
	
		if(this.getEndDateIsNotNull() && this.getEndDate().length() > 0)
		{
			if(sb.length() > 0)
				sb.append("\n");
			
			sb.append("*End Date:* ");
			sb.append(this.getEndDate());
		}
		if(this.getDefaultApptTimeIsNotNull() && this.getDefaultApptTime().length() > 0)
		{
			if(sb.length() > 0)
				sb.append("\n");
			
			sb.append("*Def. App. Time:* ");
			sb.append(this.getDefaultApptTime());
		}
		
		if(this.getNumberOfConflictsIsNotNull() && this.getNumberOfConflicts().length() > 0)
		{
			if(sb.length() > 0)
				sb.append("\n");
			
			sb.append("*Num. Conflicts:* ");
			sb.append(this.getNumberOfConflicts());
		}
		
		return new ims.utils.textile.Textile().process(sb.toString());
	}
	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]);
			}
		}
		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 Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		BookingDetailsVo clone = new BookingDetailsVo();
		
		clone.startdate = this.startdate;
		clone.enddate = this.enddate;
		clone.defaultappttime = this.defaultappttime;
		clone.numberofconflicts = this.numberofconflicts;
		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 (!(BookingDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A BookingDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		BookingDetailsVo compareObj = (BookingDetailsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getStartDate() == null && compareObj.getStartDate() != null)
				return -1;
			if(this.getStartDate() != null && compareObj.getStartDate() == null)
				return 1;
			if(this.getStartDate() != null && compareObj.getStartDate() != null)
			{
				if(caseInsensitive)
					retVal = this.getStartDate().toLowerCase().compareTo(compareObj.getStartDate().toLowerCase());
				else
					retVal = this.getStartDate().compareTo(compareObj.getStartDate());
			}
		}
		if (retVal == 0)
		{
			if(this.getEndDate() == null && compareObj.getEndDate() != null)
				return -1;
			if(this.getEndDate() != null && compareObj.getEndDate() == null)
				return 1;
			if(this.getEndDate() != null && compareObj.getEndDate() != null)
			{
				if(caseInsensitive)
					retVal = this.getEndDate().toLowerCase().compareTo(compareObj.getEndDate().toLowerCase());
				else
					retVal = this.getEndDate().compareTo(compareObj.getEndDate());
			}
		}
		if (retVal == 0)
		{
			if(this.getDefaultApptTime() == null && compareObj.getDefaultApptTime() != null)
				return -1;
			if(this.getDefaultApptTime() != null && compareObj.getDefaultApptTime() == null)
				return 1;
			if(this.getDefaultApptTime() != null && compareObj.getDefaultApptTime() != null)
			{
				if(caseInsensitive)
					retVal = this.getDefaultApptTime().toLowerCase().compareTo(compareObj.getDefaultApptTime().toLowerCase());
				else
					retVal = this.getDefaultApptTime().compareTo(compareObj.getDefaultApptTime());
			}
		}
		if (retVal == 0)
		{
			if(this.getNumberOfConflicts() == null && compareObj.getNumberOfConflicts() != null)
				return -1;
			if(this.getNumberOfConflicts() != null && compareObj.getNumberOfConflicts() == null)
				return 1;
			if(this.getNumberOfConflicts() != null && compareObj.getNumberOfConflicts() != null)
			{
				if(caseInsensitive)
					retVal = this.getNumberOfConflicts().toLowerCase().compareTo(compareObj.getNumberOfConflicts().toLowerCase());
				else
					retVal = this.getNumberOfConflicts().compareTo(compareObj.getNumberOfConflicts());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.startdate != null)
			count++;
		if(this.enddate != null)
			count++;
		if(this.defaultappttime != null)
			count++;
		if(this.numberofconflicts != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 4;
	}
	protected String startdate;
	protected String enddate;
	protected String defaultappttime;
	protected String numberofconflicts;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
