RAMADDA Data Tables
RAMADDA Data Tables
The data tables facility allow you to define a structured data base table via an XML definition in a RAMADDA plugin. The RAMADDA database facility looks for any file that ends with "db.xml", e.g., testdb.xml in the plugins directory. There are lots of examples on Github

Each database table is defined with a table tag. You need to specify a unique id and a name. Contained in the table tag are a set of column definitions. Each column has a name which ends up being the database column name so this should be legal sql. There is also a label and some flags, e.g. cansearch, canlist, that determine whether the column is shown in the list and in the search form.

The column also has a type, e.g.:


If its an enumeration then you also have to specify a column separated list of values. See the prioriity example below. The enumerationplus type allows the user to enter their own value and/or use values that have already been created. If its a string or a clob then you also need to specify a size (byte size)

Here is a tasks data table -

<table id="tasks" name="Tasks" icon="/db/tasks.gif">
   <column name="title" type="string" label="Title" cansearch="true"   canlist="true" required="true"/>
   <column name="priority" type="enumeration" label="Priority" values="High,Medium,Low" cansearch="true"   canlist="true"/>
   <column name="status" type="enumeration" label="Status" values="Not Started,In Progress,Completed,Deferred,Waiting" cansearch="true"   canlist="true">
       <property name="iscategory" value="true"/>

   <column name="complete" type="percentage" label="% Complete" cansearch="true"   canlist="true"/>
   <column name="assignedto" type="enumerationplus" values="" label="Assigned To" cansearch="true"   canlist="true">
       <property name="iscategory" value="true"/>
   <column name="description" type="string" label="Description"  canlist="false" rows="5" columns="40" size="10000" />
   <column name="startdate" type="date" label="Start Date" cansearch="true"   canlist="true"/>
   <column name="enddate" type="date" label="End Date" cansearch="true"   canlist="true"/>

Column tags can also contain property tags If a column tag has a property tag iscategory then the categorical views are shown, e.g.:
<column ...>
     <property name="iscategory" value="true"/>

If a column has a "label=true" property, e.g.:
      <property name="label" value="true"/>
then that column value is used as the label for the entry

You can define additional display templates. These show up in the "View As" menu in the search form. Templates are specified within the table tag with a template tag. There can be any number of templates. A template is defined with an id, name and (optional) mimetype. You can define optional prefix and suffix. The main part of the template is define with the contents tag. This holds macros with the names of the table columns.

<table  id="airplane_crashes"  name="Airplane Crashes"  icon="/db/database.png" >
<template id="t1" name="Template 1" mimetype="text">
Date: ${date}<br>
Location: ${location}<br>
Operator: ${operator}

External Databases
A separate facility in RAMADDA allows for integrating external databases into the repository. To do this an administrator needs to specify a set of property definitions in the RAMADDA home directory.

The first property is a list of the database names (can be arbitrary) that are defined. e.g. below there are 3 database names defined.

For each of the named databases there needs to be specified the JDBC url and the username/password. e.g.:
table.db.menagerie.user=db user
table.db.menagerie.password=db user password

table.db.employees.user=db user
table.db.employees.password=db password

Once the databases are define you can create an entry for a particular table in the database. Under the File->Pick a Type->Choose Entry Type select "External Database" under the "Database" category. When initially creating the entry you select which database is to be used, e.g., "employees". Once the entry is created go back and edit it. Now there will be a menu that lists all of the tables in the selected database.

Once created the External Database entry can act as a source of point data and can be used to create displays. Database table fields can be configured to be able to be used in the display filter specifications. When editing the entry add the following properties in the Properties field:
#This says that the particular field can be used in the display
request.<field name>.display=true


#This says that all fields can be used in the display

#This defined the field as an enumeration
request.<field name>.type=enumeration