Skip to content

development environment

Nelson Loyola edited this page Feb 26, 2019 · 10 revisions

WikiDevelopment Environment

Biobank development environment

Follow these instructions to setup a Linux computer to be used for building or developing software for Biobank.

Install required software

  1. Using the Ubuntu package manager install the required packages.

    sudo apt-get install ant git-core gettext zip unzip
  2. Follow these instructions to install the Java Standard Edition 6 Development Kit.

  3. Download Tomcat 8.5.30 from https://tomcat.apache.org/download-80.cgi.

    For security reasons, it is better to run Tomcat as a non root user and take other precautions given here: Tomcat.

  4. Download Eclipse for RCP and RAP Developers from this page. Make sure you download the 64-bit version if you are running 64-bit Ubuntu.

    Extract the file to your Eclipse Home directory. For example, if my Eclipse Home directory is /opt/eclipse, then use the following commands (this must be done using the root account):

    mkdir /opt/eclipse
    cd /opt/eclipse
    mv eclipse-rcp-indigo-SR2-linux-gtk-x86_64.tar.gz .
    tar zxvf eclipse-rcp-indigo-SR2-linux-gtk-x86_64.tar.gz

    This results in having the directory /opt/eclipse/eclipse.

  5. Download the Eclipse Delta Pack from this page and copy the file to your eclipse subdirectory in your Eclipse Home directory. From that directory extract the files (this must be done using the root account). For example:

    cp eclipse-3.7.2-delta-pack.zip /opt/eclipse/eclipse
    cd /opt/eclipse/eclipse
    unzip eclipse-3.7.2-delta-pack.zip

    The delta pack is required to build the client for the other operating systems. The delta pack version must match the version of Eclipse being used.

  6. Create a bash profile file to define enviroment variables. Create the file /opt/tomcat/.bash_profile and add the following lines:

    export CATALINA_HOME=/opt/tomcat/apache-tomcat-8.5.30
    export JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
    export JAVA_TOOL_OPTIONS=-Dhttps.protocols=TLSv1.2
    export ECLIPSE_HOME=/opt/eclipse/eclipse
    
  7. Retrieve the Biobank source code from the GitHub repository to your Biobank Source Code Home directory. It is recommended to use /opt/tomcat/build/biobank. Use the following commands starting with a shell logged into the root account.

    su - tomcat
    cd /opt/tomcat
    mkdir build
    cd build
    git clone https://github.com/cbsrbiobank/biobank.git
    cd biobank
    git submodule init
    git checkout TAG
    git submodule update

    Replace TAG with the tag name for the version you want to build. To see a list of all tags use the command:

    git tag

Eclipse setup

  1. Configure your database settings.

    ant init

    Now edit the file named db.properties at the project's root directory and fill in with your settings.

  2. Download the project dependencies.

    At the project's root directory use the following command:

    ant deploy-eclipse

    All the required libraries are copied to the Eclipse projects.

  3. Open Eclipse with the workspace pointing at the eclipse_ws directory. From the command line you can use the following command:

    <path_to_eclipse>/eclipse -data /opt/tomcat/build/biobank/eclipse_ws &
  4. From Eclipse, import the projects into the workspace: File -> Import -> General -> Existing Projects into Workspace.

  5. From the Package Explorer pane and expand the biobank2 project, and double click the plugin.xml file under it. On the right hand side of the form that pops up click on the Launch and Eclipse application link under the Testing heading.

  6. From the main menu select Run -> Debug configurations and then select the Arguments tab on the right hand side of the dialog box. Add --debug to Program arguments. Then select the Plug-ins tab and do the following:

    1. Press the Deselect All button.
    2. Select features selected below.
    3. Select biobank2.feature.core and biobank2.feature.platform.
    4. Press the Select required button.

    Now press the Debug button to launch the Biobank client in Debug mode.

  7. Optional: remove needless warnings about Non-extenalize strings (NON-NLS).

    For project biobank2.tests and biobank2.tools do the following:

    1. right click on the project in the Package Explorer pane and select Properties.
    2. From the left pane in the dialog box select: Java Compiler -> Errors/Warnings.
    3. Click Enable project specific settings to turn this setting on.
    4. Set Non-extenalize strings (missing/unused $NON-NLS$ tag) to Ignore.
    5. Click the Apply, followed by the Yes button on the dialog box that pops up.
    6. Press the OK button.

You may run into the following problems / issues:

  • Eclipse does not have the Java 1.6 JRE.

    1. From the main menu select: Window -> Preferences.
    2. From the left pane in the dialog box select: Java -> Installed JREs.
    3. Press the Add button and add the path to your Java 1.6 JDK.
  • Errors due to workspace compliance.

    1. From the main menu select: Window -> Preferences.
    2. From the left pane in the dialog box select: Java -> Compiler.
    3. Look for Compiler compliance level and select 1.6.

Creating an empty database

  1. Ensure the database seetings in db.properties (at the project root) are valid.

  2. Initialize the database: ant dbcreate.

    Alternatively, to create the database with a user that can log in, use the command ant -Ddebug=true dbcreate. This creates the user with user name testuser and password test.

  3. Initialize the database migration tables:

    ant flyway-init -Dflyway.initialVersion=1.6 -Dflyway.initialDescription="biobank v3100"
    

    This command initialize the database to the Biobank version 3.10.0 schema.

  4. Optional: save a dump of the empty database to a file for later use,

    mysqldump --login-path=local biobank | gzip > biobank_empty.sql.gz
    

Running tests

Before running tests, the database must be emptied: see Creating an empty database.

In Eclipse

To run the tests suite in Eclipse:

  1. Open the AllTestsSuite.java file by pressing Ctrl-Shift T (open type).

  2. Right click on the class name, AllTestSUite, and select Run As -> JUnit Test from the context menu that opens up.

Command Line

  • To run the tests from the command line use the following command at the project's root directory:

    ant test

    The report is written to <project_root>/testing/html/junit-noframes.html.

  • To run the tests, with code coverage, from the command line use the following command at the project's root directory:

    ant test-emma

    The report is written to <project_root>/coverage/index.html.

Test configuration

This configuration allows for testing and demos. The following are created:

  • One clinic, named Clinic1 with one contact.

  • The following studies: Study1 and Study2. Both assigned the contact from Clinic1.

  • Multiple patients are created which have one collection event and one source specimen.

  • Two sites: Site1 and Site2.

To create this confuration, follow these steps:

  1. The database must be emptied: see Creating an empty database.

  2. Add the test user to the database (if testuser does not yet exist):

    ant -Ddebug=true dbcreate-add-testuser
  3. Create the confiruation with this command:

    ant test-config-create
  4. Optional: a configuration that can link grandchild specimens can be created with the following command:

    ant -Dgrandchild=true test-config-create

    Grandchild specimens have two parents: the aliquot they came from and the source specimen.