Skip to content

Commit

Permalink
Release 1.1.0
Browse files Browse the repository at this point in the history
<!-- Release notes generated using configuration in .github/release.yml at development -->

## What's Changed
### New Features 🚀
* remove queries to user database, use user from known locations by @wow-such-code in #20
* Allow for property name adjustment in the LIMS by @KochTobi in #21
### Bugfixes 🪲
* update workflows by @wow-such-code in #19
* Ignore sequencing completed status. by @KochTobi in #22

## New Contributors
* @JohnnyQ5 made their first contribution in #18
* @wow-such-code made their first contribution in #19

**Full Changelog**: 1.0.2...1.1.0
  • Loading branch information
KochTobi authored Jul 20, 2022
2 parents 48b2044 + ad3fd9c commit 8c791fe
Show file tree
Hide file tree
Showing 18 changed files with 328 additions and 463 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

This project adheres to [Semantic Versioning](https://semver.org/).

For releases after 1.0.0 please refer to [GitHub Releases](https://github.com/qbicsoftware/sample-status-reporter/releases)

## 1.0.0 (2022-01-28)

* Add first working implementation to report updates based on a point in time.
* The application fails when any problems arise retrieving samples


52 changes: 26 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<div align="center">

# LIMS Sample Status Reporter
<i>A command line tool to report LIMS changes to the sample-tracking service</i>.


<i>A command line tool to report LIMS changes to the sample-tracking service</i>.

[![Build Maven Package](https://github.com/qbicsoftware/sample-status-reporter/actions/workflows/build_package.yml/badge.svg)](https://github.com/qbicsoftware/sample-status-reporter/actions/workflows/build_package.yml)
[![Run Maven Tests](https://github.com/qbicsoftware/sample-status-reporter/actions/workflows/run_tests.yml/badge.svg)](https://github.com/qbicsoftware/sample-status-reporter/actions/workflows/run_tests.yml)
Expand All @@ -20,7 +19,7 @@

As updating sample statuses in more then one place can lead to errors and frustration, automation of
this process is deemed important. The `sample-status-reporter` automates the migration of updated
sample statuses from an openBis LIMS to the
sample statuses from an openBis LIMS to the
[sample-tracking-service](https://github.com/qbicsoftware/sample-tracking-service).

**Interaction with the sample-tracking-service**
Expand All @@ -37,12 +36,13 @@ entry for further detail.
**Integration with the openBIS LIMS**

The sample information is retrieved automatically from an openBIS instance acting as LIMS. The
configuration of the openBIS needs to make sure each sample proviedes the following properties:
configuration of the openBIS needs to make sure each sample provides a QBiC barcode (containing `Q`) and a sample status.
Furthermore, the names of the properties providing this information needs to be provided (see [Environment Variables](#environment-variables)).

* `QBIC_BARCODE` containing `Q`
* `SAMPLE_STATUS` containing values
from `[SAMPLE_RECEIVED, QC_PASSED, QC_FAILED, LIBRARY_PREP_FINISHED]`.
* The sample status may contain values
from `["Sample received", "QC passed", "QC failed", "Library completed"]`.

Besides that you can configure LIMS statuses this tools will ignore. For this pass a comma-separated list in the `LIMS_IGNORED_STATUSES` environment variable.
This tool acts in the role of a user configured by you. Please make sure, that the configured user
only sees projects where you want to propagate the status to the sample-tracking system.

Expand Down Expand Up @@ -97,22 +97,22 @@ Please note that this project requires `java 17`.
For this application to be run the following environment variables need to be set:
| Environment Variable | Description | Default Value |
|-------------------------------------|------------------------------------------------------------------------|----------------------------------------|
| `LAST_UPDATE_FILE` | A path to a persistent file. The last successful run is stored here. | `last-updated.txt ` |
| `LIMS_PASSWORD` | The password to access the OpenBiS LIMS | |
| `LIMS_SERVER_URL` | The URL to the OpenBiS LIMS API | |
| `LIMS_USER` | The user to access the OpenBiS LIMS | |
| `SAMPLE_TRACKING_AUTH_PASSWORD` | The password for the sample tracking user | `astrongpassphrase! ` |
| `SAMPLE_TRACKING_AUTH_USER` | The username for the sample tracking service | `qbic` |
| `SAMPLE_TRACKING_LOCATION_ENDPOINT` | The endpoint to list all locations. This does not contain the base url | `/locations` |
| `SAMPLE_TRACKING_LOCATION_USER` | The sample tracking user currently using the application | `[email protected]` |
| `SAMPLE_TRACKING_URL` | The base URL for the sample tracking service | `http://localhost.de` |
| `USER_DB_DIALECT` | The database dialect of the user database | `org.hibernate.dialect.MariaDBDialect` |
| `USER_DB_DRIVER` | The database driver for the user database | `com.mysql.cj.jdbc.Driver` |
| `USER_DB_HOST` | The URL to the host of the user database containing the database name | `localhost` |
| `USER_DB_USER_NAME` | The database user name | `myusername` |
| `USER_DB_USER_PW` | The database user password | ` astrongpassphrase!` |
| Environment Variable | Description | Default Value |
|-------------------------------------|-----------------------------------------------------------------------------------------------|----------------------------------------|
| `LAST_UPDATE_FILE` | A path to a persistent file. The last successful run is stored here. | `last-updated.txt ` |
| `LIMS_PASSWORD` | The password to access the OpenBiS LIMS | |
| `LIMS_SERVER_URL` | The URL to the OpenBiS LIMS API | |
| `LIMS_USER` | The user to access the OpenBiS LIMS | |
| `LIMS_BARCODE_PROPERTY` | The name of the property in the OpenBiS LIMS from which to read the QBiC barcode | |
| `LIMS_STATUS_PROPERTY` | The name of the property in the OpenBis LIMS from which to read the sample status information | |
| `LIMS_IGNORED_STATUSES` | A comma-separated list of LIMS sample statuses to be ignored by the reporter | |
| `SAMPLE_TRACKING_AUTH_PASSWORD` | The password for the sample tracking user | `astrongpassphrase! ` |
| `SAMPLE_TRACKING_AUTH_USER` | The username for the sample tracking service | `qbic` |
| `SAMPLE_TRACKING_LOCATION_ENDPOINT` | The endpoint to list all locations. This does not contain the base url | `/locations` |
| `SAMPLE_TRACKING_LOCATION_USER` | The sample tracking user currently using the application | `[email protected]` |
| `SAMPLE_TRACKING_URL` | The base URL for the sample tracking service | `http://localhost.de` |
| `USER_DB_DIALECT` | The database dialect of the user database | `org.hibernate.dialect.MariaDBDialect` |
| `USER_DB_DRIVER` | The database driver for the user database | `com.mysql.cj.jdbc.Driver` |
| `USER_DB_HOST` | The URL to the host of the user database containing the database name | `localhost` |
| `USER_DB_USER_NAME` | The database user name | `myusername` |
| `USER_DB_USER_PW` | The database user password | ` astrongpassphrase!` |
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,21 @@ import java.time.Instant
@Component
class QbicSampleStatusReporter implements SampleStatusReporter {

@Autowired
private SampleTrackingService sampleTrackingService
@Autowired
private SampleTrackingService sampleTrackingService

@Autowired
private LocationService locationService
@Autowired
private LocationService locationService

@Override
void reportSampleStatusUpdate(SampleUpdate sampleUpdate) {
Location currentLocation = locationService.getUpdatingPersonLocation().orElseThrow({
new RuntimeException("No current location could be determined for the provided user.")
})
String sampleCode = sampleUpdate.getSample().getSampleCode()
String status = sampleUpdate.getUpdatedStatus()
Instant updateTimepoint = sampleUpdate.getModificationDate()
sampleTrackingService.updateSampleLocation(sampleCode, currentLocation, status, updateTimepoint)
}

@Override
void reportSampleStatusUpdate(SampleUpdate sampleUpdate) {
Location currentLocation = locationService.getCurrentLocation().orElseThrow({
new RuntimeException("No current location could be determined.")
})
String sampleCode = sampleUpdate.getSample().getSampleCode()
String status = sampleUpdate.getUpdatedStatus()
Instant updateTimepoint = sampleUpdate.getModificationDate()
Person responsiblePerson = locationService.getResponsiblePerson().orElseThrow({
new RuntimeException("No responsible person for the update was determined.")
})
sampleTrackingService.updateSampleLocation(sampleCode, currentLocation, status, updateTimepoint, responsiblePerson)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ package life.qbic.samplestatus.reporter.api
* @since 1.0.0
*/
interface LocationService {
/**
* <p>Returns an {@link Optional} of the current location the LIMS is configured for. <b>Must</b> return an
* object of type {@link Optional#empty} if no matching location was found.</p>
*
* @return an {@link Optional} wrapping a matching current {@link Location} or empty, if none was found.
* @throws ServiceException in case the service cannot retrieve the location due to for example connection issues.
* Must not be thrown, if the internal query was successful but no matching location was found. Instead, return an {@link Optional#empty}.
* @since 1.0.0
*/
Optional<Location> getCurrentLocation() throws ServiceException

Optional<Person> getResponsiblePerson() throws ServiceException
/**
* <p>Returns an {@link Optional} of the location the LIMS is configured for, determined by the user. <b>Must</b> return an
* object of type {@link Optional#empty} if no matching location was found.</p>
*
* @return an {@link Optional} wrapping a matching current {@link Location} or empty, if none was found.
* @throws ServiceException in case the service cannot retrieve the location due to for example connection issues.
* Must not be thrown, if the internal query was successful but no matching location was found. Instead, return an {@link Optional#empty}.
* @since 0.1.0
*/
Optional<Location> getUpdatingPersonLocation()

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,24 @@ import java.time.Instant
*/
interface SampleTrackingService {

/**
* Retrieves the location associated with the userId provided.
* @param userId an identifier for a user in the sample tracking system
* @return the location that this user is associated with
* @since 1.0.0
*/
Optional<Location> getLocationForUser(String userId)
/**
* Retrieves the location associated with the userId provided.
* @param userId an identifier for a user in the sample tracking system
* @return the location that this user is associated with
* @since 1.0.0
*/
Optional<Location> getLocationForUser(String userId)

/**
* Updates a sample to a given location with a status set in the location.
* This information is stored on the persistence layer.
* @param sampleCode the code of the sample changing status or location
* @param location the new location with a sample status already set
* @param status sample status to be set
* @param timestamp time of the update
* @throws SampleUpdateException in case the sample update was unsuccessful
* @since 1.0.0
*/
void updateSampleLocation(String sampleCode, Location location, String status, Instant timestamp) throws SampleUpdateException

/**
* Updates a sample to a given location with a status set in the location.
* This information is stored on the persistence layer.
* @param sampleCode the code of the sample changing status or location
* @param location the new location with a sample status already set
* @param status sample status to be set.
* @param timestamp the point in time that will be recorded as time of this update
* @param responsiblePerson the person responsible for this update
* @throws SampleUpdateException in case the sample update was unsuccessful
* @since 1.0.0
*/
void updateSampleLocation(String sampleCode, Location location, String status, Instant timestamp, Person responsiblePerson) throws SampleUpdateException
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class ReportSinceInstant implements Runnable {
updatedSamples.stream()
.filter(Result::isOk)
.map(Result::getValue)
.sorted((SampleUpdate su1, SampleUpdate su2) -> su1.getModificationDate().compareTo(su2.getModificationDate()))
.peek(it -> log.info("\tUpdating $it"))
.forEach(statusReporter::reportSampleStatusUpdate)
log.info("Finished processing.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ class LastUpdateSearch implements UpdateSearchService {
}

/**
* @inheritDocs
* {@inheritDoc}
* @return {@inheritDoc}
*/
@Override
Optional<Instant> getLastUpdateSearchTimePoint() {
return Optional.ofNullable(this.lastSearch)
}

/**
* @inheritDocs
* {@inheritDoc}
* @param lastSearchTimePoint {@inheritDoc}
*/
@Override
void saveLastSearchTimePoint(Instant lastSearchTimePoint) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import life.qbic.samplestatus.reporter.api.Location
import life.qbic.samplestatus.reporter.api.LocationService
import life.qbic.samplestatus.reporter.api.Person
import life.qbic.samplestatus.reporter.api.SampleTrackingService
import life.qbic.samplestatus.reporter.services.users.UserService
import life.qbic.samplestatus.reporter.api.ServiceException
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.boot.context.properties.ConfigurationProperties
Expand All @@ -21,23 +21,15 @@ import org.springframework.stereotype.Component
@ConfigurationProperties
class NcctLocationService implements LocationService {

@Value('${service.sampletracking.location.user}')
private String userId
@Value('${service.sampletracking.location.user}')
private String userId

@Autowired
private SampleTrackingService sampleTrackingService
@Autowired
private SampleTrackingService sampleTrackingService

@Autowired
private UserService userService
@Override
Optional<Location> getUpdatingPersonLocation() throws ServiceException {
return sampleTrackingService.getLocationForUser(userId)
}

@Override
Optional<Location> getCurrentLocation() {
return sampleTrackingService.getLocationForUser(userId)
}

@Override
Optional<Person> getResponsiblePerson() {
Optional<Person> responsiblePerson = userService.getPerson(userId)
return responsiblePerson
}
}
Loading

0 comments on commit 8c791fe

Please sign in to comment.