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

	public BayConfigLiteVo()
	{
	}
	public BayConfigLiteVo(Integer id, int version)
	{
		super(id, version);
	}
	public BayConfigLiteVo(ims.core.vo.beans.BayConfigLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.bay = bean.getBay() == null ? null : bean.getBay().buildVo();
		this.isactive = bean.getIsActive();
		this.male = bean.getMale();
		this.female = bean.getFemale();
		this.paediatric = bean.getPaediatric();
		this.numofbeds = bean.getNumOfBeds();
		this.numofoccupiedbeds = bean.getNumOfOccupiedBeds();
		this.openingtime = bean.getOpeningTime() == null ? null : bean.getOpeningTime().buildTime();
		this.closingtime = bean.getClosingTime() == null ? null : bean.getClosingTime().buildTime();
		this.weekdaysonly = bean.getWeekdaysOnly();
		this.bayavailabilitystatus = bean.getBayAvailabilityStatus() == null ? null : ims.core.vo.lookups.WardBayStatus.buildLookup(bean.getBayAvailabilityStatus());
		this.reopenoutofhours = ims.core.vo.ReopenBayOutOfHoursVoCollection.buildFromBeanCollection(bean.getReOpenOutOfHours());
		this.temporarybaygender = bean.getTemporaryBayGender() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getTemporaryBayGender());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.BayConfigLiteVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.bay = bean.getBay() == null ? null : bean.getBay().buildVo(map);
		this.isactive = bean.getIsActive();
		this.male = bean.getMale();
		this.female = bean.getFemale();
		this.paediatric = bean.getPaediatric();
		this.numofbeds = bean.getNumOfBeds();
		this.numofoccupiedbeds = bean.getNumOfOccupiedBeds();
		this.openingtime = bean.getOpeningTime() == null ? null : bean.getOpeningTime().buildTime();
		this.closingtime = bean.getClosingTime() == null ? null : bean.getClosingTime().buildTime();
		this.weekdaysonly = bean.getWeekdaysOnly();
		this.bayavailabilitystatus = bean.getBayAvailabilityStatus() == null ? null : ims.core.vo.lookups.WardBayStatus.buildLookup(bean.getBayAvailabilityStatus());
		this.reopenoutofhours = ims.core.vo.ReopenBayOutOfHoursVoCollection.buildFromBeanCollection(bean.getReOpenOutOfHours());
		this.temporarybaygender = bean.getTemporaryBayGender() == null ? null : ims.core.vo.lookups.Sex.buildLookup(bean.getTemporaryBayGender());
	}
	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.BayConfigLiteVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.BayConfigLiteVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.BayConfigLiteVoBean();
			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("BAY"))
			return getBay();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("MALE"))
			return getMale();
		if(fieldName.equals("FEMALE"))
			return getFemale();
		if(fieldName.equals("PAEDIATRIC"))
			return getPaediatric();
		if(fieldName.equals("NUMOFBEDS"))
			return getNumOfBeds();
		if(fieldName.equals("NUMOFOCCUPIEDBEDS"))
			return getNumOfOccupiedBeds();
		if(fieldName.equals("OPENINGTIME"))
			return getOpeningTime();
		if(fieldName.equals("CLOSINGTIME"))
			return getClosingTime();
		if(fieldName.equals("WEEKDAYSONLY"))
			return getWeekdaysOnly();
		if(fieldName.equals("BAYAVAILABILITYSTATUS"))
			return getBayAvailabilityStatus();
		if(fieldName.equals("REOPENOUTOFHOURS"))
			return getReOpenOutOfHours();
		if(fieldName.equals("TEMPORARYBAYGENDER"))
			return getTemporaryBayGender();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getBayIsNotNull()
	{
		return this.bay != null;
	}
	public ims.core.vo.LocationLiteVo getBay()
	{
		return this.bay;
	}
	public void setBay(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.bay = value;
	}
	public boolean getIsActiveIsNotNull()
	{
		return this.isactive != null;
	}
	public Boolean getIsActive()
	{
		return this.isactive;
	}
	public void setIsActive(Boolean value)
	{
		this.isValidated = false;
		this.isactive = value;
	}
	public boolean getMaleIsNotNull()
	{
		return this.male != null;
	}
	public Boolean getMale()
	{
		return this.male;
	}
	public void setMale(Boolean value)
	{
		this.isValidated = false;
		this.male = value;
	}
	public boolean getFemaleIsNotNull()
	{
		return this.female != null;
	}
	public Boolean getFemale()
	{
		return this.female;
	}
	public void setFemale(Boolean value)
	{
		this.isValidated = false;
		this.female = value;
	}
	public boolean getPaediatricIsNotNull()
	{
		return this.paediatric != null;
	}
	public Boolean getPaediatric()
	{
		return this.paediatric;
	}
	public void setPaediatric(Boolean value)
	{
		this.isValidated = false;
		this.paediatric = value;
	}
	public boolean getNumOfBedsIsNotNull()
	{
		return this.numofbeds != null;
	}
	public Integer getNumOfBeds()
	{
		return this.numofbeds;
	}
	public void setNumOfBeds(Integer value)
	{
		this.isValidated = false;
		this.numofbeds = value;
	}
	public boolean getNumOfOccupiedBedsIsNotNull()
	{
		return this.numofoccupiedbeds != null;
	}
	public Integer getNumOfOccupiedBeds()
	{
		return this.numofoccupiedbeds;
	}
	public void setNumOfOccupiedBeds(Integer value)
	{
		this.isValidated = false;
		this.numofoccupiedbeds = value;
	}
	public boolean getOpeningTimeIsNotNull()
	{
		return this.openingtime != null;
	}
	public ims.framework.utils.Time getOpeningTime()
	{
		return this.openingtime;
	}
	public void setOpeningTime(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.openingtime = value;
	}
	public boolean getClosingTimeIsNotNull()
	{
		return this.closingtime != null;
	}
	public ims.framework.utils.Time getClosingTime()
	{
		return this.closingtime;
	}
	public void setClosingTime(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.closingtime = value;
	}
	public boolean getWeekdaysOnlyIsNotNull()
	{
		return this.weekdaysonly != null;
	}
	public Boolean getWeekdaysOnly()
	{
		return this.weekdaysonly;
	}
	public void setWeekdaysOnly(Boolean value)
	{
		this.isValidated = false;
		this.weekdaysonly = value;
	}
	public boolean getBayAvailabilityStatusIsNotNull()
	{
		return this.bayavailabilitystatus != null;
	}
	public ims.core.vo.lookups.WardBayStatus getBayAvailabilityStatus()
	{
		return this.bayavailabilitystatus;
	}
	public void setBayAvailabilityStatus(ims.core.vo.lookups.WardBayStatus value)
	{
		this.isValidated = false;
		this.bayavailabilitystatus = value;
	}
	public boolean getReOpenOutOfHoursIsNotNull()
	{
		return this.reopenoutofhours != null;
	}
	public ims.core.vo.ReopenBayOutOfHoursVoCollection getReOpenOutOfHours()
	{
		return this.reopenoutofhours;
	}
	public void setReOpenOutOfHours(ims.core.vo.ReopenBayOutOfHoursVoCollection value)
	{
		this.isValidated = false;
		this.reopenoutofhours = value;
	}
	public boolean getTemporaryBayGenderIsNotNull()
	{
		return this.temporarybaygender != null;
	}
	public ims.core.vo.lookups.Sex getTemporaryBayGender()
	{
		return this.temporarybaygender;
	}
	public void setTemporaryBayGender(ims.core.vo.lookups.Sex value)
	{
		this.isValidated = false;
		this.temporarybaygender = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.bay != null)
		{
			if(!this.bay.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.reopenoutofhours != null)
		{
			if(!this.reopenoutofhours.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.bay == null)
			listOfErrors.add("Bay is mandatory");
		if(this.bay != null)
		{
			String[] listOfOtherErrors = this.bay.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.isactive == null)
			listOfErrors.add("isActive is mandatory");
		if(this.reopenoutofhours != null)
		{
			String[] listOfOtherErrors = this.reopenoutofhours.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;
	
		BayConfigLiteVo clone = new BayConfigLiteVo(this.id, this.version);
		
		if(this.bay == null)
			clone.bay = null;
		else
			clone.bay = (ims.core.vo.LocationLiteVo)this.bay.clone();
		clone.isactive = this.isactive;
		clone.male = this.male;
		clone.female = this.female;
		clone.paediatric = this.paediatric;
		clone.numofbeds = this.numofbeds;
		clone.numofoccupiedbeds = this.numofoccupiedbeds;
		if(this.openingtime == null)
			clone.openingtime = null;
		else
			clone.openingtime = (ims.framework.utils.Time)this.openingtime.clone();
		if(this.closingtime == null)
			clone.closingtime = null;
		else
			clone.closingtime = (ims.framework.utils.Time)this.closingtime.clone();
		clone.weekdaysonly = this.weekdaysonly;
		if(this.bayavailabilitystatus == null)
			clone.bayavailabilitystatus = null;
		else
			clone.bayavailabilitystatus = (ims.core.vo.lookups.WardBayStatus)this.bayavailabilitystatus.clone();
		if(this.reopenoutofhours == null)
			clone.reopenoutofhours = null;
		else
			clone.reopenoutofhours = (ims.core.vo.ReopenBayOutOfHoursVoCollection)this.reopenoutofhours.clone();
		if(this.temporarybaygender == null)
			clone.temporarybaygender = null;
		else
			clone.temporarybaygender = (ims.core.vo.lookups.Sex)this.temporarybaygender.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 (!(BayConfigLiteVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A BayConfigLiteVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		BayConfigLiteVo compareObj = (BayConfigLiteVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getBay() == null && compareObj.getBay() != null)
				return -1;
			if(this.getBay() != null && compareObj.getBay() == null)
				return 1;
			if(this.getBay() != null && compareObj.getBay() != null)
				retVal = this.getBay().compareTo(compareObj.getBay());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.bay != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.male != null)
			count++;
		if(this.female != null)
			count++;
		if(this.paediatric != null)
			count++;
		if(this.numofbeds != null)
			count++;
		if(this.numofoccupiedbeds != null)
			count++;
		if(this.openingtime != null)
			count++;
		if(this.closingtime != null)
			count++;
		if(this.weekdaysonly != null)
			count++;
		if(this.bayavailabilitystatus != null)
			count++;
		if(this.reopenoutofhours != null)
			count++;
		if(this.temporarybaygender != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected ims.core.vo.LocationLiteVo bay;
	protected Boolean isactive;
	protected Boolean male;
	protected Boolean female;
	protected Boolean paediatric;
	protected Integer numofbeds;
	protected Integer numofoccupiedbeds;
	protected ims.framework.utils.Time openingtime;
	protected ims.framework.utils.Time closingtime;
	protected Boolean weekdaysonly;
	protected ims.core.vo.lookups.WardBayStatus bayavailabilitystatus;
	protected ims.core.vo.ReopenBayOutOfHoursVoCollection reopenoutofhours;
	protected ims.core.vo.lookups.Sex temporarybaygender;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
