Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Code Block
titlePrerequisite
 JRE 7 needs to installed on machine to run JAR command

...

Introduction

This document describes the steps to create a plugin to change the labels in UI and error messages shown on OpenSpecimen. This guide is intended for developers or technical IT staff.

Steps

  1. Download the sample plugin .
  2. Extract the downloaded plugin zip into a folder Eg. os-sample-plugin. 
    Code Block
    languagebash
    $ jar -xf os-sample-plugin.jar
    To change a field name appearing on UI, edit file os-sample-plugin/test/META-INF/resources/os-plugin/i18n/en.js, add previous and new name of the field which needs to be changed in the key value format. Eg. Change the field name 'Short Title' to 'Request ID' of Distribution protocol.directory. Lets say $PLUGIN_HOME to exploded directory. 
  3. Change UI labels :- We need to add key and new value of the labels into en.js file. It will override the default labels specified in OpenSpecimen. Follow below steps 
    1. Open the file $PLUGIN_HOME/src/main/webapp/app/i18n/en.js
    2. Suppose we want to change below labels
      1. "Collection Protocols" => "Studies"
      2. "Create Collection Protocol" => "Create Study"
      3. "Title" => "Study Name"
    3. Add below JSON into opened en.js file 

      Code Block
      languagejs
      {
      	"
    dp
    1. cp": {
            "list": 
    {
    1. "Studies",
            "
    short_
    1. create_cp_title": "Create Study",
            "title": "
    Request
    1. Study 
    ID
    1. Name"
        }
      }
  4. Save and exit os-sample-plugin/test/META-INF/resources/os-plugin/i18n/en.js the file.

Change the field name in the backend

To change the field name in the backend, user has to be update the message.properties file.

Follow below steps to update the message.properties file:

  1. Edit os-sample-plugin/os-plugin-jar/errors/message.properties to change the value of field in backend. Search for the field name that needs to be changed. Eg. Change the field name 'Short Title' to 'Request ID' of Distribution protocol BO template.

  1. Code Block
    languagebash
    dp_short_title = Short Title 

    Replace Short Title with Request ID.

    Code Block
    languagebash
    dp_short_title = Request ID
  2. Save and exit message.properties
  3. Create new plugin using given command:  

    Code Block
    languagebash
    $jar -cf os-sample-plugin.jar META-INF/ pluginContext.xml errors/ pluginApiContext.xml pluginContext.xml
    
    Copy the newly created plugin to $OS_HOME/plugins/  and restart OpenSpecimen service.Change server error messages :- We need to change the messages specified in messages.properties file. It will override the default messages specified in OpenSpecimen.
    1.  Open the file $PLUGIN_HOME/src/main/resources/errors/messages.properties
    2. Suppose we want to change below error message 
      1. "Collection Protocol with same title {0} already exists." => "Study with same title {0} already exists."
      2. Add below property in opened messages.properties file 

        Code Block
        cp_dup_title=Study with same title {0} already exists.


  4. To create the plugin jar, execute the below commands from $PLUGIN_HOME directory :
    gradle clean; gradle build
  5. The plugin jar will get created at ${PLUGIN_HOME}/build/libs/os-messages-1.0.0.jar
  6. Copy create jar and paste into plugins directory
  7. Restart the tomcat.