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

/**
 * Linked to OCRR.Configuration.Investigation business object (ID: 1058100001).
 */
public class InvestigationSelectOrderVo extends ims.ocrr.configuration.vo.InvestigationRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public InvestigationSelectOrderVo()
	{
	}
	public InvestigationSelectOrderVo(Integer id, int version)
	{
		super(id, version);
	}
	public InvestigationSelectOrderVo(ims.ocrr.vo.beans.InvestigationSelectOrderVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.associnvestigations = ims.ocrr.vo.InvestigationSelectOrderVoCollection.buildFromBeanCollection(bean.getAssocInvestigations());
		this.investigationindex = bean.getInvestigationIndex() == null ? null : bean.getInvestigationIndex().buildVo();
		this.activestatus = bean.getActiveStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getActiveStatus());
		this.isaddon = bean.getIsAddon();
		this.expectedturnaround = bean.getExpectedTurnaround();
		this.turnaroundmeasure = bean.getTurnaroundMeasure() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getTurnaroundMeasure());
		this.providerservice = bean.getProviderService() == null ? null : bean.getProviderService().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ocrr.vo.beans.InvestigationSelectOrderVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.associnvestigations = ims.ocrr.vo.InvestigationSelectOrderVoCollection.buildFromBeanCollection(bean.getAssocInvestigations());
		this.investigationindex = bean.getInvestigationIndex() == null ? null : bean.getInvestigationIndex().buildVo(map);
		this.activestatus = bean.getActiveStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getActiveStatus());
		this.isaddon = bean.getIsAddon();
		this.expectedturnaround = bean.getExpectedTurnaround();
		this.turnaroundmeasure = bean.getTurnaroundMeasure() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getTurnaroundMeasure());
		this.providerservice = bean.getProviderService() == null ? null : bean.getProviderService().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ocrr.vo.beans.InvestigationSelectOrderVoBean bean = null;
		if(map != null)
			bean = (ims.ocrr.vo.beans.InvestigationSelectOrderVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ocrr.vo.beans.InvestigationSelectOrderVoBean();
			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("ASSOCINVESTIGATIONS"))
			return getAssocInvestigations();
		if(fieldName.equals("INVESTIGATIONINDEX"))
			return getInvestigationIndex();
		if(fieldName.equals("ACTIVESTATUS"))
			return getActiveStatus();
		if(fieldName.equals("ISADDON"))
			return getIsAddon();
		if(fieldName.equals("EXPECTEDTURNAROUND"))
			return getExpectedTurnaround();
		if(fieldName.equals("TURNAROUNDMEASURE"))
			return getTurnaroundMeasure();
		if(fieldName.equals("PROVIDERSERVICE"))
			return getProviderService();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAssocInvestigationsIsNotNull()
	{
		return this.associnvestigations != null;
	}
	public ims.ocrr.vo.InvestigationSelectOrderVoCollection getAssocInvestigations()
	{
		return this.associnvestigations;
	}
	public void setAssocInvestigations(ims.ocrr.vo.InvestigationSelectOrderVoCollection value)
	{
		this.isValidated = false;
		this.associnvestigations = value;
	}
	public boolean getInvestigationIndexIsNotNull()
	{
		return this.investigationindex != null;
	}
	public ims.ocrr.vo.InvestigationIndexSelectOrderVo getInvestigationIndex()
	{
		return this.investigationindex;
	}
	public void setInvestigationIndex(ims.ocrr.vo.InvestigationIndexSelectOrderVo value)
	{
		this.isValidated = false;
		this.investigationindex = value;
	}
	public boolean getActiveStatusIsNotNull()
	{
		return this.activestatus != null;
	}
	public ims.core.vo.lookups.PreActiveActiveInactiveStatus getActiveStatus()
	{
		return this.activestatus;
	}
	public void setActiveStatus(ims.core.vo.lookups.PreActiveActiveInactiveStatus value)
	{
		this.isValidated = false;
		this.activestatus = value;
	}
	public boolean getIsAddonIsNotNull()
	{
		return this.isaddon != null;
	}
	public Boolean getIsAddon()
	{
		return this.isaddon;
	}
	public void setIsAddon(Boolean value)
	{
		this.isValidated = false;
		this.isaddon = value;
	}
	public boolean getExpectedTurnaroundIsNotNull()
	{
		return this.expectedturnaround != null;
	}
	public Integer getExpectedTurnaround()
	{
		return this.expectedturnaround;
	}
	public void setExpectedTurnaround(Integer value)
	{
		this.isValidated = false;
		this.expectedturnaround = value;
	}
	public boolean getTurnaroundMeasureIsNotNull()
	{
		return this.turnaroundmeasure != null;
	}
	public ims.ocrr.vo.lookups.MinReorderPeriod getTurnaroundMeasure()
	{
		return this.turnaroundmeasure;
	}
	public void setTurnaroundMeasure(ims.ocrr.vo.lookups.MinReorderPeriod value)
	{
		this.isValidated = false;
		this.turnaroundmeasure = value;
	}
	public boolean getProviderServiceIsNotNull()
	{
		return this.providerservice != null;
	}
	public ims.ocrr.vo.LocSvcProviderSysLiteVo getProviderService()
	{
		return this.providerservice;
	}
	public void setProviderService(ims.ocrr.vo.LocSvcProviderSysLiteVo value)
	{
		this.isValidated = false;
		this.providerservice = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.associnvestigations != null)
		{
			if(!this.associnvestigations.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.investigationindex != null)
		{
			if(!this.investigationindex.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.associnvestigations != null)
		{
			String[] listOfOtherErrors = this.associnvestigations.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.investigationindex == null)
			listOfErrors.add("InvestigationIndex is mandatory");
		if(this.investigationindex != null)
		{
			String[] listOfOtherErrors = this.investigationindex.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.activestatus == null)
			listOfErrors.add("ActiveStatus is mandatory");
		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;
	
		InvestigationSelectOrderVo clone = new InvestigationSelectOrderVo(this.id, this.version);
		
		if(this.associnvestigations == null)
			clone.associnvestigations = null;
		else
			clone.associnvestigations = (ims.ocrr.vo.InvestigationSelectOrderVoCollection)this.associnvestigations.clone();
		if(this.investigationindex == null)
			clone.investigationindex = null;
		else
			clone.investigationindex = (ims.ocrr.vo.InvestigationIndexSelectOrderVo)this.investigationindex.clone();
		if(this.activestatus == null)
			clone.activestatus = null;
		else
			clone.activestatus = (ims.core.vo.lookups.PreActiveActiveInactiveStatus)this.activestatus.clone();
		clone.isaddon = this.isaddon;
		clone.expectedturnaround = this.expectedturnaround;
		if(this.turnaroundmeasure == null)
			clone.turnaroundmeasure = null;
		else
			clone.turnaroundmeasure = (ims.ocrr.vo.lookups.MinReorderPeriod)this.turnaroundmeasure.clone();
		if(this.providerservice == null)
			clone.providerservice = null;
		else
			clone.providerservice = (ims.ocrr.vo.LocSvcProviderSysLiteVo)this.providerservice.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 (!(InvestigationSelectOrderVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A InvestigationSelectOrderVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		InvestigationSelectOrderVo compareObj = (InvestigationSelectOrderVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_Investigation() == null && compareObj.getID_Investigation() != null)
				return -1;
			if(this.getID_Investigation() != null && compareObj.getID_Investigation() == null)
				return 1;
			if(this.getID_Investigation() != null && compareObj.getID_Investigation() != null)
				retVal = this.getID_Investigation().compareTo(compareObj.getID_Investigation());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.associnvestigations != null)
			count++;
		if(this.investigationindex != null)
			count++;
		if(this.activestatus != null)
			count++;
		if(this.isaddon != null)
			count++;
		if(this.expectedturnaround != null)
			count++;
		if(this.turnaroundmeasure != null)
			count++;
		if(this.providerservice != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected ims.ocrr.vo.InvestigationSelectOrderVoCollection associnvestigations;
	protected ims.ocrr.vo.InvestigationIndexSelectOrderVo investigationindex;
	protected ims.core.vo.lookups.PreActiveActiveInactiveStatus activestatus;
	protected Boolean isaddon;
	protected Integer expectedturnaround;
	protected ims.ocrr.vo.lookups.MinReorderPeriod turnaroundmeasure;
	protected ims.ocrr.vo.LocSvcProviderSysLiteVo providerservice;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
