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

/**
 * Linked to core.configuration.DrawingImage business object (ID: 1021100008).
 */
public class DrawingImageVo extends ims.core.configuration.vo.DrawingImageRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public DrawingImageVo()
	{
	}
	public DrawingImageVo(Integer id, int version)
	{
		super(id, version);
	}
	public DrawingImageVo(ims.core.vo.beans.DrawingImageVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.category = bean.getCategory() == null ? null : ims.core.vo.lookups.DrawingCategories.buildLookup(bean.getCategory());
		this.type = bean.getType() == null ? null : ims.core.vo.lookups.DrawingCategories.buildLookup(bean.getType());
		this.imagename = bean.getImageName();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo();
		this.rootgroup = bean.getRootGroup() == null ? null : bean.getRootGroup().buildVo();
		this.versionnumber = bean.getVersionNumber();
		this.imagestatus = bean.getImageStatus() == null ? null : ims.core.vo.lookups.ConfigurationStatus.buildLookup(bean.getImageStatus());
		this.questions = ims.assessment.vo.ImageFindingQuestionVoCollection.buildFromBeanCollection(bean.getQuestions());
		this.assocfindings = ims.assessment.vo.ImageFindingVoCollection.buildFromBeanCollection(bean.getAssocFindings());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.DrawingImageVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.category = bean.getCategory() == null ? null : ims.core.vo.lookups.DrawingCategories.buildLookup(bean.getCategory());
		this.type = bean.getType() == null ? null : ims.core.vo.lookups.DrawingCategories.buildLookup(bean.getType());
		this.imagename = bean.getImageName();
		this.image = bean.getImage() == null ? null : bean.getImage().buildVo(map);
		this.rootgroup = bean.getRootGroup() == null ? null : bean.getRootGroup().buildVo(map);
		this.versionnumber = bean.getVersionNumber();
		this.imagestatus = bean.getImageStatus() == null ? null : ims.core.vo.lookups.ConfigurationStatus.buildLookup(bean.getImageStatus());
		this.questions = ims.assessment.vo.ImageFindingQuestionVoCollection.buildFromBeanCollection(bean.getQuestions());
		this.assocfindings = ims.assessment.vo.ImageFindingVoCollection.buildFromBeanCollection(bean.getAssocFindings());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.core.vo.beans.DrawingImageVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.DrawingImageVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.DrawingImageVoBean();
			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("CATEGORY"))
			return getCategory();
		if(fieldName.equals("TYPE"))
			return getType();
		if(fieldName.equals("IMAGENAME"))
			return getImageName();
		if(fieldName.equals("IMAGE"))
			return getImage();
		if(fieldName.equals("ROOTGROUP"))
			return getRootGroup();
		if(fieldName.equals("VERSIONNUMBER"))
			return getVersionNumber();
		if(fieldName.equals("IMAGESTATUS"))
			return getImageStatus();
		if(fieldName.equals("QUESTIONS"))
			return getQuestions();
		if(fieldName.equals("ASSOCFINDINGS"))
			return getAssocFindings();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getCategoryIsNotNull()
	{
		return this.category != null;
	}
	public ims.core.vo.lookups.DrawingCategories getCategory()
	{
		return this.category;
	}
	public void setCategory(ims.core.vo.lookups.DrawingCategories value)
	{
		this.isValidated = false;
		this.category = value;
	}
	public boolean getTypeIsNotNull()
	{
		return this.type != null;
	}
	public ims.core.vo.lookups.DrawingCategories getType()
	{
		return this.type;
	}
	public void setType(ims.core.vo.lookups.DrawingCategories value)
	{
		this.isValidated = false;
		this.type = value;
	}
	public boolean getImageNameIsNotNull()
	{
		return this.imagename != null;
	}
	public String getImageName()
	{
		return this.imagename;
	}
	public static int getImageNameMaxLength()
	{
		return 255;
	}
	public void setImageName(String value)
	{
		this.isValidated = false;
		this.imagename = 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 getRootGroupIsNotNull()
	{
		return this.rootgroup != null;
	}
	public ims.core.vo.DrawingGroupVo getRootGroup()
	{
		return this.rootgroup;
	}
	public void setRootGroup(ims.core.vo.DrawingGroupVo value)
	{
		this.isValidated = false;
		this.rootgroup = value;
	}
	public boolean getVersionNumberIsNotNull()
	{
		return this.versionnumber != null;
	}
	public Integer getVersionNumber()
	{
		return this.versionnumber;
	}
	public void setVersionNumber(Integer value)
	{
		this.isValidated = false;
		this.versionnumber = value;
	}
	public boolean getImageStatusIsNotNull()
	{
		return this.imagestatus != null;
	}
	public ims.core.vo.lookups.ConfigurationStatus getImageStatus()
	{
		return this.imagestatus;
	}
	public void setImageStatus(ims.core.vo.lookups.ConfigurationStatus value)
	{
		this.isValidated = false;
		this.imagestatus = value;
	}
	public boolean getQuestionsIsNotNull()
	{
		return this.questions != null;
	}
	public ims.assessment.vo.ImageFindingQuestionVoCollection getQuestions()
	{
		return this.questions;
	}
	public void setQuestions(ims.assessment.vo.ImageFindingQuestionVoCollection value)
	{
		this.isValidated = false;
		this.questions = value;
	}
	public boolean getAssocFindingsIsNotNull()
	{
		return this.assocfindings != null;
	}
	public ims.assessment.vo.ImageFindingVoCollection getAssocFindings()
	{
		return this.assocfindings;
	}
	public void setAssocFindings(ims.assessment.vo.ImageFindingVoCollection value)
	{
		this.isValidated = false;
		this.assocfindings = value;
	}
	/**
	* 2Arg Contsructor
	*/
	public DrawingImageVo(Integer imageID, String imageName , Integer versionNumber)
	{
		ims.admin.vo.AppImageVo voAppImage = new ims.admin.vo.AppImageVo();
		voAppImage.setID_AppImage(imageID);
		this.setImage(voAppImage);
		this.versionnumber = versionNumber;
		this.imagename = imageName;
	}
	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.rootgroup != null)
		{
			if(!this.rootgroup.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.questions != null)
		{
			if(!this.questions.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.assocfindings != null)
		{
			if(!this.assocfindings.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.imagename != null)
			if(this.imagename.length() > 255)
				listOfErrors.add("The length of the field [imagename] in the value object [ims.core.vo.DrawingImageVo] 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.rootgroup != null)
		{
			String[] listOfOtherErrors = this.rootgroup.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.questions != null)
		{
			String[] listOfOtherErrors = this.questions.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.assocfindings != null)
		{
			String[] listOfOtherErrors = this.assocfindings.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;
	
		DrawingImageVo clone = new DrawingImageVo(this.id, this.version);
		
		if(this.category == null)
			clone.category = null;
		else
			clone.category = (ims.core.vo.lookups.DrawingCategories)this.category.clone();
		if(this.type == null)
			clone.type = null;
		else
			clone.type = (ims.core.vo.lookups.DrawingCategories)this.type.clone();
		clone.imagename = this.imagename;
		if(this.image == null)
			clone.image = null;
		else
			clone.image = (ims.admin.vo.AppImageVo)this.image.clone();
		if(this.rootgroup == null)
			clone.rootgroup = null;
		else
			clone.rootgroup = (ims.core.vo.DrawingGroupVo)this.rootgroup.clone();
		clone.versionnumber = this.versionnumber;
		if(this.imagestatus == null)
			clone.imagestatus = null;
		else
			clone.imagestatus = (ims.core.vo.lookups.ConfigurationStatus)this.imagestatus.clone();
		if(this.questions == null)
			clone.questions = null;
		else
			clone.questions = (ims.assessment.vo.ImageFindingQuestionVoCollection)this.questions.clone();
		if(this.assocfindings == null)
			clone.assocfindings = null;
		else
			clone.assocfindings = (ims.assessment.vo.ImageFindingVoCollection)this.assocfindings.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 (!(DrawingImageVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A DrawingImageVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		DrawingImageVo compareObj = (DrawingImageVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getImageName() == null && compareObj.getImageName() != null)
				return -1;
			if(this.getImageName() != null && compareObj.getImageName() == null)
				return 1;
			if(this.getImageName() != null && compareObj.getImageName() != null)
			{
				if(caseInsensitive)
					retVal = this.getImageName().toLowerCase().compareTo(compareObj.getImageName().toLowerCase());
				else
					retVal = this.getImageName().compareTo(compareObj.getImageName());
			}
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.category != null)
			count++;
		if(this.type != null)
			count++;
		if(this.imagename != null)
			count++;
		if(this.image != null)
			count++;
		if(this.rootgroup != null)
			count++;
		if(this.versionnumber != null)
			count++;
		if(this.imagestatus != null)
			count++;
		if(this.questions != null)
			count++;
		if(this.assocfindings != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 9;
	}
	protected ims.core.vo.lookups.DrawingCategories category;
	protected ims.core.vo.lookups.DrawingCategories type;
	protected String imagename;
	protected ims.admin.vo.AppImageVo image;
	protected ims.core.vo.DrawingGroupVo rootgroup;
	protected Integer versionnumber;
	protected ims.core.vo.lookups.ConfigurationStatus imagestatus;
	protected ims.assessment.vo.ImageFindingQuestionVoCollection questions;
	protected ims.assessment.vo.ImageFindingVoCollection assocfindings;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
