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


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

	public PharmacyApprovalSearchCriteriaVo()
	{
	}
	public PharmacyApprovalSearchCriteriaVo(ims.clinical.vo.beans.PharmacyApprovalSearchCriteriaVoBean bean)
	{
		this.fromdate = bean.getFromDate() == null ? null : bean.getFromDate().buildDate();
		this.todate = bean.getToDate() == null ? null : bean.getToDate().buildDate();
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo();
		this.hcp = bean.getHCP() == null ? null : bean.getHCP().buildVo();
		this.hospitalnumber = bean.getHospitalNumber();
		this.status = bean.getStatus() == null ? null : ims.clinical.vo.lookups.TTAStatus.buildLookup(bean.getStatus());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.PharmacyApprovalSearchCriteriaVoBean bean)
	{
		this.fromdate = bean.getFromDate() == null ? null : bean.getFromDate().buildDate();
		this.todate = bean.getToDate() == null ? null : bean.getToDate().buildDate();
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo(map);
		this.hcp = bean.getHCP() == null ? null : bean.getHCP().buildVo(map);
		this.hospitalnumber = bean.getHospitalNumber();
		this.status = bean.getStatus() == null ? null : ims.clinical.vo.lookups.TTAStatus.buildLookup(bean.getStatus());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.PharmacyApprovalSearchCriteriaVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.PharmacyApprovalSearchCriteriaVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.PharmacyApprovalSearchCriteriaVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getFromDateIsNotNull()
	{
		return this.fromdate != null;
	}
	public ims.framework.utils.Date getFromDate()
	{
		return this.fromdate;
	}
	public void setFromDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.fromdate = value;
	}
	public boolean getToDateIsNotNull()
	{
		return this.todate != null;
	}
	public ims.framework.utils.Date getToDate()
	{
		return this.todate;
	}
	public void setToDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.todate = value;
	}
	public boolean getLocationIsNotNull()
	{
		return this.location != null;
	}
	public ims.core.vo.LocationLiteVo getLocation()
	{
		return this.location;
	}
	public void setLocation(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.location = value;
	}
	public boolean getHCPIsNotNull()
	{
		return this.hcp != null;
	}
	public ims.core.vo.HcpLiteVo getHCP()
	{
		return this.hcp;
	}
	public void setHCP(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.hcp = value;
	}
	public boolean getHospitalNumberIsNotNull()
	{
		return this.hospitalnumber != null;
	}
	public String getHospitalNumber()
	{
		return this.hospitalnumber;
	}
	public static int getHospitalNumberMaxLength()
	{
		return 255;
	}
	public void setHospitalNumber(String value)
	{
		this.isValidated = false;
		this.hospitalnumber = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.clinical.vo.lookups.TTAStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.clinical.vo.lookups.TTAStatus value)
	{
		this.isValidated = false;
		this.status = 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 PharmacyApprovalSearchCriteriaVo))
			return false;
		PharmacyApprovalSearchCriteriaVo compareObj = (PharmacyApprovalSearchCriteriaVo)obj;
		if(this.getFromDate() == null && compareObj.getFromDate() != null)
			return false;
		if(this.getFromDate() != null && compareObj.getFromDate() == null)
			return false;
		if(this.getFromDate() != null && compareObj.getFromDate() != null)
			if(!this.getFromDate().equals(compareObj.getFromDate()))
				return false;
		if(this.getToDate() == null && compareObj.getToDate() != null)
			return false;
		if(this.getToDate() != null && compareObj.getToDate() == null)
			return false;
		if(this.getToDate() != null && compareObj.getToDate() != null)
			if(!this.getToDate().equals(compareObj.getToDate()))
				return false;
		if(this.getLocation() == null && compareObj.getLocation() != null)
			return false;
		if(this.getLocation() != null && compareObj.getLocation() == null)
			return false;
		if(this.getLocation() != null && compareObj.getLocation() != null)
			if(!this.getLocation().equals(compareObj.getLocation()))
				return false;
		if(this.getHCP() == null && compareObj.getHCP() != null)
			return false;
		if(this.getHCP() != null && compareObj.getHCP() == null)
			return false;
		if(this.getHCP() != null && compareObj.getHCP() != null)
			if(!this.getHCP().equals(compareObj.getHCP()))
				return false;
		if(this.getHospitalNumber() == null && compareObj.getHospitalNumber() != null)
			return false;
		if(this.getHospitalNumber() != null && compareObj.getHospitalNumber() == null)
			return false;
		if(this.getHospitalNumber() != null && compareObj.getHospitalNumber() != null)
			if(!this.getHospitalNumber().equals(compareObj.getHospitalNumber()))
				return false;
		if(this.getStatus() == null && compareObj.getStatus() != null)
			return false;
		if(this.getStatus() != null && compareObj.getStatus() == null)
			return false;
		if(this.getStatus() != null && compareObj.getStatus() != null)
			return this.getStatus().equals(compareObj.getStatus());
		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.location != null)
		{
			if(!this.location.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.hcp != null)
		{
			if(!this.hcp.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.location != null)
		{
			String[] listOfOtherErrors = this.location.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.hcp != null)
		{
			String[] listOfOtherErrors = this.hcp.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;
	
		PharmacyApprovalSearchCriteriaVo clone = new PharmacyApprovalSearchCriteriaVo();
		
		if(this.fromdate == null)
			clone.fromdate = null;
		else
			clone.fromdate = (ims.framework.utils.Date)this.fromdate.clone();
		if(this.todate == null)
			clone.todate = null;
		else
			clone.todate = (ims.framework.utils.Date)this.todate.clone();
		if(this.location == null)
			clone.location = null;
		else
			clone.location = (ims.core.vo.LocationLiteVo)this.location.clone();
		if(this.hcp == null)
			clone.hcp = null;
		else
			clone.hcp = (ims.core.vo.HcpLiteVo)this.hcp.clone();
		clone.hospitalnumber = this.hospitalnumber;
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.clinical.vo.lookups.TTAStatus)this.status.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 (!(PharmacyApprovalSearchCriteriaVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PharmacyApprovalSearchCriteriaVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PharmacyApprovalSearchCriteriaVo compareObj = (PharmacyApprovalSearchCriteriaVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getFromDate() == null && compareObj.getFromDate() != null)
				return -1;
			if(this.getFromDate() != null && compareObj.getFromDate() == null)
				return 1;
			if(this.getFromDate() != null && compareObj.getFromDate() != null)
				retVal = this.getFromDate().compareTo(compareObj.getFromDate());
		}
		if (retVal == 0)
		{
			if(this.getToDate() == null && compareObj.getToDate() != null)
				return -1;
			if(this.getToDate() != null && compareObj.getToDate() == null)
				return 1;
			if(this.getToDate() != null && compareObj.getToDate() != null)
				retVal = this.getToDate().compareTo(compareObj.getToDate());
		}
		if (retVal == 0)
		{
			if(this.getLocation() == null && compareObj.getLocation() != null)
				return -1;
			if(this.getLocation() != null && compareObj.getLocation() == null)
				return 1;
			if(this.getLocation() != null && compareObj.getLocation() != null)
				retVal = this.getLocation().compareTo(compareObj.getLocation());
		}
		if (retVal == 0)
		{
			if(this.getHCP() == null && compareObj.getHCP() != null)
				return -1;
			if(this.getHCP() != null && compareObj.getHCP() == null)
				return 1;
			if(this.getHCP() != null && compareObj.getHCP() != null)
				retVal = this.getHCP().compareTo(compareObj.getHCP());
		}
		if (retVal == 0)
		{
			if(this.getHospitalNumber() == null && compareObj.getHospitalNumber() != null)
				return -1;
			if(this.getHospitalNumber() != null && compareObj.getHospitalNumber() == null)
				return 1;
			if(this.getHospitalNumber() != null && compareObj.getHospitalNumber() != null)
			{
				if(caseInsensitive)
					retVal = this.getHospitalNumber().toLowerCase().compareTo(compareObj.getHospitalNumber().toLowerCase());
				else
					retVal = this.getHospitalNumber().compareTo(compareObj.getHospitalNumber());
			}
		}
		if (retVal == 0)
		{
			if(this.getStatus() == null && compareObj.getStatus() != null)
				return -1;
			if(this.getStatus() != null && compareObj.getStatus() == null)
				return 1;
			if(this.getStatus() != null && compareObj.getStatus() != null)
				retVal = this.getStatus().compareTo(compareObj.getStatus());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.fromdate != null)
			count++;
		if(this.todate != null)
			count++;
		if(this.location != null)
			count++;
		if(this.hcp != null)
			count++;
		if(this.hospitalnumber != null)
			count++;
		if(this.status != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.framework.utils.Date fromdate;
	protected ims.framework.utils.Date todate;
	protected ims.core.vo.LocationLiteVo location;
	protected ims.core.vo.HcpLiteVo hcp;
	protected String hospitalnumber;
	protected ims.clinical.vo.lookups.TTAStatus status;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
