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

	public SystemLogVo()
	{
	}
	public SystemLogVo(Integer id, int version)
	{
		super(id, version);
	}
	public SystemLogVo(ims.admin.vo.beans.SystemLogVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.eventdatetime = bean.getEventDateTime() == null ? null : bean.getEventDateTime().buildDateTime();
		this.eventtype = bean.getEventType();
		this.eventlevel = bean.getEventLevel();
		this.user = bean.getUser();
		this.source = bean.getSource();
		this.computer = bean.getComputer();
		this.useragent = bean.getUserAgent();
		this.sessionid = bean.getSessionId();
		this.message = bean.getMessage();
		this.applicationserver = bean.getApplicationServer();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.SystemLogVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.eventdatetime = bean.getEventDateTime() == null ? null : bean.getEventDateTime().buildDateTime();
		this.eventtype = bean.getEventType();
		this.eventlevel = bean.getEventLevel();
		this.user = bean.getUser();
		this.source = bean.getSource();
		this.computer = bean.getComputer();
		this.useragent = bean.getUserAgent();
		this.sessionid = bean.getSessionId();
		this.message = bean.getMessage();
		this.applicationserver = bean.getApplicationServer();
	}
	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.SystemLogVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.SystemLogVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.SystemLogVoBean();
			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("EVENTDATETIME"))
			return getEventDateTime();
		if(fieldName.equals("EVENTTYPE"))
			return getEventType();
		if(fieldName.equals("EVENTLEVEL"))
			return getEventLevel();
		if(fieldName.equals("USER"))
			return getUser();
		if(fieldName.equals("SOURCE"))
			return getSource();
		if(fieldName.equals("COMPUTER"))
			return getComputer();
		if(fieldName.equals("USERAGENT"))
			return getUserAgent();
		if(fieldName.equals("SESSIONID"))
			return getSessionId();
		if(fieldName.equals("MESSAGE"))
			return getMessage();
		if(fieldName.equals("APPLICATIONSERVER"))
			return getApplicationServer();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getEventDateTimeIsNotNull()
	{
		return this.eventdatetime != null;
	}
	public ims.framework.utils.DateTime getEventDateTime()
	{
		return this.eventdatetime;
	}
	public void setEventDateTime(ims.framework.utils.DateTime value)
	{
		this.isValidated = false;
		this.eventdatetime = value;
	}
	public boolean getEventTypeIsNotNull()
	{
		return this.eventtype != null;
	}
	public Integer getEventType()
	{
		return this.eventtype;
	}
	public void setEventType(Integer value)
	{
		this.isValidated = false;
		this.eventtype = value;
	}
	public boolean getEventLevelIsNotNull()
	{
		return this.eventlevel != null;
	}
	public Integer getEventLevel()
	{
		return this.eventlevel;
	}
	public void setEventLevel(Integer value)
	{
		this.isValidated = false;
		this.eventlevel = value;
	}
	public boolean getUserIsNotNull()
	{
		return this.user != null;
	}
	public String getUser()
	{
		return this.user;
	}
	public static int getUserMaxLength()
	{
		return 100;
	}
	public void setUser(String value)
	{
		this.isValidated = false;
		this.user = value;
	}
	public boolean getSourceIsNotNull()
	{
		return this.source != null;
	}
	public String getSource()
	{
		return this.source;
	}
	public static int getSourceMaxLength()
	{
		return 255;
	}
	public void setSource(String value)
	{
		this.isValidated = false;
		this.source = value;
	}
	public boolean getComputerIsNotNull()
	{
		return this.computer != null;
	}
	public String getComputer()
	{
		return this.computer;
	}
	public static int getComputerMaxLength()
	{
		return 255;
	}
	public void setComputer(String value)
	{
		this.isValidated = false;
		this.computer = value;
	}
	public boolean getUserAgentIsNotNull()
	{
		return this.useragent != null;
	}
	public String getUserAgent()
	{
		return this.useragent;
	}
	public static int getUserAgentMaxLength()
	{
		return 1000;
	}
	public void setUserAgent(String value)
	{
		this.isValidated = false;
		this.useragent = value;
	}
	public boolean getSessionIdIsNotNull()
	{
		return this.sessionid != null;
	}
	public String getSessionId()
	{
		return this.sessionid;
	}
	public static int getSessionIdMaxLength()
	{
		return 255;
	}
	public void setSessionId(String value)
	{
		this.isValidated = false;
		this.sessionid = value;
	}
	public boolean getMessageIsNotNull()
	{
		return this.message != null;
	}
	public String getMessage()
	{
		return this.message;
	}
	public static int getMessageMaxLength()
	{
		return 50000;
	}
	public void setMessage(String value)
	{
		this.isValidated = false;
		this.message = value;
	}
	public boolean getApplicationServerIsNotNull()
	{
		return this.applicationserver != null;
	}
	public String getApplicationServer()
	{
		return this.applicationserver;
	}
	public static int getApplicationServerMaxLength()
	{
		return 255;
	}
	public void setApplicationServer(String value)
	{
		this.isValidated = false;
		this.applicationserver = value;
	}
	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		if(this.eventdatetime != null)
			sb.append(this.eventdatetime);
		sb.append(" - ");
		if(this.user != null)
			sb.append(this.user);
		return sb.toString();
	}
	/**
	* ISystemLog interface methods
	*/
		public int getSystemLogEventId()
		{
			return id == null ? 0 : id;
		}
		public String getSystemLogEventComputer() 
		{
			return computer;
		}
		public ims.framework.enumerations.SystemLogLevel getSystemLogEventLevel() 
		{
			if(eventlevel == null)
				return null;
			return ims.framework.enumerations.SystemLogLevel.getInstance(eventlevel);
		}
		public String getSystemLogEventMessage() 
		{
			return message;
		}
		public String getSystemLogEventSource() 
		{
			return source;
		}
		public String getSystemLogEventUser() 
		{
			return user;
		}
		public String getSystemLogEventUserAgent() 
		{
			return useragent;
		}
		public String getSystemLogEventApplicationServer()
		{
			return applicationserver;
		}
	
		public ims.framework.utils.DateTime getSystemLogEventDateTime() 
		{
			return eventdatetime;
		}
		public ims.framework.enumerations.SystemLogType getSystemLogEventType() 
		{
			if(eventtype == null)
				return null;
			return ims.framework.enumerations.SystemLogType.getInstance(eventtype);
		}
		public String getSystemLogEventSessionId()
		{
			return sessionid;
		}
	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.eventdatetime == null)
			listOfErrors.add("EventDateTime is mandatory");
		if(this.eventtype == null)
			listOfErrors.add("EventType is mandatory");
		if(this.eventlevel == null)
			listOfErrors.add("EventLevel is mandatory");
		if(this.user != null)
			if(this.user.length() > 100)
				listOfErrors.add("The length of the field [user] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 100");
		if(this.source != null)
			if(this.source.length() > 255)
				listOfErrors.add("The length of the field [source] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 255");
		if(this.computer != null)
			if(this.computer.length() > 255)
				listOfErrors.add("The length of the field [computer] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 255");
		if(this.useragent != null)
			if(this.useragent.length() > 1000)
				listOfErrors.add("The length of the field [useragent] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 1000");
		if(this.sessionid != null)
			if(this.sessionid.length() > 255)
				listOfErrors.add("The length of the field [sessionid] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 255");
		if(this.message == null || this.message.length() == 0)
			listOfErrors.add("Message is mandatory");
		if(this.applicationserver != null)
			if(this.applicationserver.length() > 255)
				listOfErrors.add("The length of the field [applicationserver] in the value object [ims.admin.vo.SystemLogVo] is too big. It should be less or equal to 255");
		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;
	
		SystemLogVo clone = new SystemLogVo(this.id, this.version);
		
		if(this.eventdatetime == null)
			clone.eventdatetime = null;
		else
			clone.eventdatetime = (ims.framework.utils.DateTime)this.eventdatetime.clone();
		clone.eventtype = this.eventtype;
		clone.eventlevel = this.eventlevel;
		clone.user = this.user;
		clone.source = this.source;
		clone.computer = this.computer;
		clone.useragent = this.useragent;
		clone.sessionid = this.sessionid;
		clone.message = this.message;
		clone.applicationserver = this.applicationserver;
		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 (!(SystemLogVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A SystemLogVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		if (this.id == null)
			return 1;
		if (((SystemLogVo)obj).getBoId() == null)
			return -1;
		return this.id.compareTo(((SystemLogVo)obj).getBoId());
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.eventdatetime != null)
			count++;
		if(this.eventtype != null)
			count++;
		if(this.eventlevel != null)
			count++;
		if(this.user != null)
			count++;
		if(this.source != null)
			count++;
		if(this.computer != null)
			count++;
		if(this.useragent != null)
			count++;
		if(this.sessionid != null)
			count++;
		if(this.message != null)
			count++;
		if(this.applicationserver != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 10;
	}
	protected ims.framework.utils.DateTime eventdatetime;
	protected Integer eventtype;
	protected Integer eventlevel;
	protected String user;
	protected String source;
	protected String computer;
	protected String useragent;
	protected String sessionid;
	protected String message;
	protected String applicationserver;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
