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

	public CatheterDrainsTubeIntraOpVo()
	{
	}
	public CatheterDrainsTubeIntraOpVo(Integer id, int version)
	{
		super(id, version);
	}
	public CatheterDrainsTubeIntraOpVo(ims.clinical.vo.beans.CatheterDrainsTubeIntraOpVoBean 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.type = bean.getType() == null ? null : ims.clinical.vo.lookups.CatheterDrainsTube.buildLookup(bean.getType());
		this.size = bean.getSize();
		this.collectiondevice = bean.getCollectionDevice();
		this.lotnumber = bean.getLotNumber();
		this.bodysite = bean.getBodySite();
		this.insertedby = bean.getInsertedBy() == null ? null : bean.getInsertedBy().buildVo();
		this.lubricant = bean.getLubricant();
		this.volumeinballoon = bean.getVolumeInBalloon();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.CatheterDrainsTubeIntraOpVoBean 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.type = bean.getType() == null ? null : ims.clinical.vo.lookups.CatheterDrainsTube.buildLookup(bean.getType());
		this.size = bean.getSize();
		this.collectiondevice = bean.getCollectionDevice();
		this.lotnumber = bean.getLotNumber();
		this.bodysite = bean.getBodySite();
		this.insertedby = bean.getInsertedBy() == null ? null : bean.getInsertedBy().buildVo(map);
		this.lubricant = bean.getLubricant();
		this.volumeinballoon = bean.getVolumeInBalloon();
	}
	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.CatheterDrainsTubeIntraOpVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.CatheterDrainsTubeIntraOpVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.CatheterDrainsTubeIntraOpVoBean();
			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("TYPE"))
			return getType();
		if(fieldName.equals("SIZE"))
			return getSize();
		if(fieldName.equals("COLLECTIONDEVICE"))
			return getCollectionDevice();
		if(fieldName.equals("LOTNUMBER"))
			return getLotNumber();
		if(fieldName.equals("BODYSITE"))
			return getBodySite();
		if(fieldName.equals("INSERTEDBY"))
			return getInsertedBy();
		if(fieldName.equals("LUBRICANT"))
			return getLubricant();
		if(fieldName.equals("VOLUMEINBALLOON"))
			return getVolumeInBalloon();
		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 getTypeIsNotNull()
	{
		return this.type != null;
	}
	public ims.clinical.vo.lookups.CatheterDrainsTube getType()
	{
		return this.type;
	}
	public void setType(ims.clinical.vo.lookups.CatheterDrainsTube value)
	{
		this.isValidated = false;
		this.type = value;
	}
	public boolean getSizeIsNotNull()
	{
		return this.size != null;
	}
	public String getSize()
	{
		return this.size;
	}
	public static int getSizeMaxLength()
	{
		return 100;
	}
	public void setSize(String value)
	{
		this.isValidated = false;
		this.size = value;
	}
	public boolean getCollectionDeviceIsNotNull()
	{
		return this.collectiondevice != null;
	}
	public String getCollectionDevice()
	{
		return this.collectiondevice;
	}
	public static int getCollectionDeviceMaxLength()
	{
		return 100;
	}
	public void setCollectionDevice(String value)
	{
		this.isValidated = false;
		this.collectiondevice = value;
	}
	public boolean getLotNumberIsNotNull()
	{
		return this.lotnumber != null;
	}
	public String getLotNumber()
	{
		return this.lotnumber;
	}
	public static int getLotNumberMaxLength()
	{
		return 100;
	}
	public void setLotNumber(String value)
	{
		this.isValidated = false;
		this.lotnumber = value;
	}
	public boolean getBodySiteIsNotNull()
	{
		return this.bodysite != null;
	}
	public String getBodySite()
	{
		return this.bodysite;
	}
	public static int getBodySiteMaxLength()
	{
		return 100;
	}
	public void setBodySite(String value)
	{
		this.isValidated = false;
		this.bodysite = value;
	}
	public boolean getInsertedByIsNotNull()
	{
		return this.insertedby != null;
	}
	public ims.core.vo.HcpLiteVo getInsertedBy()
	{
		return this.insertedby;
	}
	public void setInsertedBy(ims.core.vo.HcpLiteVo value)
	{
		this.isValidated = false;
		this.insertedby = value;
	}
	public boolean getLubricantIsNotNull()
	{
		return this.lubricant != null;
	}
	public String getLubricant()
	{
		return this.lubricant;
	}
	public static int getLubricantMaxLength()
	{
		return 100;
	}
	public void setLubricant(String value)
	{
		this.isValidated = false;
		this.lubricant = value;
	}
	public boolean getVolumeInBalloonIsNotNull()
	{
		return this.volumeinballoon != null;
	}
	public String getVolumeInBalloon()
	{
		return this.volumeinballoon;
	}
	public static int getVolumeInBalloonMaxLength()
	{
		return 100;
	}
	public void setVolumeInBalloon(String value)
	{
		this.isValidated = false;
		this.volumeinballoon = 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.type == null)
			listOfErrors.add("Type is mandatory");
		if(this.size == null || this.size.length() == 0)
			listOfErrors.add("Size is mandatory");
		else if(this.size.length() > 100)
			listOfErrors.add("The length of the field [size] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		if(this.collectiondevice == null || this.collectiondevice.length() == 0)
			listOfErrors.add("CollectionDevice is mandatory");
		else if(this.collectiondevice.length() > 100)
			listOfErrors.add("The length of the field [collectiondevice] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		if(this.lotnumber == null || this.lotnumber.length() == 0)
			listOfErrors.add("LotNumber is mandatory");
		else if(this.lotnumber.length() > 100)
			listOfErrors.add("The length of the field [lotnumber] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		if(this.bodysite == null || this.bodysite.length() == 0)
			listOfErrors.add("BodySite is mandatory");
		else if(this.bodysite.length() > 100)
			listOfErrors.add("The length of the field [bodysite] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		if(this.insertedby == null)
			listOfErrors.add("InsertedBy is mandatory");
		if(this.lubricant != null)
			if(this.lubricant.length() > 100)
				listOfErrors.add("The length of the field [lubricant] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		if(this.volumeinballoon != null)
			if(this.volumeinballoon.length() > 100)
				listOfErrors.add("The length of the field [volumeinballoon] in the value object [ims.clinical.vo.CatheterDrainsTubeIntraOpVo] is too big. It should be less or equal to 100");
		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;
	
		CatheterDrainsTubeIntraOpVo clone = new CatheterDrainsTubeIntraOpVo(this.id, this.version);
		
		clone.theatreappointment = this.theatreappointment;
		if(this.type == null)
			clone.type = null;
		else
			clone.type = (ims.clinical.vo.lookups.CatheterDrainsTube)this.type.clone();
		clone.size = this.size;
		clone.collectiondevice = this.collectiondevice;
		clone.lotnumber = this.lotnumber;
		clone.bodysite = this.bodysite;
		if(this.insertedby == null)
			clone.insertedby = null;
		else
			clone.insertedby = (ims.core.vo.HcpLiteVo)this.insertedby.clone();
		clone.lubricant = this.lubricant;
		clone.volumeinballoon = this.volumeinballoon;
		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 (!(CatheterDrainsTubeIntraOpVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A CatheterDrainsTubeIntraOpVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((CatheterDrainsTubeIntraOpVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((CatheterDrainsTubeIntraOpVo)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.type != null)
			count++;
		if(this.size != null)
			count++;
		if(this.collectiondevice != null)
			count++;
		if(this.lotnumber != null)
			count++;
		if(this.bodysite != null)
			count++;
		if(this.insertedby != null)
			count++;
		if(this.lubricant != null)
			count++;
		if(this.volumeinballoon != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.scheduling.vo.Booking_AppointmentRefVo theatreappointment;
	protected ims.clinical.vo.lookups.CatheterDrainsTube type;
	protected String size;
	protected String collectiondevice;
	protected String lotnumber;
	protected String bodysite;
	protected ims.core.vo.HcpLiteVo insertedby;
	protected String lubricant;
	protected String volumeinballoon;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
