/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/pci/vo/FamilyAddressVo.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.patient.Patient business object (ID: 1001100000).
 */
public class FamilyAddressVo extends ims.core.patient.vo.PatientRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public FamilyAddressVo()
	{
	}
	public FamilyAddressVo(Integer id, int version)
	{
		super(id, version);
	}
	public FamilyAddressVo(ims.pci.vo.beans.FamilyAddressVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : new ims.core.generic.vo.PersonNameRefVo(new Integer(bean.getName().getId()), bean.getName().getVersion());
		this.address = bean.getAddress() == null ? null : new ims.core.generic.vo.AddressRefVo(new Integer(bean.getAddress().getId()), bean.getAddress().getVersion());
		if(bean.getIdentifiers() != null)
		{
			this.identifiers = new ims.core.patient.vo.PatientIdRefVoCollection();
			for(int identifiers_i = 0; identifiers_i < bean.getIdentifiers().length; identifiers_i++)
			{
				this.identifiers.add(new ims.core.patient.vo.PatientIdRefVo(new Integer(bean.getIdentifiers()[identifiers_i].getId()), bean.getIdentifiers()[identifiers_i].getVersion()));
			}
		}
		if(bean.getAddresses() != null)
		{
			this.addresses = new ims.core.generic.vo.AddressRefVoCollection();
			for(int addresses_i = 0; addresses_i < bean.getAddresses().length; addresses_i++)
			{
				this.addresses.add(new ims.core.generic.vo.AddressRefVo(new Integer(bean.getAddresses()[addresses_i].getId()), bean.getAddresses()[addresses_i].getVersion()));
			}
		}
		this.clientparent = bean.getClientParent() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getClientParent().getId()), bean.getClientParent().getVersion());
		this.communitycare = bean.getCommunityCare() == null ? null : new ims.core.patient.vo.CommunityCareDetailRefVo(new Integer(bean.getCommunityCare().getId()), bean.getCommunityCare().getVersion());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pci.vo.beans.FamilyAddressVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName() == null ? null : new ims.core.generic.vo.PersonNameRefVo(new Integer(bean.getName().getId()), bean.getName().getVersion());
		this.address = bean.getAddress() == null ? null : new ims.core.generic.vo.AddressRefVo(new Integer(bean.getAddress().getId()), bean.getAddress().getVersion());
		if(bean.getIdentifiers() != null)
		{
			this.identifiers = new ims.core.patient.vo.PatientIdRefVoCollection();
			for(int identifiers_i = 0; identifiers_i < bean.getIdentifiers().length; identifiers_i++)
			{
				this.identifiers.add(new ims.core.patient.vo.PatientIdRefVo(new Integer(bean.getIdentifiers()[identifiers_i].getId()), bean.getIdentifiers()[identifiers_i].getVersion()));
			}
		}
		if(bean.getAddresses() != null)
		{
			this.addresses = new ims.core.generic.vo.AddressRefVoCollection();
			for(int addresses_i = 0; addresses_i < bean.getAddresses().length; addresses_i++)
			{
				this.addresses.add(new ims.core.generic.vo.AddressRefVo(new Integer(bean.getAddresses()[addresses_i].getId()), bean.getAddresses()[addresses_i].getVersion()));
			}
		}
		this.clientparent = bean.getClientParent() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getClientParent().getId()), bean.getClientParent().getVersion());
		this.communitycare = bean.getCommunityCare() == null ? null : new ims.core.patient.vo.CommunityCareDetailRefVo(new Integer(bean.getCommunityCare().getId()), bean.getCommunityCare().getVersion());
	}
	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.FamilyAddressVoBean bean = null;
		if(map != null)
			bean = (ims.pci.vo.beans.FamilyAddressVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pci.vo.beans.FamilyAddressVoBean();
			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("NAME"))
			return getName();
		if(fieldName.equals("ADDRESS"))
			return getAddress();
		if(fieldName.equals("IDENTIFIERS"))
			return getIdentifiers();
		if(fieldName.equals("ADDRESSES"))
			return getAddresses();
		if(fieldName.equals("CLIENTPARENT"))
			return getClientParent();
		if(fieldName.equals("COMMUNITYCARE"))
			return getCommunityCare();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getNameIsNotNull()
	{
		return this.name != null;
	}
	public ims.core.generic.vo.PersonNameRefVo getName()
	{
		return this.name;
	}
	public void setName(ims.core.generic.vo.PersonNameRefVo value)
	{
		this.isValidated = false;
		this.name = value;
	}
	public boolean getAddressIsNotNull()
	{
		return this.address != null;
	}
	public ims.core.generic.vo.AddressRefVo getAddress()
	{
		return this.address;
	}
	public void setAddress(ims.core.generic.vo.AddressRefVo value)
	{
		this.isValidated = false;
		this.address = value;
	}
	public boolean getIdentifiersIsNotNull()
	{
		return this.identifiers != null;
	}
	public ims.core.patient.vo.PatientIdRefVoCollection getIdentifiers()
	{
		return this.identifiers;
	}
	public void setIdentifiers(ims.core.patient.vo.PatientIdRefVoCollection value)
	{
		this.isValidated = false;
		this.identifiers = value;
	}
	public boolean getAddressesIsNotNull()
	{
		return this.addresses != null;
	}
	public ims.core.generic.vo.AddressRefVoCollection getAddresses()
	{
		return this.addresses;
	}
	public void setAddresses(ims.core.generic.vo.AddressRefVoCollection value)
	{
		this.isValidated = false;
		this.addresses = value;
	}
	public boolean getClientParentIsNotNull()
	{
		return this.clientparent != null;
	}
	public ims.core.patient.vo.PatientRefVo getClientParent()
	{
		return this.clientparent;
	}
	public void setClientParent(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.clientparent = value;
	}
	public boolean getCommunityCareIsNotNull()
	{
		return this.communitycare != null;
	}
	public ims.core.patient.vo.CommunityCareDetailRefVo getCommunityCare()
	{
		return this.communitycare;
	}
	public void setCommunityCare(ims.core.patient.vo.CommunityCareDetailRefVo value)
	{
		this.isValidated = false;
		this.communitycare = value;
	}
	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 void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		FamilyAddressVo clone = new FamilyAddressVo(this.id, this.version);
		
		clone.name = this.name;
		clone.address = this.address;
		clone.identifiers = this.identifiers;
		clone.addresses = this.addresses;
		clone.clientparent = this.clientparent;
		clone.communitycare = this.communitycare;
		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 (!(FamilyAddressVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A FamilyAddressVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((FamilyAddressVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((FamilyAddressVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.name != null)
			count++;
		if(this.address != null)
			count++;
		if(this.identifiers != null)
			count++;
		if(this.addresses != null)
			count++;
		if(this.clientparent != null)
			count++;
		if(this.communitycare != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.core.generic.vo.PersonNameRefVo name;
	protected ims.core.generic.vo.AddressRefVo address;
	protected ims.core.patient.vo.PatientIdRefVoCollection identifiers;
	protected ims.core.generic.vo.AddressRefVoCollection addresses;
	protected ims.core.patient.vo.PatientRefVo clientparent;
	protected ims.core.patient.vo.CommunityCareDetailRefVo communitycare;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
