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

/**
 * Linked to Oncology.Configuration.TumourGroupSiteOverallStaging business object (ID: 1074100013).
 */
public class TumourGroupSiteOverallStagingVo extends ims.clinicaladmin.vo.TumourGroupSiteOverallStagingLiteVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public TumourGroupSiteOverallStagingVo()
	{
	}
	public TumourGroupSiteOverallStagingVo(Integer id, int version)
	{
		super(id, version);
	}
	public TumourGroupSiteOverallStagingVo(ims.clinicaladmin.vo.beans.TumourGroupSiteOverallStagingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.overallstagedescription = bean.getOverallStageDescription() == null ? null : ims.oncology.vo.lookups.TumourOverallStage.buildLookup(bean.getOverallStageDescription());
		this.isactive = bean.getIsActive();
		this.o45 = bean.getO45();
		this.tgroup = bean.getTGroup() == null ? null : new ims.oncology.configuration.vo.TumourGroupRefVo(new Integer(bean.getTGroup().getId()), bean.getTGroup().getVersion());
		this.tsite = bean.getTSite() == null ? null : new ims.oncology.configuration.vo.TumourSiteRefVo(new Integer(bean.getTSite().getId()), bean.getTSite().getVersion());
		this.tval = bean.getTVal() == null ? null : bean.getTVal().buildVo();
		this.nval = bean.getNVal() == null ? null : bean.getNVal().buildVo();
		this.mval = bean.getMVal() == null ? null : bean.getMVal().buildVo();
		this.histval = bean.getHistVal() == null ? null : bean.getHistVal().buildVo();
		this.serummarkerval = bean.getSerumMarkerVal() == null ? null : bean.getSerumMarkerVal().buildVo();
		this.diffval = bean.getDiffVal() == null ? null : bean.getDiffVal().buildVo();
		this.issaved = bean.getIsSaved();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinicaladmin.vo.beans.TumourGroupSiteOverallStagingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.overallstagedescription = bean.getOverallStageDescription() == null ? null : ims.oncology.vo.lookups.TumourOverallStage.buildLookup(bean.getOverallStageDescription());
		this.isactive = bean.getIsActive();
		this.o45 = bean.getO45();
		this.tgroup = bean.getTGroup() == null ? null : new ims.oncology.configuration.vo.TumourGroupRefVo(new Integer(bean.getTGroup().getId()), bean.getTGroup().getVersion());
		this.tsite = bean.getTSite() == null ? null : new ims.oncology.configuration.vo.TumourSiteRefVo(new Integer(bean.getTSite().getId()), bean.getTSite().getVersion());
		this.tval = bean.getTVal() == null ? null : bean.getTVal().buildVo(map);
		this.nval = bean.getNVal() == null ? null : bean.getNVal().buildVo(map);
		this.mval = bean.getMVal() == null ? null : bean.getMVal().buildVo(map);
		this.histval = bean.getHistVal() == null ? null : bean.getHistVal().buildVo(map);
		this.serummarkerval = bean.getSerumMarkerVal() == null ? null : bean.getSerumMarkerVal().buildVo(map);
		this.diffval = bean.getDiffVal() == null ? null : bean.getDiffVal().buildVo(map);
		this.issaved = bean.getIsSaved();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinicaladmin.vo.beans.TumourGroupSiteOverallStagingVoBean bean = null;
		if(map != null)
			bean = (ims.clinicaladmin.vo.beans.TumourGroupSiteOverallStagingVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinicaladmin.vo.beans.TumourGroupSiteOverallStagingVoBean();
			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("TGROUP"))
			return getTGroup();
		if(fieldName.equals("TSITE"))
			return getTSite();
		if(fieldName.equals("TVAL"))
			return getTVal();
		if(fieldName.equals("NVAL"))
			return getNVal();
		if(fieldName.equals("MVAL"))
			return getMVal();
		if(fieldName.equals("HISTVAL"))
			return getHistVal();
		if(fieldName.equals("SERUMMARKERVAL"))
			return getSerumMarkerVal();
		if(fieldName.equals("DIFFVAL"))
			return getDiffVal();
		if(fieldName.equals("ISSAVED"))
			return getIsSaved();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTGroupIsNotNull()
	{
		return this.tgroup != null;
	}
	public ims.oncology.configuration.vo.TumourGroupRefVo getTGroup()
	{
		return this.tgroup;
	}
	public void setTGroup(ims.oncology.configuration.vo.TumourGroupRefVo value)
	{
		this.isValidated = false;
		this.tgroup = value;
	}
	public boolean getTSiteIsNotNull()
	{
		return this.tsite != null;
	}
	public ims.oncology.configuration.vo.TumourSiteRefVo getTSite()
	{
		return this.tsite;
	}
	public void setTSite(ims.oncology.configuration.vo.TumourSiteRefVo value)
	{
		this.isValidated = false;
		this.tsite = value;
	}
	public boolean getTValIsNotNull()
	{
		return this.tval != null;
	}
	public ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo getTVal()
	{
		return this.tval;
	}
	public void setTVal(ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo value)
	{
		this.isValidated = false;
		this.tval = value;
	}
	public boolean getNValIsNotNull()
	{
		return this.nval != null;
	}
	public ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo getNVal()
	{
		return this.nval;
	}
	public void setNVal(ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo value)
	{
		this.isValidated = false;
		this.nval = value;
	}
	public boolean getMValIsNotNull()
	{
		return this.mval != null;
	}
	public ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo getMVal()
	{
		return this.mval;
	}
	public void setMVal(ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo value)
	{
		this.isValidated = false;
		this.mval = value;
	}
	public boolean getHistValIsNotNull()
	{
		return this.histval != null;
	}
	public ims.clinicaladmin.vo.TumourGroupHistologyVo getHistVal()
	{
		return this.histval;
	}
	public void setHistVal(ims.clinicaladmin.vo.TumourGroupHistologyVo value)
	{
		this.isValidated = false;
		this.histval = value;
	}
	public boolean getSerumMarkerValIsNotNull()
	{
		return this.serummarkerval != null;
	}
	public ims.clinicaladmin.vo.TumourSerumMarkersLiteVo getSerumMarkerVal()
	{
		return this.serummarkerval;
	}
	public void setSerumMarkerVal(ims.clinicaladmin.vo.TumourSerumMarkersLiteVo value)
	{
		this.isValidated = false;
		this.serummarkerval = value;
	}
	public boolean getDiffValIsNotNull()
	{
		return this.diffval != null;
	}
	public ims.clinicaladmin.vo.TumourGroupHistopathologyGradeVo getDiffVal()
	{
		return this.diffval;
	}
	public void setDiffVal(ims.clinicaladmin.vo.TumourGroupHistopathologyGradeVo value)
	{
		this.isValidated = false;
		this.diffval = value;
	}
	public boolean getIsSavedIsNotNull()
	{
		return this.issaved != null;
	}
	public Boolean getIsSaved()
	{
		return this.issaved;
	}
	public void setIsSaved(Boolean value)
	{
		this.isValidated = false;
		this.issaved = value;
	}
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		if(this.overallstagedescription != null)
			sb.append(this.overallstagedescription);
		return sb.toString();
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.tval != null)
		{
			if(!this.tval.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.nval != null)
		{
			if(!this.nval.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.mval != null)
		{
			if(!this.mval.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.histval != null)
		{
			if(!this.histval.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.serummarkerval != null)
		{
			if(!this.serummarkerval.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.diffval != null)
		{
			if(!this.diffval.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.overallstagedescription == null)
			listOfErrors.add("Overall Staging Value is mandatory");
		if(this.o45 != null)
			if(this.o45.length() > 1)
				listOfErrors.add("The length of the field [o45] in the value object [ims.clinicaladmin.vo.TumourGroupSiteOverallStagingVo] is too big. It should be less or equal to 1");
		if(this.tval == null)
			listOfErrors.add("TVal is mandatory");
		if(this.tval != null)
		{
			String[] listOfOtherErrors = this.tval.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.nval == null)
			listOfErrors.add("NVal is mandatory");
		if(this.nval != null)
		{
			String[] listOfOtherErrors = this.nval.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.mval == null)
			listOfErrors.add("MVal is mandatory");
		if(this.mval != null)
		{
			String[] listOfOtherErrors = this.mval.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.histval != null)
		{
			String[] listOfOtherErrors = this.histval.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.serummarkerval != null)
		{
			String[] listOfOtherErrors = this.serummarkerval.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.diffval != null)
		{
			String[] listOfOtherErrors = this.diffval.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 void clearIDAndVersion()
	{
		this.id = null;
		this.version = 0;
	}
	public Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		TumourGroupSiteOverallStagingVo clone = new TumourGroupSiteOverallStagingVo(this.id, this.version);
		
		if(this.overallstagedescription == null)
			clone.overallstagedescription = null;
		else
			clone.overallstagedescription = (ims.oncology.vo.lookups.TumourOverallStage)this.overallstagedescription.clone();
		clone.isactive = this.isactive;
		clone.o45 = this.o45;
		clone.tgroup = this.tgroup;
		clone.tsite = this.tsite;
		if(this.tval == null)
			clone.tval = null;
		else
			clone.tval = (ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo)this.tval.clone();
		if(this.nval == null)
			clone.nval = null;
		else
			clone.nval = (ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo)this.nval.clone();
		if(this.mval == null)
			clone.mval = null;
		else
			clone.mval = (ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo)this.mval.clone();
		if(this.histval == null)
			clone.histval = null;
		else
			clone.histval = (ims.clinicaladmin.vo.TumourGroupHistologyVo)this.histval.clone();
		if(this.serummarkerval == null)
			clone.serummarkerval = null;
		else
			clone.serummarkerval = (ims.clinicaladmin.vo.TumourSerumMarkersLiteVo)this.serummarkerval.clone();
		if(this.diffval == null)
			clone.diffval = null;
		else
			clone.diffval = (ims.clinicaladmin.vo.TumourGroupHistopathologyGradeVo)this.diffval.clone();
		clone.issaved = this.issaved;
		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 (!(TumourGroupSiteOverallStagingVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A TumourGroupSiteOverallStagingVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((TumourGroupSiteOverallStagingVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((TumourGroupSiteOverallStagingVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.tgroup != null)
			count++;
		if(this.tsite != null)
			count++;
		if(this.tval != null)
			count++;
		if(this.nval != null)
			count++;
		if(this.mval != null)
			count++;
		if(this.histval != null)
			count++;
		if(this.serummarkerval != null)
			count++;
		if(this.diffval != null)
			count++;
		if(this.issaved != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 9;
	}
	protected ims.oncology.configuration.vo.TumourGroupRefVo tgroup;
	protected ims.oncology.configuration.vo.TumourSiteRefVo tsite;
	protected ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo tval;
	protected ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo nval;
	protected ims.clinicaladmin.vo.TumourGroupSiteTNMValueListVo mval;
	protected ims.clinicaladmin.vo.TumourGroupHistologyVo histval;
	protected ims.clinicaladmin.vo.TumourSerumMarkersLiteVo serummarkerval;
	protected ims.clinicaladmin.vo.TumourGroupHistopathologyGradeVo diffval;
	protected Boolean issaved;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
