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


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

	public ReportSeedParsedVo()
	{
	}
	public ReportSeedParsedVo(ims.admin.vo.beans.ReportSeedParsedVoBean bean)
	{
		this.name = bean.getName();
		this.type = bean.getType();
		this.value = bean.getValue();
		this.boname = bean.getBOName();
		this.bofield = bean.getBOField();
		this.gp = bean.getGP() == null ? null : bean.getGP().buildVo();
		this.hcp = bean.getHCP() == null ? null : bean.getHCP().buildVo();
		this.mos = bean.getMOS() == null ? null : bean.getMOS().buildVo();
		this.organisation = bean.getOrganisation() == null ? null : bean.getOrganisation().buildVo();
		this.locsite = bean.getLocSite() == null ? null : bean.getLocSite().buildVo();
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo();
		this.canbenull = bean.getCanBeNull();
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.outcome = bean.getOutcome() == null ? null : ims.scheduling.vo.lookups.ApptOutcome.buildLookup(bean.getOutcome());
		this.searchtype = bean.getSearchType();
		this.searchby = bean.getSearchBy();
		this.displayfields = bean.getDisplayFields();
		this.referralby = bean.getReferralBy() == null ? null : ims.naes.vo.lookups.NAESReferredBy.buildLookup(bean.getReferralBy());
		this.displaytext = bean.getDisplayText();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.ReportSeedParsedVoBean bean)
	{
		this.name = bean.getName();
		this.type = bean.getType();
		this.value = bean.getValue();
		this.boname = bean.getBOName();
		this.bofield = bean.getBOField();
		this.gp = bean.getGP() == null ? null : bean.getGP().buildVo(map);
		this.hcp = bean.getHCP() == null ? null : bean.getHCP().buildVo(map);
		this.mos = bean.getMOS() == null ? null : bean.getMOS().buildVo(map);
		this.organisation = bean.getOrganisation() == null ? null : bean.getOrganisation().buildVo(map);
		this.locsite = bean.getLocSite() == null ? null : bean.getLocSite().buildVo(map);
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo(map);
		this.canbenull = bean.getCanBeNull();
		this.sex = bean.getSex() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getSex());
		this.outcome = bean.getOutcome() == null ? null : ims.scheduling.vo.lookups.ApptOutcome.buildLookup(bean.getOutcome());
		this.searchtype = bean.getSearchType();
		this.searchby = bean.getSearchBy();
		this.displayfields = bean.getDisplayFields();
		this.referralby = bean.getReferralBy() == null ? null : ims.naes.vo.lookups.NAESReferredBy.buildLookup(bean.getReferralBy());
		this.displaytext = bean.getDisplayText();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.admin.vo.beans.ReportSeedParsedVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.ReportSeedParsedVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.ReportSeedParsedVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getNameIsNotNull()
	{
		return this.name != null;
	}
	public String getName()
	{
		return this.name;
	}
	public static int getNameMaxLength()
	{
		return 255;
	}
	public void setName(String value)
	{
		this.isValidated = false;
		this.name = value;
	}
	public boolean getTypeIsNotNull()
	{
		return this.type != null;
	}
	public String getType()
	{
		return this.type;
	}
	public static int getTypeMaxLength()
	{
		return 255;
	}
	public void setType(String value)
	{
		this.isValidated = false;
		this.type = value;
	}
	public boolean getValueIsNotNull()
	{
		return this.value != null;
	}
	public String getValue()
	{
		return this.value;
	}
	public static int getValueMaxLength()
	{
		return 255;
	}
	public void setValue(String value)
	{
		this.isValidated = false;
		this.value = value;
	}
	public boolean getBONameIsNotNull()
	{
		return this.boname != null;
	}
	public String getBOName()
	{
		return this.boname;
	}
	public static int getBONameMaxLength()
	{
		return 255;
	}
	public void setBOName(String value)
	{
		this.isValidated = false;
		this.boname = value;
	}
	public boolean getBOFieldIsNotNull()
	{
		return this.bofield != null;
	}
	public String getBOField()
	{
		return this.bofield;
	}
	public static int getBOFieldMaxLength()
	{
		return 255;
	}
	public void setBOField(String value)
	{
		this.isValidated = false;
		this.bofield = value;
	}
	public boolean getGPIsNotNull()
	{
		return this.gp != null;
	}
	public ims.core.vo.GpShortVo getGP()
	{
		return this.gp;
	}
	public void setGP(ims.core.vo.GpShortVo value)
	{
		this.isValidated = false;
		this.gp = 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 getMOSIsNotNull()
	{
		return this.mos != null;
	}
	public ims.core.vo.MemberOfStaffShortVo getMOS()
	{
		return this.mos;
	}
	public void setMOS(ims.core.vo.MemberOfStaffShortVo value)
	{
		this.isValidated = false;
		this.mos = value;
	}
	public boolean getOrganisationIsNotNull()
	{
		return this.organisation != null;
	}
	public ims.core.vo.OrgShortVo getOrganisation()
	{
		return this.organisation;
	}
	public void setOrganisation(ims.core.vo.OrgShortVo value)
	{
		this.isValidated = false;
		this.organisation = value;
	}
	public boolean getLocSiteIsNotNull()
	{
		return this.locsite != null;
	}
	public ims.core.vo.LocSiteLiteVo getLocSite()
	{
		return this.locsite;
	}
	public void setLocSite(ims.core.vo.LocSiteLiteVo value)
	{
		this.isValidated = false;
		this.locsite = 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 getCanBeNullIsNotNull()
	{
		return this.canbenull != null;
	}
	public Boolean getCanBeNull()
	{
		return this.canbenull;
	}
	public void setCanBeNull(Boolean value)
	{
		this.isValidated = false;
		this.canbenull = value;
	}
	public boolean getSexIsNotNull()
	{
		return this.sex != null;
	}
	public ims.core.vo.lookups.Sex getSex()
	{
		return this.sex;
	}
	public void setSex(ims.core.vo.lookups.Sex value)
	{
		this.isValidated = false;
		this.sex = value;
	}
	public boolean getOutcomeIsNotNull()
	{
		return this.outcome != null;
	}
	public ims.scheduling.vo.lookups.ApptOutcome getOutcome()
	{
		return this.outcome;
	}
	public void setOutcome(ims.scheduling.vo.lookups.ApptOutcome value)
	{
		this.isValidated = false;
		this.outcome = value;
	}
	public boolean getSearchTypeIsNotNull()
	{
		return this.searchtype != null;
	}
	public String getSearchType()
	{
		return this.searchtype;
	}
	public static int getSearchTypeMaxLength()
	{
		return 255;
	}
	public void setSearchType(String value)
	{
		this.isValidated = false;
		this.searchtype = value;
	}
	public boolean getSearchByIsNotNull()
	{
		return this.searchby != null;
	}
	public String[] getSearchBy()
	{
		return this.searchby;
	}
	public static int getSearchByMaxLength()
	{
		return 255;
	}
	public void setSearchBy(String[] value)
	{
		this.isValidated = false;
		this.searchby = value;
	}
	public boolean getDisplayFieldsIsNotNull()
	{
		return this.displayfields != null;
	}
	public String[] getDisplayFields()
	{
		return this.displayfields;
	}
	public static int getDisplayFieldsMaxLength()
	{
		return 255;
	}
	public void setDisplayFields(String[] value)
	{
		this.isValidated = false;
		this.displayfields = value;
	}
	public boolean getReferralByIsNotNull()
	{
		return this.referralby != null;
	}
	public ims.naes.vo.lookups.NAESReferredBy getReferralBy()
	{
		return this.referralby;
	}
	public void setReferralBy(ims.naes.vo.lookups.NAESReferredBy value)
	{
		this.isValidated = false;
		this.referralby = value;
	}
	public boolean getDisplayTextIsNotNull()
	{
		return this.displaytext != null;
	}
	public String getDisplayText()
	{
		return this.displaytext;
	}
	public static int getDisplayTextMaxLength()
	{
		return 255;
	}
	public void setDisplayText(String value)
	{
		this.isValidated = false;
		this.displaytext = 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 ReportSeedParsedVo))
			return false;
		ReportSeedParsedVo compareObj = (ReportSeedParsedVo)obj;
		if(this.getName() == null && compareObj.getName() != null)
			return false;
		if(this.getName() != null && compareObj.getName() == null)
			return false;
		if(this.getName() != null && compareObj.getName() != null)
			if(!this.getName().equals(compareObj.getName()))
				return false;
		if(this.getType() == null && compareObj.getType() != null)
			return false;
		if(this.getType() != null && compareObj.getType() == null)
			return false;
		if(this.getType() != null && compareObj.getType() != null)
			if(!this.getType().equals(compareObj.getType()))
				return false;
		if(this.getValue() == null && compareObj.getValue() != null)
			return false;
		if(this.getValue() != null && compareObj.getValue() == null)
			return false;
		if(this.getValue() != null && compareObj.getValue() != null)
			if(!this.getValue().equals(compareObj.getValue()))
				return false;
		if(this.getBOName() == null && compareObj.getBOName() != null)
			return false;
		if(this.getBOName() != null && compareObj.getBOName() == null)
			return false;
		if(this.getBOName() != null && compareObj.getBOName() != null)
			if(!this.getBOName().equals(compareObj.getBOName()))
				return false;
		if(this.getBOField() == null && compareObj.getBOField() != null)
			return false;
		if(this.getBOField() != null && compareObj.getBOField() == null)
			return false;
		if(this.getBOField() != null && compareObj.getBOField() != null)
			return this.getBOField().equals(compareObj.getBOField());
		return super.equals(obj);
	}
	/**
	* Method used to retrieve only the BO name, without the path
	*/
	public String getShortBOName()
	{
		if (!getBONameIsNotNull())
			return null;
			
		String[] stringSplit = this.boname.split("\\.");
			
		if (stringSplit.length == 0)
			return null;
			
		return stringSplit[stringSplit.length - 1];
	}
	
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.gp != null)
		{
			if(!this.gp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.hcp != null)
		{
			if(!this.hcp.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.mos != null)
		{
			if(!this.mos.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.organisation != null)
		{
			if(!this.organisation.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.locsite != null)
		{
			if(!this.locsite.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.location != null)
		{
			if(!this.location.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.gp != null)
		{
			String[] listOfOtherErrors = this.gp.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]);
				}
			}
		}
		if(this.mos != null)
		{
			String[] listOfOtherErrors = this.mos.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.organisation != null)
		{
			String[] listOfOtherErrors = this.organisation.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.locsite != null)
		{
			String[] listOfOtherErrors = this.locsite.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[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]);
				}
			}
		}
		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;
	
		ReportSeedParsedVo clone = new ReportSeedParsedVo();
		
		clone.name = this.name;
		clone.type = this.type;
		clone.value = this.value;
		clone.boname = this.boname;
		clone.bofield = this.bofield;
		if(this.gp == null)
			clone.gp = null;
		else
			clone.gp = (ims.core.vo.GpShortVo)this.gp.clone();
		if(this.hcp == null)
			clone.hcp = null;
		else
			clone.hcp = (ims.core.vo.HcpLiteVo)this.hcp.clone();
		if(this.mos == null)
			clone.mos = null;
		else
			clone.mos = (ims.core.vo.MemberOfStaffShortVo)this.mos.clone();
		if(this.organisation == null)
			clone.organisation = null;
		else
			clone.organisation = (ims.core.vo.OrgShortVo)this.organisation.clone();
		if(this.locsite == null)
			clone.locsite = null;
		else
			clone.locsite = (ims.core.vo.LocSiteLiteVo)this.locsite.clone();
		if(this.location == null)
			clone.location = null;
		else
			clone.location = (ims.core.vo.LocationLiteVo)this.location.clone();
		clone.canbenull = this.canbenull;
		if(this.sex == null)
			clone.sex = null;
		else
			clone.sex = (ims.core.vo.lookups.Sex)this.sex.clone();
		if(this.outcome == null)
			clone.outcome = null;
		else
			clone.outcome = (ims.scheduling.vo.lookups.ApptOutcome)this.outcome.clone();
		clone.searchtype = this.searchtype;
		clone.searchby = this.searchby;
		clone.displayfields = this.displayfields;
		if(this.referralby == null)
			clone.referralby = null;
		else
			clone.referralby = (ims.naes.vo.lookups.NAESReferredBy)this.referralby.clone();
		clone.displaytext = this.displaytext;
		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 (!(ReportSeedParsedVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ReportSeedParsedVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ReportSeedParsedVo compareObj = (ReportSeedParsedVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getName() == null && compareObj.getName() != null)
				return -1;
			if(this.getName() != null && compareObj.getName() == null)
				return 1;
			if(this.getName() != null && compareObj.getName() != null)
			{
				if(caseInsensitive)
					retVal = this.getName().toLowerCase().compareTo(compareObj.getName().toLowerCase());
				else
					retVal = this.getName().compareTo(compareObj.getName());
			}
		}
		if (retVal == 0)
		{
			if(this.getType() == null && compareObj.getType() != null)
				return -1;
			if(this.getType() != null && compareObj.getType() == null)
				return 1;
			if(this.getType() != null && compareObj.getType() != null)
			{
				if(caseInsensitive)
					retVal = this.getType().toLowerCase().compareTo(compareObj.getType().toLowerCase());
				else
					retVal = this.getType().compareTo(compareObj.getType());
			}
		}
		if (retVal == 0)
		{
			if(this.getValue() == null && compareObj.getValue() != null)
				return -1;
			if(this.getValue() != null && compareObj.getValue() == null)
				return 1;
			if(this.getValue() != null && compareObj.getValue() != null)
			{
				if(caseInsensitive)
					retVal = this.getValue().toLowerCase().compareTo(compareObj.getValue().toLowerCase());
				else
					retVal = this.getValue().compareTo(compareObj.getValue());
			}
		}
		if (retVal == 0)
		{
			if(this.getBOName() == null && compareObj.getBOName() != null)
				return -1;
			if(this.getBOName() != null && compareObj.getBOName() == null)
				return 1;
			if(this.getBOName() != null && compareObj.getBOName() != null)
			{
				if(caseInsensitive)
					retVal = this.getBOName().toLowerCase().compareTo(compareObj.getBOName().toLowerCase());
				else
					retVal = this.getBOName().compareTo(compareObj.getBOName());
			}
		}
		if (retVal == 0)
		{
			if(this.getBOField() == null && compareObj.getBOField() != null)
				return -1;
			if(this.getBOField() != null && compareObj.getBOField() == null)
				return 1;
			if(this.getBOField() != null && compareObj.getBOField() != null)
			{
				if(caseInsensitive)
					retVal = this.getBOField().toLowerCase().compareTo(compareObj.getBOField().toLowerCase());
				else
					retVal = this.getBOField().compareTo(compareObj.getBOField());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.name != null)
			count++;
		if(this.type != null)
			count++;
		if(this.value != null)
			count++;
		if(this.boname != null)
			count++;
		if(this.bofield != null)
			count++;
		if(this.gp != null)
			count++;
		if(this.hcp != null)
			count++;
		if(this.mos != null)
			count++;
		if(this.organisation != null)
			count++;
		if(this.locsite != null)
			count++;
		if(this.location != null)
			count++;
		if(this.canbenull != null)
			count++;
		if(this.sex != null)
			count++;
		if(this.outcome != null)
			count++;
		if(this.searchtype != null)
			count++;
		if(this.searchby != null)
			count++;
		if(this.displayfields != null)
			count++;
		if(this.referralby != null)
			count++;
		if(this.displaytext != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 19;
	}
	protected String name;
	protected String type;
	protected String value;
	protected String boname;
	protected String bofield;
	protected ims.core.vo.GpShortVo gp;
	protected ims.core.vo.HcpLiteVo hcp;
	protected ims.core.vo.MemberOfStaffShortVo mos;
	protected ims.core.vo.OrgShortVo organisation;
	protected ims.core.vo.LocSiteLiteVo locsite;
	protected ims.core.vo.LocationLiteVo location;
	protected Boolean canbenull;
	protected ims.core.vo.lookups.Sex sex;
	protected ims.scheduling.vo.lookups.ApptOutcome outcome;
	protected String searchtype;
	protected String[] searchby;
	protected String[] displayfields;
	protected ims.naes.vo.lookups.NAESReferredBy referralby;
	protected String displaytext;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
