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

/**
 * Linked to core.admin.Test business object (ID: 1004100042).
 */
public class TestVo extends ims.core.admin.vo.TestRefVo implements ims.vo.ImsCloneable, Comparable
{
	private static final long serialVersionUID = 1L;

	public TestVo()
	{
	}
	public TestVo(Integer id, int version)
	{
		super(id, version);
	}
	public TestVo(ims.admin.vo.beans.TestVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.stringfield = bean.getStringField();
		this.intfield = bean.getIntField();
		this.booleanfield = bean.getBooleanField();
		this.decimalfield = bean.getDecimalField();
		this.datefield = bean.getDateField() == null ? null : bean.getDateField().buildDate();
		this.timefield = bean.getTimeField() == null ? null : bean.getTimeField().buildTime();
		this.datetimefield = bean.getDateTimeField() == null ? null : bean.getDateTimeField().buildDateTime();
		this.partialdatefield = bean.getPartialDateField() == null ? null : bean.getPartialDateField().buildPartialDate();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.TestVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.stringfield = bean.getStringField();
		this.intfield = bean.getIntField();
		this.booleanfield = bean.getBooleanField();
		this.decimalfield = bean.getDecimalField();
		this.datefield = bean.getDateField() == null ? null : bean.getDateField().buildDate();
		this.timefield = bean.getTimeField() == null ? null : bean.getTimeField().buildTime();
		this.datetimefield = bean.getDateTimeField() == null ? null : bean.getDateTimeField().buildDateTime();
		this.partialdatefield = bean.getPartialDateField() == null ? null : bean.getPartialDateField().buildPartialDate();
	}
	public ims.vo.ValueObjectBean getBean()
	{
		return this.getBean(new ims.vo.ValueObjectBeanMap());
	}
	public ims.vo.ValueObjectBean getBean(ims.vo.ValueObjectBeanMap map)
	{
		ims.admin.vo.beans.TestVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.TestVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.TestVoBean();
			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("STRINGFIELD"))
			return getStringField();
		if(fieldName.equals("INTFIELD"))
			return getIntField();
		if(fieldName.equals("BOOLEANFIELD"))
			return getBooleanField();
		if(fieldName.equals("DECIMALFIELD"))
			return getDecimalField();
		if(fieldName.equals("DATEFIELD"))
			return getDateField();
		if(fieldName.equals("TIMEFIELD"))
			return getTimeField();
		if(fieldName.equals("DATETIMEFIELD"))
			return getDateTimeField();
		if(fieldName.equals("PARTIALDATEFIELD"))
			return getPartialDateField();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getStringFieldIsNotNull()
	{
		return this.stringfield != null;
	}
	public String getStringField()
	{
		return this.stringfield;
	}
	public static int getStringFieldMaxLength()
	{
		return 12;
	}
	public void setStringField(String value)
	{
		this.isValidated = false;
		this.stringfield = value;
	}
	public boolean getIntFieldIsNotNull()
	{
		return this.intfield != null;
	}
	public Integer getIntField()
	{
		return this.intfield;
	}
	public void setIntField(Integer value)
	{
		this.isValidated = false;
		this.intfield = value;
	}
	public boolean getBooleanFieldIsNotNull()
	{
		return this.booleanfield != null;
	}
	public Boolean getBooleanField()
	{
		return this.booleanfield;
	}
	public void setBooleanField(Boolean value)
	{
		this.isValidated = false;
		this.booleanfield = value;
	}
	public boolean getDecimalFieldIsNotNull()
	{
		return this.decimalfield != null;
	}
	public Float getDecimalField()
	{
		return this.decimalfield;
	}
	public void setDecimalField(Float value)
	{
		this.isValidated = false;
		this.decimalfield = value;
	}
	public boolean getDateFieldIsNotNull()
	{
		return this.datefield != null;
	}
	public ims.framework.utils.Date getDateField()
	{
		return this.datefield;
	}
	public void setDateField(ims.framework.utils.Date value)
	{
		this.isValidated = false;
		this.datefield = value;
	}
	public boolean getTimeFieldIsNotNull()
	{
		return this.timefield != null;
	}
	public ims.framework.utils.Time getTimeField()
	{
		return this.timefield;
	}
	public void setTimeField(ims.framework.utils.Time value)
	{
		this.isValidated = false;
		this.timefield = value;
	}
	public boolean getDateTimeFieldIsNotNull()
	{
		return this.datetimefield != null;
	}
	public ims.framework.utils.DateTime getDateTimeField()
	{
		return this.datetimefield;
	}
	public void setDateTimeField(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.datetimefield = value;
	}
	public boolean getPartialDateFieldIsNotNull()
	{
		return this.partialdatefield != null;
	}
	public ims.framework.utils.PartialDate getPartialDateField()
	{
		return this.partialdatefield;
	}
	public void setPartialDateField(ims.framework.utils.PartialDate value)
	{
		this.isValidated = false;
		this.partialdatefield = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.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.stringfield != null)
			if(this.stringfield.length() > 12)
				listOfErrors.add("The length of the field [stringfield] in the value object [ims.admin.vo.TestVo] is too big. It should be less or equal to 12");
		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;
	
		TestVo clone = new TestVo(this.id, this.version);
		
		clone.stringfield = this.stringfield;
		clone.intfield = this.intfield;
		clone.booleanfield = this.booleanfield;
		clone.decimalfield = this.decimalfield;
		if(this.datefield == null)
			clone.datefield = null;
		else
			clone.datefield = (ims.framework.utils.Date)this.datefield.clone();
		if(this.timefield == null)
			clone.timefield = null;
		else
			clone.timefield = (ims.framework.utils.Time)this.timefield.clone();
		if(this.datetimefield == null)
			clone.datetimefield = null;
		else
			clone.datetimefield = (ims.framework.utils.DateTime)this.datetimefield.clone();
		if(this.partialdatefield == null)
			clone.partialdatefield = null;
		else
			clone.partialdatefield = (ims.framework.utils.PartialDate)this.partialdatefield.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 (!(TestVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A TestVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((TestVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((TestVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.stringfield != null)
			count++;
		if(this.intfield != null)
			count++;
		if(this.booleanfield != null)
			count++;
		if(this.decimalfield != null)
			count++;
		if(this.datefield != null)
			count++;
		if(this.timefield != null)
			count++;
		if(this.datetimefield != null)
			count++;
		if(this.partialdatefield != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 8;
	}
	protected String stringfield;
	protected Integer intfield;
	protected Boolean booleanfield;
	protected Float decimalfield;
	protected ims.framework.utils.Date datefield;
	protected ims.framework.utils.Time timefield;
	protected ims.framework.utils.DateTime datetimefield;
	protected ims.framework.utils.PartialDate partialdatefield;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
