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

/**
 * Linked to therapies.treatment.GaitTreatment business object (ID: 1019100056).
 */
public class GaitTreatmentVo extends ims.therapies.treatment.vo.GaitTreatmentRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public GaitTreatmentVo()
	{
	}
	public GaitTreatmentVo(Integer id, int version)
	{
		super(id, version);
	}
	public GaitTreatmentVo(ims.therapies.vo.beans.GaitTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.environment = bean.getEnvironment() == null ? null : ims.spinalinjuries.vo.lookups.GaitTestEnvironment.buildLookup(bean.getEnvironment());
		this.gaittechnique = bean.getGaitTechnique() == null ? null : ims.spinalinjuries.vo.lookups.GaitTechnique.buildLookup(bean.getGaitTechnique());
		this.orthosis = bean.getOrthosis() == null ? null : ims.therapies.vo.lookups.GaitOrthosis.buildLookup(bean.getOrthosis());
		this.supervisionlevel = bean.getSupervisionLevel() == null ? null : ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel.buildLookup(bean.getSupervisionLevel());
		this.gaitpractice = bean.getGaitPractice();
		this.stairpractice = bean.getStairPractice();
		this.gaitsummary = bean.getGaitSummary();
		this.walktesttime = bean.getWalkTestTime();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.GaitTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.environment = bean.getEnvironment() == null ? null : ims.spinalinjuries.vo.lookups.GaitTestEnvironment.buildLookup(bean.getEnvironment());
		this.gaittechnique = bean.getGaitTechnique() == null ? null : ims.spinalinjuries.vo.lookups.GaitTechnique.buildLookup(bean.getGaitTechnique());
		this.orthosis = bean.getOrthosis() == null ? null : ims.therapies.vo.lookups.GaitOrthosis.buildLookup(bean.getOrthosis());
		this.supervisionlevel = bean.getSupervisionLevel() == null ? null : ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel.buildLookup(bean.getSupervisionLevel());
		this.gaitpractice = bean.getGaitPractice();
		this.stairpractice = bean.getStairPractice();
		this.gaitsummary = bean.getGaitSummary();
		this.walktesttime = bean.getWalkTestTime();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.therapies.vo.beans.GaitTreatmentVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.GaitTreatmentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.GaitTreatmentVoBean();
			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("ENVIRONMENT"))
			return getEnvironment();
		if(fieldName.equals("GAITTECHNIQUE"))
			return getGaitTechnique();
		if(fieldName.equals("ORTHOSIS"))
			return getOrthosis();
		if(fieldName.equals("SUPERVISIONLEVEL"))
			return getSupervisionLevel();
		if(fieldName.equals("GAITPRACTICE"))
			return getGaitPractice();
		if(fieldName.equals("STAIRPRACTICE"))
			return getStairPractice();
		if(fieldName.equals("GAITSUMMARY"))
			return getGaitSummary();
		if(fieldName.equals("WALKTESTTIME"))
			return getWalkTestTime();
		if(fieldName.equals("SYSINFO"))
			return getSysInfo();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getEnvironmentIsNotNull()
	{
		return this.environment != null;
	}
	public ims.spinalinjuries.vo.lookups.GaitTestEnvironment getEnvironment()
	{
		return this.environment;
	}
	public void setEnvironment(ims.spinalinjuries.vo.lookups.GaitTestEnvironment value)
	{
		this.isValidated = false;
		this.environment = value;
	}
	public boolean getGaitTechniqueIsNotNull()
	{
		return this.gaittechnique != null;
	}
	public ims.spinalinjuries.vo.lookups.GaitTechnique getGaitTechnique()
	{
		return this.gaittechnique;
	}
	public void setGaitTechnique(ims.spinalinjuries.vo.lookups.GaitTechnique value)
	{
		this.isValidated = false;
		this.gaittechnique = value;
	}
	public boolean getOrthosisIsNotNull()
	{
		return this.orthosis != null;
	}
	public ims.therapies.vo.lookups.GaitOrthosis getOrthosis()
	{
		return this.orthosis;
	}
	public void setOrthosis(ims.therapies.vo.lookups.GaitOrthosis value)
	{
		this.isValidated = false;
		this.orthosis = value;
	}
	public boolean getSupervisionLevelIsNotNull()
	{
		return this.supervisionlevel != null;
	}
	public ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel getSupervisionLevel()
	{
		return this.supervisionlevel;
	}
	public void setSupervisionLevel(ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel value)
	{
		this.isValidated = false;
		this.supervisionlevel = value;
	}
	public boolean getGaitPracticeIsNotNull()
	{
		return this.gaitpractice != null;
	}
	public String getGaitPractice()
	{
		return this.gaitpractice;
	}
	public static int getGaitPracticeMaxLength()
	{
		return 255;
	}
	public void setGaitPractice(String value)
	{
		this.isValidated = false;
		this.gaitpractice = value;
	}
	public boolean getStairPracticeIsNotNull()
	{
		return this.stairpractice != null;
	}
	public String getStairPractice()
	{
		return this.stairpractice;
	}
	public static int getStairPracticeMaxLength()
	{
		return 255;
	}
	public void setStairPractice(String value)
	{
		this.isValidated = false;
		this.stairpractice = value;
	}
	public boolean getGaitSummaryIsNotNull()
	{
		return this.gaitsummary != null;
	}
	public String getGaitSummary()
	{
		return this.gaitsummary;
	}
	public static int getGaitSummaryMaxLength()
	{
		return 255;
	}
	public void setGaitSummary(String value)
	{
		this.isValidated = false;
		this.gaitsummary = value;
	}
	public boolean getWalkTestTimeIsNotNull()
	{
		return this.walktesttime != null;
	}
	public Integer getWalkTestTime()
	{
		return this.walktesttime;
	}
	public void setWalkTestTime(Integer value)
	{
		this.isValidated = false;
		this.walktesttime = value;
	}
	public boolean getSysInfoIsNotNull()
	{
		return this.sysinfo != null;
	}
	public ims.vo.SystemInformation getSysInfo()
	{
		return this.sysinfo;
	}
	public void setSysInfo(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.sysinfo = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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.environment == null)
			listOfErrors.add("Environment is a mandatory field");
		if(this.gaitpractice != null)
			if(this.gaitpractice.length() > 255)
				listOfErrors.add("The length of the field [gaitpractice] in the value object [ims.therapies.vo.GaitTreatmentVo] is too big. It should be less or equal to 255");
		if(this.stairpractice != null)
			if(this.stairpractice.length() > 255)
				listOfErrors.add("The length of the field [stairpractice] in the value object [ims.therapies.vo.GaitTreatmentVo] is too big. It should be less or equal to 255");
		if(this.gaitsummary != null)
			if(this.gaitsummary.length() > 255)
				listOfErrors.add("The length of the field [gaitsummary] in the value object [ims.therapies.vo.GaitTreatmentVo] is too big. It should be less or equal to 255");
		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;
	
		GaitTreatmentVo clone = new GaitTreatmentVo(this.id, this.version);
		
		if(this.environment == null)
			clone.environment = null;
		else
			clone.environment = (ims.spinalinjuries.vo.lookups.GaitTestEnvironment)this.environment.clone();
		if(this.gaittechnique == null)
			clone.gaittechnique = null;
		else
			clone.gaittechnique = (ims.spinalinjuries.vo.lookups.GaitTechnique)this.gaittechnique.clone();
		if(this.orthosis == null)
			clone.orthosis = null;
		else
			clone.orthosis = (ims.therapies.vo.lookups.GaitOrthosis)this.orthosis.clone();
		if(this.supervisionlevel == null)
			clone.supervisionlevel = null;
		else
			clone.supervisionlevel = (ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel)this.supervisionlevel.clone();
		clone.gaitpractice = this.gaitpractice;
		clone.stairpractice = this.stairpractice;
		clone.gaitsummary = this.gaitsummary;
		clone.walktesttime = this.walktesttime;
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.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 (!(GaitTreatmentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A GaitTreatmentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		GaitTreatmentVo compareObj = (GaitTreatmentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getSysInfo() == null && compareObj.getSysInfo() != null)
				return -1;
			if(this.getSysInfo() != null && compareObj.getSysInfo() == null)
				return 1;
			if(this.getSysInfo() != null && compareObj.getSysInfo() != null)
				retVal = this.getSysInfo().compareTo(compareObj.getSysInfo());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.environment != null)
			count++;
		if(this.gaittechnique != null)
			count++;
		if(this.orthosis != null)
			count++;
		if(this.supervisionlevel != null)
			count++;
		if(this.gaitpractice != null)
			count++;
		if(this.stairpractice != null)
			count++;
		if(this.gaitsummary != null)
			count++;
		if(this.walktesttime != null)
			count++;
		if(this.sysinfo != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.spinalinjuries.vo.lookups.GaitTestEnvironment environment;
	protected ims.spinalinjuries.vo.lookups.GaitTechnique gaittechnique;
	protected ims.therapies.vo.lookups.GaitOrthosis orthosis;
	protected ims.spinalinjuries.vo.lookups.GaitTreatmentSupervisionLevel supervisionlevel;
	protected String gaitpractice;
	protected String stairpractice;
	protected String gaitsummary;
	protected Integer walktesttime;
	protected ims.vo.SystemInformation sysinfo;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
