/FileExtraction/Java_unseen/IMS-MAXIMS_openMAXIMS/Source Library/openmaxims_workspace/ValueObjects/src/ims/assessment/vo/Question_InformationVo.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 core.clinical.QuestionInformation business object (ID: 1058100000).
 */
public class Question_InformationVo extends ims.core.clinical.vo.QuestionInformationRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public Question_InformationVo()
	{
	}
	public Question_InformationVo(Integer id, int version)
	{
		super(id, version);
	}
	public Question_InformationVo(ims.assessment.vo.beans.Question_InformationVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.text = bean.getText();
		this.shorttext = bean.getShortText();
		this.isquestion = bean.getIsQuestion();
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getStatus());
		this.answertypes = ims.assessment.vo.Question_AnswerTypeVoCollection.buildFromBeanCollection(bean.getAnswerTypes());
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.agerangemin = bean.getAgeRangeMin();
		this.agerangemax = bean.getAgeRangeMax();
		this.legendtext = bean.getLegendText();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.assessment.vo.beans.Question_InformationVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.text = bean.getText();
		this.shorttext = bean.getShortText();
		this.isquestion = bean.getIsQuestion();
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getStatus());
		this.answertypes = ims.assessment.vo.Question_AnswerTypeVoCollection.buildFromBeanCollection(bean.getAnswerTypes());
		this.genderspecific = bean.getGenderSpecific() == null ? null : ims.admin.vo.lookups.GenderSpecific.buildLookup(bean.getGenderSpecific());
		this.agerangemin = bean.getAgeRangeMin();
		this.agerangemax = bean.getAgeRangeMax();
		this.legendtext = bean.getLegendText();
	}
	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.Question_InformationVoBean bean = null;
		if(map != null)
			bean = (ims.assessment.vo.beans.Question_InformationVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.assessment.vo.beans.Question_InformationVoBean();
			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("TEXT"))
			return getText();
		if(fieldName.equals("SHORTTEXT"))
			return getShortText();
		if(fieldName.equals("ISQUESTION"))
			return getIsQuestion();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("ANSWERTYPES"))
			return getAnswerTypes();
		if(fieldName.equals("GENDERSPECIFIC"))
			return getGenderSpecific();
		if(fieldName.equals("AGERANGEMIN"))
			return getAgeRangeMin();
		if(fieldName.equals("AGERANGEMAX"))
			return getAgeRangeMax();
		if(fieldName.equals("LEGENDTEXT"))
			return getLegendText();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getTextIsNotNull()
	{
		return this.text != null;
	}
	public String getText()
	{
		return this.text;
	}
	public static int getTextMaxLength()
	{
		return 500;
	}
	public void setText(String value)
	{
		this.isValidated = false;
		this.text = value;
	}
	public boolean getShortTextIsNotNull()
	{
		return this.shorttext != null;
	}
	public String getShortText()
	{
		return this.shorttext;
	}
	public static int getShortTextMaxLength()
	{
		return 500;
	}
	public void setShortText(String value)
	{
		this.isValidated = false;
		this.shorttext = value;
	}
	public boolean getIsQuestionIsNotNull()
	{
		return this.isquestion != null;
	}
	public Boolean getIsQuestion()
	{
		return this.isquestion;
	}
	public void setIsQuestion(Boolean value)
	{
		this.isValidated = false;
		this.isquestion = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.core.vo.lookups.PreActiveActiveInactiveStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.core.vo.lookups.PreActiveActiveInactiveStatus value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getAnswerTypesIsNotNull()
	{
		return this.answertypes != null;
	}
	public ims.assessment.vo.Question_AnswerTypeVoCollection getAnswerTypes()
	{
		return this.answertypes;
	}
	public void setAnswerTypes(ims.assessment.vo.Question_AnswerTypeVoCollection value)
	{
		this.isValidated = false;
		this.answertypes = 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 getLegendTextIsNotNull()
	{
		return this.legendtext != null;
	}
	public String getLegendText()
	{
		return this.legendtext;
	}
	public static int getLegendTextMaxLength()
	{
		return 5000;
	}
	public void setLegendText(String value)
	{
		this.isValidated = false;
		this.legendtext = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.answertypes != null)
		{
			if(!this.answertypes.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.text == null || this.text.length() == 0)
			listOfErrors.add("Text is mandatory");
		else if(this.text.length() > 500)
			listOfErrors.add("The length of the field [text] in the value object [ims.assessment.vo.Question_InformationVo] is too big. It should be less or equal to 500");
		if(this.shorttext == null || this.shorttext.length() == 0)
			listOfErrors.add("ShortText is mandatory");
		else if(this.shorttext.length() > 500)
			listOfErrors.add("The length of the field [shorttext] in the value object [ims.assessment.vo.Question_InformationVo] is too big. It should be less or equal to 500");
		if(this.isquestion == null)
			listOfErrors.add("isQuestion is mandatory");
		if(this.status == null)
			listOfErrors.add("Status is mandatory");
		if(this.answertypes != null)
		{
			String[] listOfOtherErrors = this.answertypes.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		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;
	
		Question_InformationVo clone = new Question_InformationVo(this.id, this.version);
		
		clone.text = this.text;
		clone.shorttext = this.shorttext;
		clone.isquestion = this.isquestion;
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.core.vo.lookups.PreActiveActiveInactiveStatus)this.status.clone();
		if(this.answertypes == null)
			clone.answertypes = null;
		else
			clone.answertypes = (ims.assessment.vo.Question_AnswerTypeVoCollection)this.answertypes.clone();
		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.legendtext = this.legendtext;
		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 (!(Question_InformationVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A Question_InformationVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((Question_InformationVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((Question_InformationVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.text != null)
			count++;
		if(this.shorttext != null)
			count++;
		if(this.isquestion != null)
			count++;
		if(this.status != null)
			count++;
		if(this.answertypes != null)
			count++;
		if(this.genderspecific != null)
			count++;
		if(this.agerangemin != null)
			count++;
		if(this.agerangemax != null)
			count++;
		if(this.legendtext != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected String text;
	protected String shorttext;
	protected Boolean isquestion;
	protected ims.core.vo.lookups.PreActiveActiveInactiveStatus status;
	protected ims.assessment.vo.Question_AnswerTypeVoCollection answertypes;
	protected ims.admin.vo.lookups.GenderSpecific genderspecific;
	protected Integer agerangemin;
	protected Integer agerangemax;
	protected String legendtext;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
