Code Block | ||
---|---|---|
| ||
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
- Download the sample plugin .
- Extract the downloaded plugin zip into a folder Eg. os-sample-plugin.
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.Code Block language bash $ jar -xf os-sample-plugin.jar
- 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
- Open the file
$PLUGIN_HOME/src/main/webapp/app/i18n/en.js
- Suppose we want to change below labels
"Collection Protocols" => "Studies"
"Create Collection Protocol" => "Create Study"
- "Title" => "Study Name"
Add below JSON into opened
en.js
fileCode Block language js { "
cp": { "list":
"Studies", "
create_cp_title": "Create Study", "title": "
Study
Name" } }
- Open the file
- 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:
- 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.
- Save and exit message.properties
Create new plugin using given command:
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.Code Block language bash $jar -cf os-sample-plugin.jar META-INF/ pluginContext.xml errors/ pluginApiContext.xml pluginContext.xml
- Open the file
$PLUGIN_HOME/src/main/resources/errors/messages.properties
- Suppose we want to change below error message
"Collection Protocol with same title {0} already exists." => "Study with same title {0} already exists."
Add below property in opened
messages.properties
fileCode Block cp_dup_title=Study with same title {0} already exists.
- Open the file
- To create the plugin jar, execute the below commands from
$PLUGIN_HOME
directory :gradle clean; gradle build
- The plugin jar will get created at
${PLUGIN_HOME}/build/libs/os-messages-1.0.0.jar
- Copy create jar and paste into plugins directory
- Restart the tomcat.
Code Block | ||
---|---|---|
| ||
dp_short_title = Short Title |
Replace Short Title with Request ID.
Code Block | ||
---|---|---|
| ||
dp_short_title = Request ID |