
import uk.ac.ic.doc.automed.*;
import uk.ac.ic.doc.automed.reps.*;


/**
	An application that defines the graphical representation API, i.e.
	the methods that can be used in the graphical representation definition
	of a construct.
*/
public class DefineGraphicalRepresentationAPI
{
	public static void createSMRAPI()
		throws SchemaModelingRepositoryException, RepositoryAccessException
	{
	  //PJM 14/7/02 Now done by user as part of repository initailisation
	  //try{
	  //    DataSourceRepository.doDropdbCommand(new String[]{
	  //      "", SchemaModelingRepository.getSMR_DataSourceName()
	  //	});
	  //    DataSourceRepository.doCreatedbCommand(new String[]{
	  //      "", SchemaModelingRepository.getSMR_DataSourceName()
	  // 	});
	  //}
	  //catch(Exception e){
	  //	throw new RepositoryAccessException("cannot re-create SMR", e);
	  //}


		//remove existing methods
		int[] methodIds = SchemaModelingRepository.getMethodsMethIdList();
		if(methodIds!=null){
			for(int i=0; i<methodIds.length; i++){
				SchemaModelingRepository.removeMethodArgument(methodIds[i]);
				SchemaModelingRepository.removeMethod(methodIds[i]);
			}
		}	

		//define methods
		SchemaModelingRepository.createMethod("getValue", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		SchemaModelingRepository.createMethod("getLocation", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		SchemaModelingRepository.createMethod("getManager", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");

		int id4 = SchemaModelingRepository.createMethod("setShape", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		SchemaModelingRepository.createMethodArgument(id4, 1, "uk.ac.ic.doc.automed.gui.SchemaShape");

		SchemaModelingRepository.createMethod("getGraphics", "uk.ac.ic.doc.automed.gui.SchemaManager");
		SchemaModelingRepository.createMethod("createBox", "uk.ac.ic.doc.automed.gui.SchemaManager");

		int id7 = SchemaModelingRepository.createMethod("setGraphics", "uk.ac.ic.doc.automed.gui.Box");
		SchemaModelingRepository.createMethodArgument(id7, 1, "java.awt.Graphics");

		int id8 = SchemaModelingRepository.createMethod("setShapeLocation", "uk.ac.ic.doc.automed.gui.Box");
		SchemaModelingRepository.createMethodArgument(id8, 1, "java.awt.Point");

		int id9 = SchemaModelingRepository.createMethod("setText", "uk.ac.ic.doc.automed.gui.Box");
		SchemaModelingRepository.createMethodArgument(id9, 1, "java.lang.String");

		SchemaModelingRepository.createMethod("draw", "uk.ac.ic.doc.automed.gui.Box");
		SchemaModelingRepository.createMethod("getReferencedConstruct", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");

		int id12 = SchemaModelingRepository.createMethod("getGraphicObject", "uk.ac.ic.doc.automed.gui.SchemaManager");
		SchemaModelingRepository.createMethodArgument(id12, 1, "uk.ac.ic.doc.automed.reps.SchemaObject");

		SchemaModelingRepository.createMethod("getShape", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");

		int id14 = SchemaModelingRepository.createMethod("getEdgePosition", "uk.ac.ic.doc.automed.gui.Box");
		SchemaModelingRepository.createMethodArgument(id14, 1, "java.awt.Point");

		SchemaModelingRepository.createMethod("createArc", "uk.ac.ic.doc.automed.gui.SchemaManager");
		int id16 = SchemaModelingRepository.createMethod("setGraphics", "uk.ac.ic.doc.automed.gui.Arc");
		SchemaModelingRepository.createMethodArgument(id16, 1, "java.awt.Graphics");

		int id17 = SchemaModelingRepository.createMethod("setShapeLocation", "uk.ac.ic.doc.automed.gui.Arc");
		SchemaModelingRepository.createMethodArgument(id17, 1, "java.awt.Point");

		int id18 = SchemaModelingRepository.createMethod("setText", "uk.ac.ic.doc.automed.gui.Arc");
		SchemaModelingRepository.createMethodArgument(id18, 1, "java.lang.String");

		int id19 = SchemaModelingRepository.createMethod("getEdgePosition", "uk.ac.ic.doc.automed.gui.Arc");
		SchemaModelingRepository.createMethodArgument(id19, 1, "java.awt.Point");

		SchemaModelingRepository.createMethod("draw", "uk.ac.ic.doc.automed.gui.Arc");
		SchemaModelingRepository.createMethod("createLine", "uk.ac.ic.doc.automed.gui.SchemaManager");
		
		int id22 = SchemaModelingRepository.createMethod("setGraphics", "uk.ac.ic.doc.automed.gui.Line");
		SchemaModelingRepository.createMethodArgument(id22, 1, "java.awt.Graphics");
	
		int id23 = SchemaModelingRepository.createMethod("setPoint1", "uk.ac.ic.doc.automed.gui.Line");
		SchemaModelingRepository.createMethodArgument(id23, 1, "java.awt.Point");
		int id24 = SchemaModelingRepository.createMethod("setPoint2", "uk.ac.ic.doc.automed.gui.Line");
		SchemaModelingRepository.createMethodArgument(id24, 1, "java.awt.Point");
		SchemaModelingRepository.createMethod("draw", "uk.ac.ic.doc.automed.gui.Line");
		SchemaModelingRepository.createMethod("createRhombus", "uk.ac.ic.doc.automed.gui.SchemaManager");
		int id27 = SchemaModelingRepository.createMethod("setGraphics", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id27, 1, "java.awt.Graphics");
		
		int id28 = SchemaModelingRepository.createMethod("setShapeLocation", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id28, 1, "java.awt.Point");
		int id29 = SchemaModelingRepository.createMethod("setText", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id29, 1, "java.lang.String");
		int id30 = SchemaModelingRepository.createMethod("setExtend", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id30, 1, "int");
		SchemaModelingRepository.createMethod("draw", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethod("getGeneralisationExtend", "uk.ac.ic.doc.automed.gui.SchemaManager");
		SchemaModelingRepository.createMethod("getGenEdgePosition", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethod("getGeneralConstruct", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		SchemaModelingRepository.createMethod("getSpecialConstructs", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		SchemaModelingRepository.createMethod("getSpecEdgePosition", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethod("getReferencedConstructs", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		int id38 = SchemaModelingRepository.createMethod("getEntityEdgePosition", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id38, 1, "java.awt.Point");
		int id39 = SchemaModelingRepository.createMethod("getEdgePosition", "uk.ac.ic.doc.automed.gui.Rhombus");
		SchemaModelingRepository.createMethodArgument(id39, 1, "java.awt.Point");

		int isPrimaryKeyForeignKey = SchemaModelingRepository.createMethod("isPrimaryKeyForeignKey", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
	
		int getExtend = SchemaModelingRepository.createMethod("getExtend", "uk.ac.ic.doc.automed.gui.SchemaManager");
		SchemaModelingRepository.createMethodArgument(getExtend, 1, "boolean"); 
		
		int getTableWithForeignKey = SchemaModelingRepository.createMethod("getTableWithForeignKey", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		
		int getTableForeignKeyPoints = SchemaModelingRepository.createMethod("getTableForeignKeyPoints", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		
		int getReferencedTable = SchemaModelingRepository.createMethod("getReferencedTable", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		
		int getReferencedField = SchemaModelingRepository.createMethod("getReferencedField", "uk.ac.ic.doc.automed.gui.GraphicSchemaObject");
		
		int setTextLine = SchemaModelingRepository.createMethod("setText", "uk.ac.ic.doc.automed.gui.Line");
		SchemaModelingRepository.createMethodArgument(setTextLine, 1, "java.lang.String");
	}

	public static void main(String[] args)
	{
		try{
			System.out.println("Defining graphical representation API...");	
			DefineGraphicalRepresentationAPI.createSMRAPI();
		}
		catch(Exception e){
			e.printStackTrace();
		}
	}
}
