Page tree

Overview

This page documents the use of admin tools to generate sample data.

Prerequisites

  • MySQL database must already exist (e.g. "refset").  
  • MySQL database connection parameters must be defined in the properties file specified by "refset.config".
  • The file system directory specified by the "hibernate.search.default.indexBase" in the properties file specified by refset.config must exist.
  • IMPORTANT: The Tomcat server must not be running while this is invoked, otherwise indexes can get corrupted.

Details

This tool is used to generate sample data.  It can be used after Create Database and Reindex Objects are independently run, or can be run with a "mode" parameter that causes those steps to be automatically run.  This tool is an easy way to refresh the database with contents that can be used for testing.

Following are some details about the implementation of this tool:

Mojo: GenerateSampleData.java (in admin/src/main/resources/java/org/ihtsdo/otf/refset/mojo)
Project: admin
Configuration Parameters

  • Profile "Sample"
  • refset.config - the standard configuration file specified as a -D parameter
  • mode - "create" will destroy the database and indexes and recreate them before loading sample data.  any other value than "create" will assume those prior steps have already been run.

  • Integration tests should be run against a database loaded with this data.

There is a simlar tool run with "Sample2" as the profile that also generates sample data that looks more realistic but does not work with integration tests.

Samples

Sample command line call of the admin tool to recreate a database, clear indexes,  and load sample data:

% cd /home/ihtsdo/refset/code/admin
% mvn install -PSample -Dmode=create -Drefset.config=/home/ihtsdo/refset/config/config.properties

Troubleshooting

If running "Sample" with -Dmode=create, you may have errors due to do with a legacy table structure with indexes or foreign keys that are no longer valid.  Clear the state of the database first by either dropping and recreating the schema, or by running the contents of "admin/src/main/resources/truncate_all.sql" into your database.

 

# stop the server
% service tomcat7 stop
 
% cd /home/ihtsdo/refset/code
% mysql -u<user> -p refset < admin/src/main/resources/truncate_all.sql
  
% cd /home/ihtsdo/refset/code/admin
% mvn install -PSample -Dmode=create -Drefset.config=/home/ihtsdo/refset/config/config.properties

 

  • n/a

 

  • No labels