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

/**
 * Linked to Assessment.Configuration.ImageFinding business object (ID: 1028100002).
 */
public class ImageFindingVo extends ims.assessment.configuration.vo.ImageFindingRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public ImageFindingVo()
	{
	}
	public ImageFindingVo(Integer id, int version)
	{
		super(id, version);
	}
	public ImageFindingVo(ims.assessment.vo.beans.ImageFindingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.description = bean.getDescription();
		this.displaytext = bean.getDisplayText();
		this.colour = bean.getColour() == null ? null : bean.getColour().buildColor();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo();
		this.renderstyle = bean.getRenderStyle();
		this.findingquestions = ims.assessment.vo.ImageFindingQuestionVoCollection.buildFromBeanCollection(bean.getFindingQuestions());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.assessment.vo.beans.ImageFindingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.description = bean.getDescription();
		this.displaytext = bean.getDisplayText();
		this.colour = bean.getColour() == null ? null : bean.getColour().buildColor();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo(map);
		this.renderstyle = bean.getRenderStyle();
		this.findingquestions = ims.assessment.vo.ImageFindingQuestionVoCollection.buildFromBeanCollection(bean.getFindingQuestions());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.assessment.vo.beans.ImageFindingVoBean bean = null;
		if(map != null)
			bean = (ims.assessment.vo.beans.ImageFindingVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.assessment.vo.beans.ImageFindingVoBean();
			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("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("DISPLAYTEXT"))
			return getDisplayText();
		if(fieldName.equals("COLOUR"))
			return getColour();
		if(fieldName.equals("IMAGE"))
			return getImage();
		if(fieldName.equals("RENDERSTYLE"))
			return getRenderStyle();
		if(fieldName.equals("FINDINGQUESTIONS"))
			return getFindingQuestions();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 255;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getDisplayTextIsNotNull()
	{
		return this.displaytext != null;
	}
	public String getDisplayText()
	{
		return this.displaytext;
	}
	public static int getDisplayTextMaxLength()
	{
		return 255;
	}
	public void setDisplayText(String value)
	{
		this.isValidated = false;
		this.displaytext = 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 getImageIsNotNull()
	{
		return this.image != null;
	}
	public ims.admin.vo.AppImageVo getImage()
	{
		return this.image;
	}
	public void setImage(ims.admin.vo.AppImageVo value)
	{
		this.isValidated = false;
		this.image = value;
	}
	public boolean getRenderStyleIsNotNull()
	{
		return this.renderstyle != null;
	}
	public Boolean getRenderStyle()
	{
		return this.renderstyle;
	}
	public void setRenderStyle(Boolean value)
	{
		this.isValidated = false;
		this.renderstyle = value;
	}
	public boolean getFindingQuestionsIsNotNull()
	{
		return this.findingquestions != null;
	}
	public ims.assessment.vo.ImageFindingQuestionVoCollection getFindingQuestions()
	{
		return this.findingquestions;
	}
	public void setFindingQuestions(ims.assessment.vo.ImageFindingQuestionVoCollection value)
	{
		this.isValidated = false;
		this.findingquestions = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.image != null)
		{
			if(!this.image.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.findingquestions != null)
		{
			if(!this.findingquestions.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.description != null)
			if(this.description.length() > 255)
				listOfErrors.add("The length of the field [description] in the value object [ims.assessment.vo.ImageFindingVo] is too big. It should be less or equal to 255");
		if(this.displaytext != null)
			if(this.displaytext.length() > 255)
				listOfErrors.add("The length of the field [displaytext] in the value object [ims.assessment.vo.ImageFindingVo] is too big. It should be less or equal to 255");
		if(this.image != null)
		{
			String[] listOfOtherErrors = this.image.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.findingquestions != null)
		{
			String[] listOfOtherErrors = this.findingquestions.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		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;
	
		ImageFindingVo clone = new ImageFindingVo(this.id, this.version);
		
		clone.description = this.description;
		clone.displaytext = this.displaytext;
		if(this.colour == null)
			clone.colour = null;
		else
			clone.colour = (ims.framework.utils.Color)this.colour.clone();
		if(this.image == null)
			clone.image = null;
		else
			clone.image = (ims.admin.vo.AppImageVo)this.image.clone();
		clone.renderstyle = this.renderstyle;
		if(this.findingquestions == null)
			clone.findingquestions = null;
		else
			clone.findingquestions = (ims.assessment.vo.ImageFindingQuestionVoCollection)this.findingquestions.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 (!(ImageFindingVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A ImageFindingVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		ImageFindingVo compareObj = (ImageFindingVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_ImageFinding() == null && compareObj.getID_ImageFinding() != null)
				return -1;
			if(this.getID_ImageFinding() != null && compareObj.getID_ImageFinding() == null)
				return 1;
			if(this.getID_ImageFinding() != null && compareObj.getID_ImageFinding() != null)
				retVal = this.getID_ImageFinding().compareTo(compareObj.getID_ImageFinding());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.description != null)
			count++;
		if(this.displaytext != null)
			count++;
		if(this.colour != null)
			count++;
		if(this.image != null)
			count++;
		if(this.renderstyle != null)
			count++;
		if(this.findingquestions != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected String description;
	protected String displaytext;
	protected ims.framework.utils.Color colour;
	protected ims.admin.vo.AppImageVo image;
	protected Boolean renderstyle;
	protected ims.assessment.vo.ImageFindingQuestionVoCollection findingquestions;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
