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

	public BatchPricingVo()
	{
	}
	public BatchPricingVo(Integer id, int version)
	{
		super(id, version);
	}
	public BatchPricingVo(ims.core.vo.beans.BatchPricingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.batchname = bean.getBatchName();
		this.recordedby = bean.getRecordedBy() == null ? null : bean.getRecordedBy().buildVo();
		this.recordingdate = bean.getRecordingDate() == null ? null : bean.getRecordingDate().buildDateTime();
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo();
		this.status = bean.getStatus() == null ? null : ims.ntpf.vo.lookups.BatchStatus.buildLookup(bean.getStatus());
		this.locationservice = ims.core.vo.LocationServiceVoCollection.buildFromBeanCollection(bean.getLocationService());
		this.percentageapplied = bean.getPercentageApplied();
		this.effectivefrom = bean.getEffectiveFrom() == null ? null : bean.getEffectiveFrom().buildDate();
		this.activateddate = bean.getActivatedDate() == null ? null : bean.getActivatedDate().buildDate();
		this.isprinted = bean.getIsPrinted();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.core.vo.beans.BatchPricingVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.batchname = bean.getBatchName();
		this.recordedby = bean.getRecordedBy() == null ? null : bean.getRecordedBy().buildVo(map);
		this.recordingdate = bean.getRecordingDate() == null ? null : bean.getRecordingDate().buildDateTime();
		this.location = bean.getLocation() == null ? null : bean.getLocation().buildVo(map);
		this.status = bean.getStatus() == null ? null : ims.ntpf.vo.lookups.BatchStatus.buildLookup(bean.getStatus());
		this.locationservice = ims.core.vo.LocationServiceVoCollection.buildFromBeanCollection(bean.getLocationService());
		this.percentageapplied = bean.getPercentageApplied();
		this.effectivefrom = bean.getEffectiveFrom() == null ? null : bean.getEffectiveFrom().buildDate();
		this.activateddate = bean.getActivatedDate() == null ? null : bean.getActivatedDate().buildDate();
		this.isprinted = bean.getIsPrinted();
	}
	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.BatchPricingVoBean bean = null;
		if(map != null)
			bean = (ims.core.vo.beans.BatchPricingVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.core.vo.beans.BatchPricingVoBean();
			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("RECORDEDBY"))
			return getRecordedBy();
		if(fieldName.equals("RECORDINGDATE"))
			return getRecordingDate();
		if(fieldName.equals("LOCATION"))
			return getLocation();
		if(fieldName.equals("STATUS"))
			return getStatus();
		if(fieldName.equals("LOCATIONSERVICE"))
			return getLocationService();
		if(fieldName.equals("PERCENTAGEAPPLIED"))
			return getPercentageApplied();
		if(fieldName.equals("EFFECTIVEFROM"))
			return getEffectiveFrom();
		if(fieldName.equals("ACTIVATEDDATE"))
			return getActivatedDate();
		if(fieldName.equals("ISPRINTED"))
			return getIsPrinted();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getRecordedByIsNotNull()
	{
		return this.recordedby != null;
	}
	public ims.core.vo.MemberOfStaffLiteVo getRecordedBy()
	{
		return this.recordedby;
	}
	public void setRecordedBy(ims.core.vo.MemberOfStaffLiteVo value)
	{
		this.isValidated = false;
		this.recordedby = value;
	}
	public boolean getRecordingDateIsNotNull()
	{
		return this.recordingdate != null;
	}
	public ims.framework.utils.DateTime getRecordingDate()
	{
		return this.recordingdate;
	}
	public void setRecordingDate(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.recordingdate = value;
	}
	public boolean getLocationIsNotNull()
	{
		return this.location != null;
	}
	public ims.core.vo.LocationLiteVo getLocation()
	{
		return this.location;
	}
	public void setLocation(ims.core.vo.LocationLiteVo value)
	{
		this.isValidated = false;
		this.location = value;
	}
	public boolean getStatusIsNotNull()
	{
		return this.status != null;
	}
	public ims.ntpf.vo.lookups.BatchStatus getStatus()
	{
		return this.status;
	}
	public void setStatus(ims.ntpf.vo.lookups.BatchStatus value)
	{
		this.isValidated = false;
		this.status = value;
	}
	public boolean getLocationServiceIsNotNull()
	{
		return this.locationservice != null;
	}
	public ims.core.vo.LocationServiceVoCollection getLocationService()
	{
		return this.locationservice;
	}
	public void setLocationService(ims.core.vo.LocationServiceVoCollection value)
	{
		this.isValidated = false;
		this.locationservice = value;
	}
	public boolean getPercentageAppliedIsNotNull()
	{
		return this.percentageapplied != null;
	}
	public Float getPercentageApplied()
	{
		return this.percentageapplied;
	}
	public void setPercentageApplied(Float value)
	{
		this.isValidated = false;
		this.percentageapplied = value;
	}
	public boolean getEffectiveFromIsNotNull()
	{
		return this.effectivefrom != null;
	}
	public ims.framework.utils.Date getEffectiveFrom()
	{
		return this.effectivefrom;
	}
	public void setEffectiveFrom(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.effectivefrom = value;
	}
	public boolean getActivatedDateIsNotNull()
	{
		return this.activateddate != null;
	}
	public ims.framework.utils.Date getActivatedDate()
	{
		return this.activateddate;
	}
	public void setActivatedDate(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.activateddate = value;
	}
	public boolean getIsPrintedIsNotNull()
	{
		return this.isprinted != null;
	}
	public Boolean getIsPrinted()
	{
		return this.isprinted;
	}
	public void setIsPrinted(Boolean value)
	{
		this.isValidated = false;
		this.isprinted = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.location != null)
		{
			if(!this.location.isValidated())
			{
				this.isBusy = false;
				return false;
			}
		}
		if(this.locationservice != null)
		{
			if(!this.locationservice.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.batchname == null || this.batchname.length() == 0)
			listOfErrors.add("BatchName is mandatory");
		if(this.location == null)
			listOfErrors.add("Location is mandatory");
		if(this.location != null)
		{
			String[] listOfOtherErrors = this.location.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.locationservice == null || this.locationservice.size() == 0)
			listOfErrors.add("LocationService are mandatory");
		if(this.locationservice != null)
		{
			String[] listOfOtherErrors = this.locationservice.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;
	
		BatchPricingVo clone = new BatchPricingVo(this.id, this.version);
		
		clone.batchname = this.batchname;
		if(this.recordedby == null)
			clone.recordedby = null;
		else
			clone.recordedby = (ims.core.vo.MemberOfStaffLiteVo)this.recordedby.clone();
		if(this.recordingdate == null)
			clone.recordingdate = null;
		else
			clone.recordingdate = (ims.framework.utils.DateTime)this.recordingdate.clone();
		if(this.location == null)
			clone.location = null;
		else
			clone.location = (ims.core.vo.LocationLiteVo)this.location.clone();
		if(this.status == null)
			clone.status = null;
		else
			clone.status = (ims.ntpf.vo.lookups.BatchStatus)this.status.clone();
		if(this.locationservice == null)
			clone.locationservice = null;
		else
			clone.locationservice = (ims.core.vo.LocationServiceVoCollection)this.locationservice.clone();
		clone.percentageapplied = this.percentageapplied;
		if(this.effectivefrom == null)
			clone.effectivefrom = null;
		else
			clone.effectivefrom = (ims.framework.utils.Date)this.effectivefrom.clone();
		if(this.activateddate == null)
			clone.activateddate = null;
		else
			clone.activateddate = (ims.framework.utils.Date)this.activateddate.clone();
		clone.isprinted = this.isprinted;
		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 (!(BatchPricingVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A BatchPricingVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((BatchPricingVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((BatchPricingVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.recordedby != null)
			count++;
		if(this.recordingdate != null)
			count++;
		if(this.location != null)
			count++;
		if(this.status != null)
			count++;
		if(this.locationservice != null)
			count++;
		if(this.percentageapplied != null)
			count++;
		if(this.effectivefrom != null)
			count++;
		if(this.activateddate != null)
			count++;
		if(this.isprinted != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 9;
	}
	protected ims.core.vo.MemberOfStaffLiteVo recordedby;
	protected ims.framework.utils.DateTime recordingdate;
	protected ims.core.vo.LocationLiteVo location;
	protected ims.ntpf.vo.lookups.BatchStatus status;
	protected ims.core.vo.LocationServiceVoCollection locationservice;
	protected Float percentageapplied;
	protected ims.framework.utils.Date effectivefrom;
	protected ims.framework.utils.Date activateddate;
	protected Boolean isprinted;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
