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

/**
 * Linked to core.resource.place.PciAddressHistory business object (ID: 1007100013).
 */
public class PciAddressHistoryVo extends ims.core.resource.place.vo.PciAddressHistoryRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PciAddressHistoryVo()
	{
	}
	public PciAddressHistoryVo(Integer id, int version)
	{
		super(id, version);
	}
	public PciAddressHistoryVo(ims.pci.vo.beans.PciAddressHistoryVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.line1 = bean.getLine1();
		this.line2 = bean.getLine2();
		this.line3 = bean.getLine3();
		this.line4 = bean.getLine4();
		this.line5 = bean.getLine5();
		this.postcode = bean.getPostCode();
		this.phone = bean.getPhone();
		this.county = bean.getCounty() == null ? null : ims.ntpf.vo.lookups.County.buildLookup(bean.getCounty());
		this.fax = bean.getFax();
		this.updatedate = bean.getUpdateDate() == null ? null : bean.getUpdateDate().buildDateTime();
		this.notificationdate = bean.getNotificationDate() == null ? null : bean.getNotificationDate().buildDate();
		this.lho = bean.getLho() == null ? null : bean.getLho().buildVo();
		this.cca = bean.getCca() == null ? null : bean.getCca().buildVo();
		this.sector = bean.getSector() == null ? null : bean.getSector().buildVo();
		this.phndistrict = bean.getPhnDistrict() == null ? null : bean.getPhnDistrict().buildVo();
		this.ded = bean.getDED() == null ? null : bean.getDED().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.PciAddressHistoryVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.line1 = bean.getLine1();
		this.line2 = bean.getLine2();
		this.line3 = bean.getLine3();
		this.line4 = bean.getLine4();
		this.line5 = bean.getLine5();
		this.postcode = bean.getPostCode();
		this.phone = bean.getPhone();
		this.county = bean.getCounty() == null ? null : ims.ntpf.vo.lookups.County.buildLookup(bean.getCounty());
		this.fax = bean.getFax();
		this.updatedate = bean.getUpdateDate() == null ? null : bean.getUpdateDate().buildDateTime();
		this.notificationdate = bean.getNotificationDate() == null ? null : bean.getNotificationDate().buildDate();
		this.lho = bean.getLho() == null ? null : bean.getLho().buildVo(map);
		this.cca = bean.getCca() == null ? null : bean.getCca().buildVo(map);
		this.sector = bean.getSector() == null ? null : bean.getSector().buildVo(map);
		this.phndistrict = bean.getPhnDistrict() == null ? null : bean.getPhnDistrict().buildVo(map);
		this.ded = bean.getDED() == null ? null : bean.getDED().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.PciAddressHistoryVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.PciAddressHistoryVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.PciAddressHistoryVoBean();
			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("LINE1"))
			return getLine1();
		if(fieldName.equals("LINE2"))
			return getLine2();
		if(fieldName.equals("LINE3"))
			return getLine3();
		if(fieldName.equals("LINE4"))
			return getLine4();
		if(fieldName.equals("LINE5"))
			return getLine5();
		if(fieldName.equals("POSTCODE"))
			return getPostCode();
		if(fieldName.equals("PHONE"))
			return getPhone();
		if(fieldName.equals("COUNTY"))
			return getCounty();
		if(fieldName.equals("FAX"))
			return getFax();
		if(fieldName.equals("UPDATEDATE"))
			return getUpdateDate();
		if(fieldName.equals("NOTIFICATIONDATE"))
			return getNotificationDate();
		if(fieldName.equals("LHO"))
			return getLho();
		if(fieldName.equals("CCA"))
			return getCca();
		if(fieldName.equals("SECTOR"))
			return getSector();
		if(fieldName.equals("PHNDISTRICT"))
			return getPhnDistrict();
		if(fieldName.equals("DED"))
			return getDED();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getLine1IsNotNull()
	{
		return this.line1 != null;
	}
	public String getLine1()
	{
		return this.line1;
	}
	public static int getLine1MaxLength()
	{
		return 40;
	}
	public void setLine1(String value)
	{
		this.isValidated = false;
		this.line1 = value;
	}
	public boolean getLine2IsNotNull()
	{
		return this.line2 != null;
	}
	public String getLine2()
	{
		return this.line2;
	}
	public static int getLine2MaxLength()
	{
		return 40;
	}
	public void setLine2(String value)
	{
		this.isValidated = false;
		this.line2 = value;
	}
	public boolean getLine3IsNotNull()
	{
		return this.line3 != null;
	}
	public String getLine3()
	{
		return this.line3;
	}
	public static int getLine3MaxLength()
	{
		return 40;
	}
	public void setLine3(String value)
	{
		this.isValidated = false;
		this.line3 = value;
	}
	public boolean getLine4IsNotNull()
	{
		return this.line4 != null;
	}
	public String getLine4()
	{
		return this.line4;
	}
	public static int getLine4MaxLength()
	{
		return 40;
	}
	public void setLine4(String value)
	{
		this.isValidated = false;
		this.line4 = value;
	}
	public boolean getLine5IsNotNull()
	{
		return this.line5 != null;
	}
	public String getLine5()
	{
		return this.line5;
	}
	public static int getLine5MaxLength()
	{
		return 40;
	}
	public void setLine5(String value)
	{
		this.isValidated = false;
		this.line5 = value;
	}
	public boolean getPostCodeIsNotNull()
	{
		return this.postcode != null;
	}
	public String getPostCode()
	{
		return this.postcode;
	}
	public static int getPostCodeMaxLength()
	{
		return 10;
	}
	public void setPostCode(String value)
	{
		this.isValidated = false;
		this.postcode = value;
	}
	public boolean getPhoneIsNotNull()
	{
		return this.phone != null;
	}
	public String getPhone()
	{
		return this.phone;
	}
	public static int getPhoneMaxLength()
	{
		return 30;
	}
	public void setPhone(String value)
	{
		this.isValidated = false;
		this.phone = value;
	}
	public boolean getCountyIsNotNull()
	{
		return this.county != null;
	}
	public ims.ntpf.vo.lookups.County getCounty()
	{
		return this.county;
	}
	public void setCounty(ims.ntpf.vo.lookups.County value)
	{
		this.isValidated = false;
		this.county = value;
	}
	public boolean getFaxIsNotNull()
	{
		return this.fax != null;
	}
	public String getFax()
	{
		return this.fax;
	}
	public static int getFaxMaxLength()
	{
		return 30;
	}
	public void setFax(String value)
	{
		this.isValidated = false;
		this.fax = value;
	}
	public boolean getUpdateDateIsNotNull()
	{
		return this.updatedate != null;
	}
	public ims.framework.utils.DateTime getUpdateDate()
	{
		return this.updatedate;
	}
	public void setUpdateDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.updatedate = value;
	}
	public boolean getNotificationDateIsNotNull()
	{
		return this.notificationdate != null;
	}
	public ims.framework.utils.Date getNotificationDate()
	{
		return this.notificationdate;
	}
	public void setNotificationDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.notificationdate = value;
	}
	public boolean getLhoIsNotNull()
	{
		return this.lho != null;
	}
	public ims.core.vo.OrgLiteVo getLho()
	{
		return this.lho;
	}
	public void setLho(ims.core.vo.OrgLiteVo value)
	{
		this.isValidated = false;
		this.lho = value;
	}
	public boolean getCcaIsNotNull()
	{
		return this.cca != null;
	}
	public ims.core.vo.LocSiteLiteVo getCca()
	{
		return this.cca;
	}
	public void setCca(ims.core.vo.LocSiteLiteVo value)
	{
		this.isValidated = false;
		this.cca = value;
	}
	public boolean getSectorIsNotNull()
	{
		return this.sector != null;
	}
	public ims.core.vo.LocationLiteVo getSector()
	{
		return this.sector;
	}
	public void setSector(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.sector = value;
	}
	public boolean getPhnDistrictIsNotNull()
	{
		return this.phndistrict != null;
	}
	public ims.core.vo.LocationLiteVo getPhnDistrict()
	{
		return this.phndistrict;
	}
	public void setPhnDistrict(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.phndistrict = value;
	}
	public boolean getDEDIsNotNull()
	{
		return this.ded != null;
	}
	public ims.core.vo.DEDLiteVo getDED()
	{
		return this.ded;
	}
	public void setDED(ims.core.vo.DEDLiteVo value)
	{
		this.isValidated = false;
		this.ded = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.lho != null)
		{
			if(!this.lho.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.cca != null)
		{
			if(!this.cca.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.sector != null)
		{
			if(!this.sector.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.phndistrict != null)
		{
			if(!this.phndistrict.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.ded != null)
		{
			if(!this.ded.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.line1 != null)
			if(this.line1.length() > 40)
				listOfErrors.add("The length of the field [line1] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 40");
		if(this.line2 != null)
			if(this.line2.length() > 40)
				listOfErrors.add("The length of the field [line2] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 40");
		if(this.line3 != null)
			if(this.line3.length() > 40)
				listOfErrors.add("The length of the field [line3] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 40");
		if(this.line4 != null)
			if(this.line4.length() > 40)
				listOfErrors.add("The length of the field [line4] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 40");
		if(this.line5 != null)
			if(this.line5.length() > 40)
				listOfErrors.add("The length of the field [line5] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 40");
		if(this.postcode != null)
			if(this.postcode.length() > 10)
				listOfErrors.add("The length of the field [postcode] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 10");
		if(this.phone != null)
			if(this.phone.length() > 30)
				listOfErrors.add("The length of the field [phone] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 30");
		if(this.fax != null)
			if(this.fax.length() > 30)
				listOfErrors.add("The length of the field [fax] in the value object [ims.pci.vo.PciAddressHistoryVo] is too big. It should be less or equal to 30");
		if(this.lho != null)
		{
			String[] listOfOtherErrors = this.lho.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.cca != null)
		{
			String[] listOfOtherErrors = this.cca.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.sector != null)
		{
			String[] listOfOtherErrors = this.sector.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.phndistrict != null)
		{
			String[] listOfOtherErrors = this.phndistrict.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.ded != null)
		{
			String[] listOfOtherErrors = this.ded.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 void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		PciAddressHistoryVo clone = new PciAddressHistoryVo(this.id, this.version);
		
		clone.line1 = this.line1;
		clone.line2 = this.line2;
		clone.line3 = this.line3;
		clone.line4 = this.line4;
		clone.line5 = this.line5;
		clone.postcode = this.postcode;
		clone.phone = this.phone;
		if(this.county == null)
			clone.county = null;
		else
			clone.county = (ims.ntpf.vo.lookups.County)this.county.clone();
		clone.fax = this.fax;
		if(this.updatedate == null)
			clone.updatedate = null;
		else
			clone.updatedate = (ims.framework.utils.DateTime)this.updatedate.clone();
		if(this.notificationdate == null)
			clone.notificationdate = null;
		else
			clone.notificationdate = (ims.framework.utils.Date)this.notificationdate.clone();
		if(this.lho == null)
			clone.lho = null;
		else
			clone.lho = (ims.core.vo.OrgLiteVo)this.lho.clone();
		if(this.cca == null)
			clone.cca = null;
		else
			clone.cca = (ims.core.vo.LocSiteLiteVo)this.cca.clone();
		if(this.sector == null)
			clone.sector = null;
		else
			clone.sector = (ims.core.vo.LocationLiteVo)this.sector.clone();
		if(this.phndistrict == null)
			clone.phndistrict = null;
		else
			clone.phndistrict = (ims.core.vo.LocationLiteVo)this.phndistrict.clone();
		if(this.ded == null)
			clone.ded = null;
		else
			clone.ded = (ims.core.vo.DEDLiteVo)this.ded.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 (!(PciAddressHistoryVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PciAddressHistoryVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PciAddressHistoryVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PciAddressHistoryVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.line1 != null)
			count++;
		if(this.line2 != null)
			count++;
		if(this.line3 != null)
			count++;
		if(this.line4 != null)
			count++;
		if(this.line5 != null)
			count++;
		if(this.postcode != null)
			count++;
		if(this.phone != null)
			count++;
		if(this.county != null)
			count++;
		if(this.fax != null)
			count++;
		if(this.updatedate != null)
			count++;
		if(this.notificationdate != null)
			count++;
		if(this.lho != null)
			count++;
		if(this.cca != null)
			count++;
		if(this.sector != null)
			count++;
		if(this.phndistrict != null)
			count++;
		if(this.ded != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 16;
	}
	protected String line1;
	protected String line2;
	protected String line3;
	protected String line4;
	protected String line5;
	protected String postcode;
	protected String phone;
	protected ims.ntpf.vo.lookups.County county;
	protected String fax;
	protected ims.framework.utils.DateTime updatedate;
	protected ims.framework.utils.Date notificationdate;
	protected ims.core.vo.OrgLiteVo lho;
	protected ims.core.vo.LocSiteLiteVo cca;
	protected ims.core.vo.LocationLiteVo sector;
	protected ims.core.vo.LocationLiteVo phndistrict;
	protected ims.core.vo.DEDLiteVo ded;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
