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

	public PrintAgentVo()
	{
	}
	public PrintAgentVo(Integer id, int version)
	{
		super(id, version);
	}
	public PrintAgentVo(ims.admin.vo.beans.PrintAgentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.queryserverurl = bean.getQueryServerUrl();
		this.reportserverurl = bean.getReportServerUrl();
		this.templatestoprint = ims.admin.vo.TemplatePrinterVoCollection.buildFromBeanCollection(bean.getTemplatesToPrint());
		this.description = bean.getDescription();
		this.trigger = bean.getTrigger();
		this.lastsuccessfulrundatetime = bean.getLastSuccessfulRunDateTime() == null ? null : bean.getLastSuccessfulRunDateTime().buildDateTime();
		this.lastrundatetime = bean.getLastRunDateTime() == null ? null : bean.getLastRunDateTime().buildDateTime();
		this.jobtype = bean.getJobType() == null ? null : ims.ntpf.vo.lookups.JobType.buildLookup(bean.getJobType());
		this.isactive = bean.getIsActive();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.dnaapptsinlastxhrs = bean.getDNAApptsInLastXhrs();
		this.noofrecordsupdated = bean.getNoOfRecordsUpdated();
		this.locationtoprintfor = bean.getLocationToPrintFor() == null ? null : bean.getLocationToPrintFor().buildVo();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.PrintAgentVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.queryserverurl = bean.getQueryServerUrl();
		this.reportserverurl = bean.getReportServerUrl();
		this.templatestoprint = ims.admin.vo.TemplatePrinterVoCollection.buildFromBeanCollection(bean.getTemplatesToPrint());
		this.description = bean.getDescription();
		this.trigger = bean.getTrigger();
		this.lastsuccessfulrundatetime = bean.getLastSuccessfulRunDateTime() == null ? null : bean.getLastSuccessfulRunDateTime().buildDateTime();
		this.lastrundatetime = bean.getLastRunDateTime() == null ? null : bean.getLastRunDateTime().buildDateTime();
		this.jobtype = bean.getJobType() == null ? null : ims.ntpf.vo.lookups.JobType.buildLookup(bean.getJobType());
		this.isactive = bean.getIsActive();
		this.sysinfo = bean.getSysInfo() == null ? null : bean.getSysInfo().buildSystemInformation();
		this.dnaapptsinlastxhrs = bean.getDNAApptsInLastXhrs();
		this.noofrecordsupdated = bean.getNoOfRecordsUpdated();
		this.locationtoprintfor = bean.getLocationToPrintFor() == null ? null : bean.getLocationToPrintFor().buildVo(map);
	}
	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.PrintAgentVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.PrintAgentVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.PrintAgentVoBean();
			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("QUERYSERVERURL"))
			return getQueryServerUrl();
		if(fieldName.equals("REPORTSERVERURL"))
			return getReportServerUrl();
		if(fieldName.equals("TEMPLATESTOPRINT"))
			return getTemplatesToPrint();
		if(fieldName.equals("DESCRIPTION"))
			return getDescription();
		if(fieldName.equals("TRIGGER"))
			return getTrigger();
		if(fieldName.equals("LASTSUCCESSFULRUNDATETIME"))
			return getLastSuccessfulRunDateTime();
		if(fieldName.equals("LASTRUNDATETIME"))
			return getLastRunDateTime();
		if(fieldName.equals("JOBTYPE"))
			return getJobType();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("SYSINFO"))
			return getSysInfo();
		if(fieldName.equals("DNAAPPTSINLASTXHRS"))
			return getDNAApptsInLastXhrs();
		if(fieldName.equals("NOOFRECORDSUPDATED"))
			return getNoOfRecordsUpdated();
		if(fieldName.equals("LOCATIONTOPRINTFOR"))
			return getLocationToPrintFor();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getQueryServerUrlIsNotNull()
	{
		return this.queryserverurl != null;
	}
	public String getQueryServerUrl()
	{
		return this.queryserverurl;
	}
	public static int getQueryServerUrlMaxLength()
	{
		return 255;
	}
	public void setQueryServerUrl(String value)
	{
		this.isValidated = false;
		this.queryserverurl = value;
	}
	public boolean getReportServerUrlIsNotNull()
	{
		return this.reportserverurl != null;
	}
	public String getReportServerUrl()
	{
		return this.reportserverurl;
	}
	public static int getReportServerUrlMaxLength()
	{
		return 255;
	}
	public void setReportServerUrl(String value)
	{
		this.isValidated = false;
		this.reportserverurl = value;
	}
	public boolean getTemplatesToPrintIsNotNull()
	{
		return this.templatestoprint != null;
	}
	public ims.admin.vo.TemplatePrinterVoCollection getTemplatesToPrint()
	{
		return this.templatestoprint;
	}
	public void setTemplatesToPrint(ims.admin.vo.TemplatePrinterVoCollection value)
	{
		this.isValidated = false;
		this.templatestoprint = value;
	}
	public boolean getDescriptionIsNotNull()
	{
		return this.description != null;
	}
	public String getDescription()
	{
		return this.description;
	}
	public static int getDescriptionMaxLength()
	{
		return 100;
	}
	public void setDescription(String value)
	{
		this.isValidated = false;
		this.description = value;
	}
	public boolean getTriggerIsNotNull()
	{
		return this.trigger != null;
	}
	public String getTrigger()
	{
		return this.trigger;
	}
	public static int getTriggerMaxLength()
	{
		return 1000;
	}
	public void setTrigger(String value)
	{
		this.isValidated = false;
		this.trigger = value;
	}
	public boolean getLastSuccessfulRunDateTimeIsNotNull()
	{
		return this.lastsuccessfulrundatetime != null;
	}
	public ims.framework.utils.DateTime getLastSuccessfulRunDateTime()
	{
		return this.lastsuccessfulrundatetime;
	}
	public void setLastSuccessfulRunDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.lastsuccessfulrundatetime = value;
	}
	public boolean getLastRunDateTimeIsNotNull()
	{
		return this.lastrundatetime != null;
	}
	public ims.framework.utils.DateTime getLastRunDateTime()
	{
		return this.lastrundatetime;
	}
	public void setLastRunDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.lastrundatetime = value;
	}
	public boolean getJobTypeIsNotNull()
	{
		return this.jobtype != null;
	}
	public ims.ntpf.vo.lookups.JobType getJobType()
	{
		return this.jobtype;
	}
	public void setJobType(ims.ntpf.vo.lookups.JobType value)
	{
		this.isValidated = false;
		this.jobtype = 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 getSysInfoIsNotNull()
	{
		return this.sysinfo != null;
	}
	public ims.vo.SystemInformation getSysInfo()
	{
		return this.sysinfo;
	}
	public void setSysInfo(ims.vo.SystemInformation value)
	{
		this.isValidated = false;
		this.sysinfo = value;
	}
	public boolean getDNAApptsInLastXhrsIsNotNull()
	{
		return this.dnaapptsinlastxhrs != null;
	}
	public Integer getDNAApptsInLastXhrs()
	{
		return this.dnaapptsinlastxhrs;
	}
	public void setDNAApptsInLastXhrs(Integer value)
	{
		this.isValidated = false;
		this.dnaapptsinlastxhrs = value;
	}
	public boolean getNoOfRecordsUpdatedIsNotNull()
	{
		return this.noofrecordsupdated != null;
	}
	public Integer getNoOfRecordsUpdated()
	{
		return this.noofrecordsupdated;
	}
	public void setNoOfRecordsUpdated(Integer value)
	{
		this.isValidated = false;
		this.noofrecordsupdated = value;
	}
	public boolean getLocationToPrintForIsNotNull()
	{
		return this.locationtoprintfor != null;
	}
	public ims.core.vo.LocSiteLiteVo getLocationToPrintFor()
	{
		return this.locationtoprintfor;
	}
	public void setLocationToPrintFor(ims.core.vo.LocSiteLiteVo value)
	{
		this.isValidated = false;
		this.locationtoprintfor = value;
	}
	public boolean isValidated()
	{
		if(this.isBusy)
			return true;
		this.isBusy = true;
	
		if(!this.isValidated)
		{
			this.isBusy = false;
			return false;
		}
		if(this.templatestoprint != null)
		{
			if(!this.templatestoprint.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.queryserverurl == null || this.queryserverurl.length() == 0)
			listOfErrors.add("QueryServerUrl is mandatory");
		else if(this.queryserverurl.length() > 255)
			listOfErrors.add("The length of the field [queryserverurl] in the value object [ims.admin.vo.PrintAgentVo] is too big. It should be less or equal to 255");
		if(this.reportserverurl == null || this.reportserverurl.length() == 0)
			listOfErrors.add("ReportServerUrl is mandatory");
		else if(this.reportserverurl.length() > 255)
			listOfErrors.add("The length of the field [reportserverurl] in the value object [ims.admin.vo.PrintAgentVo] is too big. It should be less or equal to 255");
		if(this.templatestoprint != null)
		{
			String[] listOfOtherErrors = this.templatestoprint.validate();
			if(listOfOtherErrors != null)
			{
				for(int x = 0; x < listOfOtherErrors.length; x++)
				{
					listOfErrors.add(listOfOtherErrors[x]);
				}
			}
		}
		if(this.description == null || this.description.length() == 0)
			listOfErrors.add("Description is mandatory");
		else if(this.description.length() > 100)
			listOfErrors.add("The length of the field [description] in the value object [ims.admin.vo.PrintAgentVo] is too big. It should be less or equal to 100");
		if(this.trigger == null || this.trigger.length() == 0)
			listOfErrors.add("Trigger is mandatory");
		else if(this.trigger.length() > 1000)
			listOfErrors.add("The length of the field [trigger] in the value object [ims.admin.vo.PrintAgentVo] is too big. It should be less or equal to 1000");
		if(this.jobtype == null)
			listOfErrors.add("JobType is mandatory");
		if(this.isactive == null)
			listOfErrors.add("isActive 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;
	
		PrintAgentVo clone = new PrintAgentVo(this.id, this.version);
		
		clone.queryserverurl = this.queryserverurl;
		clone.reportserverurl = this.reportserverurl;
		if(this.templatestoprint == null)
			clone.templatestoprint = null;
		else
			clone.templatestoprint = (ims.admin.vo.TemplatePrinterVoCollection)this.templatestoprint.clone();
		clone.description = this.description;
		clone.trigger = this.trigger;
		if(this.lastsuccessfulrundatetime == null)
			clone.lastsuccessfulrundatetime = null;
		else
			clone.lastsuccessfulrundatetime = (ims.framework.utils.DateTime)this.lastsuccessfulrundatetime.clone();
		if(this.lastrundatetime == null)
			clone.lastrundatetime = null;
		else
			clone.lastrundatetime = (ims.framework.utils.DateTime)this.lastrundatetime.clone();
		if(this.jobtype == null)
			clone.jobtype = null;
		else
			clone.jobtype = (ims.ntpf.vo.lookups.JobType)this.jobtype.clone();
		clone.isactive = this.isactive;
		if(this.sysinfo == null)
			clone.sysinfo = null;
		else
			clone.sysinfo = (ims.vo.SystemInformation)this.sysinfo.clone();
		clone.dnaapptsinlastxhrs = this.dnaapptsinlastxhrs;
		clone.noofrecordsupdated = this.noofrecordsupdated;
		if(this.locationtoprintfor == null)
			clone.locationtoprintfor = null;
		else
			clone.locationtoprintfor = (ims.core.vo.LocSiteLiteVo)this.locationtoprintfor.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 (!(PrintAgentVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A PrintAgentVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		PrintAgentVo compareObj = (PrintAgentVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_PrintAgent() == null && compareObj.getID_PrintAgent() != null)
				return -1;
			if(this.getID_PrintAgent() != null && compareObj.getID_PrintAgent() == null)
				return 1;
			if(this.getID_PrintAgent() != null && compareObj.getID_PrintAgent() != null)
				retVal = this.getID_PrintAgent().compareTo(compareObj.getID_PrintAgent());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.queryserverurl != null)
			count++;
		if(this.reportserverurl != null)
			count++;
		if(this.templatestoprint != null)
			count++;
		if(this.description != null)
			count++;
		if(this.trigger != null)
			count++;
		if(this.lastsuccessfulrundatetime != null)
			count++;
		if(this.lastrundatetime != null)
			count++;
		if(this.jobtype != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.sysinfo != null)
			count++;
		if(this.dnaapptsinlastxhrs != null)
			count++;
		if(this.noofrecordsupdated != null)
			count++;
		if(this.locationtoprintfor != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 13;
	}
	protected String queryserverurl;
	protected String reportserverurl;
	protected ims.admin.vo.TemplatePrinterVoCollection templatestoprint;
	protected String description;
	protected String trigger;
	protected ims.framework.utils.DateTime lastsuccessfulrundatetime;
	protected ims.framework.utils.DateTime lastrundatetime;
	protected ims.ntpf.vo.lookups.JobType jobtype;
	protected Boolean isactive;
	protected ims.vo.SystemInformation sysinfo;
	protected Integer dnaapptsinlastxhrs;
	protected Integer noofrecordsupdated;
	protected ims.core.vo.LocSiteLiteVo locationtoprintfor;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
