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


public class AuditVo extends ims.vo.ValueObject implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public AuditVo()
	{
	}
	public AuditVo(ims.core.vo.beans.AuditVoBean bean)
	{
		this.auditdatetime = bean.getAuditDateTime() == null ? null : bean.getAuditDateTime().buildDateTime();
		this.audituser = bean.getAuditUser();
		this.action = bean.getAction();
		this.classidentifier = bean.getClassIdentifier();
		this.classname = bean.getClassName();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo();
		this.difffields = bean.getDiffFields();
		this.hostname = bean.getHostName();
		this.contact = bean.getContact() == null ? null : bean.getContact().buildVo();
		this.carecontext = bean.getCareContext() == null ? null : bean.getCareContext().buildVo();
		this.audituserrole = bean.getAuditUserRole();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.AuditVoBean bean)
	{
		this.auditdatetime = bean.getAuditDateTime() == null ? null : bean.getAuditDateTime().buildDateTime();
		this.audituser = bean.getAuditUser();
		this.action = bean.getAction();
		this.classidentifier = bean.getClassIdentifier();
		this.classname = bean.getClassName();
		this.patient = bean.getPatient() == null ? null : bean.getPatient().buildVo(map);
		this.difffields = bean.getDiffFields();
		this.hostname = bean.getHostName();
		this.contact = bean.getContact() == null ? null : bean.getContact().buildVo(map);
		this.carecontext = bean.getCareContext() == null ? null : bean.getCareContext().buildVo(map);
		this.audituserrole = bean.getAuditUserRole();
	}
	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.AuditVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.AuditVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.AuditVoBean();
			map.addValueObjectBean(this, bean);
			bean.populate(map, this);
		}
		return bean;
	}
	public boolean getAuditDateTimeIsNotNull()
	{
		return this.auditdatetime != null;
	}
	public ims.framework.utils.DateTime getAuditDateTime()
	{
		return this.auditdatetime;
	}
	public void setAuditDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.auditdatetime = value;
	}
	public boolean getAuditUserIsNotNull()
	{
		return this.audituser != null;
	}
	public String getAuditUser()
	{
		return this.audituser;
	}
	public static int getAuditUserMaxLength()
	{
		return 255;
	}
	public void setAuditUser(String value)
	{
		this.isValidated = false;
		this.audituser = value;
	}
	public boolean getActionIsNotNull()
	{
		return this.action != null;
	}
	public String getAction()
	{
		return this.action;
	}
	public static int getActionMaxLength()
	{
		return 255;
	}
	public void setAction(String value)
	{
		this.isValidated = false;
		this.action = value;
	}
	public boolean getClassIdentifierIsNotNull()
	{
		return this.classidentifier != null;
	}
	public Integer getClassIdentifier()
	{
		return this.classidentifier;
	}
	public void setClassIdentifier(Integer value)
	{
		this.isValidated = false;
		this.classidentifier = value;
	}
	public boolean getClassNameIsNotNull()
	{
		return this.classname != null;
	}
	public String getClassName()
	{
		return this.classname;
	}
	public static int getClassNameMaxLength()
	{
		return 255;
	}
	public void setClassName(String value)
	{
		this.isValidated = false;
		this.classname = value;
	}
	public boolean getPatientIsNotNull()
	{
		return this.patient != null;
	}
	public ims.core.vo.PatientShort getPatient()
	{
		return this.patient;
	}
	public void setPatient(ims.core.vo.PatientShort value)
	{
		this.isValidated = false;
		this.patient = value;
	}
	public boolean getDiffFieldsIsNotNull()
	{
		return this.difffields != null;
	}
	public String getDiffFields()
	{
		return this.difffields;
	}
	public static int getDiffFieldsMaxLength()
	{
		return 255;
	}
	public void setDiffFields(String value)
	{
		this.isValidated = false;
		this.difffields = value;
	}
	public boolean getHostNameIsNotNull()
	{
		return this.hostname != null;
	}
	public String getHostName()
	{
		return this.hostname;
	}
	public static int getHostNameMaxLength()
	{
		return 255;
	}
	public void setHostName(String value)
	{
		this.isValidated = false;
		this.hostname = value;
	}
	public boolean getContactIsNotNull()
	{
		return this.contact != null;
	}
	public ims.core.vo.ClinicalContactShortVo getContact()
	{
		return this.contact;
	}
	public void setContact(ims.core.vo.ClinicalContactShortVo value)
	{
		this.isValidated = false;
		this.contact = value;
	}
	public boolean getCareContextIsNotNull()
	{
		return this.carecontext != null;
	}
	public ims.core.vo.CareContextShortVo getCareContext()
	{
		return this.carecontext;
	}
	public void setCareContext(ims.core.vo.CareContextShortVo value)
	{
		this.isValidated = false;
		this.carecontext = value;
	}
	public boolean getAuditUserRoleIsNotNull()
	{
		return this.audituserrole != null;
	}
	public String getAuditUserRole()
	{
		return this.audituserrole;
	}
	public static int getAuditUserRoleMaxLength()
	{
		return 255;
	}
	public void setAuditUserRole(String value)
	{
		this.isValidated = false;
		this.audituserrole = value;
	}
	public final String getIItemText()
	{
		return toString();
	}
	public final Integer getBoId() 
	{
		return null;
	}
	public final String getBoClassName()
	{
		return null;
	}
	public boolean equals(Object obj)
	{
		if(obj == null)
			return false;
		if(!(obj instanceof AuditVo))
			return false;
		AuditVo compareObj = (AuditVo)obj;
		if(this.getClassIdentifier() == null && compareObj.getClassIdentifier() != null)
			return false;
		if(this.getClassIdentifier() != null && compareObj.getClassIdentifier() == null)
			return false;
		if(this.getClassIdentifier() != null && compareObj.getClassIdentifier() != null)
			if(!this.getClassIdentifier().equals(compareObj.getClassIdentifier()))
				return false;
		if(this.getClassName() == null && compareObj.getClassName() != null)
			return false;
		if(this.getClassName() != null && compareObj.getClassName() == null)
			return false;
		if(this.getClassName() != null && compareObj.getClassName() != null)
			if(!this.getClassName().equals(compareObj.getClassName()))
				return false;
		if(this.getAuditDateTime() == null && compareObj.getAuditDateTime() != null)
			return false;
		if(this.getAuditDateTime() != null && compareObj.getAuditDateTime() == null)
			return false;
		if(this.getAuditDateTime() != null && compareObj.getAuditDateTime() != null)
			return this.getAuditDateTime().equals(compareObj.getAuditDateTime());
		return super.equals(obj);
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.patient != null)
		{
			if(!this.patient.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.contact != null)
		{
			if(!this.contact.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.carecontext != null)
		{
			if(!this.carecontext.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.patient != null)
		{
			String[] listOfOtherErrors = this.patient.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.contact != null)
		{
			String[] listOfOtherErrors = this.contact.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.carecontext != null)
		{
			String[] listOfOtherErrors = this.carecontext.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 Object clone()
	{
		if(this.isBusy)
			return this;
		this.isBusy = true;
	
		AuditVo clone = new AuditVo();
		
		if(this.auditdatetime == null)
			clone.auditdatetime = null;
		else
			clone.auditdatetime = (ims.framework.utils.DateTime)this.auditdatetime.clone();
		clone.audituser = this.audituser;
		clone.action = this.action;
		clone.classidentifier = this.classidentifier;
		clone.classname = this.classname;
		if(this.patient == null)
			clone.patient = null;
		else
			clone.patient = (ims.core.vo.PatientShort)this.patient.clone();
		clone.difffields = this.difffields;
		clone.hostname = this.hostname;
		if(this.contact == null)
			clone.contact = null;
		else
			clone.contact = (ims.core.vo.ClinicalContactShortVo)this.contact.clone();
		if(this.carecontext == null)
			clone.carecontext = null;
		else
			clone.carecontext = (ims.core.vo.CareContextShortVo)this.carecontext.clone();
		clone.audituserrole = this.audituserrole;
		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 (!(AuditVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A AuditVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		AuditVo compareObj = (AuditVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getAuditDateTime() == null && compareObj.getAuditDateTime() != null)
				return -1;
			if(this.getAuditDateTime() != null && compareObj.getAuditDateTime() == null)
				return 1;
			if(this.getAuditDateTime() != null && compareObj.getAuditDateTime() != null)
				retVal = this.getAuditDateTime().compareTo(compareObj.getAuditDateTime());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.auditdatetime != null)
			count++;
		if(this.audituser != null)
			count++;
		if(this.action != null)
			count++;
		if(this.classidentifier != null)
			count++;
		if(this.classname != null)
			count++;
		if(this.patient != null)
			count++;
		if(this.difffields != null)
			count++;
		if(this.hostname != null)
			count++;
		if(this.contact != null)
			count++;
		if(this.carecontext != null)
			count++;
		if(this.audituserrole != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 11;
	}
	protected ims.framework.utils.DateTime auditdatetime;
	protected String audituser;
	protected String action;
	protected Integer classidentifier;
	protected String classname;
	protected ims.core.vo.PatientShort patient;
	protected String difffields;
	protected String hostname;
	protected ims.core.vo.ClinicalContactShortVo contact;
	protected ims.core.vo.CareContextShortVo carecontext;
	protected String audituserrole;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
