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

/**
 * Linked to clinical.LaserDetailIntraOp business object (ID: 1072100139).
 */
public class LaserDetailIntraOpVo extends ims.clinical.vo.LaserDetailIntraOpRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public LaserDetailIntraOpVo()
	{
	}
	public LaserDetailIntraOpVo(Integer id, int version)
	{
		super(id, version);
	}
	public LaserDetailIntraOpVo(ims.clinical.vo.beans.LaserDetailIntraOpVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.theatreappointment = bean.getTheatreAppointment() == null ? null : new ims.scheduling.vo.Booking_AppointmentRefVo(new Integer(bean.getTheatreAppointment().getId()), bean.getTheatreAppointment().getVersion());
		this.devicename = bean.getDeviceName() == null ? null : ims.core.vo.lookups.LaserDeviceName.buildLookup(bean.getDeviceName());
		this.deviceserialnumber = bean.getDeviceSerialNumber() == null ? null : ims.core.vo.lookups.LaserDeviceSerialNumber.buildLookup(bean.getDeviceSerialNumber());
		this.laserfibrelotnumber = bean.getLaserFibreLotNumber();
		this.lasermode = bean.getLaserMode() == null ? null : ims.core.vo.lookups.LaserMode.buildLookup(bean.getLaserMode());
		this.power = bean.getPower();
		this.totaldurationseconds = bean.getTotalDurationSeconds();
		this.numberofburns = bean.getNumberOfBurns();
		this.laseroperator = bean.getLaserOperator() == null ? null : bean.getLaserOperator().buildVo();
		this.patientsafetymeasures = ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection.buildFromBeanCollection(bean.getPatientSafetyMeasures());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.LaserDetailIntraOpVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.theatreappointment = bean.getTheatreAppointment() == null ? null : new ims.scheduling.vo.Booking_AppointmentRefVo(new Integer(bean.getTheatreAppointment().getId()), bean.getTheatreAppointment().getVersion());
		this.devicename = bean.getDeviceName() == null ? null : ims.core.vo.lookups.LaserDeviceName.buildLookup(bean.getDeviceName());
		this.deviceserialnumber = bean.getDeviceSerialNumber() == null ? null : ims.core.vo.lookups.LaserDeviceSerialNumber.buildLookup(bean.getDeviceSerialNumber());
		this.laserfibrelotnumber = bean.getLaserFibreLotNumber();
		this.lasermode = bean.getLaserMode() == null ? null : ims.core.vo.lookups.LaserMode.buildLookup(bean.getLaserMode());
		this.power = bean.getPower();
		this.totaldurationseconds = bean.getTotalDurationSeconds();
		this.numberofburns = bean.getNumberOfBurns();
		this.laseroperator = bean.getLaserOperator() == null ? null : bean.getLaserOperator().buildVo(map);
		this.patientsafetymeasures = ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection.buildFromBeanCollection(bean.getPatientSafetyMeasures());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.LaserDetailIntraOpVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.LaserDetailIntraOpVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.LaserDetailIntraOpVoBean();
			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("THEATREAPPOINTMENT"))
			return getTheatreAppointment();
		if(fieldName.equals("DEVICENAME"))
			return getDeviceName();
		if(fieldName.equals("DEVICESERIALNUMBER"))
			return getDeviceSerialNumber();
		if(fieldName.equals("LASERFIBRELOTNUMBER"))
			return getLaserFibreLotNumber();
		if(fieldName.equals("LASERMODE"))
			return getLaserMode();
		if(fieldName.equals("POWER"))
			return getPower();
		if(fieldName.equals("TOTALDURATIONSECONDS"))
			return getTotalDurationSeconds();
		if(fieldName.equals("NUMBEROFBURNS"))
			return getNumberOfBurns();
		if(fieldName.equals("LASEROPERATOR"))
			return getLaserOperator();
		if(fieldName.equals("PATIENTSAFETYMEASURES"))
			return getPatientSafetyMeasures();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTheatreAppointmentIsNotNull()
	{
		return this.theatreappointment != null;
	}
	public ims.scheduling.vo.Booking_AppointmentRefVo getTheatreAppointment()
	{
		return this.theatreappointment;
	}
	public void setTheatreAppointment(ims.scheduling.vo.Booking_AppointmentRefVo value)
	{
		this.isValidated = false;
		this.theatreappointment = value;
	}
	public boolean getDeviceNameIsNotNull()
	{
		return this.devicename != null;
	}
	public ims.core.vo.lookups.LaserDeviceName getDeviceName()
	{
		return this.devicename;
	}
	public void setDeviceName(ims.core.vo.lookups.LaserDeviceName value)
	{
		this.isValidated = false;
		this.devicename = value;
	}
	public boolean getDeviceSerialNumberIsNotNull()
	{
		return this.deviceserialnumber != null;
	}
	public ims.core.vo.lookups.LaserDeviceSerialNumber getDeviceSerialNumber()
	{
		return this.deviceserialnumber;
	}
	public void setDeviceSerialNumber(ims.core.vo.lookups.LaserDeviceSerialNumber value)
	{
		this.isValidated = false;
		this.deviceserialnumber = value;
	}
	public boolean getLaserFibreLotNumberIsNotNull()
	{
		return this.laserfibrelotnumber != null;
	}
	public String getLaserFibreLotNumber()
	{
		return this.laserfibrelotnumber;
	}
	public static int getLaserFibreLotNumberMaxLength()
	{
		return 75;
	}
	public void setLaserFibreLotNumber(String value)
	{
		this.isValidated = false;
		this.laserfibrelotnumber = value;
	}
	public boolean getLaserModeIsNotNull()
	{
		return this.lasermode != null;
	}
	public ims.core.vo.lookups.LaserMode getLaserMode()
	{
		return this.lasermode;
	}
	public void setLaserMode(ims.core.vo.lookups.LaserMode value)
	{
		this.isValidated = false;
		this.lasermode = value;
	}
	public boolean getPowerIsNotNull()
	{
		return this.power != null;
	}
	public Float getPower()
	{
		return this.power;
	}
	public void setPower(Float value)
	{
		this.isValidated = false;
		this.power = value;
	}
	public boolean getTotalDurationSecondsIsNotNull()
	{
		return this.totaldurationseconds != null;
	}
	public Integer getTotalDurationSeconds()
	{
		return this.totaldurationseconds;
	}
	public void setTotalDurationSeconds(Integer value)
	{
		this.isValidated = false;
		this.totaldurationseconds = value;
	}
	public boolean getNumberOfBurnsIsNotNull()
	{
		return this.numberofburns != null;
	}
	public Integer getNumberOfBurns()
	{
		return this.numberofburns;
	}
	public void setNumberOfBurns(Integer value)
	{
		this.isValidated = false;
		this.numberofburns = value;
	}
	public boolean getLaserOperatorIsNotNull()
	{
		return this.laseroperator != null;
	}
	public ims.core.vo.HcpLiteVo getLaserOperator()
	{
		return this.laseroperator;
	}
	public void setLaserOperator(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.laseroperator = value;
	}
	public boolean getPatientSafetyMeasuresIsNotNull()
	{
		return this.patientsafetymeasures != null;
	}
	public ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection getPatientSafetyMeasures()
	{
		return this.patientsafetymeasures;
	}
	public void setPatientSafetyMeasures(ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection value)
	{
		this.isValidated = false;
		this.patientsafetymeasures = 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.theatreappointment == null)
			listOfErrors.add("TheatreAppointment is mandatory");
		if(this.devicename == null)
			listOfErrors.add("Device Name is mandatory");
		if(this.deviceserialnumber == null)
			listOfErrors.add("Device Serial Number is mandatory");
		if(this.laserfibrelotnumber == null || this.laserfibrelotnumber.length() == 0)
			listOfErrors.add("Laser Fibre Lot is mandatory");
		else if(this.laserfibrelotnumber.length() > 75)
			listOfErrors.add("The length of the field [laserfibrelotnumber] in the value object [ims.clinical.vo.LaserDetailIntraOpVo] is too big. It should be less or equal to 75");
		if(this.lasermode == null)
			listOfErrors.add("Laser is mandatory");
		if(this.power == null)
			listOfErrors.add("Power is mandatory");
		if(this.totaldurationseconds == null)
			listOfErrors.add("Total Duration is mandatory");
		if(this.numberofburns == null)
			listOfErrors.add("Number Of Burns is mandatory");
		if(this.laseroperator == null)
			listOfErrors.add("Laser Operator is mandatory");
		if(this.patientsafetymeasures == null || this.patientsafetymeasures.size() == 0)
			listOfErrors.add("Patient Safety Measures 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;
	
		LaserDetailIntraOpVo clone = new LaserDetailIntraOpVo(this.id, this.version);
		
		clone.theatreappointment = this.theatreappointment;
		if(this.devicename == null)
			clone.devicename = null;
		else
			clone.devicename = (ims.core.vo.lookups.LaserDeviceName)this.devicename.clone();
		if(this.deviceserialnumber == null)
			clone.deviceserialnumber = null;
		else
			clone.deviceserialnumber = (ims.core.vo.lookups.LaserDeviceSerialNumber)this.deviceserialnumber.clone();
		clone.laserfibrelotnumber = this.laserfibrelotnumber;
		if(this.lasermode == null)
			clone.lasermode = null;
		else
			clone.lasermode = (ims.core.vo.lookups.LaserMode)this.lasermode.clone();
		clone.power = this.power;
		clone.totaldurationseconds = this.totaldurationseconds;
		clone.numberofburns = this.numberofburns;
		if(this.laseroperator == null)
			clone.laseroperator = null;
		else
			clone.laseroperator = (ims.core.vo.HcpLiteVo)this.laseroperator.clone();
		if(this.patientsafetymeasures == null)
			clone.patientsafetymeasures = null;
		else
			clone.patientsafetymeasures = (ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection)this.patientsafetymeasures.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 (!(LaserDetailIntraOpVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A LaserDetailIntraOpVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((LaserDetailIntraOpVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((LaserDetailIntraOpVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.theatreappointment != null)
			count++;
		if(this.devicename != null)
			count++;
		if(this.deviceserialnumber != null)
			count++;
		if(this.laserfibrelotnumber != null)
			count++;
		if(this.lasermode != null)
			count++;
		if(this.power != null)
			count++;
		if(this.totaldurationseconds != null)
			count++;
		if(this.numberofburns != null)
			count++;
		if(this.laseroperator != null)
			count++;
		if(this.patientsafetymeasures != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 10;
	}
	protected ims.scheduling.vo.Booking_AppointmentRefVo theatreappointment;
	protected ims.core.vo.lookups.LaserDeviceName devicename;
	protected ims.core.vo.lookups.LaserDeviceSerialNumber deviceserialnumber;
	protected String laserfibrelotnumber;
	protected ims.core.vo.lookups.LaserMode lasermode;
	protected Float power;
	protected Integer totaldurationseconds;
	protected Integer numberofburns;
	protected ims.core.vo.HcpLiteVo laseroperator;
	protected ims.core.vo.lookups.LaserPatientSafetyMeasuresCollection patientsafetymeasures;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
