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

/**
 * Linked to emergency.Configuration.WhiteBoardQuestionConfig business object (ID: 1087100020).
 */
public class WhiteBoardQuestionConfigVo extends ims.emergency.configuration.vo.WhiteBoardQuestionConfigRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public WhiteBoardQuestionConfigVo()
	{
	}
	public WhiteBoardQuestionConfigVo(Integer id, int version)
	{
		super(id, version);
	}
	public WhiteBoardQuestionConfigVo(ims.emergency.vo.beans.WhiteBoardQuestionConfigVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.questiontext = bean.getQuestionText();
		this.columnheadertext = bean.getColumnHeaderText();
		this.answertype = bean.getAnswerType() == null ? null : ims.core.vo.lookups.QuestionAnswerType.buildLookup(bean.getAnswerType());
		this.options = ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection.buildFromBeanCollection(bean.getOptions());
		this.columnwidth = bean.getColumnWidth();
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.agerangemin = bean.getAgeRangeMin();
		this.agerangemax = bean.getAgeRangeMax();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.emergency.vo.beans.WhiteBoardQuestionConfigVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.questiontext = bean.getQuestionText();
		this.columnheadertext = bean.getColumnHeaderText();
		this.answertype = bean.getAnswerType() == null ? null : ims.core.vo.lookups.QuestionAnswerType.buildLookup(bean.getAnswerType());
		this.options = ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection.buildFromBeanCollection(bean.getOptions());
		this.columnwidth = bean.getColumnWidth();
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.agerangemin = bean.getAgeRangeMin();
		this.agerangemax = bean.getAgeRangeMax();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.emergency.vo.beans.WhiteBoardQuestionConfigVoBean bean = null;
		if(map != null)
			bean = (ims.emergency.vo.beans.WhiteBoardQuestionConfigVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.emergency.vo.beans.WhiteBoardQuestionConfigVoBean();
			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("QUESTIONTEXT"))
			return getQuestionText();
		if(fieldName.equals("COLUMNHEADERTEXT"))
			return getColumnHeaderText();
		if(fieldName.equals("ANSWERTYPE"))
			return getAnswerType();
		if(fieldName.equals("OPTIONS"))
			return getOptions();
		if(fieldName.equals("COLUMNWIDTH"))
			return getColumnWidth();
		if(fieldName.equals("GENDERSPECIFIC"))
			return getGenderSpecific();
		if(fieldName.equals("AGERANGEMIN"))
			return getAgeRangeMin();
		if(fieldName.equals("AGERANGEMAX"))
			return getAgeRangeMax();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getQuestionTextIsNotNull()
	{
		return this.questiontext != null;
	}
	public String getQuestionText()
	{
		return this.questiontext;
	}
	public static int getQuestionTextMaxLength()
	{
		return 500;
	}
	public void setQuestionText(String value)
	{
		this.isValidated = false;
		this.questiontext = value;
	}
	public boolean getColumnHeaderTextIsNotNull()
	{
		return this.columnheadertext != null;
	}
	public String getColumnHeaderText()
	{
		return this.columnheadertext;
	}
	public static int getColumnHeaderTextMaxLength()
	{
		return 500;
	}
	public void setColumnHeaderText(String value)
	{
		this.isValidated = false;
		this.columnheadertext = value;
	}
	public boolean getAnswerTypeIsNotNull()
	{
		return this.answertype != null;
	}
	public ims.core.vo.lookups.QuestionAnswerType getAnswerType()
	{
		return this.answertype;
	}
	public void setAnswerType(ims.core.vo.lookups.QuestionAnswerType value)
	{
		this.isValidated = false;
		this.answertype = value;
	}
	public boolean getOptionsIsNotNull()
	{
		return this.options != null;
	}
	public ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection getOptions()
	{
		return this.options;
	}
	public void setOptions(ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection value)
	{
		this.isValidated = false;
		this.options = value;
	}
	public boolean getColumnWidthIsNotNull()
	{
		return this.columnwidth != null;
	}
	public Integer getColumnWidth()
	{
		return this.columnwidth;
	}
	public void setColumnWidth(Integer value)
	{
		this.isValidated = false;
		this.columnwidth = value;
	}
	public boolean getGenderSpecificIsNotNull()
	{
		return this.genderspecific != null;
	}
	public ims.admin.vo.lookups.GenderSpecific getGenderSpecific()
	{
		return this.genderspecific;
	}
	public void setGenderSpecific(ims.admin.vo.lookups.GenderSpecific value)
	{
		this.isValidated = false;
		this.genderspecific = value;
	}
	public boolean getAgeRangeMinIsNotNull()
	{
		return this.agerangemin != null;
	}
	public Integer getAgeRangeMin()
	{
		return this.agerangemin;
	}
	public void setAgeRangeMin(Integer value)
	{
		this.isValidated = false;
		this.agerangemin = value;
	}
	public boolean getAgeRangeMaxIsNotNull()
	{
		return this.agerangemax != null;
	}
	public Integer getAgeRangeMax()
	{
		return this.agerangemax;
	}
	public void setAgeRangeMax(Integer value)
	{
		this.isValidated = false;
		this.agerangemax = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.options != null)
		{
			if(!this.options.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.questiontext == null || this.questiontext.length() == 0)
			listOfErrors.add("QuestionText is mandatory");
		else if(this.questiontext.length() > 500)
			listOfErrors.add("The length of the field [questiontext] in the value object [ims.emergency.vo.WhiteBoardQuestionConfigVo] is too big. It should be less or equal to 500");
		if(this.columnheadertext == null || this.columnheadertext.length() == 0)
			listOfErrors.add("ColumnHeaderText is mandatory");
		else if(this.columnheadertext.length() > 500)
			listOfErrors.add("The length of the field [columnheadertext] in the value object [ims.emergency.vo.WhiteBoardQuestionConfigVo] is too big. It should be less or equal to 500");
		if(this.answertype == null)
			listOfErrors.add("AnswerType is mandatory");
		if(this.options != null)
		{
			String[] listOfOtherErrors = this.options.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.columnwidth == null)
			listOfErrors.add("ColumnWidth is mandatory");
		if(this.genderspecific == null)
			listOfErrors.add("GenderSpecific 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;
	
		WhiteBoardQuestionConfigVo clone = new WhiteBoardQuestionConfigVo(this.id, this.version);
		
		clone.questiontext = this.questiontext;
		clone.columnheadertext = this.columnheadertext;
		if(this.answertype == null)
			clone.answertype = null;
		else
			clone.answertype = (ims.core.vo.lookups.QuestionAnswerType)this.answertype.clone();
		if(this.options == null)
			clone.options = null;
		else
			clone.options = (ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection)this.options.clone();
		clone.columnwidth = this.columnwidth;
		if(this.genderspecific == null)
			clone.genderspecific = null;
		else
			clone.genderspecific = (ims.admin.vo.lookups.GenderSpecific)this.genderspecific.clone();
		clone.agerangemin = this.agerangemin;
		clone.agerangemax = this.agerangemax;
		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 (!(WhiteBoardQuestionConfigVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A WhiteBoardQuestionConfigVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((WhiteBoardQuestionConfigVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((WhiteBoardQuestionConfigVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.questiontext != null)
			count++;
		if(this.columnheadertext != null)
			count++;
		if(this.answertype != null)
			count++;
		if(this.options != null)
			count++;
		if(this.columnwidth != null)
			count++;
		if(this.genderspecific != null)
			count++;
		if(this.agerangemin != null)
			count++;
		if(this.agerangemax != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected String questiontext;
	protected String columnheadertext;
	protected ims.core.vo.lookups.QuestionAnswerType answertype;
	protected ims.core.vo.AnswerOptionForEDWhiteboardConfigVoCollection options;
	protected Integer columnwidth;
	protected ims.admin.vo.lookups.GenderSpecific genderspecific;
	protected Integer agerangemin;
	protected Integer agerangemax;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
