package aPackage;

import tap.metadata.TAPColumn;
import tap.metadata.TAPMetadata;
import tap.metadata.TAPSchema;
import tap.metadata.TAPTable;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;

public class MyMetadata extends TAPMetadata {
	public MyMetadata(){

		/* Call the TAPMetadata constructor.
		 * IMPORTANT: without this call, TAPMetadata attributes are not set and the following class functions will fail with a NullPointerException. */
		super();

		// Describe our table SuperCat:
		TAPTable table = new TAPTable("SuperCat");
		table.setDescription("Catalog gathering all my super stars.");

		// Add all columns to publish:

		/* Here, 4 different methods can be used: */
		// 1st method: with the full TAPTable function
		table.addColumn("id", new DBType(DBDatatype.BIGINT), null, null, null, null, true, true, false);
		// 2nd method: with the shorted TAPTable function
		table.addColumn("name"); // no need to specify the datatype since the default one is VARCHAR
		// 3rd method: add more details to the column created with the TAPTable function
		TAPColumn column = table.addColumn("type");
		column.setDatatype(new DBType(DBDatatype.VARCHAR, 32));
		// 4th method: build a TAPColumn that will be add inside the TAPTable
		column = new TAPColumn("ra", new DBType(DBDatatype.DOUBLE), "Right ascension.");
		column.setUnit("deg");
		column.setUcd("pos.eq.ra;meta.main");
		column.setIndexed(true);
		table.addColumn(column);

		// Add the remaining columns:
		table.addColumn("dec", new DBType(DBDatatype.DOUBLE), "Declination.", "deg", "pos.eq.dec;meta.main", null, false, true, false);
		table.addColumn(new TAPColumn("magg", new DBType(DBDatatype.REAL), "Magnitude.", "mag", "phot.mag;em.opt.V", null, false, false, false));

		// Describe the schema containing our table:
		TAPSchema schema = new TAPSchema("public");
		schema.addTable(table);

		// Add the whole TAP schema inside this TAPMetadata object:
		addSchema(schema);

		/* Note: Now, all schemas, tables and columns are known by the TAP library.
		 *       Do not worry about the description of TAP_SCHEMA, it will be added automatically by the library.*/
	}
}
