///Current version
///ID:          $Id: VoTable.cs,v 1.1.1.1 2006/11/14 02:56:37 gupchup Exp $
///Revision:    $Revision: 1.1.1.1 $
///Date:        $Date: 2006/11/14 02:56:37 $

//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.0.3705.288
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

// 
// This source code was auto-generated by xsd, Version=1.0.3705.288.
// and modified to fit the VOTable specifications by Tamas Budavari and Maria Nieto-Santisteban
using System;
using System.Data;
using System.Collections;
using System.Xml.Serialization;


namespace Edu.Jhu.footprintweb
{
	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class COOSYS 
	{
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string equinox;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string epoch;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
			//		[System.ComponentModel.DefaultValueAttribute(COOSYSSystem.eq_FK5)]
		public COOSYSSystem system = COOSYSSystem.eq_FK5;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlTextAttribute()]
		public string Value;

		public COOSYS ()
		{
			this.ID = "J2000";
			this.equinox = "2000.";
			this.epoch = "2000.";
		}

		public COOSYS (string id, string equinox, string epoch, COOSYSSystem cooSys)
		{
			this.ID = id;
			this.equinox = equinox;
			this.epoch = epoch;
			this.system = cooSys;
		}
	}

	/// <remarks/>
	public enum COOSYSSystem 
	{
    
		/// <remarks/>
		eq_FK4,
    
		/// <remarks/>
		eq_FK5,
    
		/// <remarks/>
		ICRS,
    
		/// <remarks/>
		ecl_FK4,
    
		/// <remarks/>
		ecl_FK5,
    
		/// <remarks/>
		galactic,
    
		/// <remarks/>
		supergalactic,
    
		/// <remarks/>
		xy,
    
		/// <remarks/>
		barycentric,
    
		/// <remarks/>
		geo_app,
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class DATA 
	{
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("TABLEDATA", typeof(TR[]))]
		public object Item;
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class TD 
	{
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="IDREF")]
		public string @ref;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlTextAttribute()]
		public string Value;
	}

	/// <remarks/>
	//[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	[System.Xml.Serialization.XmlRootAttribute("TR", IsNullable=false)]
	public class TR
	{		    
		[System.Xml.Serialization.XmlElement("TD")]
		public TD[] TD;
	}
	

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class DEFINITIONS 
	{    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("COOSYS")]
		public COOSYS[] COOSYS;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("PARAM")]
		public PARAM[] PARAM;
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class PARAM 
	{
    
		/// <remarks/>
		public string DESCRIPTION;
    
		/// <remarks/>
		public VALUES VALUES;
        
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string unit;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public PARAMDatatype datatype;
    
		/// <remarks/>
		//[System.Xml.Serialization.XmlIgnoreAttribute()]
		//public bool datatypeSpecified;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string precision;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string width;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="IDREF")]
		public string @ref;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string ucd;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string value;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string arraysize;

		public PARAM (){}

		public PARAM (string id, string val, string unit, string datatype)
		{
			Hashtable PDT_table = ConvPARAMDatatypeTable();
			
			this.ID = id;
			this.value = val;
			this.unit = unit;
			this.datatype = (PARAMDatatype)PDT_table[datatype];
		}

		public Hashtable ConvPARAMDatatypeTable()
		{
			Hashtable PDT_table = new Hashtable();

			PDT_table.Add("System.Byte",	PARAMDatatype.unsignedByte);
			PDT_table.Add("System.Int16",	PARAMDatatype.@short);
			PDT_table.Add("System.Int32",	PARAMDatatype.@int);
			PDT_table.Add("System.Int64",	PARAMDatatype.@long);
			PDT_table.Add("System.Char",	PARAMDatatype.@char);
			PDT_table.Add("System.Single",	PARAMDatatype.@float);
			PDT_table.Add("System.Double",	PARAMDatatype.@double);
			PDT_table.Add("System.String",	PARAMDatatype.@char);

			return PDT_table;
		}
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class VALUES 
	{        
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("OPTION")]
		public OPTION[] OPTION;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		[System.ComponentModel.DefaultValueAttribute(VALUESType.legal)]
		public VALUESType type = VALUESType.legal;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string @null;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		[System.ComponentModel.DefaultValueAttribute(VALUESInvalid.no)]
		public VALUESInvalid invalid = VALUESInvalid.no;
	}

	
	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class OPTION 
	{
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("OPTION")]
		public OPTION[] OPTION1;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string value;
	}

	/// <remarks/>
	public enum VALUESType 
	{
    
		/// <remarks/>
		legal,
    
		/// <remarks/>
		actual,
	}

	/// <remarks/>
	public enum VALUESInvalid 
	{
    
		/// <remarks/>
		yes,
    
		/// <remarks/>
		no,
	}



	public enum PARAMDatatype 
	{
		/// <remarks/>	
		unknown = -1,
		/// <remarks/>
		boolean,
    
		/// <remarks/>
		bit,
    
		/// <remarks/>
		unsignedByte,
    
		/// <remarks/>
		@short,
    
		/// <remarks/>
		@int,
    
		/// <remarks/>
		@long,
    
		/// <remarks/>
		@char,
    
		/// <remarks/>
		unicodeChar,
    
		/// <remarks/>
		@float,
    
		/// <remarks/>
		@double,
    
		/// <remarks/>
		floatComplex,
    
		/// <remarks/>
		doubleComplex,
	}

	/// <remarks/>
	public enum FIELDDatatype
	{
		unknown = -1,
		/// <remarks/>
		boolean,
    
		/// <remarks/>
		bit,
    
		/// <remarks/>
		unsignedByte,
    
		/// <remarks/>
		@short,
    
		/// <remarks/>
		@int,
    
		/// <remarks/>
		@long,
    
		/// <remarks/>
		@char,
    
		/// <remarks/>
		unicodeChar,
    
		/// <remarks/>
		@float,
    
		/// <remarks/>
		@double,
    
		/// <remarks/>
		floatComplex,
    
		/// <remarks/>
		doubleComplex,

		/// <remarks/>
		@date
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class FIELD 
	{
				
		/// <remarks/>
		public string DESCRIPTION;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("VALUES")]
		public VALUES[] VALUES;
    
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string unit;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public FIELDDatatype datatype;
		
    
		/* // between comments to allow datatype be serialized 
		   // (otherwise, it doesn't show up)
		/// <remarks/>
		[System.Xml.Serialization.XmlIgnoreAttribute()]
		public bool datatypeSpecified;
		*/
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string precision;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string width;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="IDREF")]
		public string @ref;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string ucd;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string arraysize;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public FIELDType type;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlIgnoreAttribute()]
		public bool typeSpecified;

		public FIELD (){}

		public FIELD (DataRow oneField) 
		{			
			
			Hashtable FDT_table = ConvFIELDDatatypeTable();


			this.DESCRIPTION = oneField["DESCRIPTION"].ToString();
			// this.VALUES = oneField["VALUES"] // this is another class so let's forget about it for now
			// this.LINK = oneField["LINK"] // this is another class so let's forget about it for now				
			this.ID =  oneField["ID"].ToString();
			this.datatype = (FIELDDatatype)FDT_table[oneField["datatype"].ToString()];
			this.ucd = oneField["ucd"].ToString();				


		}
		
		static public Hashtable ConvFIELDDatatypeTable()
		{
			Hashtable FDT_table = new Hashtable();

			FDT_table.Add("System.Byte",	FIELDDatatype.unsignedByte);
			FDT_table.Add("System.Int16",	FIELDDatatype.@short);
			FDT_table.Add("System.Int32",	FIELDDatatype.@int);
			FDT_table.Add("System.Int64",	FIELDDatatype.@long);
			FDT_table.Add("System.Char",	FIELDDatatype.@char);
			FDT_table.Add("System.Single",	FIELDDatatype.@float);
			FDT_table.Add("System.Double",	FIELDDatatype.@double);
			FDT_table.Add("System.String",	FIELDDatatype.@char);

			// Added by Dobos
			FDT_table.Add("System.DateTime",	FIELDDatatype.@char);

			return FDT_table;
		}

	}


	

	/// <remarks/>
	public enum FIELDType 
	{
    
		/// <remarks/>
		hidden,
    
		/// <remarks/>
		no_query,
    
		/// <remarks/>
		trigger,
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class INFO 
	{
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlTextAttribute()]
		public string value;
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class RESOURCE 
	{
    
		/// <remarks/>
		public string DESCRIPTION;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("INFO")]
		public INFO[] INFO;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("COOSYS")]
		public COOSYS[] COOSYS;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("PARAM")]
		public PARAM[] PARAM;
        
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("TABLE")]
		public TABLE[] TABLE;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("RESOURCE")]
		public RESOURCE[] RESOURCE1;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
			// [System.ComponentModel.DefaultValueAttribute(RESOURCEType.results)]
		public RESOURCEType type = RESOURCEType.results;
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class TABLE 
	{
    
		/// <remarks/>
		public string DESCRIPTION;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("FIELD")]
		public FIELD[] FIELD;
        
		/// <remarks/>
		public DATA DATA;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string name;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="IDREF")]
		public string @ref;
	}

	/// <remarks/>
	public enum RESOURCEType 
	{
    
		/// <remarks/>
		results,
    
		/// <remarks/>
		meta,
	}

	/// <remarks/>
	[System.Xml.Serialization.XmlRootAttribute(Namespace="http://skyservice.pha.jhu.edu", IsNullable=false)]
	public class VOTABLE 
	{
    
		public static string Revision
		{
			get
			{
				return "$Revision: 1.1.1.1 $";
			}
		}

		/// <remarks/>
		public string DESCRIPTION;
    
		/// <remarks/>
		public DEFINITIONS DEFINITIONS;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("INFO")]
		public INFO[] INFO;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlElementAttribute("RESOURCE")]
		public RESOURCE[] RESOURCE;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute(DataType="ID")]
		public string ID;
    
		/// <remarks/>
		[System.Xml.Serialization.XmlAttributeAttribute()]
		public string version;

		public VOTABLE ()
		{}

		public VOTABLE (string info)
		{			
			this.version = "v1.0";

			this.INFO = new INFO[1];
			this.INFO[0] = new INFO();
			this.INFO[0].name = "ERROR" ;	
			this.INFO[0].value = info;
		}
		
		public VOTABLE (DataSet ds)
		{
			this.version = "v1.0";

			this.RESOURCE = new RESOURCE[1];
			this.RESOURCE[0] = new RESOURCE();
			this.RESOURCE[0].type = RESOURCEType.results;

			int ntbl = ds.Tables.Count;
			this.RESOURCE[0].TABLE = new TABLE[ntbl];

			// get name and type of columns
			Hashtable votype = FIELD.ConvFIELDDatatypeTable();
			for (int k=0; k<ntbl; k++)
			{
				DataTable dt = ds.Tables[k];
				this.RESOURCE[0].TABLE[k] = new TABLE();
				this.RESOURCE[0].TABLE[k].FIELD = new FIELD[dt.Columns.Count];
				for (int j=0; j<dt.Columns.Count; j++)
				{	
					this.RESOURCE[0].TABLE[k].FIELD[j] = new FIELD();
					this.RESOURCE[0].TABLE[k].FIELD[j].name = dt.Columns[j].ColumnName;
					this.RESOURCE[0].TABLE[k].FIELD[j].datatype = (FIELDDatatype) votype[dt.Columns[j].DataType.ToString()];
					// if char, let's make it a string
					if (this.RESOURCE[0].TABLE[k].FIELD[j].datatype == FIELDDatatype.@char) 
					{
						this.RESOURCE[0].TABLE[k].FIELD[j].arraysize = "*";
					}
				}
				// load data
				TR[] data = new TR[dt.Rows.Count];
				for (int i=0; i<data.Length; i++)
				{
					data[i] = new TR();
					data[i].TD = new TD[dt.Columns.Count];
					for (int j=0; j<data[i].TD.Length; j++)
					{
						data[i].TD[j] = new TD();
						data[i].TD[j].Value = Convert.ToString(ds.Tables[k].Rows[i][j]);
					}
				}
				this.RESOURCE[0].TABLE[k].DATA = new DATA();
				this.RESOURCE[0].TABLE[k].DATA.Item = data;						
			}
		}
	}
}
/* Revision History
        $Log: VoTable.cs,v $
        Revision 1.1.1.1  2006/11/14 02:56:37  gupchup
        no message

        Revision 1.1  2006/02/13 23:02:06  budavari
        Website added to solution

        Revision 1.1.1.1  2004/03/31 17:55:49  dobos
        v 2.0

        Revision 1.1.1.1  2003/08/03 20:58:33  dobos
        Firts version

        Revision 1.1.1.1  2003/07/31 13:59:31  dobos
        Stable version

        Revision 1.3  2003/06/04 20:46:11  budavari
        Simplified VOTable

        Revision 1.2  2003/06/04 17:38:30  budavari
        New namespace

        Revision 1.1.1.1  2003/05/30 20:28:20  budavari
        Import the project

*/