Skip to content

Commit

Permalink
Merge branch 'hotfix-1.5.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
arteymix committed Nov 22, 2022
2 parents 79c312c + 92d27c1 commit 3b6c3b1
Show file tree
Hide file tree
Showing 74 changed files with 1,684 additions and 1,568 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ src/test/resources/cache/reactome_stable_ids.txt filter=lfs diff=lfs merge=lfs -
src/test/resources/cache/nbo-base.obo filter=lfs diff=lfs merge=lfs -text
src/main/resources/cache/DIOPT_filtered_data_Sept2022.gz filter=lfs diff=lfs merge=lfs -text
src/main/resources/cache/DIOPT_filtered_data_May2021.gz filter=lfs diff=lfs merge=lfs -text
src/test/resources/cache/mondo2.obo filter=lfs diff=lfs merge=lfs -text
31 changes: 28 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
mysql56:
image: mysql:5.6
ports:
- "3306:3306"
environment:
- MYSQL_USER=springuser
- MYSQL_PASSWORD=ThePassword
- MYSQL_DATABASE=db_example
- MYSQL_RANDOM_ROOT_PASSWORD=true
mysql57:
image: mysql:5.7
ports:
- "3306:3306"
environment:
- MYSQL_USER=springuser
- MYSQL_PASSWORD=ThePassword
- MYSQL_DATABASE=db_example
- MYSQL_RANDOM_ROOT_PASSWORD=true
mysql:
image: mysql
image: mysql:8.0
ports:
- "3306:3306"
environment:
- MYSQL_USER=springuser
- MYSQL_PASSWORD=ThePassword
- MYSQL_DATABASE=db_example
- MYSQL_RANDOM_ROOT_PASSWORD=true
volumes:
- "./conf.d:/etc/mysql/conf.d:ro"
mariadb:
image: mariadb:10.6
ports:
- "3306:3306"
environment:
- MARIADB_USER=springuser
- MARIADB_PASSWORD=ThePassword
- MARIADB_DATABASE=db_example
- MARIADB_RANDOM_ROOT_PASSWORD=true
31 changes: 24 additions & 7 deletions docs/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ The content of `messages.properties` has precedence over the values stored in th
categories and terms. This allows you to override values that are imported from an OBO source as you see fit.

```properties
rdp.ontologies.{ontologyName}.title
rdp.ontologies.{ontologyName}.definition
rdp.ontologies.{ontologyName}.terms.{termName}.title
rdp.ontologies.{ontologyName}.terms.{termName}.definition
rdp.ontologies.{ontologyName}.title=
rdp.ontologies.{ontologyName}.definition=
rdp.ontologies.{ontologyName}.terms.{termName}.title=
rdp.ontologies.{ontologyName}.terms.{termName}.definition=
```

If your ontology/category is based on a [PURL](https://obofoundry.org/principles/fp-003-uris.html) source, its name will
Expand Down Expand Up @@ -520,13 +520,30 @@ In the file, each entry requires two parts: `rdp.faq.questions.<q_key>` and `rdp
question and the corresponding answer, respectively.

```properties
rdp.faq.keys=<q_key>
rdp.faq.questions.<q_key>=A relevant question.
rdp.faq.answers.<q_key>=A plausible answer.
```

The provided default file can be found
in [faq.properties](https://github.com/PavlidisLab/rdp/tree/{{ config.extra.git_ref
}}/src/main/resources/faq.properties).
The provided default file can be found in [faq.properties](https://github.com/PavlidisLab/rdp/tree/{{ config.extra.git_ref }}/src/main/resources/faq.properties).

### Ordering FAQ entries

!!! note

New in 1.5.4

he `rdp.faq.keys` FAQ setting can be used to customize the ordering and appearance of FAQ entries. If the setting is
left unset, the default will be to arrange FAQ questions in alphabetic order of their keys.

### Translating FAQ entries

!!! note

New in 1.5.4

The FAQ messages can now be translated by reusing the `rdp.faq.questions.<q_key>` and `rdp.faq.answers.<q_key>` as codes
for the `messages.properties` file.

## Terms of service and privacy policy

Expand Down
20 changes: 16 additions & 4 deletions docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This section describes the essential steps to deploy an RDP registry.

## Obtain a distribution of RDP

Download the [latest JAR distribution](https://github.com/PavlidisLab/rdp/releases/latest) from GitHub.
Download the [JAR distribution from GitHub](https://github.com/PavlidisLab/rdp/releases/v{{ config.extra.rdp_version }}).

```bash
wget https://github.com/PavlidisLab/rdp/releases/download/v{{ config.extra.rdp_version }}/rdp-{{ config.extra.rdp_version }}.jar
Expand All @@ -29,9 +29,21 @@ create user '<database username>'@'%' identified by '<database password>';
grant all on rdp.* to '<database username>'@'%';
```

If you're using MySQL 5.6 or prior, use the `utf8` character set. It is a 3 bytes subset of the typical 4-bytes UTF-8
character encoding. Otherwise, you will face issues with the index size limit of 767 bytes due to some of our indexed
columns containing 255 characters (4 * 255 = 1020 > 767, but 3 * 255 = 765).
If you're using MySQL 5.6 or prior, use the `utf8mb3` character set. It is a 3 bytes subset of the typical 4-bytes
UTF-8 character encoding. Otherwise, you will face issues with the index size limit of 767 bytes due to some of our
indexed columns containing 255 characters (4 * 255 = 1020 > 767, but 3 * 255 = 765).

You should also adjust Hibernate dialect by adding the following to your `application.properties`:

```properties
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL55Dialect
```

Likewise, if you are using MariaDB, for which we recommend the current 10.6 LTS, use the following dialect:

```properties
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB106Dialect
```

## Setup application.properties

Expand Down
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ plugins:
markdown_extensions:
- admonition
extra:
rdp_version: 1.5.3
rdp_version: 1.5.4
git_ref: master
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>ubc.pavlab</groupId>
<artifactId>rdp</artifactId>
<version>1.5.3</version>
<version>1.5.4</version>

<description>
Registry for model organism researchers, developed for the Canadian Rare Disease Models &amp; Mechanisms Network.
Expand All @@ -28,7 +28,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.12</version>
<version>2.6.13</version>
</parent>

<dependencies>
Expand Down Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-webmvc-core</artifactId>
<version>1.6.11</version>
<version>1.6.12</version>
</dependency>

<!-- Database Migration -->
Expand Down Expand Up @@ -198,7 +198,7 @@

<properties>
<java.version>1.8</java.version>
<flyway.version>7.15.0</flyway.version>
<flyway.version>5.2.4</flyway.version>
<skipWebpack>false</skipWebpack>
</properties>

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/ubc/pavlab/rdp/JpaAuditingConfig.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package ubc.pavlab.rdp;

import org.springframework.context.annotation.Configuration;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

/**
* Configuration for auditing entities creation and modification with Spring Data JPA.
*
* @author poirigui
*/
@Configuration
@EnableJpaAuditing
public class JpaAuditingConfig {
}
77 changes: 46 additions & 31 deletions src/main/java/ubc/pavlab/rdp/MigrationConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import org.springframework.boot.autoconfigure.flyway.FlywayMigrationStrategy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.JdbcTemplate;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;

/**
Expand All @@ -21,26 +21,43 @@
@CommonsLog
public class MigrationConfig {

@RequiredArgsConstructor
private enum NewChecksumReason {
/**
* A migration applied with Flyway 3.
* <p>
* The checksum algorithm has changed.
*/
FLYWAY_3( "has been performed with Flyway 3.2.1" ),
/**
* A migration that introduced a regression with MySQL 5.7.
*/
MYSQL_5_7_REGRESSION( "introduced a regression with MySQL 5.7" );
final String reason;
}

/**
* Expected migration information that are used to determine if a repair is necessary.
*/
@RequiredArgsConstructor
private static class ExpectedMigrationInfo {
private final String version;
private final int pre15Checksum;
private final int post15Checksum;
private final int preRepairChecksum;
private final int postRepairChecksum;
private final NewChecksumReason newChecksumReason;
}

private static final ExpectedMigrationInfo[] MIGRATION_META = {
new ExpectedMigrationInfo( "1.0.0", -330642568, 1889522940 ),
new ExpectedMigrationInfo( "1.3.2", 1109324745, 1109324745 ),
new ExpectedMigrationInfo( "1.4.0", 310023814, 1017485172 ),
new ExpectedMigrationInfo( "1.4.1", -1543189200, 1330781885 ),
new ExpectedMigrationInfo( "1.4.2", 1706447069, 253128706 ),
new ExpectedMigrationInfo( "1.4.3", 571489108, 571489108 ),
new ExpectedMigrationInfo( "1.4.6", 399726006, 504755998 ),
new ExpectedMigrationInfo( "1.4.11", 1536441374, 709491229 ),
new ExpectedMigrationInfo( "1.4.11.1", -1312864724, -907949910 )
new ExpectedMigrationInfo( "1.0.0", -330642568, 1889522940, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.3.2", 1109324745, 1109324745, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.0", 310023814, 1017485172, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.1", -1543189200, 1330781885, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.2", 1706447069, 253128706, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.3", 571489108, 571489108, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.6", 399726006, 504755998, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.11", 1536441374, 709491229, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.4.11.1", -1312864724, -907949910, NewChecksumReason.FLYWAY_3 ),
new ExpectedMigrationInfo( "1.5.0.4", 625408518, -1065145387, NewChecksumReason.MYSQL_5_7_REGRESSION )
};

/**
Expand All @@ -50,20 +67,17 @@ private static class ExpectedMigrationInfo {
@Bean
public FlywayMigrationStrategy flywayMigrationStrategy() {
return flyway -> {
try {
// drop version_rank column
Connection connection = flyway.getConfiguration().getDataSource().getConnection();
// lookup the schema_version table and version_rank column
boolean hasVersionRankColumn;
try ( ResultSet resultSet = connection.getMetaData().getColumns( null, null, "schema_version", "version_rank" ) ) {
hasVersionRankColumn = resultSet.next();
}
if ( hasVersionRankColumn ) {
log.warn( "The 'schema_version' table is still using the 'version_rank' column from Flyway 3.2.1; will proceed to remove it..." );
connection.createStatement().execute( "alter table schema_version drop column version_rank" );
// drop version_rank column
JdbcTemplate jdbcTemplate = new JdbcTemplate( flyway.getConfiguration().getDataSource() );
// lookup the schema_version table and version_rank column
Boolean hasVersionRankColumn = jdbcTemplate.execute( (ConnectionCallback<Boolean>) con -> {
try ( ResultSet resultSet = con.getMetaData().getColumns( null, null, "schema_version", "version_rank" ) ) {
return resultSet.next();
}
} catch ( SQLException e ) {
throw new RuntimeException( e );
} );
if ( hasVersionRankColumn != null && hasVersionRankColumn ) {
log.warn( "The 'schema_version' table is still using the 'version_rank' column from Flyway 3.2.1; will proceed to remove it..." );
jdbcTemplate.execute( "alter table schema_version drop column version_rank" );
}
MigrationInfo[] appliedMigrations = flyway.info().applied();
boolean repairNeeded = false;
Expand All @@ -74,15 +88,16 @@ public FlywayMigrationStrategy flywayMigrationStrategy() {
.orElse( null );
if ( expectedMigration != null &&
appliedMigration.getChecksum() != null &&
appliedMigration.getChecksum().equals( expectedMigration.pre15Checksum ) &&
!appliedMigration.getChecksum().equals( expectedMigration.post15Checksum ) ) {
log.warn( String.format( "Flyway migration %s has been performed with Flyway 3.2.1, checksum will be bumped from %s to %s after repair.",
appliedMigration.getVersion(), appliedMigration.getChecksum(), expectedMigration.post15Checksum ) );
appliedMigration.getChecksum().equals( expectedMigration.preRepairChecksum ) &&
!appliedMigration.getChecksum().equals( expectedMigration.postRepairChecksum ) ) {
repairNeeded = true;
log.warn( String.format( "Flyway migration %s %s, checksum will be bumped from %s to %s after repair.",
appliedMigration.getVersion(), expectedMigration.newChecksumReason.reason,
appliedMigration.getChecksum(), expectedMigration.postRepairChecksum ) );
}
}
if ( repairNeeded ) {
log.warn( "Flyway 3.2.1 migrations detected, Flyway repair will be performed." );
log.warn( "Flyway repair will now be performed." );
flyway.repair();
}
flyway.migrate();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ubc/pavlab/rdp/RemoteResourceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public AsyncRestTemplate remoteResourceRestTemplate( ApplicationSettings applica
SimpleClientHttpRequestFactory httpRequestFactory = new SimpleClientHttpRequestFactory();
httpRequestFactory.setTaskExecutor( new SimpleAsyncTaskExecutor() );
if ( applicationSettings.getIsearch().getRequestTimeout() != null ) {
log.warn( "The 'rdp.settings.isearch.request-timeout' configuration is deprecated." );
log.warn( "The 'rdp.settings.isearch.request-timeout' configuration is deprecated, use 'rdp.settings.isearch.connect-timeout' and 'rdp.settings.isearch.read-timeout' instead." );
httpRequestFactory.setConnectTimeout( 1000 );
httpRequestFactory.setReadTimeout( (int) applicationSettings.getIsearch().getRequestTimeout().toMillis() );
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import javax.validation.constraints.Size;
import java.io.*;
import java.net.URL;
import java.sql.Timestamp;
import java.text.MessageFormat;
import java.time.Duration;
import java.time.Instant;
Expand Down Expand Up @@ -134,7 +133,7 @@ public Object createServiceAccount( @Validated(User.ValidationServiceAccount.cla

user.setEmail( serviceEmail );
user.setEnabled( true );
user.setEnabledAt( Timestamp.from( Instant.now() ) );
user.setEnabledAt( Instant.now() );

Profile profile = user.getProfile();
profile.setPrivacyLevel( PrivacyLevelType.PRIVATE );
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/ubc/pavlab/rdp/controllers/ApiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import ubc.pavlab.rdp.services.*;
import ubc.pavlab.rdp.settings.ApplicationSettings;
import ubc.pavlab.rdp.settings.SiteSettings;
import ubc.pavlab.rdp.util.Messages;

import java.net.URI;
import java.util.*;
Expand Down Expand Up @@ -426,7 +427,7 @@ private void initUserTerm( UserOntologyTerm term, Locale locale ) {

@SneakyThrows
private <T extends RemoteResource> T initRemoteResource( T remoteResource, Locale locale ) {
remoteResource.setOrigin( messageSource.getMessage( "rdp.site.shortname", null, locale ) );
remoteResource.setOrigin( messageSource.getMessage( Messages.SHORTNAME, locale ) );
// Ensure that the path of the URL is effectively stripped from any trailing slashes and that its string
// representation is free of query parameters, fragments, etc.
// The main reason we do this is to avoid double slashes when generating URLs to profiles on partner sites
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/ubc/pavlab/rdp/model/AccessToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
import ubc.pavlab.rdp.model.enums.PrivacyLevelType;

import javax.persistence.*;
import java.sql.Timestamp;
import java.time.Duration;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.time.Instant;
import java.time.temporal.TemporalAmount;
import java.util.Optional;

Expand All @@ -31,7 +29,7 @@ public class AccessToken extends Token implements UserContent {
private User user;

@CreatedDate
private Timestamp createdAt;
private Instant createdAt;

@Override
protected TemporalAmount getDuration() {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/ubc/pavlab/rdp/model/Gene.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.time.LocalDate;

/**
* Created by mjacobson on 17/01/18.
Expand Down Expand Up @@ -41,7 +41,6 @@ public abstract class Gene implements Serializable {
private String aliases;

@JsonIgnore
@Temporal(TemporalType.DATE)
@Column(name = "modification_date")
private Date modificationDate;
private LocalDate modificationDate;
}
Loading

0 comments on commit 3b6c3b1

Please sign in to comment.