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

	public AppImageVo()
	{
	}
	public AppImageVo(Integer id, int version)
	{
		super(id, version);
	}
	public AppImageVo(ims.admin.vo.beans.AppImageVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.imagepath = bean.getImagePath();
		this.issystem = bean.getIsSystem();
		this.namespace = bean.getNameSpace();
		this.isactive = bean.getIsActive();
		this.width = bean.getWidth();
		this.height = bean.getHeight();
	}
	public void populate(ims.vo.ValueObjectBeanMap map, ims.admin.vo.beans.AppImageVoBean bean)
	{
		this.id = bean.getId();
		this.version = bean.getVersion();
		this.imagepath = bean.getImagePath();
		this.issystem = bean.getIsSystem();
		this.namespace = bean.getNameSpace();
		this.isactive = bean.getIsActive();
		this.width = bean.getWidth();
		this.height = bean.getHeight();
	}
	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.AppImageVoBean bean = null;
		if(map != null)
			bean = (ims.admin.vo.beans.AppImageVoBean)map.getValueObjectBean(this);
		if (bean == null)
		{
			bean = new ims.admin.vo.beans.AppImageVoBean();
			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("IMAGEPATH"))
			return getImagePath();
		if(fieldName.equals("ISSYSTEM"))
			return getIsSystem();
		if(fieldName.equals("NAMESPACE"))
			return getNameSpace();
		if(fieldName.equals("ISACTIVE"))
			return getIsActive();
		if(fieldName.equals("WIDTH"))
			return getWidth();
		if(fieldName.equals("HEIGHT"))
			return getHeight();
		return super.getFieldValueByFieldName(fieldName);
	}
	public boolean getImagePathIsNotNull()
	{
		return this.imagepath != null;
	}
	public String getImagePath()
	{
		return this.imagepath;
	}
	public static int getImagePathMaxLength()
	{
		return 200;
	}
	public void setImagePath(String value)
	{
		this.isValidated = false;
		this.imagepath = value;
	}
	public boolean getIsSystemIsNotNull()
	{
		return this.issystem != null;
	}
	public Boolean getIsSystem()
	{
		return this.issystem;
	}
	public void setIsSystem(Boolean value)
	{
		this.isValidated = false;
		this.issystem = value;
	}
	public boolean getNameSpaceIsNotNull()
	{
		return this.namespace != null;
	}
	public Integer getNameSpace()
	{
		return this.namespace;
	}
	public void setNameSpace(Integer value)
	{
		this.isValidated = false;
		this.namespace = 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 getWidthIsNotNull()
	{
		return this.width != null;
	}
	public Integer getWidth()
	{
		return this.width;
	}
	public void setWidth(Integer value)
	{
		this.isValidated = false;
		this.width = value;
	}
	public boolean getHeightIsNotNull()
	{
		return this.height != null;
	}
	public Integer getHeight()
	{
		return this.height;
	}
	public void setHeight(Integer value)
	{
		this.isValidated = false;
		this.height = value;
	}
	/**
	* IAppImage interface methods
	*/
		public int getImageId()
		{
			if(getID_AppImage() == null)
				return 0;
			return getID_AppImage().intValue();
		}
		public int getImageWidth()
		{
			if (width == null)
				return -1;
			else
				return getWidth().intValue();
		}
		public int getImageHeight()
		{
			if (height == null)
				return -1;
			else
				return getHeight().intValue();
		}
		public ims.framework.utils.beans.ImageBean getImageBean()
		{
			return new ims.framework.utils.beans.ImageBean(this);
		}
		public ims.framework.utils.ImageInfo getImageInfo()
		{
			return ims.framework.utils.ImagePath.getImageInfo(this.getImagePath());
		}
		public boolean isActive()
		{
			if(isactive != null && isactive.booleanValue())
				return true;
			return false;
		}
		public String toXMLString()
		{
			StringBuffer sb = new StringBuffer();
			sb.append("<class id=\"" + this.getImageId() + "\" >");
			sb.append(" source=\"" + ims.configuration.EnvironmentConfig.getImportExportSourceName() + "\" >");
			sb.append("<imagePath>");
			sb.append(this.getImagePath());
			sb.append("</imagePath>");
			sb.append("<width>");
			sb.append(this.getWidth());
			sb.append("</width>");
			sb.append("<height>");
			sb.append(this.getHeight());
			sb.append("</height>");
			sb.append("</class>");
			return sb.toString();
		}
	
	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.imagepath == null || this.imagepath.length() == 0)
			listOfErrors.add("Please enter a Path for the image - Mandatory Field");
		else if(this.imagepath.length() > 200)
			listOfErrors.add("The length of the field [imagepath] in the value object [ims.admin.vo.AppImageVo] is too big. It should be less or equal to 200");
		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;
	
		AppImageVo clone = new AppImageVo(this.id, this.version);
		
		clone.imagepath = this.imagepath;
		clone.issystem = this.issystem;
		clone.namespace = this.namespace;
		clone.isactive = this.isactive;
		clone.width = this.width;
		clone.height = this.height;
		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 (!(AppImageVo.class.isAssignableFrom(obj.getClass())))
		{
			throw new ClassCastException("A AppImageVo object cannot be compared an Object of type " + obj.getClass().getName());
		}
		AppImageVo compareObj = (AppImageVo)obj;
		int retVal = 0;
		if (retVal == 0)
		{
			if(this.getID_AppImage() == null && compareObj.getID_AppImage() != null)
				return -1;
			if(this.getID_AppImage() != null && compareObj.getID_AppImage() == null)
				return 1;
			if(this.getID_AppImage() != null && compareObj.getID_AppImage() != null)
				retVal = this.getID_AppImage().compareTo(compareObj.getID_AppImage());
		}
		return retVal;
	}
	public synchronized static int generateValueObjectUniqueID()
	{
		return ims.vo.ValueObject.generateUniqueID();
	}
	public int countFieldsWithValue()
	{
		int count = 0;
		if(this.imagepath != null)
			count++;
		if(this.issystem != null)
			count++;
		if(this.namespace != null)
			count++;
		if(this.isactive != null)
			count++;
		if(this.width != null)
			count++;
		if(this.height != null)
			count++;
		return count;
	}
	public int countValueObjectFields()
	{
		return 6;
	}
	protected String imagepath;
	protected Boolean issystem;
	protected Integer namespace;
	protected Boolean isactive;
	protected Integer width;
	protected Integer height;
	private boolean isValidated = false;
	private boolean isBusy = false;
}
