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

/**
 * Linked to OCRR.Configuration.PathSpecimenContainer business object (ID: 1058100007).
 */
public class PathSpecimenContainerVo extends ims.ocrr.vo.PathSpecimenContainerListVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public PathSpecimenContainerVo()
	{
	}
	public PathSpecimenContainerVo(Integer id, int version)
	{
		super(id, version);
	}
	public PathSpecimenContainerVo(ims.ocrr.vo.beans.PathSpecimenContainerVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.volume = bean.getVolume();
		this.colour = bean.getColour() == null ? null : ims.ocrr.vo.lookups.SpecimenColour.buildLookup(bean.getColour());
		this.manufacturer = bean.getManufacturer() == null ? null : ims.ocrr.vo.lookups.SpecimenManufacturer.buildLookup(bean.getManufacturer());
		this.manufrefno = bean.getManufRefNo();
		this.size = bean.getSize() == null ? null : ims.ocrr.vo.lookups.PathContainerSize.buildLookup(bean.getSize());
		this.material = bean.getMaterial() == null ? null : ims.ocrr.vo.lookups.PathContainerMaterial.buildLookup(bean.getMaterial());
		this.additive = ims.ocrr.vo.lookups.PathContainerAdditiveCollection.buildFromBeanCollection(bean.getAdditive());
		this.notes = bean.getNotes();
		this.isactive = bean.getIsActive();
		this.volumeunits = bean.getVolumeUnits() == null ? null : ims.ocrr.vo.lookups.PathVolumeUnits.buildLookup(bean.getVolumeUnits());
		this.pathspecimenorder = bean.getPathSpecimenOrder();
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.ocrr.vo.beans.PathSpecimenContainerVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.name = bean.getName();
		this.volume = bean.getVolume();
		this.colour = bean.getColour() == null ? null : ims.ocrr.vo.lookups.SpecimenColour.buildLookup(bean.getColour());
		this.manufacturer = bean.getManufacturer() == null ? null : ims.ocrr.vo.lookups.SpecimenManufacturer.buildLookup(bean.getManufacturer());
		this.manufrefno = bean.getManufRefNo();
		this.size = bean.getSize() == null ? null : ims.ocrr.vo.lookups.PathContainerSize.buildLookup(bean.getSize());
		this.material = bean.getMaterial() == null ? null : ims.ocrr.vo.lookups.PathContainerMaterial.buildLookup(bean.getMaterial());
		this.additive = ims.ocrr.vo.lookups.PathContainerAdditiveCollection.buildFromBeanCollection(bean.getAdditive());
		this.notes = bean.getNotes();
		this.isactive = bean.getIsActive();
		this.volumeunits = bean.getVolumeUnits() == null ? null : ims.ocrr.vo.lookups.PathVolumeUnits.buildLookup(bean.getVolumeUnits());
		this.pathspecimenorder = bean.getPathSpecimenOrder();
		this.taxonomymap = ims.core.vo.TaxonomyMapCollection.buildFromBeanCollection(bean.getTaxonomyMap());
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.ocrr.vo.beans.PathSpecimenContainerVoBean bean = null;
		if(map != null)
			bean = (ims.ocrr.vo.beans.PathSpecimenContainerVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.ocrr.vo.beans.PathSpecimenContainerVoBean();
			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("COLOUR"))
			return getColour();
		if(fieldName.equals("MANUFACTURER"))
			return getManufacturer();
		if(fieldName.equals("MANUFREFNO"))
			return getManufRefNo();
		if(fieldName.equals("SIZE"))
			return getSize();
		if(fieldName.equals("MATERIAL"))
			return getMaterial();
		if(fieldName.equals("ADDITIVE"))
			return getAdditive();
		if(fieldName.equals("NOTES"))
			return getNotes();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("VOLUMEUNITS"))
			return getVolumeUnits();
		if(fieldName.equals("PATHSPECIMENORDER"))
			return getPathSpecimenOrder();
		if(fieldName.equals("TAXONOMYMAP"))
			return getTaxonomyMap();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getColourIsNotNull()
	{
		return this.colour != null;
	}
	public ims.ocrr.vo.lookups.SpecimenColour getColour()
	{
		return this.colour;
	}
	public void setColour(ims.ocrr.vo.lookups.SpecimenColour value)
	{
		this.isValidated = false;
		this.colour = value;
	}
	public boolean getManufacturerIsNotNull()
	{
		return this.manufacturer != null;
	}
	public ims.ocrr.vo.lookups.SpecimenManufacturer getManufacturer()
	{
		return this.manufacturer;
	}
	public void setManufacturer(ims.ocrr.vo.lookups.SpecimenManufacturer value)
	{
		this.isValidated = false;
		this.manufacturer = value;
	}
	public boolean getManufRefNoIsNotNull()
	{
		return this.manufrefno != null;
	}
	public String getManufRefNo()
	{
		return this.manufrefno;
	}
	public static int getManufRefNoMaxLength()
	{
		return 50;
	}
	public void setManufRefNo(String value)
	{
		this.isValidated = false;
		this.manufrefno = value;
	}
	public boolean getSizeIsNotNull()
	{
		return this.size != null;
	}
	public ims.ocrr.vo.lookups.PathContainerSize getSize()
	{
		return this.size;
	}
	public void setSize(ims.ocrr.vo.lookups.PathContainerSize value)
	{
		this.isValidated = false;
		this.size = value;
	}
	public boolean getMaterialIsNotNull()
	{
		return this.material != null;
	}
	public ims.ocrr.vo.lookups.PathContainerMaterial getMaterial()
	{
		return this.material;
	}
	public void setMaterial(ims.ocrr.vo.lookups.PathContainerMaterial value)
	{
		this.isValidated = false;
		this.material = value;
	}
	public boolean getAdditiveIsNotNull()
	{
		return this.additive != null;
	}
	public ims.ocrr.vo.lookups.PathContainerAdditiveCollection getAdditive()
	{
		return this.additive;
	}
	public void setAdditive(ims.ocrr.vo.lookups.PathContainerAdditiveCollection value)
	{
		this.isValidated = false;
		this.additive = value;
	}
	public boolean getNotesIsNotNull()
	{
		return this.notes != null;
	}
	public String getNotes()
	{
		return this.notes;
	}
	public static int getNotesMaxLength()
	{
		return 250;
	}
	public void setNotes(String value)
	{
		this.isValidated = false;
		this.notes = 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 getVolumeUnitsIsNotNull()
	{
		return this.volumeunits != null;
	}
	public ims.ocrr.vo.lookups.PathVolumeUnits getVolumeUnits()
	{
		return this.volumeunits;
	}
	public void setVolumeUnits(ims.ocrr.vo.lookups.PathVolumeUnits value)
	{
		this.isValidated = false;
		this.volumeunits = value;
	}
	public boolean getPathSpecimenOrderIsNotNull()
	{
		return this.pathspecimenorder != null;
	}
	public Integer getPathSpecimenOrder()
	{
		return this.pathspecimenorder;
	}
	public void setPathSpecimenOrder(Integer value)
	{
		this.isValidated = false;
		this.pathspecimenorder = value;
	}
	public boolean getTaxonomyMapIsNotNull()
	{
		return this.taxonomymap != null;
	}
	public ims.core.vo.TaxonomyMapCollection getTaxonomyMap()
	{
		return this.taxonomymap;
	}
	public void setTaxonomyMap(ims.core.vo.TaxonomyMapCollection value)
	{
		this.isValidated = false;
		this.taxonomymap = value;
	}
	/**
	* toString
	*/
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		if(this.name != null)
			sb.append(this.name);
		sb.append(" ( Cap: ");
		if(this.volume != null)
			sb.append(this.volume);
		else
		{
			sb.append("N/A )");
			return sb.toString();
		}
		sb.append(" ");
		if(this.volumeunits != null)
			sb.append(this.volumeunits);
		sb.append(" )");
		return sb.toString();
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.taxonomymap != null)
		{
			if(!this.taxonomymap.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() > 50)
			listOfErrors.add("The length of the field [name] in the value object [ims.ocrr.vo.PathSpecimenContainerVo] is too big. It should be less or equal to 50");
		if(this.manufrefno != null)
			if(this.manufrefno.length() > 50)
				listOfErrors.add("The length of the field [manufrefno] in the value object [ims.ocrr.vo.PathSpecimenContainerVo] is too big. It should be less or equal to 50");
		if(this.notes != null)
			if(this.notes.length() > 250)
				listOfErrors.add("The length of the field [notes] in the value object [ims.ocrr.vo.PathSpecimenContainerVo] is too big. It should be less or equal to 250");
		if(this.isactive == null)
			listOfErrors.add("isActive is mandatory");
		if(this.taxonomymap != null)
		{
			String[] listOfOtherErrors = this.taxonomymap.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;
	
		PathSpecimenContainerVo clone = new PathSpecimenContainerVo(this.id, this.version);
		
		clone.name = this.name;
		clone.volume = this.volume;
		if(this.colour == null)
			clone.colour = null;
		else
			clone.colour = (ims.ocrr.vo.lookups.SpecimenColour)this.colour.clone();
		if(this.manufacturer == null)
			clone.manufacturer = null;
		else
			clone.manufacturer = (ims.ocrr.vo.lookups.SpecimenManufacturer)this.manufacturer.clone();
		clone.manufrefno = this.manufrefno;
		if(this.size == null)
			clone.size = null;
		else
			clone.size = (ims.ocrr.vo.lookups.PathContainerSize)this.size.clone();
		if(this.material == null)
			clone.material = null;
		else
			clone.material = (ims.ocrr.vo.lookups.PathContainerMaterial)this.material.clone();
		if(this.additive == null)
			clone.additive = null;
		else
			clone.additive = (ims.ocrr.vo.lookups.PathContainerAdditiveCollection)this.additive.clone();
		clone.notes = this.notes;
		clone.isactive = this.isactive;
		if(this.volumeunits == null)
			clone.volumeunits = null;
		else
			clone.volumeunits = (ims.ocrr.vo.lookups.PathVolumeUnits)this.volumeunits.clone();
		clone.pathspecimenorder = this.pathspecimenorder;
		if(this.taxonomymap == null)
			clone.taxonomymap = null;
		else
			clone.taxonomymap = (ims.core.vo.TaxonomyMapCollection)this.taxonomymap.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 (!(PathSpecimenContainerVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PathSpecimenContainerVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PathSpecimenContainerVo compareObj = (PathSpecimenContainerVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_PathSpecimenContainer() == null && compareObj.getID_PathSpecimenContainer() != null)
				return -1;
			if(this.getID_PathSpecimenContainer() != null && compareObj.getID_PathSpecimenContainer() == null)
				return 1;
			if(this.getID_PathSpecimenContainer() != null && compareObj.getID_PathSpecimenContainer() != null)
				retVal = this.getID_PathSpecimenContainer().compareTo(compareObj.getID_PathSpecimenContainer());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = super.countFieldsWithValue();
		if(this.colour != null)
			count++;
		if(this.manufacturer != null)
			count++;
		if(this.manufrefno != null)
			count++;
		if(this.size != null)
			count++;
		if(this.material != null)
			count++;
		if(this.additive != null)
			count++;
		if(this.notes != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.volumeunits != null)
			count++;
		if(this.pathspecimenorder != null)
			count++;
		if(this.taxonomymap != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return super.countValueObjectFields() + 11;
	}
	protected ims.ocrr.vo.lookups.SpecimenColour colour;
	protected ims.ocrr.vo.lookups.SpecimenManufacturer manufacturer;
	protected String manufrefno;
	protected ims.ocrr.vo.lookups.PathContainerSize size;
	protected ims.ocrr.vo.lookups.PathContainerMaterial material;
	protected ims.ocrr.vo.lookups.PathContainerAdditiveCollection additive;
	protected String notes;
	protected Boolean isactive;
	protected ims.ocrr.vo.lookups.PathVolumeUnits volumeunits;
	protected Integer pathspecimenorder;
	protected ims.core.vo.TaxonomyMapCollection taxonomymap;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
