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

/**
 * Linked to core.patient.PDSAddr business object (ID: 1001100025).
 */
public class PDSAddrVo extends ims.core.patient.vo.PDSAddrRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PDSAddrVo()
	{
	}
	public PDSAddrVo(Integer id, int version)
	{
		super(id, version);
	}
	public PDSAddrVo(ims.core.vo.beans.PDSAddrVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.addresslines = bean.getAddressLines();
		this.postcode = bean.getPostcode();
		this.addresskey = bean.getAddressKey();
		this.description = bean.getDescription();
		this.addresstype = bean.getAddressType() == null ? null : ims.core.vo.lookups.AddressType.buildLookup(bean.getAddressType());
		this.beffdate = bean.getBeffdate();
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.betdatecnf = bean.getBetdatecnf();
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.objectidentifier = bean.getObjectIdentifier();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.PDSAddrVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.addresslines = bean.getAddressLines();
		this.postcode = bean.getPostcode();
		this.addresskey = bean.getAddressKey();
		this.description = bean.getDescription();
		this.addresstype = bean.getAddressType() == null ? null : ims.core.vo.lookups.AddressType.buildLookup(bean.getAddressType());
		this.beffdate = bean.getBeffdate();
		this.beffdatecnf = bean.getBeffdatecnf();
		this.betdate = bean.getBetdate() == null ? null : bean.getBetdate().buildDate();
		this.betdatecnf = bean.getBetdatecnf();
		this.pdsupdatemode = bean.getPdsUpdateMode() == null ? null : ims.core.vo.lookups.PDSUpdateMode.buildLookup(bean.getPdsUpdateMode());
		this.objectidentifier = bean.getObjectIdentifier();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.PDSAddrVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.PDSAddrVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.PDSAddrVoBean();
			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("ADDRESSLINES"))
			return getAddressLines();
		if(fieldName.equals("POSTCODE"))
			return getPostcode();
		if(fieldName.equals("ADDRESSKEY"))
			return getAddressKey();
		if(fieldName.equals("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("ADDRESSTYPE"))
			return getAddressType();
		if(fieldName.equals("BEFFDATE"))
			return getBeffdate();
		if(fieldName.equals("BEFFDATECNF"))
			return getBeffdatecnf();
		if(fieldName.equals("BETDATE"))
			return getBetdate();
		if(fieldName.equals("BETDATECNF"))
			return getBetdatecnf();
		if(fieldName.equals("PDSUPDATEMODE"))
			return getPdsUpdateMode();
		if(fieldName.equals("OBJECTIDENTIFIER"))
			return getObjectIdentifier();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAddressLinesIsNotNull()
	{
		return this.addresslines != null;
	}
	public String getAddressLines()
	{
		return this.addresslines;
	}
	public static int getAddressLinesMaxLength()
	{
		return 200;
	}
	public void setAddressLines(String value)
	{
		this.isValidated = false;
		this.addresslines = 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 getAddressKeyIsNotNull()
	{
		return this.addresskey != null;
	}
	public String getAddressKey()
	{
		return this.addresskey;
	}
	public static int getAddressKeyMaxLength()
	{
		return 10;
	}
	public void setAddressKey(String value)
	{
		this.isValidated = false;
		this.addresskey = value;
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 100;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getAddressTypeIsNotNull()
	{
		return this.addresstype != null;
	}
	public ims.core.vo.lookups.AddressType getAddressType()
	{
		return this.addresstype;
	}
	public void setAddressType(ims.core.vo.lookups.AddressType value)
	{
		this.isValidated = false;
		this.addresstype = value;
	}
	public boolean getBeffdateIsNotNull()
	{
		return this.beffdate != null;
	}
	public Boolean getBeffdate()
	{
		return this.beffdate;
	}
	public void setBeffdate(Boolean value)
	{
		this.isValidated = false;
		this.beffdate = value;
	}
	public boolean getBeffdatecnfIsNotNull()
	{
		return this.beffdatecnf != null;
	}
	public Boolean getBeffdatecnf()
	{
		return this.beffdatecnf;
	}
	public void setBeffdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.beffdatecnf = value;
	}
	public boolean getBetdateIsNotNull()
	{
		return this.betdate != null;
	}
	public ims.framework.utils.Date getBetdate()
	{
		return this.betdate;
	}
	public void setBetdate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.betdate = value;
	}
	public boolean getBetdatecnfIsNotNull()
	{
		return this.betdatecnf != null;
	}
	public Boolean getBetdatecnf()
	{
		return this.betdatecnf;
	}
	public void setBetdatecnf(Boolean value)
	{
		this.isValidated = false;
		this.betdatecnf = value;
	}
	public boolean getPdsUpdateModeIsNotNull()
	{
		return this.pdsupdatemode != null;
	}
	public ims.core.vo.lookups.PDSUpdateMode getPdsUpdateMode()
	{
		return this.pdsupdatemode;
	}
	public void setPdsUpdateMode(ims.core.vo.lookups.PDSUpdateMode value)
	{
		this.isValidated = false;
		this.pdsupdatemode = value;
	}
	public boolean getObjectIdentifierIsNotNull()
	{
		return this.objectidentifier != null;
	}
	public String getObjectIdentifier()
	{
		return this.objectidentifier;
	}
	public static int getObjectIdentifierMaxLength()
	{
		return 14;
	}
	public void setObjectIdentifier(String value)
	{
		this.isValidated = false;
		this.objectidentifier = 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]);
			}
		}
		if(this.addresslines != null)
			if(this.addresslines.length() > 200)
				listOfErrors.add("The length of the field [addresslines] in the value object [ims.core.vo.PDSAddrVo] is too big. It should be less or equal to 200");
		if(this.postcode != null)
			if(this.postcode.length() > 10)
				listOfErrors.add("The length of the field [postcode] in the value object [ims.core.vo.PDSAddrVo] is too big. It should be less or equal to 10");
		if(this.addresskey != null)
			if(this.addresskey.length() > 10)
				listOfErrors.add("The length of the field [addresskey] in the value object [ims.core.vo.PDSAddrVo] is too big. It should be less or equal to 10");
		if(this.description != null)
			if(this.description.length() > 100)
				listOfErrors.add("The length of the field [description] in the value object [ims.core.vo.PDSAddrVo] is too big. It should be less or equal to 100");
		if(this.objectidentifier != null)
			if(this.objectidentifier.length() > 14)
				listOfErrors.add("The length of the field [objectidentifier] in the value object [ims.core.vo.PDSAddrVo] is too big. It should be less or equal to 14");
		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;
	
		PDSAddrVo clone = new PDSAddrVo(this.id, this.version);
		
		clone.addresslines = this.addresslines;
		clone.postcode = this.postcode;
		clone.addresskey = this.addresskey;
		clone.description = this.description;
		if(this.addresstype == null)
			clone.addresstype = null;
		else
			clone.addresstype = (ims.core.vo.lookups.AddressType)this.addresstype.clone();
		clone.beffdate = this.beffdate;
		clone.beffdatecnf = this.beffdatecnf;
		if(this.betdate == null)
			clone.betdate = null;
		else
			clone.betdate = (ims.framework.utils.Date)this.betdate.clone();
		clone.betdatecnf = this.betdatecnf;
		if(this.pdsupdatemode == null)
			clone.pdsupdatemode = null;
		else
			clone.pdsupdatemode = (ims.core.vo.lookups.PDSUpdateMode)this.pdsupdatemode.clone();
		clone.objectidentifier = this.objectidentifier;
		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 (!(PDSAddrVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PDSAddrVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PDSAddrVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PDSAddrVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.addresslines != null)
			count++;
		if(this.postcode != null)
			count++;
		if(this.addresskey != null)
			count++;
		if(this.description != null)
			count++;
		if(this.addresstype != null)
			count++;
		if(this.beffdate != null)
			count++;
		if(this.beffdatecnf != null)
			count++;
		if(this.betdate != null)
			count++;
		if(this.betdatecnf != null)
			count++;
		if(this.pdsupdatemode != null)
			count++;
		if(this.objectidentifier != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected String addresslines;
	protected String postcode;
	protected String addresskey;
	protected String description;
	protected ims.core.vo.lookups.AddressType addresstype;
	protected Boolean beffdate;
	protected Boolean beffdatecnf;
	protected ims.framework.utils.Date betdate;
	protected Boolean betdatecnf;
	protected ims.core.vo.lookups.PDSUpdateMode pdsupdatemode;
	protected String objectidentifier;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
