This application requires a database configured to reflect this data model.
The data model that holds sample tracking information is defined by attributes and relations shown in the following ER diagram.
For API version 2 the service uses the following API classes:
For the deprecated API version 1, different API classes are used.
The information provided by those classes might be outdated or not informative.
The only valid information is contained in the Location
object. Here the status
and the arrivalTime
represent the current status
and statusValidSince
information.
Location
and Person
information of any form are discarded from API version 2 on.
To build, package and run the sample-tracking service, the service needs configuration. For more details on configuration, see the configuration section.
Checkout the latest code from master
and run the maven goal mvn clean jetty:run
starting the application on your machine.
Alternatively you can package the application and run it as .jar
. First compile the project and
build an executable java archive:
mvn clean package
The JAR file will be created in the /target
folder:
|-target
|---sampletracking-2.0.0-jar-with-dependencies.jar
|---...
Now change into the folder and run the sample tracking service with:
java -jar sampletracking-2.0.0-jar-with-dependencies.jar
The default configuration of the app binds to the local port 8080 to the systems localhost:
http://localhost:8080
If you want to change the server port, let's say 8085
, you can configure it by setting the
server.port
property explicitly:
java -jar -Dserver.port=8085 sampletracking-1.0.0-jar-with-dependencies.jar
For the application to use the database the following information is read from environment variables:
environment variable | description |
---|---|
TR_DB_HOST |
The sample tracking database host address |
TR_DB_USER |
The sample tracking database user |
TR_DB_PWD |
The sample tracking database user |
TR_DB_NAME |
The sample tracking database name |
SERVICES_LOG_PATH |
The path to the folder in which the log file is located. |
A user-role definition is needed. By default, a file is expected at /etc/micronaut.d/userroles.yml
. The file follows YAML format specification and can look like this:
---
servicereader:
token: 123! // replace with your token
roles:
- READER
servicewriter:
token: 123456! // replace with your token
roles:
- READER
- WRITER
...
The Response codes in the sample-tracking API follow the REST API status code terminology:
RESPONSE CODE | TEXT | Purpose |
---|---|---|
200 | OK | For successful GET and PUT requests. |
201 | Created | The request has created a new resource |
400 | Bad Request | Issued when a malformed request was sent. |
401 | Unauthorized | Sent when the client provided invalid credentials |
404 | Not Found | The accessed resource doesn't exist or couldn't be found. |
500 | Internal Server Error | When an error has occurred within the API. |
The endpoints formatting follows the OpenAPI Specifications
Gets the current sample status. The response provides information from since when the current status is valid.
/v2/samples/{sampleCode}/status:
get:
summary: "GET samples/{sampleId}/status"
parameters:
- name: "sampleCode"
in: "path"
responses:
"200":
description: "OK"
/v2/samples/QABCD001A0/status
{
"status": "METADATA_REGISTERED",
"statusValidSince": "2022-07-27T00:00:01.352Z",
"sampleCode": "QABCD001A0"
}
Sets the current status of a sample. The response provides information from since when the current status is valid.
/v2/samples/{sampleCode}/status:
put:
summary: "PUT /v2/samples/{sampleCode}/status"
parameters:
- name: "sampleCode"
in: "path"
responses:
"200":
description: "OK"
PUT /v2/samples/QABCD001A0/status
{
"status": "METADATA_REGISTERED",
"validSince": "2022-07-27T00:00:01.352Z"
}
Gets the current sample statuses of samples matching the project. The response provides information from since when the current status is valid.
/v2/projects/{projectCode}/status:
get:
summary: "GET v2/projects/{projectCode}/status"
parameters:
- name: "projectCode"
in: "path"
required: true
responses:
"200":
description: "OK"
/v2/projects/QSTTS/status
[
{
"sampleCode": "QSTTS020A1",
"status": "SAMPLE_QC_PASS",
"statusValidSince": "2022-07-29T12:32:32.432Z"
},
{
"sampleCode": "QSTTS022AH",
"status": "SAMPLE_QC_PASS",
"statusValidSince": "2022-07-29T12:32:32.432Z"
}
]
Gets the sample information including current and past locations for a specific sample ID in JSON format
/samples/{sampleId}:
get:
summary: "GET samples/{sampleId}"
parameters:
- name: "sampleId"
in: "path"
responses:
"200":
description: "OK"
/sample/QMUJW064AW
{
"code": "QMUJW064AW",
"current_location": {
"name": "QBiC",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "QBiC",
"street": "Auf der Morgenstelle 10",
"zip_code": 72076,
"country": "Germany"
},
"sample_status": "METADATA_REGISTERED",
"arrival_date": "2019-12-03T10:32Z"
}
}
Updates the status set in the current location of the provided sampleId with the provided sample status.
/samples/{sampleId}/currentLocation/{status}:
put:
summary: "PUT samples/{sampleId}/currentLocation/{status}"
parameters:
- name: "sampleId"
in: "path"
- name: "status"
in: "path"
responses:
"201":
description: "OK"
/samples/QMUJW064AW/currentLocation/data_available/
Response code: 201 (Sample status updated to DATA_AVAILABLE.)
Gets the location information for a given user id in JSON Format:
/locations/{user_id}:
get:
summary: "GET locations/{user_id}"
parameters:
- name: "user_id"
in: "path"
responses:
"200":
description: "OK"
/locations/[email protected]
[
{
"name": "QBiC",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "QBiC",
"street": "Auf der Morgenstelle 10",
"zip_code": 72076,
"country": "Germany"
}
},
{
"name": "Awesome Partner Lab",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "Partner Labs",
"street": "Example Street 5",
"zip_code": 12345,
"country": "ImaginationLand"
}
},
{
"name": "Splendid Facility",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "Partner Facilities",
"street": "Example Lane 10",
"zip_code": 12345,
"country": "ImaginationLand"
}
}
]
Updates the current location of a provided sampleId with the provided location information.
/samples/{sampleId}/currentLocation/:
post:
summary: "POST samples/{sampleId}/currentLocation/"
parameters:
- name: "sampleId"
in: "path"
responses:
"200":
description: "OK"
/samples/QMUJW064AW/currentLocation/
Additionally, the location information has to be provided in the JSON Format:
{
"name":"Example Location Name",
"responsible_person":"Max Mustermann",
"responsible_person_email":"[email protected]",
"address":{
"affiliation":"QBiC",
"street":"Auf der Morgenstelle 6",
"zip_code":72076,
"country":"Germany"
},
"sample_status":"WAITING",
"arrival_date":"2021-12-07T09:38Z",
"forward_date":"2021-12-07T09:38Z"
}
NOTE: The provided location information should be stripped of all newlines("\n"), otherwise it can't be interpreted by the sample-tracking-service
The sample-tracking-service will return the set location information:
{
"name":"Example Location Name",
"responsible_person":"Max Mustermann",
"responsible_person_email":"[email protected]",
"address":{
"affiliation":"QBiC",
"street":"Auf der Morgenstelle 6",
"zip_code":72076,
"country":"Germany"
},
"sample_status":"WAITING",
"arrival_date":"2021-12-07T09:38Z",
"forward_date":"2021-12-07T09:38Z"
}
Gets all the location to users linked information in JSON format
/locations/:
get:
summary: "GET locations/"
responses:
"200":
description: "OK"
/locations/
[
{
"name": "QBiC",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "QBiC",
"street": "Auf der Morgenstelle 10",
"zip_code": 72076,
"country": "Germany"
}
},
{
"name": "Awesome Partner Lab",
"responsible_person": "John Doe",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "Partner Labs",
"street": "Example Street 5",
"zip_code": 12345,
"country": "ImaginationLand"
}
},
{
"name": "QBiC",
"responsible_person": "Erika Musterfrau",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "QBiC",
"street": "Auf der Morgenstelle 10",
"zip_code": 72076,
"country": "Germany"
}
},
{
"name": "Splendid Facility",
"responsible_person": "Erika Musterfrau",
"responsible_person_email": "[email protected]",
"address": {
"affiliation": "Partner Facilities",
"street": "Example Lane 10",
"zip_code": 12345,
"country": "ImaginationLand"
}
},
}]
NOTE: This method is deprecated and will be removed in future versions
Gets the linked affiliation and person information for an email address in JSON Format:
/locations/contacts/{email}:
get:
summary: "GET locations/contacts/{email}"
deprecated: true
parameters:
- name: "email"
in: "path"
responses:
"200":
description: "OK"
/locations/contacts/[email protected]
{
"full_name": "John Doe",
"address": {
"affiliation": "QBiC",
"street": "Auf der Morgenstelle 10",
"zip_code": 72076,
"country": "Germany"
},
"email": "[email protected]"
}
This work is licensed under the MIT license.
Note: This work uses the Miconaut Framework which is licensed under Apache 2.0.