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

/**
 * Linked to core.clinical.FilmPacket business object (ID: 1003100115).
 */
public class FilmPacketVo extends ims.core.clinical.vo.FilmPacketRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public FilmPacketVo()
	{
	}
	public FilmPacketVo(Integer id, int version)
	{
		super(id, version);
	}
	public FilmPacketVo(ims.core.vo.beans.FilmPacketVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.mediatype = bean.getMediaType() == null ? null : ims.core.vo.lookups.MediaType.buildLookup(bean.getMediaType());
		this.recordinguser = bean.getRecordingUser() == null ? null : bean.getRecordingUser().buildVo();
		this.recordingdatetime = bean.getRecordingDateTime() == null ? null : bean.getRecordingDateTime().buildDateTime();
		this.transferhistory = ims.core.vo.FilmPacketTransferVoCollection.buildFromBeanCollection(bean.getTransferHistory());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.hospital = bean.getHospital();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.FilmPacketVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.mediatype = bean.getMediaType() == null ? null : ims.core.vo.lookups.MediaType.buildLookup(bean.getMediaType());
		this.recordinguser = bean.getRecordingUser() == null ? null : bean.getRecordingUser().buildVo(map);
		this.recordingdatetime = bean.getRecordingDateTime() == null ? null : bean.getRecordingDateTime().buildDateTime();
		this.transferhistory = ims.core.vo.FilmPacketTransferVoCollection.buildFromBeanCollection(bean.getTransferHistory());
		this.patient = bean.getPatient() == null ? null : new ims.core.patient.vo.PatientRefVo(new Integer(bean.getPatient().getId()), bean.getPatient().getVersion());
		this.hospital = bean.getHospital();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.FilmPacketVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.FilmPacketVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.FilmPacketVoBean();
			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("MEDIATYPE"))
			return getMediaType();
		if(fieldName.equals("RECORDINGUSER"))
			return getRecordingUser();
		if(fieldName.equals("RECORDINGDATETIME"))
			return getRecordingDateTime();
		if(fieldName.equals("TRANSFERHISTORY"))
			return getTransferHistory();
		if(fieldName.equals("PATIENT"))
			return getPatient();
		if(fieldName.equals("HOSPITAL"))
			return getHospital();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getMediaTypeIsNotNull()
	{
		return this.mediatype != null;
	}
	public ims.core.vo.lookups.MediaType getMediaType()
	{
		return this.mediatype;
	}
	public void setMediaType(ims.core.vo.lookups.MediaType value)
	{
		this.isValidated = false;
		this.mediatype = value;
	}
	public boolean getRecordingUserIsNotNull()
	{
		return this.recordinguser != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getRecordingUser()
	{
		return this.recordinguser;
	}
	public void setRecordingUser(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.recordinguser = value;
	}
	public boolean getRecordingDateTimeIsNotNull()
	{
		return this.recordingdatetime != null;
	}
	public ims.framework.utils.DateTime getRecordingDateTime()
	{
		return this.recordingdatetime;
	}
	public void setRecordingDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.recordingdatetime = value;
	}
	public boolean getTransferHistoryIsNotNull()
	{
		return this.transferhistory != null;
	}
	public ims.core.vo.FilmPacketTransferVoCollection getTransferHistory()
	{
		return this.transferhistory;
	}
	public void setTransferHistory(ims.core.vo.FilmPacketTransferVoCollection value)
	{
		this.isValidated = false;
		this.transferhistory = value;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.patient.vo.PatientRefVo getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.patient.vo.PatientRefVo value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getHospitalIsNotNull()
	{
		return this.hospital != null;
	}
	public String getHospital()
	{
		return this.hospital;
	}
	public static int getHospitalMaxLength()
	{
		return 60;
	}
	public void setHospital(String value)
	{
		this.isValidated = false;
		this.hospital = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.transferhistory != null)
		{
			if(!this.transferhistory.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.mediatype == null)
			listOfErrors.add("MediaType is mandatory");
		if(this.recordinguser == null)
			listOfErrors.add("RecordingUser is mandatory");
		if(this.recordingdatetime == null)
			listOfErrors.add("RecordingDateTime is mandatory");
		if(this.transferhistory != null)
		{
			String[] listOfOtherErrors = this.transferhistory.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.hospital != null)
			if(this.hospital.length() > 60)
				listOfErrors.add("The length of the field [hospital] in the value object [ims.core.vo.FilmPacketVo] is too big. It should be less or equal to 60");
		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;
	
		FilmPacketVo clone = new FilmPacketVo(this.id, this.version);
		
		if(this.mediatype == null)
			clone.mediatype = null;
		else
			clone.mediatype = (ims.core.vo.lookups.MediaType)this.mediatype.clone();
		if(this.recordinguser == null)
			clone.recordinguser = null;
		else
			clone.recordinguser = (ims.core.vo.MemberOfStaffLiteVo)this.recordinguser.clone();
		if(this.recordingdatetime == null)
			clone.recordingdatetime = null;
		else
			clone.recordingdatetime = (ims.framework.utils.DateTime)this.recordingdatetime.clone();
		if(this.transferhistory == null)
			clone.transferhistory = null;
		else
			clone.transferhistory = (ims.core.vo.FilmPacketTransferVoCollection)this.transferhistory.clone();
		clone.patient = this.patient;
		clone.hospital = this.hospital;
		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 (!(FilmPacketVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A FilmPacketVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((FilmPacketVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((FilmPacketVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.mediatype != null)
			count++;
		if(this.recordinguser != null)
			count++;
		if(this.recordingdatetime != null)
			count++;
		if(this.transferhistory != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.hospital != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected ims.core.vo.lookups.MediaType mediatype;
	protected ims.core.vo.MemberOfStaffLiteVo recordinguser;
	protected ims.framework.utils.DateTime recordingdatetime;
	protected ims.core.vo.FilmPacketTransferVoCollection transferhistory;
	protected ims.core.patient.vo.PatientRefVo patient;
	protected String hospital;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
