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

/**
 * Linked to spinalinjuries.Shared.RespExamDetails business object (ID: 1024100006).
 */
public class RespExam extends ims.spinalinjuries.shared.vo.RespExamDetailsRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public RespExam()
	{
	}
	public RespExam(Integer id, int version)
	{
		super(id, version);
	}
	public RespExam(ims.spinalinjuries.vo.beans.RespExamBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.airentry = bean.getAirEntry();
		this.additionalfactors = bean.getAdditionalFactors();
		this.analysisofasses = bean.getAnalysisofAsses();
		this.assnotes = bean.getAssNotes();
		this.respexamobs = bean.getRespExamObs() == null ? null : bean.getRespExamObs().buildVo();
		this.respexamausc = bean.getRespExamAusc() == null ? null : bean.getRespExamAusc().buildVo();
		this.respexamlungf = bean.getRespExamLungF() == null ? null : bean.getRespExamLungF().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.spinalinjuries.vo.beans.RespExamBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.airentry = bean.getAirEntry();
		this.additionalfactors = bean.getAdditionalFactors();
		this.analysisofasses = bean.getAnalysisofAsses();
		this.assnotes = bean.getAssNotes();
		this.respexamobs = bean.getRespExamObs() == null ? null : bean.getRespExamObs().buildVo(map);
		this.respexamausc = bean.getRespExamAusc() == null ? null : bean.getRespExamAusc().buildVo(map);
		this.respexamlungf = bean.getRespExamLungF() == null ? null : bean.getRespExamLungF().buildVo(map);
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.spinalinjuries.vo.beans.RespExamBean bean = null;
		if(map != null)
			bean = (ims.spinalinjuries.vo.beans.RespExamBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.spinalinjuries.vo.beans.RespExamBean();
			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("AIRENTRY"))
			return getAirEntry();
		if(fieldName.equals("ADDITIONALFACTORS"))
			return getAdditionalFactors();
		if(fieldName.equals("ANALYSISOFASSES"))
			return getAnalysisofAsses();
		if(fieldName.equals("ASSNOTES"))
			return getAssNotes();
		if(fieldName.equals("RESPEXAMOBS"))
			return getRespExamObs();
		if(fieldName.equals("RESPEXAMAUSC"))
			return getRespExamAusc();
		if(fieldName.equals("RESPEXAMLUNGF"))
			return getRespExamLungF();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getAirEntryIsNotNull()
	{
		return this.airentry != null;
	}
	public Boolean getAirEntry()
	{
		return this.airentry;
	}
	public void setAirEntry(Boolean value)
	{
		this.isValidated = false;
		this.airentry = value;
	}
	public boolean getAdditionalFactorsIsNotNull()
	{
		return this.additionalfactors != null;
	}
	public String getAdditionalFactors()
	{
		return this.additionalfactors;
	}
	public static int getAdditionalFactorsMaxLength()
	{
		return 500;
	}
	public void setAdditionalFactors(String value)
	{
		this.isValidated = false;
		this.additionalfactors = value;
	}
	public boolean getAnalysisofAssesIsNotNull()
	{
		return this.analysisofasses != null;
	}
	public String getAnalysisofAsses()
	{
		return this.analysisofasses;
	}
	public static int getAnalysisofAssesMaxLength()
	{
		return 500;
	}
	public void setAnalysisofAsses(String value)
	{
		this.isValidated = false;
		this.analysisofasses = value;
	}
	public boolean getAssNotesIsNotNull()
	{
		return this.assnotes != null;
	}
	public String getAssNotes()
	{
		return this.assnotes;
	}
	public static int getAssNotesMaxLength()
	{
		return 500;
	}
	public void setAssNotes(String value)
	{
		this.isValidated = false;
		this.assnotes = value;
	}
	public boolean getRespExamObsIsNotNull()
	{
		return this.respexamobs != null;
	}
	public ims.spinalinjuries.vo.RespExamObs getRespExamObs()
	{
		return this.respexamobs;
	}
	public void setRespExamObs(ims.spinalinjuries.vo.RespExamObs value)
	{
		this.isValidated = false;
		this.respexamobs = value;
	}
	public boolean getRespExamAuscIsNotNull()
	{
		return this.respexamausc != null;
	}
	public ims.spinalinjuries.vo.RespExamAusc getRespExamAusc()
	{
		return this.respexamausc;
	}
	public void setRespExamAusc(ims.spinalinjuries.vo.RespExamAusc value)
	{
		this.isValidated = false;
		this.respexamausc = value;
	}
	public boolean getRespExamLungFIsNotNull()
	{
		return this.respexamlungf != null;
	}
	public ims.spinalinjuries.vo.RespExamLungF getRespExamLungF()
	{
		return this.respexamlungf;
	}
	public void setRespExamLungF(ims.spinalinjuries.vo.RespExamLungF value)
	{
		this.isValidated = false;
		this.respexamlungf = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.respexamobs != null)
		{
			if(!this.respexamobs.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.respexamausc != null)
		{
			if(!this.respexamausc.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.respexamlungf != null)
		{
			if(!this.respexamlungf.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.additionalfactors != null)
			if(this.additionalfactors.length() > 500)
				listOfErrors.add("The length of the field [additionalfactors] in the value object [ims.spinalinjuries.vo.RespExam] is too big. It should be less or equal to 500");
		if(this.analysisofasses != null)
			if(this.analysisofasses.length() > 500)
				listOfErrors.add("The length of the field [analysisofasses] in the value object [ims.spinalinjuries.vo.RespExam] is too big. It should be less or equal to 500");
		if(this.assnotes != null)
			if(this.assnotes.length() > 500)
				listOfErrors.add("The length of the field [assnotes] in the value object [ims.spinalinjuries.vo.RespExam] is too big. It should be less or equal to 500");
		if(this.respexamobs != null)
		{
			String[] listOfOtherErrors = this.respexamobs.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.respexamausc != null)
		{
			String[] listOfOtherErrors = this.respexamausc.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.respexamlungf != null)
		{
			String[] listOfOtherErrors = this.respexamlungf.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;
	
		RespExam clone = new RespExam(this.id, this.version);
		
		clone.airentry = this.airentry;
		clone.additionalfactors = this.additionalfactors;
		clone.analysisofasses = this.analysisofasses;
		clone.assnotes = this.assnotes;
		if(this.respexamobs == null)
			clone.respexamobs = null;
		else
			clone.respexamobs = (ims.spinalinjuries.vo.RespExamObs)this.respexamobs.clone();
		if(this.respexamausc == null)
			clone.respexamausc = null;
		else
			clone.respexamausc = (ims.spinalinjuries.vo.RespExamAusc)this.respexamausc.clone();
		if(this.respexamlungf == null)
			clone.respexamlungf = null;
		else
			clone.respexamlungf = (ims.spinalinjuries.vo.RespExamLungF)this.respexamlungf.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 (!(RespExam.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A RespExam object cannot be compared an Object of type " + obj.getClass().getName());
		}
		RespExam compareObj = (RespExam)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_RespExamDetails() == null && compareObj.getID_RespExamDetails() != null)
				return -1;
			if(this.getID_RespExamDetails() != null && compareObj.getID_RespExamDetails() == null)
				return 1;
			if(this.getID_RespExamDetails() != null && compareObj.getID_RespExamDetails() != null)
				retVal = this.getID_RespExamDetails().compareTo(compareObj.getID_RespExamDetails());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.airentry != null)
			count++;
		if(this.additionalfactors != null)
			count++;
		if(this.analysisofasses != null)
			count++;
		if(this.assnotes != null)
			count++;
		if(this.respexamobs != null)
			count++;
		if(this.respexamausc != null)
			count++;
		if(this.respexamlungf != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected Boolean airentry;
	protected String additionalfactors;
	protected String analysisofasses;
	protected String assnotes;
	protected ims.spinalinjuries.vo.RespExamObs respexamobs;
	protected ims.spinalinjuries.vo.RespExamAusc respexamausc;
	protected ims.spinalinjuries.vo.RespExamLungF respexamlungf;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
