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

/**
 * Linked to dto_move.RadiotherapyMachine business object (ID: 1105100003).
 */
public class RadiotherapyMachineVo extends ims.dto_move.vo.RadiotherapyMachineRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public RadiotherapyMachineVo()
	{
	}
	public RadiotherapyMachineVo(Integer id, int version)
	{
		super(id, version);
	}
	public RadiotherapyMachineVo(ims.dtomove.vo.beans.RadiotherapyMachineVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.location = bean.getLocation() == null ? null : new ims.dto_move.vo.InternalLocationRefVo(new Integer(bean.getLocation().getId()), bean.getLocation().getVersion());
		this.name = bean.getName();
		this.datecomm = bean.getDateComm() == null ? null : bean.getDateComm().buildDate();
		this.machinetype = bean.getMachineType();
		this.active = bean.getActive();
		this.datedecomm = bean.getDateDeComm() == null ? null : bean.getDateDeComm().buildDate();
		this.modalities = ims.dtomove.vo.MachineModalityVoCollection.buildFromBeanCollection(bean.getModalities());
		this.exclusiontimes = ims.dtomove.vo.MachineExclusionTimeVoCollection.buildFromBeanCollection(bean.getExclusionTimes());
		this.exclusiondates = ims.dtomove.vo.MachineExclusionDateVoCollection.buildFromBeanCollection(bean.getExclusionDates());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.dtomove.vo.beans.RadiotherapyMachineVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.location = bean.getLocation() == null ? null : new ims.dto_move.vo.InternalLocationRefVo(new Integer(bean.getLocation().getId()), bean.getLocation().getVersion());
		this.name = bean.getName();
		this.datecomm = bean.getDateComm() == null ? null : bean.getDateComm().buildDate();
		this.machinetype = bean.getMachineType();
		this.active = bean.getActive();
		this.datedecomm = bean.getDateDeComm() == null ? null : bean.getDateDeComm().buildDate();
		this.modalities = ims.dtomove.vo.MachineModalityVoCollection.buildFromBeanCollection(bean.getModalities());
		this.exclusiontimes = ims.dtomove.vo.MachineExclusionTimeVoCollection.buildFromBeanCollection(bean.getExclusionTimes());
		this.exclusiondates = ims.dtomove.vo.MachineExclusionDateVoCollection.buildFromBeanCollection(bean.getExclusionDates());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.dtomove.vo.beans.RadiotherapyMachineVoBean bean = null;
		if(map != null)
			bean = (ims.dtomove.vo.beans.RadiotherapyMachineVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.dtomove.vo.beans.RadiotherapyMachineVoBean();
			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("LOCATION"))
			return getLocation();
		if(fieldName.equals("NAME"))
			return getName();
		if(fieldName.equals("DATECOMM"))
			return getDateComm();
		if(fieldName.equals("MACHINETYPE"))
			return getMachineType();
		if(fieldName.equals("ACTIVE"))
			return getActive();
		if(fieldName.equals("DATEDECOMM"))
			return getDateDeComm();
		if(fieldName.equals("MODALITIES"))
			return getModalities();
		if(fieldName.equals("EXCLUSIONTIMES"))
			return getExclusionTimes();
		if(fieldName.equals("EXCLUSIONDATES"))
			return getExclusionDates();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getLocationIsNotNull()
	{
		return this.location != null;
	}
	public ims.dto_move.vo.InternalLocationRefVo getLocation()
	{
		return this.location;
	}
	public void setLocation(ims.dto_move.vo.InternalLocationRefVo value)
	{
		this.isValidated = false;
		this.location = value;
	}
	public boolean getNameIsNotNull()
	{
		return this.name != null;
	}
	public String getName()
	{
		return this.name;
	}
	public static int getNameMaxLength()
	{
		return 50;
	}
	public void setName(String value)
	{
		this.isValidated = false;
		this.name = value;
	}
	public boolean getDateCommIsNotNull()
	{
		return this.datecomm != null;
	}
	public ims.framework.utils.Date getDateComm()
	{
		return this.datecomm;
	}
	public void setDateComm(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datecomm = value;
	}
	public boolean getMachineTypeIsNotNull()
	{
		return this.machinetype != null;
	}
	public Integer getMachineType()
	{
		return this.machinetype;
	}
	public void setMachineType(Integer value)
	{
		this.isValidated = false;
		this.machinetype = value;
	}
	public boolean getActiveIsNotNull()
	{
		return this.active != null;
	}
	public String getActive()
	{
		return this.active;
	}
	public static int getActiveMaxLength()
	{
		return 1;
	}
	public void setActive(String value)
	{
		this.isValidated = false;
		this.active = value;
	}
	public boolean getDateDeCommIsNotNull()
	{
		return this.datedecomm != null;
	}
	public ims.framework.utils.Date getDateDeComm()
	{
		return this.datedecomm;
	}
	public void setDateDeComm(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datedecomm = value;
	}
	public boolean getModalitiesIsNotNull()
	{
		return this.modalities != null;
	}
	public ims.dtomove.vo.MachineModalityVoCollection getModalities()
	{
		return this.modalities;
	}
	public void setModalities(ims.dtomove.vo.MachineModalityVoCollection value)
	{
		this.isValidated = false;
		this.modalities = value;
	}
	public boolean getExclusionTimesIsNotNull()
	{
		return this.exclusiontimes != null;
	}
	public ims.dtomove.vo.MachineExclusionTimeVoCollection getExclusionTimes()
	{
		return this.exclusiontimes;
	}
	public void setExclusionTimes(ims.dtomove.vo.MachineExclusionTimeVoCollection value)
	{
		this.isValidated = false;
		this.exclusiontimes = value;
	}
	public boolean getExclusionDatesIsNotNull()
	{
		return this.exclusiondates != null;
	}
	public ims.dtomove.vo.MachineExclusionDateVoCollection getExclusionDates()
	{
		return this.exclusiondates;
	}
	public void setExclusionDates(ims.dtomove.vo.MachineExclusionDateVoCollection value)
	{
		this.isValidated = false;
		this.exclusiondates = 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.name != null)
			if(this.name.length() > 50)
				listOfErrors.add("The length of the field [name] in the value object [ims.dtomove.vo.RadiotherapyMachineVo] is too big. It should be less or equal to 50");
		if(this.active != null)
			if(this.active.length() > 1)
				listOfErrors.add("The length of the field [active] in the value object [ims.dtomove.vo.RadiotherapyMachineVo] is too big. It should be less or equal to 1");
		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;
	
		RadiotherapyMachineVo clone = new RadiotherapyMachineVo(this.id, this.version);
		
		clone.location = this.location;
		clone.name = this.name;
		if(this.datecomm == null)
			clone.datecomm = null;
		else
			clone.datecomm = (ims.framework.utils.Date)this.datecomm.clone();
		clone.machinetype = this.machinetype;
		clone.active = this.active;
		if(this.datedecomm == null)
			clone.datedecomm = null;
		else
			clone.datedecomm = (ims.framework.utils.Date)this.datedecomm.clone();
		if(this.modalities == null)
			clone.modalities = null;
		else
			clone.modalities = (ims.dtomove.vo.MachineModalityVoCollection)this.modalities.clone();
		if(this.exclusiontimes == null)
			clone.exclusiontimes = null;
		else
			clone.exclusiontimes = (ims.dtomove.vo.MachineExclusionTimeVoCollection)this.exclusiontimes.clone();
		if(this.exclusiondates == null)
			clone.exclusiondates = null;
		else
			clone.exclusiondates = (ims.dtomove.vo.MachineExclusionDateVoCollection)this.exclusiondates.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 (!(RadiotherapyMachineVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A RadiotherapyMachineVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((RadiotherapyMachineVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((RadiotherapyMachineVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.location != null)
			count++;
		if(this.name != null)
			count++;
		if(this.datecomm != null)
			count++;
		if(this.machinetype != null)
			count++;
		if(this.active != null)
			count++;
		if(this.datedecomm != null)
			count++;
		if(this.modalities != null)
			count++;
		if(this.exclusiontimes != null)
			count++;
		if(this.exclusiondates != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.dto_move.vo.InternalLocationRefVo location;
	protected String name;
	protected ims.framework.utils.Date datecomm;
	protected Integer machinetype;
	protected String active;
	protected ims.framework.utils.Date datedecomm;
	protected ims.dtomove.vo.MachineModalityVoCollection modalities;
	protected ims.dtomove.vo.MachineExclusionTimeVoCollection exclusiontimes;
	protected ims.dtomove.vo.MachineExclusionDateVoCollection exclusiondates;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
