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


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

	public MyOrderComponentVo()
	{
	}
	public MyOrderComponentVo(ims.ocrr.vo.beans.MyOrderComponentVoBean bean)
	{
		this.id = bean.getID();
		this.componenttype = bean.getComponentType() == null ? null : ims.ocrr.vo.lookups.SelectAndOrderComponentType.buildLookup(bean.getComponentType());
		this.text = bean.getText();
		this.tooltip = bean.getTooltip();
		this.category = bean.getCategory() == null ? null : ims.ocrr.vo.lookups.Category.buildLookup(bean.getCategory());
		this.helptext = bean.getHelpText();
		this.additionallocationinfo = bean.getAdditionalLocationInfo();
		this.parentinvestigationid = bean.getParentInvestigationId();
		this.isaddon = bean.getIsAddon();
		this.requiressite = bean.getRequiresSite();
		this.serviceid = bean.getServiceID();
		this.minreorderperiod = bean.getMinReOrderPeriod() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getMinReOrderPeriod());
		this.minreorderval = bean.getMinReOrderVal();
		this.minreorderfemaleperiod = bean.getMinReOrderFemalePeriod() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getMinReOrderFemalePeriod());
		this.minreorderfemaleval = bean.getMinReOrderFemaleVal();
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.phlebmaycollect = bean.getPhlebMayCollect();
		this.reorderreason = bean.getReOrderReason();
		if(bean.getAssociatedInvestigations() != null)
		{
			this.associatedinvestigations = new ims.ocrr.configuration.vo.InvestigationRefVoCollection();
			for(int associatedinvestigations_i = 0; associatedinvestigations_i < bean.getAssociatedInvestigations().length; associatedinvestigations_i++)
			{
				this.associatedinvestigations.add(new ims.ocrr.configuration.vo.InvestigationRefVo(new Integer(bean.getAssociatedInvestigations()[associatedinvestigations_i].getId()), bean.getAssociatedInvestigations()[associatedinvestigations_i].getVersion()));
			}
		}
		this.components = ims.ocrr.vo.MyOrderChildComponentVoCollection.buildFromBeanCollection(bean.getComponents());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ocrr.vo.beans.MyOrderComponentVoBean bean)
	{
		this.id = bean.getID();
		this.componenttype = bean.getComponentType() == null ? null : ims.ocrr.vo.lookups.SelectAndOrderComponentType.buildLookup(bean.getComponentType());
		this.text = bean.getText();
		this.tooltip = bean.getTooltip();
		this.category = bean.getCategory() == null ? null : ims.ocrr.vo.lookups.Category.buildLookup(bean.getCategory());
		this.helptext = bean.getHelpText();
		this.additionallocationinfo = bean.getAdditionalLocationInfo();
		this.parentinvestigationid = bean.getParentInvestigationId();
		this.isaddon = bean.getIsAddon();
		this.requiressite = bean.getRequiresSite();
		this.serviceid = bean.getServiceID();
		this.minreorderperiod = bean.getMinReOrderPeriod() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getMinReOrderPeriod());
		this.minreorderval = bean.getMinReOrderVal();
		this.minreorderfemaleperiod = bean.getMinReOrderFemalePeriod() == null ? null : ims.ocrr.vo.lookups.MinReorderPeriod.buildLookup(bean.getMinReOrderFemalePeriod());
		this.minreorderfemaleval = bean.getMinReOrderFemaleVal();
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.phlebmaycollect = bean.getPhlebMayCollect();
		this.reorderreason = bean.getReOrderReason();
		if(bean.getAssociatedInvestigations() != null)
		{
			this.associatedinvestigations = new ims.ocrr.configuration.vo.InvestigationRefVoCollection();
			for(int associatedinvestigations_i = 0; associatedinvestigations_i < bean.getAssociatedInvestigations().length; associatedinvestigations_i++)
			{
				this.associatedinvestigations.add(new ims.ocrr.configuration.vo.InvestigationRefVo(new Integer(bean.getAssociatedInvestigations()[associatedinvestigations_i].getId()), bean.getAssociatedInvestigations()[associatedinvestigations_i].getVersion()));
			}
		}
		this.components = ims.ocrr.vo.MyOrderChildComponentVoCollection.buildFromBeanCollection(bean.getComponents());
	}
	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.MyOrderComponentVoBean bean = null;
		if(map != null)
			bean = (ims.ocrr.vo.beans.MyOrderComponentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ocrr.vo.beans.MyOrderComponentVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getComponentsIsNotNull()
	{
		return this.components != null;
	}
	public ims.ocrr.vo.MyOrderChildComponentVoCollection getComponents()
	{
		return this.components;
	}
	public void setComponents(ims.ocrr.vo.MyOrderChildComponentVoCollection value)
	{
		this.isValidated = false;
		this.components = value;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof MyOrderComponentVo))
			return false;
		MyOrderComponentVo compareObj = (MyOrderComponentVo)obj;
		if(this.getID() == null && compareObj.getID() != null)
			return false;
		if(this.getID() != null && compareObj.getID() == null)
			return false;
		if(this.getID() != null && compareObj.getID() != null)
			if(!this.getID().equals(compareObj.getID()))
				return false;
		if(this.getComponentType() == null && compareObj.getComponentType() != null)
			return false;
		if(this.getComponentType() != null && compareObj.getComponentType() == null)
			return false;
		if(this.getComponentType() != null && compareObj.getComponentType() != null)
			return this.getComponentType().equals(compareObj.getComponentType());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.components != null)
		{
			if(!this.components.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.components != null)
		{
			String[] listOfOtherErrors = this.components.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;
	
		MyOrderComponentVo clone = new MyOrderComponentVo();
		
		clone.id = this.id;
		if(this.componenttype == null)
			clone.componenttype = null;
		else
			clone.componenttype = (ims.ocrr.vo.lookups.SelectAndOrderComponentType)this.componenttype.clone();
		clone.text = this.text;
		clone.tooltip = this.tooltip;
		if(this.category == null)
			clone.category = null;
		else
			clone.category = (ims.ocrr.vo.lookups.Category)this.category.clone();
		clone.helptext = this.helptext;
		clone.additionallocationinfo = this.additionallocationinfo;
		clone.parentinvestigationid = this.parentinvestigationid;
		clone.isaddon = this.isaddon;
		clone.requiressite = this.requiressite;
		clone.serviceid = this.serviceid;
		if(this.minreorderperiod == null)
			clone.minreorderperiod = null;
		else
			clone.minreorderperiod = (ims.ocrr.vo.lookups.MinReorderPeriod)this.minreorderperiod.clone();
		clone.minreorderval = this.minreorderval;
		if(this.minreorderfemaleperiod == null)
			clone.minreorderfemaleperiod = null;
		else
			clone.minreorderfemaleperiod = (ims.ocrr.vo.lookups.MinReorderPeriod)this.minreorderfemaleperiod.clone();
		clone.minreorderfemaleval = this.minreorderfemaleval;
		if(this.genderspecific == null)
			clone.genderspecific = null;
		else
			clone.genderspecific = (ims.admin.vo.lookups.GenderSpecific)this.genderspecific.clone();
		clone.phlebmaycollect = this.phlebmaycollect;
		clone.reorderreason = this.reorderreason;
		clone.associatedinvestigations = this.associatedinvestigations;
		if(this.components == null)
			clone.components = null;
		else
			clone.components = (ims.ocrr.vo.MyOrderChildComponentVoCollection)this.components.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 (!(MyOrderComponentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A MyOrderComponentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		MyOrderComponentVo compareObj = (MyOrderComponentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID() == null && compareObj.getID() != null)
				return -1;
			if(this.getID() != null && compareObj.getID() == null)
				return 1;
			if(this.getID() != null && compareObj.getID() != null)
				retVal = this.getID().compareTo(compareObj.getID());
		}
		if (retVal == 0)
		{
			if(this.getComponentType() == null && compareObj.getComponentType() != null)
				return -1;
			if(this.getComponentType() != null && compareObj.getComponentType() == null)
				return 1;
			if(this.getComponentType() != null && compareObj.getComponentType() != null)
				retVal = this.getComponentType().compareTo(compareObj.getComponentType());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.components != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 1;
	}
	protected ims.ocrr.vo.MyOrderChildComponentVoCollection components;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
