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

/**
 * Linked to Pathways.PatientJourneyTarget business object (ID: 1088100001).
 */
public class PatientJourneyTargetVo extends ims.pathways.vo.PatientJourneyTargetRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PatientJourneyTargetVo()
	{
	}
	public PatientJourneyTargetVo(Integer id, int version)
	{
		super(id, version);
	}
	public PatientJourneyTargetVo(ims.pathways.vo.beans.PatientJourneyTargetVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.pathwaytarget = bean.getPathwayTarget() == null ? null : bean.getPathwayTarget().buildVo();
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo();
		this.pathwayjourney = bean.getPathwayJourney() == null ? null : bean.getPathwayJourney().buildVo();
		this.weeknumber = bean.getWeekNumber();
		this.targetdate = bean.getTargetDate() == null ? null : bean.getTargetDate().buildDate();
		this.colour = bean.getColour() == null ? null : bean.getColour().buildColor();
		this.targetcalfromdate = bean.getTargetCalFromDate() == null ? null : bean.getTargetCalFromDate().buildDate();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pathways.vo.beans.PatientJourneyTargetVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.pathwaytarget = bean.getPathwayTarget() == null ? null : bean.getPathwayTarget().buildVo(map);
		this.currentstatus = bean.getCurrentStatus() == null ? null : bean.getCurrentStatus().buildVo(map);
		this.pathwayjourney = bean.getPathwayJourney() == null ? null : bean.getPathwayJourney().buildVo(map);
		this.weeknumber = bean.getWeekNumber();
		this.targetdate = bean.getTargetDate() == null ? null : bean.getTargetDate().buildDate();
		this.colour = bean.getColour() == null ? null : bean.getColour().buildColor();
		this.targetcalfromdate = bean.getTargetCalFromDate() == null ? null : bean.getTargetCalFromDate().buildDate();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.pathways.vo.beans.PatientJourneyTargetVoBean bean = null;
		if(map != null)
			bean = (ims.pathways.vo.beans.PatientJourneyTargetVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pathways.vo.beans.PatientJourneyTargetVoBean();
			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("PATHWAYTARGET"))
			return getPathwayTarget();
		if(fieldName.equals("CURRENTSTATUS"))
			return getCurrentStatus();
		if(fieldName.equals("PATHWAYJOURNEY"))
			return getPathwayJourney();
		if(fieldName.equals("WEEKNUMBER"))
			return getWeekNumber();
		if(fieldName.equals("TARGETDATE"))
			return getTargetDate();
		if(fieldName.equals("COLOUR"))
			return getColour();
		if(fieldName.equals("TARGETCALFROMDATE"))
			return getTargetCalFromDate();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getPathwayTargetIsNotNull()
	{
		return this.pathwaytarget != null;
	}
	public ims.pathways.vo.PathwayTargetShortVo getPathwayTarget()
	{
		return this.pathwaytarget;
	}
	public void setPathwayTarget(ims.pathways.vo.PathwayTargetShortVo value)
	{
		this.isValidated = false;
		this.pathwaytarget = value;
	}
	public boolean getCurrentStatusIsNotNull()
	{
		return this.currentstatus != null;
	}
	public ims.pathways.vo.JourneyTargetStatusVo getCurrentStatus()
	{
		return this.currentstatus;
	}
	public void setCurrentStatus(ims.pathways.vo.JourneyTargetStatusVo value)
	{
		this.isValidated = false;
		this.currentstatus = value;
	}
	public boolean getPathwayJourneyIsNotNull()
	{
		return this.pathwayjourney != null;
	}
	public ims.pathways.vo.PatientJourneyVo getPathwayJourney()
	{
		return this.pathwayjourney;
	}
	public void setPathwayJourney(ims.pathways.vo.PatientJourneyVo value)
	{
		this.isValidated = false;
		this.pathwayjourney = value;
	}
	public boolean getWeekNumberIsNotNull()
	{
		return this.weeknumber != null;
	}
	public Integer getWeekNumber()
	{
		return this.weeknumber;
	}
	public void setWeekNumber(Integer value)
	{
		this.isValidated = false;
		this.weeknumber = value;
	}
	public boolean getTargetDateIsNotNull()
	{
		return this.targetdate != null;
	}
	public ims.framework.utils.Date getTargetDate()
	{
		return this.targetdate;
	}
	public void setTargetDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.targetdate = value;
	}
	public boolean getColourIsNotNull()
	{
		return this.colour != null;
	}
	public ims.framework.utils.Color getColour()
	{
		return this.colour;
	}
	public void setColour(ims.framework.utils.Color value)
	{
		this.isValidated = false;
		this.colour = value;
	}
	public boolean getTargetCalFromDateIsNotNull()
	{
		return this.targetcalfromdate != null;
	}
	public ims.framework.utils.Date getTargetCalFromDate()
	{
		return this.targetcalfromdate;
	}
	public void setTargetCalFromDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.targetcalfromdate = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.pathwaytarget != null)
		{
			if(!this.pathwaytarget.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.currentstatus != null)
		{
			if(!this.currentstatus.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.pathwayjourney != null)
		{
			if(!this.pathwayjourney.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.pathwaytarget == null)
			listOfErrors.add("PathwayTarget is mandatory");
		if(this.pathwaytarget != null)
		{
			String[] listOfOtherErrors = this.pathwaytarget.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.currentstatus == null)
			listOfErrors.add("CurrentStatus is mandatory");
		if(this.currentstatus != null)
		{
			String[] listOfOtherErrors = this.currentstatus.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.pathwayjourney != null)
		{
			String[] listOfOtherErrors = this.pathwayjourney.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.weeknumber == null)
			listOfErrors.add("WeekNumber is mandatory");
		if(this.targetdate == null)
			listOfErrors.add("TargetDate 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;
	
		PatientJourneyTargetVo clone = new PatientJourneyTargetVo(this.id, this.version);
		
		if(this.pathwaytarget == null)
			clone.pathwaytarget = null;
		else
			clone.pathwaytarget = (ims.pathways.vo.PathwayTargetShortVo)this.pathwaytarget.clone();
		if(this.currentstatus == null)
			clone.currentstatus = null;
		else
			clone.currentstatus = (ims.pathways.vo.JourneyTargetStatusVo)this.currentstatus.clone();
		if(this.pathwayjourney == null)
			clone.pathwayjourney = null;
		else
			clone.pathwayjourney = (ims.pathways.vo.PatientJourneyVo)this.pathwayjourney.clone();
		clone.weeknumber = this.weeknumber;
		if(this.targetdate == null)
			clone.targetdate = null;
		else
			clone.targetdate = (ims.framework.utils.Date)this.targetdate.clone();
		if(this.colour == null)
			clone.colour = null;
		else
			clone.colour = (ims.framework.utils.Color)this.colour.clone();
		if(this.targetcalfromdate == null)
			clone.targetcalfromdate = null;
		else
			clone.targetcalfromdate = (ims.framework.utils.Date)this.targetcalfromdate.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 (!(PatientJourneyTargetVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PatientJourneyTargetVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((PatientJourneyTargetVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((PatientJourneyTargetVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.pathwaytarget != null)
			count++;
		if(this.currentstatus != null)
			count++;
		if(this.pathwayjourney != null)
			count++;
		if(this.weeknumber != null)
			count++;
		if(this.targetdate != null)
			count++;
		if(this.colour != null)
			count++;
		if(this.targetcalfromdate != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 7;
	}
	protected ims.pathways.vo.PathwayTargetShortVo pathwaytarget;
	protected ims.pathways.vo.JourneyTargetStatusVo currentstatus;
	protected ims.pathways.vo.PatientJourneyVo pathwayjourney;
	protected Integer weeknumber;
	protected ims.framework.utils.Date targetdate;
	protected ims.framework.utils.Color colour;
	protected ims.framework.utils.Date targetcalfromdate;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
