/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/therapies/vo/ElectrotherapyPneumaticTreatmentVo.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.ElectrotherapyPneumaticTreatment business object (ID: 1019100025).
 */
public class ElectrotherapyPneumaticTreatmentVo extends ims.therapies.treatment.vo.ElectrotherapyPneumaticTreatmentRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ElectrotherapyPneumaticTreatmentVo()
	{
	}
	public ElectrotherapyPneumaticTreatmentVo(Integer id, int version)
	{
		super(id, version);
	}
	public ElectrotherapyPneumaticTreatmentVo(ims.therapies.vo.beans.ElectrotherapyPneumaticTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.machineused = bean.getMachineUsed() == null ? null : bean.getMachineUsed().buildVo();
		this.startingposition = bean.getStartingPosition() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticStartingPos.buildLookup(bean.getStartingPosition());
		this.laterality = bean.getLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getLaterality());
		this.area = bean.getArea() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticArea.buildLookup(bean.getArea());
		this.splints = bean.getSplints() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticSplints.buildLookup(bean.getSplints());
		this.cycle = bean.getCycle() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticCycle.buildLookup(bean.getCycle());
		this.duration = bean.getDuration();
		this.pressure = bean.getPressure();
		this.minpressure = bean.getMinPressure();
		this.maxpressure = bean.getMaxPressure();
		this.inflation = bean.getInflation();
		this.resttime = bean.getRestTime();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.therapies.vo.beans.ElectrotherapyPneumaticTreatmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.machineused = bean.getMachineUsed() == null ? null : bean.getMachineUsed().buildVo(map);
		this.startingposition = bean.getStartingPosition() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticStartingPos.buildLookup(bean.getStartingPosition());
		this.laterality = bean.getLaterality() == null ? null : ims.core.vo.lookups.LateralityLRB.buildLookup(bean.getLaterality());
		this.area = bean.getArea() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticArea.buildLookup(bean.getArea());
		this.splints = bean.getSplints() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticSplints.buildLookup(bean.getSplints());
		this.cycle = bean.getCycle() == null ? null : ims.spinalinjuries.vo.lookups.PneumaticCycle.buildLookup(bean.getCycle());
		this.duration = bean.getDuration();
		this.pressure = bean.getPressure();
		this.minpressure = bean.getMinPressure();
		this.maxpressure = bean.getMaxPressure();
		this.inflation = bean.getInflation();
		this.resttime = bean.getRestTime();
	}
	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.ElectrotherapyPneumaticTreatmentVoBean bean = null;
		if(map != null)
			bean = (ims.therapies.vo.beans.ElectrotherapyPneumaticTreatmentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.therapies.vo.beans.ElectrotherapyPneumaticTreatmentVoBean();
			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("MACHINEUSED"))
			return getMachineUsed();
		if(fieldName.equals("STARTINGPOSITION"))
			return getStartingPosition();
		if(fieldName.equals("LATERALITY"))
			return getLaterality();
		if(fieldName.equals("AREA"))
			return getArea();
		if(fieldName.equals("SPLINTS"))
			return getSplints();
		if(fieldName.equals("CYCLE"))
			return getCycle();
		if(fieldName.equals("DURATION"))
			return getDuration();
		if(fieldName.equals("PRESSURE"))
			return getPressure();
		if(fieldName.equals("MINPRESSURE"))
			return getMinPressure();
		if(fieldName.equals("MAXPRESSURE"))
			return getMaxPressure();
		if(fieldName.equals("INFLATION"))
			return getInflation();
		if(fieldName.equals("RESTTIME"))
			return getRestTime();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getMachineUsedIsNotNull()
	{
		return this.machineused != null;
	}
	public ims.therapies.vo.TreatmentEquipmentConfigVo getMachineUsed()
	{
		return this.machineused;
	}
	public void setMachineUsed(ims.therapies.vo.TreatmentEquipmentConfigVo value)
	{
		this.isValidated = false;
		this.machineused = value;
	}
	public boolean getStartingPositionIsNotNull()
	{
		return this.startingposition != null;
	}
	public ims.spinalinjuries.vo.lookups.PneumaticStartingPos getStartingPosition()
	{
		return this.startingposition;
	}
	public void setStartingPosition(ims.spinalinjuries.vo.lookups.PneumaticStartingPos value)
	{
		this.isValidated = false;
		this.startingposition = value;
	}
	public boolean getLateralityIsNotNull()
	{
		return this.laterality != null;
	}
	public ims.core.vo.lookups.LateralityLRB getLaterality()
	{
		return this.laterality;
	}
	public void setLaterality(ims.core.vo.lookups.LateralityLRB value)
	{
		this.isValidated = false;
		this.laterality = value;
	}
	public boolean getAreaIsNotNull()
	{
		return this.area != null;
	}
	public ims.spinalinjuries.vo.lookups.PneumaticArea getArea()
	{
		return this.area;
	}
	public void setArea(ims.spinalinjuries.vo.lookups.PneumaticArea value)
	{
		this.isValidated = false;
		this.area = value;
	}
	public boolean getSplintsIsNotNull()
	{
		return this.splints != null;
	}
	public ims.spinalinjuries.vo.lookups.PneumaticSplints getSplints()
	{
		return this.splints;
	}
	public void setSplints(ims.spinalinjuries.vo.lookups.PneumaticSplints value)
	{
		this.isValidated = false;
		this.splints = value;
	}
	public boolean getCycleIsNotNull()
	{
		return this.cycle != null;
	}
	public ims.spinalinjuries.vo.lookups.PneumaticCycle getCycle()
	{
		return this.cycle;
	}
	public void setCycle(ims.spinalinjuries.vo.lookups.PneumaticCycle value)
	{
		this.isValidated = false;
		this.cycle = value;
	}
	public boolean getDurationIsNotNull()
	{
		return this.duration != null;
	}
	public Integer getDuration()
	{
		return this.duration;
	}
	public void setDuration(Integer value)
	{
		this.isValidated = false;
		this.duration = value;
	}
	public boolean getPressureIsNotNull()
	{
		return this.pressure != null;
	}
	public Integer getPressure()
	{
		return this.pressure;
	}
	public void setPressure(Integer value)
	{
		this.isValidated = false;
		this.pressure = value;
	}
	public boolean getMinPressureIsNotNull()
	{
		return this.minpressure != null;
	}
	public Integer getMinPressure()
	{
		return this.minpressure;
	}
	public void setMinPressure(Integer value)
	{
		this.isValidated = false;
		this.minpressure = value;
	}
	public boolean getMaxPressureIsNotNull()
	{
		return this.maxpressure != null;
	}
	public Integer getMaxPressure()
	{
		return this.maxpressure;
	}
	public void setMaxPressure(Integer value)
	{
		this.isValidated = false;
		this.maxpressure = value;
	}
	public boolean getInflationIsNotNull()
	{
		return this.inflation != null;
	}
	public Integer getInflation()
	{
		return this.inflation;
	}
	public void setInflation(Integer value)
	{
		this.isValidated = false;
		this.inflation = value;
	}
	public boolean getRestTimeIsNotNull()
	{
		return this.resttime != null;
	}
	public Integer getRestTime()
	{
		return this.resttime;
	}
	public void setRestTime(Integer value)
	{
		this.isValidated = false;
		this.resttime = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.machineused != null)
		{
			if(!this.machineused.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.machineused == null)
			listOfErrors.add("MachineUsed is mandatory");
		if(this.machineused != null)
		{
			String[] listOfOtherErrors = this.machineused.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.startingposition == null)
			listOfErrors.add("StartingPosition is mandatory");
		if(this.cycle == null)
			listOfErrors.add("Cycle is mandatory");
		if(this.duration == null)
			listOfErrors.add("Duration 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;
	
		ElectrotherapyPneumaticTreatmentVo clone = new ElectrotherapyPneumaticTreatmentVo(this.id, this.version);
		
		if(this.machineused == null)
			clone.machineused = null;
		else
			clone.machineused = (ims.therapies.vo.TreatmentEquipmentConfigVo)this.machineused.clone();
		if(this.startingposition == null)
			clone.startingposition = null;
		else
			clone.startingposition = (ims.spinalinjuries.vo.lookups.PneumaticStartingPos)this.startingposition.clone();
		if(this.laterality == null)
			clone.laterality = null;
		else
			clone.laterality = (ims.core.vo.lookups.LateralityLRB)this.laterality.clone();
		if(this.area == null)
			clone.area = null;
		else
			clone.area = (ims.spinalinjuries.vo.lookups.PneumaticArea)this.area.clone();
		if(this.splints == null)
			clone.splints = null;
		else
			clone.splints = (ims.spinalinjuries.vo.lookups.PneumaticSplints)this.splints.clone();
		if(this.cycle == null)
			clone.cycle = null;
		else
			clone.cycle = (ims.spinalinjuries.vo.lookups.PneumaticCycle)this.cycle.clone();
		clone.duration = this.duration;
		clone.pressure = this.pressure;
		clone.minpressure = this.minpressure;
		clone.maxpressure = this.maxpressure;
		clone.inflation = this.inflation;
		clone.resttime = this.resttime;
		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 (!(ElectrotherapyPneumaticTreatmentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ElectrotherapyPneumaticTreatmentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ElectrotherapyPneumaticTreatmentVo compareObj = (ElectrotherapyPneumaticTreatmentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_ElectrotherapyPneumaticTreatment() == null && compareObj.getID_ElectrotherapyPneumaticTreatment() != null)
				return -1;
			if(this.getID_ElectrotherapyPneumaticTreatment() != null && compareObj.getID_ElectrotherapyPneumaticTreatment() == null)
				return 1;
			if(this.getID_ElectrotherapyPneumaticTreatment() != null && compareObj.getID_ElectrotherapyPneumaticTreatment() != null)
				retVal = this.getID_ElectrotherapyPneumaticTreatment().compareTo(compareObj.getID_ElectrotherapyPneumaticTreatment());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.machineused != null)
			count++;
		if(this.startingposition != null)
			count++;
		if(this.laterality != null)
			count++;
		if(this.area != null)
			count++;
		if(this.splints != null)
			count++;
		if(this.cycle != null)
			count++;
		if(this.duration != null)
			count++;
		if(this.pressure != null)
			count++;
		if(this.minpressure != null)
			count++;
		if(this.maxpressure != null)
			count++;
		if(this.inflation != null)
			count++;
		if(this.resttime != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 12;
	}
	protected ims.therapies.vo.TreatmentEquipmentConfigVo machineused;
	protected ims.spinalinjuries.vo.lookups.PneumaticStartingPos startingposition;
	protected ims.core.vo.lookups.LateralityLRB laterality;
	protected ims.spinalinjuries.vo.lookups.PneumaticArea area;
	protected ims.spinalinjuries.vo.lookups.PneumaticSplints splints;
	protected ims.spinalinjuries.vo.lookups.PneumaticCycle cycle;
	protected Integer duration;
	protected Integer pressure;
	protected Integer minpressure;
	protected Integer maxpressure;
	protected Integer inflation;
	protected Integer resttime;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
