import java.util.*; import java.io.*; import java.sql.*; import edu.neu.ccs.demeter.dj.*; /******************************************************************************/ /* The class dictionary file has 3 sections: */ /* Section 1 includes all the common classes necessary for implementing */ /* the functionality. This part is static and should not have */ /* to be changed. */ /* Section 2 defines the DBMS vendors and the formats of SQL statements; */ /* this part has to be changed whenever a new vendor is added. */ /* Section 3 describes the database tables and their columns; this part */ /* has to be changed whenever a table definition is modified or */ /* added. */ /******************************************************************************/ /******************************************************************************/ /* SECTION 1: Common classes. */ /******************************************************************************/ // Structure of the input request Request = "" ConnectionParameters Input "". ConnectionParameters = "" Vendor Url Userid Password "". Vendor = String. Url = String. Userid = String. Password = String. Input : Query | Insert. Query = "" List(TargetData) [Condition] [Order] [ShowHierarchy] "". TargetData = TableName List(ColumnSpec). TableName = "" String "
". ColumnSpec = "" String ":" Ident "". Condition = "" String "". Order = "" List(OrderItem) "". OrderItem = [OrderTable] OrderColumn. OrderTable = "" String "
". OrderColumn = "" String "". ShowHierarchy = "" "" [ParentTable] ParentColumn "" "" [ChildTable] ChildColumn "" RelationColumn "". ParentTable = "" String "
". ParentColumn = "" String "". ChildTable = "" String "
". ChildColumn = "" String "". RelationColumn = "" String "". Insert = "" TableName List(ColumnValue) "". ColumnValue = ColumnSpec InsertValue. InsertValue = "" String "". List(S) ~ S {S}. // Visitors defined in the application RequestProcessingVisitor = extends Visitor. ResultPrintVisitor = extends Visitor. // Container classes used for grouping data items ConnectionArgs = . EntityStructure = . HierarchyArgs = . // The "main" class XMLandDB = . // Accessory classes DataManager = . Utils = . // Class containing the final object structure created after retrieving data Resultset = List(DBEntity). /******************************************************************************/ /* SECTION 2: SQL statement format definitions for DBMS vendors. */ /******************************************************************************/ // List all vendor format names as subclasses of VendorFormat VendorFormat : generic_Format | myDBMS_Format. // List all DBMS drivers for vendors as subclasses of VendorDriver VendorDriver : generic_Driver | myDBMS_Driver. // All vendor format specification must follow the naming convention as // illustrated by the pre-defined "generic" format, and they must also consist // of the same parts (format, columnList, tableList, etc.). The constant // string literals and the order of the parts can be different. generic_Driver = "sun.jdbc.odbc.JdbcOdbcDriver". generic_Format = generic_StmtFormat. generic_StmtFormat : generic_SelectFormat | generic_InsertFormat. generic_SelectFormat = "select" Ident *l "from" Ident *l ["where" Ident *l] ["order by" Ident]. generic_InsertFormat = "insert into" Ident " (" Ident ")" *l " values (" Ident ")". myDBMS_Driver = "my.driver". myDBMS_Format = myDBMS_StmtFormat. myDBMS_StmtFormat : myDBMS_SelectFormat | myDBMS_InsertFormat. myDBMS_SelectFormat = "SELECT" Ident *l "FROM" Ident *l ["WHERE" Ident *l] ["ORDER BY" Ident]. myDBMS_InsertFormat = "INSERT INTO"
Ident " (" Ident ")" *l " VALUES (" Ident ")". /******************************************************************************/ /* SECTION 3: Database table definitions. */ /******************************************************************************/ // Maintain all lists sorted alphabetically for quick manual lookup; the program // itself doesn't require any specific order // List all tables as subclasses of DBEntity DBEntity : department | employee. // List all distinct column names as subclasses of DBAttr DBAttr : dept_id | dept_name | emp_id | emp_name | mgr_id | salary common String. // List all virtual columns (to be used for creating hierarchies of objects) as // subclasses of DBVirtualAttr // These columns do not actually exist in the database but are used to specify // relationships between entities. DBVirtualAttr : employees | manages common List(DBEntity) ".". // Specify the columns for each table - each column should be defined as an // optional part unless it is going to be included in all queries to the owner // table; the virtual columns must also be included here department = "department" [dept_id] [dept_name] [employees]. employee = "employee" [emp_id] [emp_name] [dept_id] [mgr_id] [salary] [manages]. // List the columns (including virtual ones) - specify columns with the same // name (obviously belonging to different tables) only once dept_id = "dept_id". dept_name = "dept_name". emp_id = "emp_id". emp_name = "emp_name". employees = "employees". manages = "manages". mgr_id = "mgr_id". salary = "salary".