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

/**
 * Linked to eDischarge.TTAStatus business object (ID: 1099100017).
 */
public class TTAStatusVo extends ims.edischarge.vo.TTAStatusRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public TTAStatusVo()
	{
	}
	public TTAStatusVo(Integer id, int version)
	{
		super(id, version);
	}
	public TTAStatusVo(ims.clinical.vo.beans.TTAStatusVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.status = bean.getStatus() == null ? null : ims.clinical.vo.lookups.TTAStatus.buildLookup(bean.getStatus());
		this.authoringuser = bean.getAuthoringUser() == null ? null : bean.getAuthoringUser().buildVo();
		this.statusdatetime = bean.getStatusDateTime() == null ? null : bean.getStatusDateTime().buildDateTime();
		this.reasonforrejection = bean.getReasonForRejection();
		this.reasonforsuspension = bean.getReasonForSuspension();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.clinical.vo.beans.TTAStatusVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.status = bean.getStatus() == null ? null : ims.clinical.vo.lookups.TTAStatus.buildLookup(bean.getStatus());
		this.authoringuser = bean.getAuthoringUser() == null ? null : bean.getAuthoringUser().buildVo(map);
		this.statusdatetime = bean.getStatusDateTime() == null ? null : bean.getStatusDateTime().buildDateTime();
		this.reasonforrejection = bean.getReasonForRejection();
		this.reasonforsuspension = bean.getReasonForSuspension();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.clinical.vo.beans.TTAStatusVoBean bean = null;
		if(map != null)
			bean = (ims.clinical.vo.beans.TTAStatusVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.clinical.vo.beans.TTAStatusVoBean();
			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("STATUS"))
			return getStatus();
		if(fieldName.equals("AUTHORINGUSER"))
			return getAuthoringUser();
		if(fieldName.equals("STATUSDATETIME"))
			return getStatusDateTime();
		if(fieldName.equals("REASONFORREJECTION"))
			return getReasonForRejection();
		if(fieldName.equals("REASONFORSUSPENSION"))
			return getReasonForSuspension();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.clinical.vo.lookups.TTAStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.clinical.vo.lookups.TTAStatus value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getAuthoringUserIsNotNull()
	{
		return this.authoringuser != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getAuthoringUser()
	{
		return this.authoringuser;
	}
	public void setAuthoringUser(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.authoringuser = value;
	}
	public boolean getStatusDateTimeIsNotNull()
	{
		return this.statusdatetime != null;
	}
	public ims.framework.utils.DateTime getStatusDateTime()
	{
		return this.statusdatetime;
	}
	public void setStatusDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.statusdatetime = value;
	}
	public boolean getReasonForRejectionIsNotNull()
	{
		return this.reasonforrejection != null;
	}
	public String getReasonForRejection()
	{
		return this.reasonforrejection;
	}
	public static int getReasonForRejectionMaxLength()
	{
		return 1500;
	}
	public void setReasonForRejection(String value)
	{
		this.isValidated = false;
		this.reasonforrejection = value;
	}
	public boolean getReasonForSuspensionIsNotNull()
	{
		return this.reasonforsuspension != null;
	}
	public String getReasonForSuspension()
	{
		return this.reasonforsuspension;
	}
	public static int getReasonForSuspensionMaxLength()
	{
		return 1500;
	}
	public void setReasonForSuspension(String value)
	{
		this.isValidated = false;
		this.reasonforsuspension = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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.status == null)
			listOfErrors.add("Status is mandatory");
		if(this.authoringuser == null)
			listOfErrors.add("User must be member of staff.");
		if(this.statusdatetime == null)
			listOfErrors.add("User must be member of staff.");
		if(this.reasonforrejection != null)
			if(this.reasonforrejection.length() > 1500)
				listOfErrors.add("The length of the field [reasonforrejection] in the value object [ims.clinical.vo.TTAStatusVo] is too big. It should be less or equal to 1500");
		if(this.reasonforsuspension != null)
			if(this.reasonforsuspension.length() > 1500)
				listOfErrors.add("The length of the field [reasonforsuspension] in the value object [ims.clinical.vo.TTAStatusVo] is too big. It should be less or equal to 1500");
		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;
	
		TTAStatusVo clone = new TTAStatusVo(this.id, this.version);
		
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.clinical.vo.lookups.TTAStatus)this.status.clone();
		if(this.authoringuser == null)
			clone.authoringuser = null;
		else
			clone.authoringuser = (ims.core.vo.MemberOfStaffLiteVo)this.authoringuser.clone();
		if(this.statusdatetime == null)
			clone.statusdatetime = null;
		else
			clone.statusdatetime = (ims.framework.utils.DateTime)this.statusdatetime.clone();
		clone.reasonforrejection = this.reasonforrejection;
		clone.reasonforsuspension = this.reasonforsuspension;
		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 (!(TTAStatusVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A TTAStatusVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((TTAStatusVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((TTAStatusVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.status != null)
			count++;
		if(this.authoringuser != null)
			count++;
		if(this.statusdatetime != null)
			count++;
		if(this.reasonforrejection != null)
			count++;
		if(this.reasonforsuspension != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 5;
	}
	protected ims.clinical.vo.lookups.TTAStatus status;
	protected ims.core.vo.MemberOfStaffLiteVo authoringuser;
	protected ims.framework.utils.DateTime statusdatetime;
	protected String reasonforrejection;
	protected String reasonforsuspension;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
