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


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

	public DeliverShotDetailsVo()
	{
	}
	public DeliverShotDetailsVo(ims.pci.vo.beans.DeliverShotDetailsVoBean bean)
	{
		this.delivereddate = bean.getDeliveredDate() == null ? null : bean.getDeliveredDate().buildDate();
		this.vaccinemanufacturer = bean.getVaccineManufacturer() == null ? null : ims.clinical.vo.lookups.VaccineManufacturer.buildLookup(bean.getVaccineManufacturer());
		this.expirydate = bean.getExpiryDate() == null ? null : bean.getExpiryDate().buildDate();
		this.batchnumber = bean.getBatchNumber();
		this.paymenttype = bean.getPaymentType() == null ? null : ims.pci.vo.lookups.PaymentType.buildLookup(bean.getPaymentType());
		this.deliveredby = bean.getDeliveredBy() == null ? null : bean.getDeliveredBy().buildVo();
		this.deliveredbygp = bean.getDeliveredByGp() == null ? null : bean.getDeliveredByGp().buildVo();
		this.paymentgp = bean.getPaymentGp() == null ? null : bean.getPaymentGp().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.DeliverShotDetailsVoBean bean)
	{
		this.delivereddate = bean.getDeliveredDate() == null ? null : bean.getDeliveredDate().buildDate();
		this.vaccinemanufacturer = bean.getVaccineManufacturer() == null ? null : ims.clinical.vo.lookups.VaccineManufacturer.buildLookup(bean.getVaccineManufacturer());
		this.expirydate = bean.getExpiryDate() == null ? null : bean.getExpiryDate().buildDate();
		this.batchnumber = bean.getBatchNumber();
		this.paymenttype = bean.getPaymentType() == null ? null : ims.pci.vo.lookups.PaymentType.buildLookup(bean.getPaymentType());
		this.deliveredby = bean.getDeliveredBy() == null ? null : bean.getDeliveredBy().buildVo(map);
		this.deliveredbygp = bean.getDeliveredByGp() == null ? null : bean.getDeliveredByGp().buildVo(map);
		this.paymentgp = bean.getPaymentGp() == null ? null : bean.getPaymentGp().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.pci.vo.beans.DeliverShotDetailsVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.DeliverShotDetailsVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.DeliverShotDetailsVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getDeliveredDateIsNotNull()
	{
		return this.delivereddate != null;
	}
	public ims.framework.utils.Date getDeliveredDate()
	{
		return this.delivereddate;
	}
	public void setDeliveredDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.delivereddate = value;
	}
	public boolean getVaccineManufacturerIsNotNull()
	{
		return this.vaccinemanufacturer != null;
	}
	public ims.clinical.vo.lookups.VaccineManufacturer getVaccineManufacturer()
	{
		return this.vaccinemanufacturer;
	}
	public void setVaccineManufacturer(ims.clinical.vo.lookups.VaccineManufacturer value)
	{
		this.isValidated = false;
		this.vaccinemanufacturer = value;
	}
	public boolean getExpiryDateIsNotNull()
	{
		return this.expirydate != null;
	}
	public ims.framework.utils.Date getExpiryDate()
	{
		return this.expirydate;
	}
	public void setExpiryDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.expirydate = value;
	}
	public boolean getBatchNumberIsNotNull()
	{
		return this.batchnumber != null;
	}
	public String getBatchNumber()
	{
		return this.batchnumber;
	}
	public static int getBatchNumberMaxLength()
	{
		return 255;
	}
	public void setBatchNumber(String value)
	{
		this.isValidated = false;
		this.batchnumber = value;
	}
	public boolean getPaymentTypeIsNotNull()
	{
		return this.paymenttype != null;
	}
	public ims.pci.vo.lookups.PaymentType getPaymentType()
	{
		return this.paymenttype;
	}
	public void setPaymentType(ims.pci.vo.lookups.PaymentType value)
	{
		this.isValidated = false;
		this.paymenttype = value;
	}
	public boolean getDeliveredByIsNotNull()
	{
		return this.deliveredby != null;
	}
	public ims.core.vo.HcpLiteVo getDeliveredBy()
	{
		return this.deliveredby;
	}
	public void setDeliveredBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.deliveredby = value;
	}
	public boolean getDeliveredByGpIsNotNull()
	{
		return this.deliveredbygp != null;
	}
	public ims.core.vo.GpShortVo getDeliveredByGp()
	{
		return this.deliveredbygp;
	}
	public void setDeliveredByGp(ims.core.vo.GpShortVo value)
	{
		this.isValidated = false;
		this.deliveredbygp = value;
	}
	public boolean getPaymentGpIsNotNull()
	{
		return this.paymentgp != null;
	}
	public ims.core.vo.GpShortVo getPaymentGp()
	{
		return this.paymentgp;
	}
	public void setPaymentGp(ims.core.vo.GpShortVo value)
	{
		this.isValidated = false;
		this.paymentgp = 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 DeliverShotDetailsVo))
			return false;
		DeliverShotDetailsVo compareObj = (DeliverShotDetailsVo)obj;
		if(this.getDeliveredDate() == null && compareObj.getDeliveredDate() != null)
			return false;
		if(this.getDeliveredDate() != null && compareObj.getDeliveredDate() == null)
			return false;
		if(this.getDeliveredDate() != null && compareObj.getDeliveredDate() != null)
			if(!this.getDeliveredDate().equals(compareObj.getDeliveredDate()))
				return false;
		if(this.getVaccineManufacturer() == null && compareObj.getVaccineManufacturer() != null)
			return false;
		if(this.getVaccineManufacturer() != null && compareObj.getVaccineManufacturer() == null)
			return false;
		if(this.getVaccineManufacturer() != null && compareObj.getVaccineManufacturer() != null)
			if(!this.getVaccineManufacturer().equals(compareObj.getVaccineManufacturer()))
				return false;
		if(this.getExpiryDate() == null && compareObj.getExpiryDate() != null)
			return false;
		if(this.getExpiryDate() != null && compareObj.getExpiryDate() == null)
			return false;
		if(this.getExpiryDate() != null && compareObj.getExpiryDate() != null)
			if(!this.getExpiryDate().equals(compareObj.getExpiryDate()))
				return false;
		if(this.getBatchNumber() == null && compareObj.getBatchNumber() != null)
			return false;
		if(this.getBatchNumber() != null && compareObj.getBatchNumber() == null)
			return false;
		if(this.getBatchNumber() != null && compareObj.getBatchNumber() != null)
			if(!this.getBatchNumber().equals(compareObj.getBatchNumber()))
				return false;
		if(this.getPaymentType() == null && compareObj.getPaymentType() != null)
			return false;
		if(this.getPaymentType() != null && compareObj.getPaymentType() == null)
			return false;
		if(this.getPaymentType() != null && compareObj.getPaymentType() != null)
			if(!this.getPaymentType().equals(compareObj.getPaymentType()))
				return false;
		if(this.getDeliveredBy() == null && compareObj.getDeliveredBy() != null)
			return false;
		if(this.getDeliveredBy() != null && compareObj.getDeliveredBy() == null)
			return false;
		if(this.getDeliveredBy() != null && compareObj.getDeliveredBy() != null)
			if(!this.getDeliveredBy().equals(compareObj.getDeliveredBy()))
				return false;
		if(this.getDeliveredByGp() == null && compareObj.getDeliveredByGp() != null)
			return false;
		if(this.getDeliveredByGp() != null && compareObj.getDeliveredByGp() == null)
			return false;
		if(this.getDeliveredByGp() != null && compareObj.getDeliveredByGp() != null)
			if(!this.getDeliveredByGp().equals(compareObj.getDeliveredByGp()))
				return false;
		if(this.getPaymentGp() == null && compareObj.getPaymentGp() != null)
			return false;
		if(this.getPaymentGp() != null && compareObj.getPaymentGp() == null)
			return false;
		if(this.getPaymentGp() != null && compareObj.getPaymentGp() != null)
			return this.getPaymentGp().equals(compareObj.getPaymentGp());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.deliveredby != null)
		{
			if(!this.deliveredby.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.deliveredbygp != null)
		{
			if(!this.deliveredbygp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.paymentgp != null)
		{
			if(!this.paymentgp.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.deliveredby != null)
		{
			String[] listOfOtherErrors = this.deliveredby.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.deliveredbygp != null)
		{
			String[] listOfOtherErrors = this.deliveredbygp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.paymentgp != null)
		{
			String[] listOfOtherErrors = this.paymentgp.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[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;
	
		DeliverShotDetailsVo clone = new DeliverShotDetailsVo();
		
		if(this.delivereddate == null)
			clone.delivereddate = null;
		else
			clone.delivereddate = (ims.framework.utils.Date)this.delivereddate.clone();
		if(this.vaccinemanufacturer == null)
			clone.vaccinemanufacturer = null;
		else
			clone.vaccinemanufacturer = (ims.clinical.vo.lookups.VaccineManufacturer)this.vaccinemanufacturer.clone();
		if(this.expirydate == null)
			clone.expirydate = null;
		else
			clone.expirydate = (ims.framework.utils.Date)this.expirydate.clone();
		clone.batchnumber = this.batchnumber;
		if(this.paymenttype == null)
			clone.paymenttype = null;
		else
			clone.paymenttype = (ims.pci.vo.lookups.PaymentType)this.paymenttype.clone();
		if(this.deliveredby == null)
			clone.deliveredby = null;
		else
			clone.deliveredby = (ims.core.vo.HcpLiteVo)this.deliveredby.clone();
		if(this.deliveredbygp == null)
			clone.deliveredbygp = null;
		else
			clone.deliveredbygp = (ims.core.vo.GpShortVo)this.deliveredbygp.clone();
		if(this.paymentgp == null)
			clone.paymentgp = null;
		else
			clone.paymentgp = (ims.core.vo.GpShortVo)this.paymentgp.clone();
		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 (!(DeliverShotDetailsVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A DeliverShotDetailsVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		DeliverShotDetailsVo compareObj = (DeliverShotDetailsVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getDeliveredDate() == null && compareObj.getDeliveredDate() != null)
				return -1;
			if(this.getDeliveredDate() != null && compareObj.getDeliveredDate() == null)
				return 1;
			if(this.getDeliveredDate() != null && compareObj.getDeliveredDate() != null)
				retVal = this.getDeliveredDate().compareTo(compareObj.getDeliveredDate());
		}
		if (retVal == 0)
		{
			if(this.getVaccineManufacturer() == null && compareObj.getVaccineManufacturer() != null)
				return -1;
			if(this.getVaccineManufacturer() != null && compareObj.getVaccineManufacturer() == null)
				return 1;
			if(this.getVaccineManufacturer() != null && compareObj.getVaccineManufacturer() != null)
				retVal = this.getVaccineManufacturer().compareTo(compareObj.getVaccineManufacturer());
		}
		if (retVal == 0)
		{
			if(this.getExpiryDate() == null && compareObj.getExpiryDate() != null)
				return -1;
			if(this.getExpiryDate() != null && compareObj.getExpiryDate() == null)
				return 1;
			if(this.getExpiryDate() != null && compareObj.getExpiryDate() != null)
				retVal = this.getExpiryDate().compareTo(compareObj.getExpiryDate());
		}
		if (retVal == 0)
		{
			if(this.getBatchNumber() == null && compareObj.getBatchNumber() != null)
				return -1;
			if(this.getBatchNumber() != null && compareObj.getBatchNumber() == null)
				return 1;
			if(this.getBatchNumber() != null && compareObj.getBatchNumber() != null)
			{
				if(caseInsensitive)
					retVal = this.getBatchNumber().toLowerCase().compareTo(compareObj.getBatchNumber().toLowerCase());
				else
					retVal = this.getBatchNumber().compareTo(compareObj.getBatchNumber());
			}
		}
		if (retVal == 0)
		{
			if(this.getPaymentType() == null && compareObj.getPaymentType() != null)
				return -1;
			if(this.getPaymentType() != null && compareObj.getPaymentType() == null)
				return 1;
			if(this.getPaymentType() != null && compareObj.getPaymentType() != null)
				retVal = this.getPaymentType().compareTo(compareObj.getPaymentType());
		}
		if (retVal == 0)
		{
			if(this.getDeliveredBy() == null && compareObj.getDeliveredBy() != null)
				return -1;
			if(this.getDeliveredBy() != null && compareObj.getDeliveredBy() == null)
				return 1;
			if(this.getDeliveredBy() != null && compareObj.getDeliveredBy() != null)
				retVal = this.getDeliveredBy().compareTo(compareObj.getDeliveredBy());
		}
		if (retVal == 0)
		{
			if(this.getDeliveredByGp() == null && compareObj.getDeliveredByGp() != null)
				return -1;
			if(this.getDeliveredByGp() != null && compareObj.getDeliveredByGp() == null)
				return 1;
			if(this.getDeliveredByGp() != null && compareObj.getDeliveredByGp() != null)
				retVal = this.getDeliveredByGp().compareTo(compareObj.getDeliveredByGp());
		}
		if (retVal == 0)
		{
			if(this.getPaymentGp() == null && compareObj.getPaymentGp() != null)
				return -1;
			if(this.getPaymentGp() != null && compareObj.getPaymentGp() == null)
				return 1;
			if(this.getPaymentGp() != null && compareObj.getPaymentGp() != null)
				retVal = this.getPaymentGp().compareTo(compareObj.getPaymentGp());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.delivereddate != null)
			count++;
		if(this.vaccinemanufacturer != null)
			count++;
		if(this.expirydate != null)
			count++;
		if(this.batchnumber != null)
			count++;
		if(this.paymenttype != null)
			count++;
		if(this.deliveredby != null)
			count++;
		if(this.deliveredbygp != null)
			count++;
		if(this.paymentgp != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected ims.framework.utils.Date delivereddate;
	protected ims.clinical.vo.lookups.VaccineManufacturer vaccinemanufacturer;
	protected ims.framework.utils.Date expirydate;
	protected String batchnumber;
	protected ims.pci.vo.lookups.PaymentType paymenttype;
	protected ims.core.vo.HcpLiteVo deliveredby;
	protected ims.core.vo.GpShortVo deliveredbygp;
	protected ims.core.vo.GpShortVo paymentgp;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
