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

/**
 * Linked to Pathways.Configuration.Event business object (ID: 1089100000).
 */
public class EventLiteVo extends ims.pathways.configuration.vo.EventRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public EventLiteVo()
	{
	}
	public EventLiteVo(Integer id, int version)
	{
		super(id, version);
	}
	public EventLiteVo(ims.pathways.vo.beans.EventLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.description = bean.getDescription();
		this.icon = bean.getIcon() == null ? null : bean.getIcon().buildVo();
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getStatus());
		this.actioningroles = ims.admin.vo.AppRoleShortVoCollection.buildFromBeanCollection(bean.getActioningRoles());
		this.patientdiaryimpact = bean.getPatientDiaryImpact();
		this.eventtype = bean.getEventType() == null ? null : ims.pathways.vo.lookups.EventCreationType.buildLookup(bean.getEventType());
		this.startsclock = bean.getStartsClock();
		this.stopsclock = bean.getStopsClock();
		this.endspathway = bean.getEndsPathway();
		this.ismanualscheduledevent = bean.getIsManualScheduledEvent();
		this.cancellationtype = bean.getCancellationType() == null ? null : ims.scheduling.vo.lookups.Status_Reason.buildLookup(bean.getCancellationType());
		this.cancellationreason = bean.getCancellationReason() == null ? null : ims.scheduling.vo.lookups.CancelAppointmentReason.buildLookup(bean.getCancellationReason());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.pathways.vo.beans.EventLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.description = bean.getDescription();
		this.icon = bean.getIcon() == null ? null : bean.getIcon().buildVo(map);
		this.status = bean.getStatus() == null ? null : ims.core.vo.lookups.PreActiveActiveInactiveStatus.buildLookup(bean.getStatus());
		this.actioningroles = ims.admin.vo.AppRoleShortVoCollection.buildFromBeanCollection(bean.getActioningRoles());
		this.patientdiaryimpact = bean.getPatientDiaryImpact();
		this.eventtype = bean.getEventType() == null ? null : ims.pathways.vo.lookups.EventCreationType.buildLookup(bean.getEventType());
		this.startsclock = bean.getStartsClock();
		this.stopsclock = bean.getStopsClock();
		this.endspathway = bean.getEndsPathway();
		this.ismanualscheduledevent = bean.getIsManualScheduledEvent();
		this.cancellationtype = bean.getCancellationType() == null ? null : ims.scheduling.vo.lookups.Status_Reason.buildLookup(bean.getCancellationType());
		this.cancellationreason = bean.getCancellationReason() == null ? null : ims.scheduling.vo.lookups.CancelAppointmentReason.buildLookup(bean.getCancellationReason());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.pathways.vo.beans.EventLiteVoBean bean = null;
		if(map != null)
			bean = (ims.pathways.vo.beans.EventLiteVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.pathways.vo.beans.EventLiteVoBean();
			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("NAME"))
			return getName();
		if(fieldName.equals("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("ICON"))
			return getIcon();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("ACTIONINGROLES"))
			return getActioningRoles();
		if(fieldName.equals("PATIENTDIARYIMPACT"))
			return getPatientDiaryImpact();
		if(fieldName.equals("EVENTTYPE"))
			return getEventType();
		if(fieldName.equals("STARTSCLOCK"))
			return getStartsClock();
		if(fieldName.equals("STOPSCLOCK"))
			return getStopsClock();
		if(fieldName.equals("ENDSPATHWAY"))
			return getEndsPathway();
		if(fieldName.equals("ISMANUALSCHEDULEDEVENT"))
			return getIsManualScheduledEvent();
		if(fieldName.equals("CANCELLATIONTYPE"))
			return getCancellationType();
		if(fieldName.equals("CANCELLATIONREASON"))
			return getCancellationReason();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getNameIsNotNull()
	{
		return this.name != null;
	}
	public String getName()
	{
		return this.name;
	}
	public static int getNameMaxLength()
	{
		return 255;
	}
	public void setName(String value)
	{
		this.isValidated = false;
		this.name = value;
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 255;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getIconIsNotNull()
	{
		return this.icon != null;
	}
	public ims.admin.vo.AppImageVo getIcon()
	{
		return this.icon;
	}
	public void setIcon(ims.admin.vo.AppImageVo value)
	{
		this.isValidated = false;
		this.icon = 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 getActioningRolesIsNotNull()
	{
		return this.actioningroles != null;
	}
	public ims.admin.vo.AppRoleShortVoCollection getActioningRoles()
	{
		return this.actioningroles;
	}
	public void setActioningRoles(ims.admin.vo.AppRoleShortVoCollection value)
	{
		this.isValidated = false;
		this.actioningroles = value;
	}
	public boolean getPatientDiaryImpactIsNotNull()
	{
		return this.patientdiaryimpact != null;
	}
	public Boolean getPatientDiaryImpact()
	{
		return this.patientdiaryimpact;
	}
	public void setPatientDiaryImpact(Boolean value)
	{
		this.isValidated = false;
		this.patientdiaryimpact = value;
	}
	public boolean getEventTypeIsNotNull()
	{
		return this.eventtype != null;
	}
	public ims.pathways.vo.lookups.EventCreationType getEventType()
	{
		return this.eventtype;
	}
	public void setEventType(ims.pathways.vo.lookups.EventCreationType value)
	{
		this.isValidated = false;
		this.eventtype = value;
	}
	public boolean getStartsClockIsNotNull()
	{
		return this.startsclock != null;
	}
	public Boolean getStartsClock()
	{
		return this.startsclock;
	}
	public void setStartsClock(Boolean value)
	{
		this.isValidated = false;
		this.startsclock = value;
	}
	public boolean getStopsClockIsNotNull()
	{
		return this.stopsclock != null;
	}
	public Boolean getStopsClock()
	{
		return this.stopsclock;
	}
	public void setStopsClock(Boolean value)
	{
		this.isValidated = false;
		this.stopsclock = value;
	}
	public boolean getEndsPathwayIsNotNull()
	{
		return this.endspathway != null;
	}
	public Boolean getEndsPathway()
	{
		return this.endspathway;
	}
	public void setEndsPathway(Boolean value)
	{
		this.isValidated = false;
		this.endspathway = value;
	}
	public boolean getIsManualScheduledEventIsNotNull()
	{
		return this.ismanualscheduledevent != null;
	}
	public Boolean getIsManualScheduledEvent()
	{
		return this.ismanualscheduledevent;
	}
	public void setIsManualScheduledEvent(Boolean value)
	{
		this.isValidated = false;
		this.ismanualscheduledevent = value;
	}
	public boolean getCancellationTypeIsNotNull()
	{
		return this.cancellationtype != null;
	}
	public ims.scheduling.vo.lookups.Status_Reason getCancellationType()
	{
		return this.cancellationtype;
	}
	public void setCancellationType(ims.scheduling.vo.lookups.Status_Reason value)
	{
		this.isValidated = false;
		this.cancellationtype = value;
	}
	public boolean getCancellationReasonIsNotNull()
	{
		return this.cancellationreason != null;
	}
	public ims.scheduling.vo.lookups.CancelAppointmentReason getCancellationReason()
	{
		return this.cancellationreason;
	}
	public void setCancellationReason(ims.scheduling.vo.lookups.CancelAppointmentReason value)
	{
		this.isValidated = false;
		this.cancellationreason = value;
	}
	/**
	* toString
	*/
	public String toString()
		{
			return this.name;
		}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.icon != null)
		{
			if(!this.icon.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.actioningroles != null)
		{
			if(!this.actioningroles.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() > 255)
			listOfErrors.add("The length of the field [name] in the value object [ims.pathways.vo.EventLiteVo] is too big. It should be less or equal to 255");
		if(this.description != null)
			if(this.description.length() > 255)
				listOfErrors.add("The length of the field [description] in the value object [ims.pathways.vo.EventLiteVo] is too big. It should be less or equal to 255");
		if(this.icon != null)
		{
			String[] listOfOtherErrors = this.icon.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.status == null)
			listOfErrors.add("Status is mandatory");
		if(this.actioningroles != null)
		{
			String[] listOfOtherErrors = this.actioningroles.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.eventtype == null)
			listOfErrors.add("Event Type 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;
	
		EventLiteVo clone = new EventLiteVo(this.id, this.version);
		
		clone.name = this.name;
		clone.description = this.description;
		if(this.icon == null)
			clone.icon = null;
		else
			clone.icon = (ims.admin.vo.AppImageVo)this.icon.clone();
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.core.vo.lookups.PreActiveActiveInactiveStatus)this.status.clone();
		if(this.actioningroles == null)
			clone.actioningroles = null;
		else
			clone.actioningroles = (ims.admin.vo.AppRoleShortVoCollection)this.actioningroles.clone();
		clone.patientdiaryimpact = this.patientdiaryimpact;
		if(this.eventtype == null)
			clone.eventtype = null;
		else
			clone.eventtype = (ims.pathways.vo.lookups.EventCreationType)this.eventtype.clone();
		clone.startsclock = this.startsclock;
		clone.stopsclock = this.stopsclock;
		clone.endspathway = this.endspathway;
		clone.ismanualscheduledevent = this.ismanualscheduledevent;
		if(this.cancellationtype == null)
			clone.cancellationtype = null;
		else
			clone.cancellationtype = (ims.scheduling.vo.lookups.Status_Reason)this.cancellationtype.clone();
		if(this.cancellationreason == null)
			clone.cancellationreason = null;
		else
			clone.cancellationreason = (ims.scheduling.vo.lookups.CancelAppointmentReason)this.cancellationreason.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 (!(EventLiteVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A EventLiteVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((EventLiteVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((EventLiteVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.name != null)
			count++;
		if(this.description != null)
			count++;
		if(this.icon != null)
			count++;
		if(this.status != null)
			count++;
		if(this.actioningroles != null)
			count++;
		if(this.patientdiaryimpact != null)
			count++;
		if(this.eventtype != null)
			count++;
		if(this.startsclock != null)
			count++;
		if(this.stopsclock != null)
			count++;
		if(this.endspathway != null)
			count++;
		if(this.ismanualscheduledevent != null)
			count++;
		if(this.cancellationtype != null)
			count++;
		if(this.cancellationreason != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected String name;
	protected String description;
	protected ims.admin.vo.AppImageVo icon;
	protected ims.core.vo.lookups.PreActiveActiveInactiveStatus status;
	protected ims.admin.vo.AppRoleShortVoCollection actioningroles;
	protected Boolean patientdiaryimpact;
	protected ims.pathways.vo.lookups.EventCreationType eventtype;
	protected Boolean startsclock;
	protected Boolean stopsclock;
	protected Boolean endspathway;
	protected Boolean ismanualscheduledevent;
	protected ims.scheduling.vo.lookups.Status_Reason cancellationtype;
	protected ims.scheduling.vo.lookups.CancelAppointmentReason cancellationreason;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
