package ca.mcgill.cs.creco.persistence;

import org.json.JSONObject;
import org.json.simple.*;

public class Attribute {
	private String displayName;
	private String description;
	private String attributeId;
	private String filterWidget;
	private String dataPresentationFormat;
	
	private String attributeGroup;
	private String unitName;
	
	// Note the json attribute 'value' varies in data type
	// from one jsonAttribute to the next.  Users of the class
	// have to check
	private Object value;
	
	private Integer sortOrder;
	
	private Boolean isForDisplayOnCro;
	private Boolean isCategoryCommonAttribute;
	
	private static String[] stringFields = 
	{
		"displayName","description","attributeId","filterWidget",
		"dataPresentationFormat", "attributeGroup", "unitName"
	};
	
	private static String[] boolFields = 
	{
		"isForDisplayOnCro", "isCategoryCommonAttribute"
	};
	
	public String getString(String key)
	{
		if(key.equals("displayName"))
		{
			return this.displayName;
		}
		else if(key.equals("description"))
		{
			return this.description;
		} 
		else if(key.equals("attributeId"))
		{
			return this.attributeId;
		}
		else if(key.equals("filterWidget"))
		{
			return this.filterWidget;
		}
		else if(key.equals("dataPresentationFormat"))
		{
			return this.dataPresentationFormat;
		}
		else if(key.equals("attributeGroup"))
		{
			return this.attributeGroup;
		}
		else if(key.equals("unitName"))
		{
			return this.unitName;
		}
		else
		{
			return null;
		}							
	}
	
	public Boolean getBool(String key)
	{
		if(key.equals("isForDisplayOnCRO"))
		{
			return this.isForDisplayOnCro;
		}
		else if(key.equals("isCategoryCommonAttribute"))
		{
			return this.isCategoryCommonAttribute;
		}
		else
		{
			return null;
		}
	}

	public Integer getInt(String key)
	{
		if(key.equals("sortOrder"))
		{
			return this.sortOrder;
		}
		else
		{
			return null;
		}
	}
	
	public String getAttributeName()
	{
		return this.displayName;
	}
	
	public String getId() {
		return this.attributeId;
	}
	

	private void setValue(Object val)
	{
		this.value = val;
	}
	
	private void setInt(String key, Integer val)
	{
		if(key.equals("sortOrder"))
		{
			this.sortOrder = val;
		}
	}
	
	private void setDouble(String key, Double val) {
		if(key.equals("value"))
		{
			this.value = val;
		}
	}
	
	private void setBool(String key, Boolean val)
	{
		if(key.equals("isForDisplayOnCro"))
		{
			this.isForDisplayOnCro = val;
		}
		else if(key.equals("isCategoryCommonAttribute"))
		{
			this.isCategoryCommonAttribute = val;
		}
	}
	
	private void setString(String key, String val)
	{
		if(key.equals("displayName"))
		{
			this.displayName = val;
		}
		else if(key.equals("description"))
		{
			this.description = val;
		}
		else if(key.equals("attributeId"))
		{
			this.attributeId = val;
		}
		else if(key.equals("filterWidget"))
		{
			this.filterWidget = val;
		}
		else if(key.equals("dataPresentationFormat"))
		{
			this.dataPresentationFormat = val;	
		}
	}
	
}

@@ -38,63 +38,8 @@
 e;%0A%0A
-import org.json.JSONObject;%0Aimport org.json.simple.*;%0A%0A
 publ
@@ -375,16 +375,21 @@
  next.  
+%0A%09// 
 Users of
@@ -398,20 +398,16 @@
 he class
-%0A%09//
  have to
@@ -816,16 +816,133 @@
 %22%0A%09%7D;%0A%09%0A
+%09public Object getValue()%0A%09%7B%0A%09%09return this.value;%0A%09%7D%0A%09%0A%09public Integer getSortOrder()%0A%09%7B%0A%09%09return this.sortOrder;%0A%09%7D%0A
 %09public 
@@ -2069,22 +2069,21 @@
 %09%7D%0A%09%0A%0A%09p
-rivate
+ublic
  void se
@@ -2123,38 +2123,37 @@
 e = val;%0A%09%7D%0A%09%0A%09p
-rivate
+ublic
  void setInt(Str
@@ -2239,38 +2239,37 @@
 val;%0A%09%09%7D%0A%09%7D%0A%09%0A%09p
-rivate
+ublic
  void setDouble(
@@ -2348,38 +2348,37 @@
 val;%0A%09%09%7D%0A%09%7D%0A%09%0A%09p
-rivate
+ublic
  void setBool(St
@@ -2589,22 +2589,21 @@
 %0A%09%7D%0A%09%0A%09p
-rivate
+ublic
  void se

fix changes caused by misusing git