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

	public UserAssessmentVo()
	{
	}
	public UserAssessmentVo(Integer id, int version)
	{
		super(id, version);
	}
	public UserAssessmentVo(ims.assessment.vo.beans.UserAssessmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.description = bean.getDescription();
		this.assessmenttype = bean.getAssessmentType() == null ? null : ims.core.vo.lookups.UserDefinedAssessmentType.buildLookup(bean.getAssessmentType());
		this.activestatus = bean.getActiveStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getActiveStatus());
		this.helpurl = bean.getHelpURL();
		this.systeminfo = bean.getSystemInfo() == null ? null : bean.getSystemInfo().buildSystemInformation();
		this.scoringmethod = bean.getScoringMethod() == null ? null : ims.core.vo.lookups.UserAssessmentScoringMethod.buildLookup(bean.getScoringMethod());
		this.isflatview = bean.getIsFlatView();
		this.category = bean.getCategory() == null ? null : ims.core.vo.lookups.UserAssessmentCategory.buildLookup(bean.getCategory());
		this.ismultiplegroup = bean.getIsMultipleGroup();
		this.groupquestionwidth = bean.getGroupQuestionWidth();
		this.storeprintedassessment = bean.getStorePrintedAssessment();
		this.questiongroups = ims.core.vo.AssessmentQuestionGroupVoCollection.buildFromBeanCollection(bean.getQuestionGroups());
		this.ismultirole = bean.getIsMultiRole();
		this.assessmentroles = ims.assessment.vo.AssessmentRoleVoCollection.buildFromBeanCollection(bean.getAssessmentRoles());
		this.headertext = bean.getHeaderText();
		this.footertext = bean.getFooterText();
		this.maxheaderheight = bean.getMaxHeaderHeight();
		this.maxfooterheight = bean.getMaxFooterHeight();
		this.associatedreport = bean.getAssociatedReport() == null ? null : new ims.core.admin.vo.TemplateBoRefVo(new Integer(bean.getAssociatedReport().getId()), bean.getAssociatedReport().getVersion());
		this.assessmentspecialties = ims.core.vo.lookups.SpecialtyCollection.buildFromBeanCollection(bean.getAssessmentSpecialties());
		this.cancopylast = bean.getCanCopyLast();
		this.copylastfromcontext = bean.getCopyLastFromContext() == null ? null : ims.assessment.vo.lookups.CopyLastAssessmentContextType.buildLookup(bean.getCopyLastFromContext());
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
		this.services = ims.core.vo.ServiceShortVoCollection.buildFromBeanCollection(bean.getServices());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.assessment.vo.beans.UserAssessmentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.description = bean.getDescription();
		this.assessmenttype = bean.getAssessmentType() == null ? null : ims.core.vo.lookups.UserDefinedAssessmentType.buildLookup(bean.getAssessmentType());
		this.activestatus = bean.getActiveStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getActiveStatus());
		this.helpurl = bean.getHelpURL();
		this.systeminfo = bean.getSystemInfo() == null ? null : bean.getSystemInfo().buildSystemInformation();
		this.scoringmethod = bean.getScoringMethod() == null ? null : ims.core.vo.lookups.UserAssessmentScoringMethod.buildLookup(bean.getScoringMethod());
		this.isflatview = bean.getIsFlatView();
		this.category = bean.getCategory() == null ? null : ims.core.vo.lookups.UserAssessmentCategory.buildLookup(bean.getCategory());
		this.ismultiplegroup = bean.getIsMultipleGroup();
		this.groupquestionwidth = bean.getGroupQuestionWidth();
		this.storeprintedassessment = bean.getStorePrintedAssessment();
		this.questiongroups = ims.core.vo.AssessmentQuestionGroupVoCollection.buildFromBeanCollection(bean.getQuestionGroups());
		this.ismultirole = bean.getIsMultiRole();
		this.assessmentroles = ims.assessment.vo.AssessmentRoleVoCollection.buildFromBeanCollection(bean.getAssessmentRoles());
		this.headertext = bean.getHeaderText();
		this.footertext = bean.getFooterText();
		this.maxheaderheight = bean.getMaxHeaderHeight();
		this.maxfooterheight = bean.getMaxFooterHeight();
		this.associatedreport = bean.getAssociatedReport() == null ? null : new ims.core.admin.vo.TemplateBoRefVo(new Integer(bean.getAssociatedReport().getId()), bean.getAssociatedReport().getVersion());
		this.assessmentspecialties = ims.core.vo.lookups.SpecialtyCollection.buildFromBeanCollection(bean.getAssessmentSpecialties());
		this.cancopylast = bean.getCanCopyLast();
		this.copylastfromcontext = bean.getCopyLastFromContext() == null ? null : ims.assessment.vo.lookups.CopyLastAssessmentContextType.buildLookup(bean.getCopyLastFromContext());
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
		this.services = ims.core.vo.ServiceShortVoCollection.buildFromBeanCollection(bean.getServices());
	}
	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.UserAssessmentVoBean bean = null;
		if(map != null)
			bean = (ims.assessment.vo.beans.UserAssessmentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.assessment.vo.beans.UserAssessmentVoBean();
			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("QUESTIONGROUPS"))
			return getQuestionGroups();
		if(fieldName.equals("ISMULTIROLE"))
			return getIsMultiRole();
		if(fieldName.equals("ASSESSMENTROLES"))
			return getAssessmentRoles();
		if(fieldName.equals("HEADERTEXT"))
			return getHeaderText();
		if(fieldName.equals("FOOTERTEXT"))
			return getFooterText();
		if(fieldName.equals("MAXHEADERHEIGHT"))
			return getMaxHeaderHeight();
		if(fieldName.equals("MAXFOOTERHEIGHT"))
			return getMaxFooterHeight();
		if(fieldName.equals("ASSOCIATEDREPORT"))
			return getAssociatedReport();
		if(fieldName.equals("ASSESSMENTSPECIALTIES"))
			return getAssessmentSpecialties();
		if(fieldName.equals("CANCOPYLAST"))
			return getCanCopyLast();
		if(fieldName.equals("COPYLASTFROMCONTEXT"))
			return getCopyLastFromContext();
		if(fieldName.equals("TAXONOMYMAP"))
			return getTaxonomyMap();
		if(fieldName.equals("SERVICES"))
			return getServices();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getQuestionGroupsIsNotNull()
	{
		return this.questiongroups != null;
	}
	public ims.core.vo.AssessmentQuestionGroupVoCollection getQuestionGroups()
	{
		return this.questiongroups;
	}
	public void setQuestionGroups(ims.core.vo.AssessmentQuestionGroupVoCollection value)
	{
		this.isValidated = false;
		this.questiongroups = value;
	}
	public boolean getIsMultiRoleIsNotNull()
	{
		return this.ismultirole != null;
	}
	public Boolean getIsMultiRole()
	{
		return this.ismultirole;
	}
	public void setIsMultiRole(Boolean value)
	{
		this.isValidated = false;
		this.ismultirole = value;
	}
	public boolean getAssessmentRolesIsNotNull()
	{
		return this.assessmentroles != null;
	}
	public ims.assessment.vo.AssessmentRoleVoCollection getAssessmentRoles()
	{
		return this.assessmentroles;
	}
	public void setAssessmentRoles(ims.assessment.vo.AssessmentRoleVoCollection value)
	{
		this.isValidated = false;
		this.assessmentroles = value;
	}
	public boolean getHeaderTextIsNotNull()
	{
		return this.headertext != null;
	}
	public String getHeaderText()
	{
		return this.headertext;
	}
	public static int getHeaderTextMaxLength()
	{
		return 5000;
	}
	public void setHeaderText(String value)
	{
		this.isValidated = false;
		this.headertext = value;
	}
	public boolean getFooterTextIsNotNull()
	{
		return this.footertext != null;
	}
	public String getFooterText()
	{
		return this.footertext;
	}
	public static int getFooterTextMaxLength()
	{
		return 5000;
	}
	public void setFooterText(String value)
	{
		this.isValidated = false;
		this.footertext = value;
	}
	public boolean getMaxHeaderHeightIsNotNull()
	{
		return this.maxheaderheight != null;
	}
	public Integer getMaxHeaderHeight()
	{
		return this.maxheaderheight;
	}
	public void setMaxHeaderHeight(Integer value)
	{
		this.isValidated = false;
		this.maxheaderheight = value;
	}
	public boolean getMaxFooterHeightIsNotNull()
	{
		return this.maxfooterheight != null;
	}
	public Integer getMaxFooterHeight()
	{
		return this.maxfooterheight;
	}
	public void setMaxFooterHeight(Integer value)
	{
		this.isValidated = false;
		this.maxfooterheight = value;
	}
	public boolean getAssociatedReportIsNotNull()
	{
		return this.associatedreport != null;
	}
	public ims.core.admin.vo.TemplateBoRefVo getAssociatedReport()
	{
		return this.associatedreport;
	}
	public void setAssociatedReport(ims.core.admin.vo.TemplateBoRefVo value)
	{
		this.isValidated = false;
		this.associatedreport = value;
	}
	public boolean getAssessmentSpecialtiesIsNotNull()
	{
		return this.assessmentspecialties != null;
	}
	public ims.core.vo.lookups.SpecialtyCollection getAssessmentSpecialties()
	{
		return this.assessmentspecialties;
	}
	public void setAssessmentSpecialties(ims.core.vo.lookups.SpecialtyCollection value)
	{
		this.isValidated = false;
		this.assessmentspecialties = value;
	}
	public boolean getCanCopyLastIsNotNull()
	{
		return this.cancopylast != null;
	}
	public Boolean getCanCopyLast()
	{
		return this.cancopylast;
	}
	public void setCanCopyLast(Boolean value)
	{
		this.isValidated = false;
		this.cancopylast = value;
	}
	public boolean getCopyLastFromContextIsNotNull()
	{
		return this.copylastfromcontext != null;
	}
	public ims.assessment.vo.lookups.CopyLastAssessmentContextType getCopyLastFromContext()
	{
		return this.copylastfromcontext;
	}
	public void setCopyLastFromContext(ims.assessment.vo.lookups.CopyLastAssessmentContextType value)
	{
		this.isValidated = false;
		this.copylastfromcontext = value;
	}
	public boolean getTaxonomyMapIsNotNull()
	{
		return this.taxonomymap != null;
	}
	public ims.core.vo.TaxonomyMapCollection getTaxonomyMap()
	{
		return this.taxonomymap;
	}
	public void setTaxonomyMap(ims.core.vo.TaxonomyMapCollection value)
	{
		this.isValidated = false;
		this.taxonomymap = value;
	}
	public boolean getServicesIsNotNull()
	{
		return this.services != null;
	}
	public ims.core.vo.ServiceShortVoCollection getServices()
	{
		return this.services;
	}
	public void setServices(ims.core.vo.ServiceShortVoCollection value)
	{
		this.isValidated = false;
		this.services = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.questiongroups != null)
		{
			if(!this.questiongroups.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.assessmentroles != null)
		{
			if(!this.assessmentroles.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.taxonomymap != null)
		{
			if(!this.taxonomymap.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.name == null || this.name.length() == 0)
			listOfErrors.add("Name is mandatory");
		else if(this.name.length() > 100)
			listOfErrors.add("The length of the field [name] in the value object [ims.assessment.vo.UserAssessmentVo] is too big. It should be less or equal to 100");
		if(this.description != null)
			if(this.description.length() > 500)
				listOfErrors.add("The length of the field [description] in the value object [ims.assessment.vo.UserAssessmentVo] is too big. It should be less or equal to 500");
		if(this.activestatus == null)
			listOfErrors.add("ActiveStatus is mandatory");
		if(this.helpurl != null)
			if(this.helpurl.length() > 1024)
				listOfErrors.add("The length of the field [helpurl] in the value object [ims.assessment.vo.UserAssessmentVo] is too big. It should be less or equal to 1024");
		if(this.isflatview == null)
			listOfErrors.add("isFlatView is mandatory");
		if(this.groupquestionwidth != null && (this.groupquestionwidth.intValue() < 50 || this.groupquestionwidth.intValue() > 600))
			listOfErrors.add("Group Question Width has an invalid value. The valid range of values is between 50 and 600");
		if(this.questiongroups != null)
		{
			String[] listOfOtherErrors = this.questiongroups.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.assessmentroles != null)
		{
			String[] listOfOtherErrors = this.assessmentroles.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.maxheaderheight != null && (this.maxheaderheight.intValue() < 50 || this.maxheaderheight.intValue() > 300))
			listOfErrors.add("The maximum header height value should be between 50 and 300");
		if(this.maxfooterheight != null && (this.maxfooterheight.intValue() < 50 || this.maxfooterheight.intValue() > 300))
			listOfErrors.add("The maximum footer height value should be between 50 and 300");
		if(this.taxonomymap != null)
		{
			String[] listOfOtherErrors = this.taxonomymap.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;
	
		UserAssessmentVo clone = new UserAssessmentVo(this.id, this.version);
		
		clone.name = this.name;
		clone.description = this.description;
		if(this.assessmenttype == null)
			clone.assessmenttype = null;
		else
			clone.assessmenttype = (ims.core.vo.lookups.UserDefinedAssessmentType)this.assessmenttype.clone();
		if(this.activestatus == null)
			clone.activestatus = null;
		else
			clone.activestatus = (ims.core.vo.lookups.PreActiveActiveInactiveStatus)this.activestatus.clone();
		clone.helpurl = this.helpurl;
		if(this.systeminfo == null)
			clone.systeminfo = null;
		else
			clone.systeminfo = (ims.vo.SystemInformation)this.systeminfo.clone();
		if(this.scoringmethod == null)
			clone.scoringmethod = null;
		else
			clone.scoringmethod = (ims.core.vo.lookups.UserAssessmentScoringMethod)this.scoringmethod.clone();
		clone.isflatview = this.isflatview;
		if(this.category == null)
			clone.category = null;
		else
			clone.category = (ims.core.vo.lookups.UserAssessmentCategory)this.category.clone();
		clone.ismultiplegroup = this.ismultiplegroup;
		clone.groupquestionwidth = this.groupquestionwidth;
		clone.storeprintedassessment = this.storeprintedassessment;
		if(this.questiongroups == null)
			clone.questiongroups = null;
		else
			clone.questiongroups = (ims.core.vo.AssessmentQuestionGroupVoCollection)this.questiongroups.clone();
		clone.ismultirole = this.ismultirole;
		if(this.assessmentroles == null)
			clone.assessmentroles = null;
		else
			clone.assessmentroles = (ims.assessment.vo.AssessmentRoleVoCollection)this.assessmentroles.clone();
		clone.headertext = this.headertext;
		clone.footertext = this.footertext;
		clone.maxheaderheight = this.maxheaderheight;
		clone.maxfooterheight = this.maxfooterheight;
		clone.associatedreport = this.associatedreport;
		if(this.assessmentspecialties == null)
			clone.assessmentspecialties = null;
		else
			clone.assessmentspecialties = (ims.core.vo.lookups.SpecialtyCollection)this.assessmentspecialties.clone();
		clone.cancopylast = this.cancopylast;
		if(this.copylastfromcontext == null)
			clone.copylastfromcontext = null;
		else
			clone.copylastfromcontext = (ims.assessment.vo.lookups.CopyLastAssessmentContextType)this.copylastfromcontext.clone();
		if(this.taxonomymap == null)
			clone.taxonomymap = null;
		else
			clone.taxonomymap = (ims.core.vo.TaxonomyMapCollection)this.taxonomymap.clone();
		if(this.services == null)
			clone.services = null;
		else
			clone.services = (ims.core.vo.ServiceShortVoCollection)this.services.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 (!(UserAssessmentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A UserAssessmentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		UserAssessmentVo compareObj = (UserAssessmentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getName() == null && compareObj.getName() != null)
				return -1;
			if(this.getName() != null && compareObj.getName() == null)
				return 1;
			if(this.getName() != null && compareObj.getName() != null)
			{
				if(caseInsensitive)
					retVal = this.getName().toLowerCase().compareTo(compareObj.getName().toLowerCase());
				else
					retVal = this.getName().compareTo(compareObj.getName());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.questiongroups != null)
			count++;
		if(this.ismultirole != null)
			count++;
		if(this.assessmentroles != null)
			count++;
		if(this.headertext != null)
			count++;
		if(this.footertext != null)
			count++;
		if(this.maxheaderheight != null)
			count++;
		if(this.maxfooterheight != null)
			count++;
		if(this.associatedreport != null)
			count++;
		if(this.assessmentspecialties != null)
			count++;
		if(this.cancopylast != null)
			count++;
		if(this.copylastfromcontext != null)
			count++;
		if(this.taxonomymap != null)
			count++;
		if(this.services != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 13;
	}
	protected ims.core.vo.AssessmentQuestionGroupVoCollection questiongroups;
	protected Boolean ismultirole;
	protected ims.assessment.vo.AssessmentRoleVoCollection assessmentroles;
	protected String headertext;
	protected String footertext;
	protected Integer maxheaderheight;
	protected Integer maxfooterheight;
	protected ims.core.admin.vo.TemplateBoRefVo associatedreport;
	protected ims.core.vo.lookups.SpecialtyCollection assessmentspecialties;
	protected Boolean cancopylast;
	protected ims.assessment.vo.lookups.CopyLastAssessmentContextType copylastfromcontext;
	protected ims.core.vo.TaxonomyMapCollection taxonomymap;
	protected ims.core.vo.ServiceShortVoCollection services;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
