diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 55cc1ad5826136eeb8c81fdacaf86e62fae8453d..32b145a6d262485f0739b734e494ea3a8aa3bc40 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,7 +22,7 @@ variables: JAR_PATH: "backend/build/libs/faidare.jar" GIT_DEPTH: 0 IMAGE_TAG: $CI_COMMIT_REF_SLUG - ELASTIC_VERSION: "7.13.2" + ELASTIC_VERSION: "7.17.6" DOCKER_OPTS: "--mtu=1450" # Gradle cache for all jobs @@ -52,11 +52,13 @@ build-loader-docker-image: - changes: - Dockerfile - scripts/* - - backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/*_mapping.json - - backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/settings.json + - backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/*_mapping.json + - backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json - .gitlab-ci.yml - if: $CI_PIPELINE_SOURCE == "merge_request_event" || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH - allow_failure: true +# allow_failure: true + tags: + - openstack # TESTS test-and-sonarqube: @@ -77,12 +79,16 @@ test-and-sonarqube: # so there will be no bootstrap checks that would fail on CI # especially the error regarding # `max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]` - command: ["bin/elasticsearch", "-Ediscovery.type=single-node"] + command: [ "bin/elasticsearch", "-Ediscovery.type=single-node" ] + variables: GRADLE_OPTS: "-Xms512m -Xmx8192m -XX:MaxMetaspaceSize=8192m -Dorg.gradle.daemon=false" SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task ES_JAVA_OPTS: "-Xms2g -Xmx2g" + ES_HOST: "elasticsearch" # Set the Elasticsearch host + ES_PORT: "9200" # Set the Elasticsearch port + JSON_DIR: "./data/test/" # Directory containing JSON files for bulk loading cache: key: "${CI_COMMIT_REF_NAME}" policy: pull-push @@ -90,7 +96,23 @@ test-and-sonarqube: - ".gradle" - .sonar/cache script: - - ./gradlew test jacocoTestReport -s sonarqube + # Wait for Elasticsearch to be ready to receive requests + - echo "Waiting for Elasticsearch to start..." + #- until curl -s "http://${ES_HOST}:${ES_PORT}"| grep "You Know, for Search" > /dev/null; do sleep 1; done # Polling until Elasticsearch is available + - until curl -s "http://${ES_HOST}:${ES_PORT}/_cluster/health?wait_for_status=green&timeout=60s"; do sleep 1; done + - curl -X GET "http://${ES_HOST}:${ES_PORT}/_cat/shards?v" + - echo "Elasticsearch is up and running." # Confirmation message when Elasticsearch is ready + - echo "Listing JSON directory contents:" + - ls -la "${JSON_DIR}" # List files in the JSON directory + - echo "${JSON_DIR}" + # Launch the data loading script + - ./scripts/harvest.sh -jsonDir "${JSON_DIR}" -es_host "${ES_HOST}" -es_port "${ES_PORT}" -env "dev" -type "all" </dev/null # Execute the script to load data into Elasticsearch + - curl -X GET "http://${ES_HOST}:${ES_PORT}/_cat/indices?v" + - curl -X GET "http://${ES_HOST}:${ES_PORT}/_aliases" + - echo "Trying to access Elasticsearch logs..." + - curl -s "http://${ES_HOST}:${ES_PORT}/_cluster/health?pretty" + # Launch tests + - ./gradlew test jacocoTestReport -s sonar artifacts: reports: junit: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d760ec6adacfe12bb2a75e792815543c496d1546..d7aa977221fd77f7b2740083ca26d0df394693c4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -68,6 +68,11 @@ * `detect-secrets scan --update .secrets.baseline` to update the secret baseline, then * `detect-secrets audit .secrets.baseline` to tag it as a false positive if relevant. +### Run backend tests +After loading test data into your local Elasticsearch instance, you can run the following command to run backend tests: + +`./gradlew test jacocoTestReport -s sonarqube` + ## Testing recommendations Behaviour driven development (upon [TDD](https://dannorth.net/2012/05/31/bdd-is-like-tdd-if/)) is recommended for all new developments. diff --git a/Dockerfile b/Dockerfile index bc573165c6c01ab081bc948c4b3409fb3c33976e..3201c9650234c0a9a003a58a4ee5d516654a215e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,10 +5,10 @@ COPY scripts/harvest.sh /opt/scripts/ COPY scripts/to_bulk.jq /opt/scripts/ # COPY dao settings -COPY backend/src/test/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json /opt/backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/settings.json +COPY backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json /opt/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json # COPY dao mappings -COPY backend/src/test/resources/fr/inrae/urgi/faidare/repository/es/setup/index/*_mapping.json /opt/backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/ +COPY backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/*_mapping.json /opt/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/ RUN apk add --update --no-cache bash curl jq parallel wget grep gzip sed date coreutils diff --git a/HOW-TO-LOAD-DATA.md b/HOW-TO-LOAD-DATA.md new file mode 100644 index 0000000000000000000000000000000000000000..85d1b0e22a5d9c23b369470e95623ef02b012a1f --- /dev/null +++ b/HOW-TO-LOAD-DATA.md @@ -0,0 +1,143 @@ + + +# TL;DR +For general data loading commands, see [Data Harvesting and Indexing](#Data Harvesting and Indexing). +For loading test data, see [Test data](#Test data). + + +## Data Harvesting and Indexing + +Before all, take care to get data locally before running any indexing script. + +### Indexing commands without Docker + +Start an elasticsearch instance using +```sh +docker-compose up +``` +Then, to index the data in the specified directory (`/path/to/local/data/`) into the Elasticsearch instance running on localhost, run the following command: + +```sh +./scripts/harvest.sh -jsonDir /path/to/local/data/ -es_host localhost -env dev -v +``` +See `./scripts/harvest.sh --help` for more information. + +### Indexing commands with Docker per Operating System + +The FAIDARE Docker image uses Alpine Linux as the base, which can lead to compatibility issues on certain systems, such as macOS with ARM processors (Apple Silicon). Below are the specific instructions for running the indexing command on Linux, macOS, and Windows: +- Finding the Container for `--network` + To determine the name of the container to use with the `--network=container:<container_name>` option, run the following command: +```sh +docker ps + +``` +This will list all running containers. Look for the container name in the NAMES column. For example, if the container name is `elasticsearch-faidare`, you would use it as follows: +```sh +--network=container:elasticsearch-faidare + +``` + +1. Linux + Run the command as is: +```sh +docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ + +``` +2. MacOS: + On Apple Silicon (ARM64), ensure Rosetta is enabled for Docker Desktop and specify the platform explicitly: +```sh +docker run --platform linux/amd64 -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ + +``` +For Intel-based Macs, no additional flags are needed: +```sh +docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ + +``` +3. Windows: + Adapt the volume path to Windows format (e.g., C:/path/to/local/data): +```sh +docker run -t --volume C:/path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ + +``` + +To more help add `--help` parameter to the command. + +If you depend on committed changes in indexing scripts under a specific branch (the docker image should have been automatically created by the CI), you need to change the tag of the docker image according to the branch name (ie. for branch `epic/merge-faidare-dd`, use tag `epic-merge-faidare-dd`, see `CI_COMMIT_REF_SLUG` [Gitlab predefined variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-reference)), as following: + +```sh +docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:epic-merge-faidare-dd` -jsonDir /opt/data/ --help +``` + +### Docker container maintenance + +[Data Harvesting and Indexing](#Data Harvesting and Indexing) section above expects to have an available docker image on the forgemia docker registry. The Gitlab CI rebuild it when needed, but you can update or push such an image using the following commands: + +```sh +# build the image +docker build -t registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest . + +# Login before pushing the image +TOKEN= # your PAT from forgeMIA +echo "$TOKEN" | docker login registry.forgemia.inra.fr/urgi-is/docker-rare -u <your ForgeMIA username> --password-stdin + +# push the built image +docker push registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest +``` + +That should ease the indexing of data without having to craft a dedicated environment. + + + +## Test data +`docker compose up` will start an Elasticsearch instance + +To load the test data with the necessary indices and mappings, you can use one of the following methods: +1. Using the Docker image (recommended for simplicity and consistency). +2. Running the script locally on your machine. + +### Option 1: Using the Docker Image +For detailed instructions on using the FAIDARE Docker image, refer to the relevant section in the [README.md](https://forgemia.inra.fr/urgi-is/faidare/-/blob/fix/NewReadMeHowToDevelopOnFaidare/README.md#data-harvesting-and-indexing). + ```sh +docker run -t --volume ./data/test:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ + ``` +*NB*: adapt the docker command depending on your [operating system](### Indexing commands with Docker per Operating System). + +*NB2*: Ensure you have an up to date access token to the container registry. If not, you can generate one from the [ForgeMIA](https://forgemia.inra.fr/urgi-is/docker-rare/-/settings/access_tokens) website or contact us. + +For instance for MacOS ARM on the new-api branch, the command would be: +```sh +docker compose up + +docker run --platform linux/amd64 -t --volume ./data/test:/opt/data/ \ +--network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:fix-newreadmehowtodeveloponfaidare \ +-jsonDir /opt/data/ +``` + +### Option 2: Running the Script Locally +If you prefer, you can run the `harvest.sh` script directly on your machine. However, please ensure the following dependencies are installed: +- jq (v1.6+): https://github.com/stedolan/jq/releases/tag/jq-1.6 +- GNU parallel: https://www.gnu.org/software/parallel/ +- gzip: http://www.gzip.org/ + +**Instructions by Operating System** + +1. Linux: Run the script as follows: + +`./scripts/harvest.sh -jsonDir data/test/ -es_host localhost -env dev -v` + +2. macOS: Ensure GNU utilities like readlink are available. If using a macOS-specific environment, you might need to install them using Homebrew: + +`brew install coreutils gnu-parallel jq gzip` + +Then run: + +`./scripts/harvest.sh -jsonDir data/test/ -es_host localhost -env dev -v` + +3. Windows: You can run the script using a Bash environment like Git Bash, WSL, or Cygwin. Ensure all required dependencies are installed within the environment: + + `./scripts/harvest.sh -jsonDir data/test/ -es_host localhost -env dev -v` + +Note for macOS and Windows users: Compatibility issues might arise due to system differences. If you encounter any issues, it is recommended to use the Docker-based method. + + diff --git a/README.md b/README.md index f49182dcc156aff02c7d0fd22c3bef276dbf6570..148fe0e3eefb552a611eff58bb0456e3097f5a3b 100644 --- a/README.md +++ b/README.md @@ -1,70 +1,81 @@ # FAIDARE: FAIR Data-finder for Agronomic Research -This application provides web services (based on the BrAPI standard) and a web interface with easy to use filters to facilitate the access to plant datasets from a federation of sources. +FAIDARE is a application that provides web services (based on the BrAPI standard) and a user-friendly web interface to access plant datasets from a federation of sources. [[_TOC_]] -## How to contribute +## Overview +- Purpose: Facilitate access to federated plant datasets for agronomic research. +- Key Features: + + - BrAPI-compliant web services. + - Intuitive filters for dataset exploration. + - Support for Elasticsearch and Kibana. + +## How to Contribute Look at the [contribution guide](CONTRIBUTING.md). -## Install development environment +## Data loading + +For loading data in the FAIDARE Elasticsearch, see [HOW-TO-LOAD-DATA.md](HOW-TO-LOAD-DATA.md). -- Install `node` and `yarn` +## Setting Up the Development Environment -Installation via `nvm` is recommended for easier control of installed version: -https://github.com/creationix/nvm +### Prerequisites +1. Node.js and Yarn +Install Node.js (v16.14.0 recommended) and Yarn. Using nvm is advised for version control: https://github.com/creationix/nvm. ```sh nvm install 16.14.0 nvm use v16.14.0 ``` +2. Java JDK17 +Install the latest JDK17 version for your operating system. -- Install JS dependencies +3. Docker +Required to run Elasticsearch and Kibana locally. Ensure Docker and Docker Compose are installed. +### Installation Steps +1. Install JavaScript Dependencies +Navigate to the web directory and install dependencies: ```sh cd web yarn ``` -- Install latest Java JDK8 - -See latest instructions for your operating system. - -- (Optional) Install `docker` - -If you want to run an Elasticsearch and Kibana instance on your machine. -You can use your favorite package manager for that - - -## Run backend development server - -First make sure you have access to an Elasticsearch HTTP API server on `http://127.0.0.1:9200` (either via ssh tunneling or by running a local server). - -If you want to run an Elasticsearch server on your development machine you can use the `docker`/`docker-compose` configuration like so: - +2. Start Elasticsearch and Kibana +Launch using Docker Compose: ```sh docker compose up ``` -> This will launch an Elasticsearch server (with port forwarding `9200`) and a Kibana server (with port forwarding `5601`) +- Elasticsearch available at http://127.0.0.1:9200 + +- Kibana available at http://127.0.0.1:5601 + + Note: Prepare your Elasticsearch indices before proceeding. -> **Warning**: This repository does not automatically index data into Elasticsearch, you need to prepare your indices beforehand. +## Running the Backend Server +### Basic API Server -If you just need access to API, you can run: +Run the backend server with: ```sh ./gradlew bootRun ``` -If you are developing and need to work on the `web` assets (scripts, styles, etc), -you'll need to run the application with the `dev` profile: +### Development Server + +If you are working on frontend assets, start the backend with the dev profile: ```sh ./gradlew bootRun --args='--spring.profiles.active=dev' ``` -Otherwise, for the complete server (backend APIs + web interface), you can run: +### Complete Backend + Web Interface + +For the full application: ```sh ./gradlew assemble && java -jar backend/build/libs/faidare.jar @@ -92,45 +103,6 @@ otherwise the changes won't be shown in the browser. `yarn watch:prod` is also available to use production settings, while `yarn build` and `yarn build:prod` do the same but without watching the changes. -## Harvest - -Before all, take care to get data locally before running any indexing script. - -### TL;DR - -Data indexing to your local Elasticsearch is done using the following command (take care to change the path to local data). Note that your local Elasticsearch instance should be already runing using `docker-compose up`: - -```sh -docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -jsonDir /opt/data/ --help -``` - -Remove the `--help` parameter to run the loading with default params. - -If you depend on committed changes in indexing scripts under a specific branch (the docker image should have been automatically created by the CI), you need to change the tag of the docker image according to the branch name (ie. for branch `epic/merge-faidare-dd`, use tag `epic-merge-faidare-dd`, see `CI_COMMIT_REF_SLUG` [Gitlab predefined variable](https://docs.gitlab.com/ee/ci/variables/predefined_variables.html#predefined-variables-reference)), as following: - -```sh -docker run -t --volume /path/to/local/data:/opt/data/ --network=container:elasticsearch-faidare registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:epic-merge-faidare-dd` -jsonDir /opt/data/ --help -``` - -### Portability - -#### Docker - -[TL;DR](#TLDR) section above expects to have an available docker image on the forgemia docker registry. The Gitlab CI rebuil it when needed, but you can update or push such an image using the following commands: - -```sh -# build the image -docker build -t registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest . - -# Login before pushing the image -docker login registry.forgemia.inra.fr/urgi-is/docker-rare -u <your ForgeMIA username> - -# push the built image -docker push registry.forgemia.inra.fr/urgi-is/docker-rare/faidare-loader:latest -``` - -That should ease the indexing of data without having to craft a dedicated environment. - ## GitLab CI When creating merge requests on the ForgeMIA GitLab, the GitLab CI will @@ -138,19 +110,25 @@ automatically run the tests of the project (no need to do anything). If you want to run the GitLab CI locally, you have to follow this steps: -1. [Install gitlab-runner](https://docs.gitlab.com/runner/install/) -2. Run the following command (with the correct GnpIS security token): +### Important: +The `gitlab-runner exec` command was fully removed in GitLab Runner 16.0 and is no longer available in version 17.0 (released May 2024). This command was deprecated in GitLab 15.7 (December 2022), and its removal was part of the breaking changes introduced in GitLab Runner 16.0. -```sh -gitlab-runner exec docker test -``` +For more information, see the official [deprecation notice](https://docs.gitlab.com/ee/update/deprecations.html?utm_source=chatgpt.com#the-gitlab-runner-exec-command-is-deprecated). + +### Alternatives to gitlab-runner exec: +1. Use the Validate option on GitLab +GitLab provides an integrated Pipeline Editor that allows you to validate and simulate the execution of your .gitlab-ci.yml file before actually running the pipeline. +To use this feature, go to CI/CD > Pipelines > Editor in your GitLab project. Here, you can paste your .gitlab-ci.yml file and click the Validate button to check the syntax and simulate its execution. + +2. Emulators +While gitlab-runner exec is deprecated, third-party tools and emulators can help simulate GitLab CI pipelines locally. These tools may be useful for testing and troubleshooting, though they may not replicate the GitLab CI environment exactly. ## Spring Cloud config On bootstrap, the application will try to connect to a remote Spring Cloud config server to fetch its configuration. -The details of this remote server are filled in the `bootstrap.yml` file. +The details of this remote server are filled in the `bootstrap.yml` file. ( TODO: This file is not found ) By default, it tries to connect to the remote server on http://localhost:8888 but it can of course be changed, or even configured via the `SPRING_CONFIG_URI` environment variable. diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/api/brapi/ContextPathControllerAdvice.java b/backend/src/main/java/fr/inrae/urgi/faidare/api/brapi/ContextPathControllerAdvice.java new file mode 100644 index 0000000000000000000000000000000000000000..4b2de4abcaf21beeb4e40d45008bff8eb840b737 --- /dev/null +++ b/backend/src/main/java/fr/inrae/urgi/faidare/api/brapi/ContextPathControllerAdvice.java @@ -0,0 +1,16 @@ +package fr.inrae.urgi.faidare.api.brapi; + +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.RestController; + +@ControllerAdvice(annotations = RestController.class) +public class ContextPathControllerAdvice { + + @ModelAttribute("contextPath") + public String contextPath(final HttpServletRequest request) { + return request.getContextPath(); + } + +} diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/config/ElasticSearchConfig.java b/backend/src/main/java/fr/inrae/urgi/faidare/config/ElasticSearchConfig.java index d16bf44c531935e61a75f3f43d385517ac21f175..1e2ee37d9e15ac02006c6f48855f0bb227519f55 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/config/ElasticSearchConfig.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/config/ElasticSearchConfig.java @@ -5,10 +5,12 @@ import org.apache.http.impl.nio.reactor.IOReactorConfig; import org.elasticsearch.client.NodeSelector; import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClientBuilder; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; @Configuration public class ElasticSearchConfig { @@ -19,9 +21,11 @@ public class ElasticSearchConfig { @Value("${data.elasticsearch.port}") private Integer esPort; + /** * Provides builder for {@link ElasticsearchRestClientAutoConfiguration} */ + //TODO: is this deprecated ? @Bean public RestClientBuilder restClientBuilder() { // if we are on CI, we use a hardcoded host, else we use the injected value @@ -37,4 +41,27 @@ public class ElasticSearchConfig { ); } + private FaidareProperties faidareProperties; + + @Bean + public FaidareProperties faidareProperties() { + return new FaidareProperties(); + } + + public ElasticSearchConfig(FaidareProperties faidareProperties) { + this.faidareProperties = faidareProperties; + } + + /** + * Exposes the bean of type FaidareProperties under the name + * "faidarePropertiesBean"so that "faidarePropertiesBean" can be used + * in SpEL expressions + */ + @Primary + @Bean + public FaidareProperties faidarePropertiesBean() { + return this.faidareProperties; + } + + } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/config/FaidareProperties.java b/backend/src/main/java/fr/inrae/urgi/faidare/config/FaidareProperties.java index 5b91c8211f03d81f7f5f1a8db302dc83f7eb691a..32b7bf02b5101e19fb49e7a35c681bf77295e68d 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/config/FaidareProperties.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/config/FaidareProperties.java @@ -21,6 +21,10 @@ public class FaidareProperties { * The URL used by the germplasm card to generate links to the faidare search application * (i.e. the faidare flavor of data-discovery). */ + + @NotBlank + private String elasticsearchIndexingTemplate; + @NotBlank private String searchUrl; @@ -48,6 +52,14 @@ public class FaidareProperties { this.securityUserGroupWsToken = securityUserGroupWsToken; } + public String getElasticsearchIndexingTemplate() { + return elasticsearchIndexingTemplate; + } + + public void setElasticsearchIndexingTemplate(String elasticsearchIndexingTemplate) { + this.elasticsearchIndexingTemplate = elasticsearchIndexingTemplate; + } + public String getSearchUrl() { return searchUrl; } @@ -88,4 +100,17 @@ public class FaidareProperties { } return null; } + + /** + * Get Elasticearch alias name using the template property, the document type and the group id + */ + public String getAliasName (String documentType, long groupId) { + return getBaseIndexName(documentType) + "-group" + groupId; + } + + + private String getBaseIndexName(String documentType) { + documentType = documentType.replaceAll("([a-z0-9])([A-Z])", "$1-$2").toLowerCase(); + return elasticsearchIndexingTemplate.replace("{documentType}", documentType); + } } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/GermplasmV1DaoCustomImpl.java b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/GermplasmV1DaoCustomImpl.java index 30d55ef04105c739d96e8835991f1fc9bf835d86..4703b3722096ba17b71e2b99334ed400bffa96ee 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/GermplasmV1DaoCustomImpl.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/GermplasmV1DaoCustomImpl.java @@ -1,8 +1,10 @@ package fr.inrae.urgi.faidare.dao.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.brapi.GermplasmSitemapVO; import fr.inrae.urgi.faidare.domain.brapi.v1.GermplasmV1VO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; import org.springframework.data.elasticsearch.client.elc.NativeQuery; import org.springframework.data.elasticsearch.client.elc.NativeQueryBuilder; import org.springframework.data.elasticsearch.client.elc.Queries; @@ -18,6 +20,7 @@ import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilde import java.util.Set; import java.util.stream.Stream; +@Import({ElasticSearchConfig.class}) public class GermplasmV1DaoCustomImpl implements GermplasmV1DaoCustom{ @Autowired @@ -38,7 +41,7 @@ public class GermplasmV1DaoCustomImpl implements GermplasmV1DaoCustom{ .withQuery(builder -> builder.matchAll(Queries.matchAllQuery())) .withSourceFilter(new FetchSourceFilterBuilder().withIncludes("germplasmDbId").build()) .build(); - return elasticsearchOperations.searchForStream(query, GermplasmSitemapVO.class, IndexCoordinates.of(GermplasmV1VO.INDEX_NAME)) + return elasticsearchOperations.searchForStream(query, GermplasmSitemapVO.class, IndexCoordinates.of("faidare_germplasm_dev-group0")) .stream() .map(SearchHit::getContent); } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/LocationV1DaoCustomImpl.java b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/LocationV1DaoCustomImpl.java index 978ce22a99f70986ec83739fcb27d0228aeca8f8..c8ea02c07fee77d135daa436f80f23a83fc106de 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/LocationV1DaoCustomImpl.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/LocationV1DaoCustomImpl.java @@ -1,8 +1,10 @@ package fr.inrae.urgi.faidare.dao.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.LocationVO; import fr.inrae.urgi.faidare.domain.brapi.LocationSitemapVO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.data.elasticsearch.client.elc.NativeQuery; import org.springframework.data.elasticsearch.client.elc.NativeQueryBuilder; @@ -12,7 +14,7 @@ import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilder; import java.util.stream.Stream; - +@Import({ElasticSearchConfig.class}) public class LocationV1DaoCustomImpl implements LocationV1DaoCustom { @Autowired @@ -25,7 +27,7 @@ public class LocationV1DaoCustomImpl implements LocationV1DaoCustom { .withQuery(builder -> builder.matchAll(Queries.matchAllQuery())) .withSourceFilter(new FetchSourceFilterBuilder().withIncludes("locationDbId").build()) .build(); - return esTemplate.searchForStream(query, LocationSitemapVO.class, IndexCoordinates.of(LocationVO.INDEX_NAME)) + return esTemplate.searchForStream(query, LocationSitemapVO.class, IndexCoordinates.of("faidare_location_dev-group0")) .stream() .map(SearchHit::getContent); } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/StudyV1DaoCustomImpl.java b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/StudyV1DaoCustomImpl.java index 5683d3eff4f540156fbc165c11a08d61a9122b74..584b6de9a095e8c51a5ee5a2328acfc6a948411e 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/StudyV1DaoCustomImpl.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v1/StudyV1DaoCustomImpl.java @@ -1,10 +1,12 @@ package fr.inrae.urgi.faidare.dao.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.dao.v2.StudyCriteria; import fr.inrae.urgi.faidare.domain.brapi.StudySitemapVO; import fr.inrae.urgi.faidare.domain.brapi.v1.StudyV1VO; import fr.inrae.urgi.faidare.domain.brapi.v2.StudyV2VO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Import; import org.springframework.data.elasticsearch.client.elc.ElasticsearchTemplate; import org.springframework.data.elasticsearch.client.elc.NativeQuery; import org.springframework.data.elasticsearch.client.elc.NativeQueryBuilder; @@ -19,7 +21,7 @@ import org.springframework.data.elasticsearch.core.query.CriteriaQueryBuilder; import org.springframework.data.elasticsearch.core.query.FetchSourceFilterBuilder; import java.util.stream.Stream; - +@Import({ElasticSearchConfig.class}) public class StudyV1DaoCustomImpl implements StudyV1DaoCustom { @Autowired @@ -153,7 +155,7 @@ public class StudyV1DaoCustomImpl implements StudyV1DaoCustom { .withQuery(builder -> builder.matchAll(Queries.matchAllQuery())) .withSourceFilter(new FetchSourceFilterBuilder().withIncludes("studyDbId").build()) .build(); - return esTemplate.searchForStream(query, StudySitemapVO.class, IndexCoordinates.of(StudyV1VO.INDEX_NAME)) + return esTemplate.searchForStream(query, StudySitemapVO.class, IndexCoordinates.of("faidare_study_dev-group0")) .stream() .map(SearchHit::getContent); } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmCriteria.java b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmCriteria.java index c0a0c2441b8503acefb48d121ae684a5bf441f65..05044275ec0b6444813a8c050fbe38c6333b6efb 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmCriteria.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmCriteria.java @@ -1,5 +1,9 @@ package fr.inrae.urgi.faidare.dao.v2; +import fr.inrae.urgi.faidare.domain.SynonymsVO; +import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; + import java.util.List; public class GermplasmCriteria { @@ -26,7 +30,7 @@ public class GermplasmCriteria { private List<String> species; private List<String> studyDbIds; private List<String> studyNames; - private List<String> synonyms; + private List<SynonymsVO> synonyms; private List<String> trialDbIds; private List<String> trialNames; @@ -123,9 +127,9 @@ public class GermplasmCriteria { public void setStudyNames(List<String> studyNames) { this.studyNames = studyNames; } - public List<String> getSynonyms() { return synonyms; } + public List<SynonymsVO> getSynonyms() { return synonyms; } - public void setSynonyms(List<String> synonyms) { this.synonyms = synonyms; } + public void setSynonyms(List<SynonymsVO> synonyms) { this.synonyms = synonyms; } public List<String> getTrialDbIds() { return trialDbIds; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmV2DaoCustomImpl.java b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmV2DaoCustomImpl.java index 9059d778b5424520c5cdd526a4d3c9187d7e81fe..d678e51b2391bd79e4ddb4b62537d60ee56a1426 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmV2DaoCustomImpl.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/dao/v2/GermplasmV2DaoCustomImpl.java @@ -5,6 +5,7 @@ package fr.inrae.urgi.faidare.dao.v2; //https://www.baeldung.com/spring-data-elasticsearch-queries import fr.inrae.urgi.faidare.api.brapi.v2.BrapiListResponse; +import fr.inrae.urgi.faidare.domain.SynonymsVO; import fr.inrae.urgi.faidare.domain.brapi.v2.GermplasmV2VO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; @@ -14,6 +15,7 @@ import org.springframework.data.elasticsearch.core.query.Criteria; import org.springframework.data.elasticsearch.core.query.CriteriaQuery; import org.springframework.data.elasticsearch.core.query.CriteriaQueryBuilder; +import java.util.List; public class GermplasmV2DaoCustomImpl implements GermplasmV2DaoCustom { @@ -133,7 +135,12 @@ public class GermplasmV2DaoCustomImpl implements GermplasmV2DaoCustom { if(germplasmCriteria.getSynonyms() != null && !germplasmCriteria.getSynonyms().isEmpty()){ - esCrit.and(new Criteria("synonyms").in(germplasmCriteria.getSynonyms())); + List<String> synonymValues = germplasmCriteria.getSynonyms() + .stream() + .map(SynonymsVO::getSynonym) + .toList(); + esCrit.and(new Criteria().and("synonymsV2.synonym").in(synonymValues)); + //esCrit.and(new Criteria("synonyms").in(germplasmCriteria.getSynonyms())); } if(germplasmCriteria.getTrialDbIds() != null diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/CollPopVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/CollPopVO.java index b76386e2fd19cd3150dec43ad6569b13c54d26da..54c171101d9c8651ed78486f218332dd34885ec1 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/CollPopVO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/CollPopVO.java @@ -1,10 +1,12 @@ package fr.inrae.urgi.faidare.domain; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.elasticsearch.annotations.Document; +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_germplasm_dev-group0", - //indexName = "faidare_germplasm_beta-group0", + indexName = "#{@faidarePropertiesBean.getAliasName('germplasm', 0L)}", createIndex = false ) public class CollPopVO { diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/GermplasmMcpdVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/GermplasmMcpdVO.java index a3c704c472fd3842e2019f5d61524eb81b215ff2..6cee46630ad35b29cf0ad256cff64137dcaad6f7 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/GermplasmMcpdVO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/GermplasmMcpdVO.java @@ -3,6 +3,7 @@ package fr.inrae.urgi.faidare.domain; import java.util.List; import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; @@ -56,10 +57,16 @@ public final class GermplasmMcpdVO { private String genus; - @Field(type=FieldType.Text) - @Id + //@Field(type=FieldType.Text) + //@Id private String germplasmDbId; + @JsonProperty("@id") + @Field(name="germplasmPUI")//TODO : should take germpalsmURI as it is always fed in the new transformer + private String id; + + @Id + private String _id; //private String germplasmName; //private String germplasmPUI; @@ -121,6 +128,14 @@ public final class GermplasmMcpdVO { this.accessionNames = accessionNames; } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getAccessionNumber() { return accessionNumber; } @@ -161,6 +176,14 @@ public final class GermplasmMcpdVO { this.ancestralData = ancestralData; } + public String get_id() { + return _id; + } + + public void set_id(String _id) { + this._id = _id; + } + public String getPUID() { return PUID; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/LocationVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/LocationVO.java index 597dc355c8cd9fd37221f59d866973ab501f3759..9ee14994d2b676e9a013ec561e408145d5274437 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/LocationVO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/LocationVO.java @@ -2,17 +2,20 @@ package fr.inrae.urgi.faidare.domain; import java.util.List; import java.util.Objects; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; +@Import({ElasticSearchConfig.class}) @Document( - indexName = LocationVO.INDEX_NAME, - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('location', 0L)}", + createIndex = false ) public class LocationVO { - public static final String INDEX_NAME = "faidare_location_dev-group0"; + //public static final String INDEX_NAME = "faidare_location_dev-group0"; private String abbreviation; diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/SynonymsVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/SynonymsVO.java new file mode 100644 index 0000000000000000000000000000000000000000..045bb1c1ad92b3472b0e4112b7087d50db763be9 --- /dev/null +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/SynonymsVO.java @@ -0,0 +1,34 @@ +package fr.inrae.urgi.faidare.domain; + +public class SynonymsVO { + private String type; + private String synonym; + + public SynonymsVO() { + this.type = null; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getSynonym() { + return synonym; + } + + public void setSynonym(String synonym) { + this.synonym = synonym; + } + + @Override + public String toString() { + return "{" + + "type='" + type + '\'' + + ", synonym='" + synonym + '\'' + + '}'; + } +} diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/XRefDocumentVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/XRefDocumentVO.java index 03774ce4f7d79ab598e1bb387570bb5e6907ca03..472bb99644c9542a2eb95a98b7a2ea16d0dc1d20 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/XRefDocumentVO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/XRefDocumentVO.java @@ -3,13 +3,15 @@ package fr.inrae.urgi.faidare.domain; import java.util.List; import java.util.Objects; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_xref_dev-group0", - //indexName = "faidare_xref_beta-group0", - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('xref', 0L)}", + createIndex = false ) public class XRefDocumentVO { diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmAttributeV1VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmAttributeV1VO.java index e490ae7359a1d8406e165774f53e3757a49377d7..36fba13f8faf67139c144255ebedb8065ba981e0 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmAttributeV1VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmAttributeV1VO.java @@ -1,14 +1,17 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import java.util.List; import java.util.Objects; +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_germplasm-attribute_dev-group0", - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('germplasm-attribute', 0L)}", + createIndex = false ) public class GermplasmAttributeV1VO { diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmPedigreeV1VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmPedigreeV1VO.java index 8e1f893079c0dd00422e83de0537a043a744536c..3b259505c887ecf2855e652f0111198ac2c1f26c 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmPedigreeV1VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmPedigreeV1VO.java @@ -1,23 +1,32 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; +import com.fasterxml.jackson.annotation.JsonProperty; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; +import org.springframework.data.elasticsearch.annotations.Field; import java.util.List; import java.util.Objects; //indexName = "#{@dataDiscoveryProperties.getElasticsearchPrefix}resource-alias" +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_germplasm-pedigree_dev-group0", - //indexName = "faidare_pedigree_beta-group0", - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('germplasm-pedigree', 0L)}", + createIndex = false ) //@Mapping(mappingPath = "fr/inra/urgi/datadiscovery/domain/faidare/FaidareGeneticResource.mapping.json") public final class GermplasmPedigreeV1VO { @Id private String _id; + @JsonProperty("@id") + @Field(name="@id")//TODO : should take germpalsmURI as it is always fed in the new transformer + private String id; private String germplasmDbId; + + private String germplasmPedigreeDbId; private String defaultDisplayName; private String pedigree; private Long groupId; @@ -32,9 +41,12 @@ public final class GermplasmPedigreeV1VO { private String parent2Type; private List<SiblingV1VO> siblings; private String germplasmURI; + + private String germplasmPedigreeURI; private String parent1URI; private String parent2URI; - + @JsonProperty("@type") + private String type = "germplasmPedigree"; @Override public boolean equals(Object o) { if (this == o) return true; @@ -47,10 +59,42 @@ public final class GermplasmPedigreeV1VO { return crossingPlan; } + public String getGermplasmPedigreeURI() { + return germplasmPedigreeURI; + } + + public void setGermplasmPedigreeURI(String germplasmPedigreeURI) { + this.germplasmPedigreeURI = germplasmPedigreeURI; + } + public void setCrossingPlan(String crossingPlan) { this.crossingPlan = crossingPlan; } + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getGermplasmPedigreeDbId() { + return germplasmPedigreeDbId; + } + + public void setGermplasmPedigreeDbId(String germplasmPedigreeDbId) { + this.germplasmPedigreeDbId = germplasmPedigreeDbId; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + public String getCrossingYear() { return crossingYear; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmV1VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmV1VO.java index 1f0f7628a30e8c7a6c649bfb1df901d19fa7f0ce..7ba49058f90e68e466598fd73db49f6e11a83842 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmV1VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/GermplasmV1VO.java @@ -1,7 +1,9 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; import com.fasterxml.jackson.annotation.JsonProperty; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.*; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; @@ -9,12 +11,13 @@ import org.springframework.data.elasticsearch.annotations.Field; import java.util.List; import java.util.Objects; +@Import({ElasticSearchConfig.class}) @Document( - indexName = GermplasmV1VO.INDEX_NAME, - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('germplasm', 0L)}", + createIndex = false ) public final class GermplasmV1VO { - public static final String INDEX_NAME = "faidare_germplasm_dev-group0"; + //public static final String INDEX_NAME = "faidare_germplasm_dev-group0"; private List<String> accessionNames; private String accessionNumber; @@ -25,8 +28,10 @@ public final class GermplasmV1VO { private String biologicalStatusOfAccessionCode; private GermplasmInstituteVO breeder; private List<GenealogyVO> children; + @Field(name = "originSite") private SiteVO collectingSite; //GnpIS private List<CollPopVO> collection; + @Field(name = "collector") private GermplasmInstituteVO collector; private String commonCropName; private String countryOfOriginCode; @@ -34,6 +39,8 @@ public final class GermplasmV1VO { //private List<GermplasmInstitute> breedingInstitutes; //private GermplasmCollectingInfo collectingInfo; private String defaultDisplayName; + @Field(name = "documentationURL") + private String url; private String documentationURL; private List<DonorVO> donors; private List<SiteVO> evaluationSites; //GnpIS @@ -45,10 +52,11 @@ public final class GermplasmV1VO { private String germplasmName; private String germplasmPUI; private Long groupId; //GnpIS - @Field(name="germplasmPUI") + @Field(name = "germplasmPUI") private String germplasmURI; @JsonProperty("@id") - @Field(name="germplasmPUI")//TODO : should take germpalsmURI as it is always fed in the new transformer + @Field(name = "germplasmPUI") +//TODO : should take germpalsmURI as it is always fed in the new transformer private String id; private InstituteVO holdingInstitute; //GnpIS private InstituteVO holdingGenbank; //GnpIS @@ -85,10 +93,16 @@ public final class GermplasmV1VO { private String subtaxa; private String subtaxaAuthority; private String subtaxon; + private List<TaxonSourceVO> taxonIds; private String subtaxonAuthority; + @Field(name = "synonyms") private List<String> synonyms; private List<String> taxonCommonNames; private List<String> typeOfGermplasmStorageCode; + private String taxonComment; + private List<String> taxonSynonyms; + private String geneticNature; + private String comment; @JsonProperty("@type") private String type = "germplasm"; @@ -97,7 +111,52 @@ public final class GermplasmV1VO { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GermplasmV1VO that = (GermplasmV1VO) o; - return Objects.equals(accessionNames, that.accessionNames) && Objects.equals(accessionNumber, that.accessionNumber) && Objects.equals(acquisitionDate, that.acquisitionDate) && Objects.equals(acquisitionSourceCode, that.acquisitionSourceCode) && Objects.equals(alternateIDs, that.alternateIDs) && Objects.equals(ancestralData, that.ancestralData) && Objects.equals(biologicalStatusOfAccessionCode, that.biologicalStatusOfAccessionCode) && Objects.equals(collection, that.collection) && Objects.equals(commonCropName, that.commonCropName) && Objects.equals(countryOfOriginCode, that.countryOfOriginCode) && Objects.equals(defaultDisplayName, that.defaultDisplayName) && Objects.equals(documentationURL, that.documentationURL) && Objects.equals(genus, that.genus) && Objects.equals(genusSpecies, that.genusSpecies) && Objects.equals(genusSpeciesSubtaxa, that.genusSpeciesSubtaxa) && Objects.equals(germplasmDbId, that.germplasmDbId) && Objects.equals(donors, that.donors) && Objects.equals(evaluationSites, that.evaluationSites) && Objects.equals(germplasmName, that.germplasmName) && Objects.equals(germplasmPUI, that.germplasmPUI) && Objects.equals(groupId, that.groupId) && Objects.equals(germplasmURI, that.germplasmURI) && Objects.equals(id, that.id) && Objects.equals(holdingInstitute, that.holdingInstitute) && Objects.equals(holdingGenbank, that.holdingGenbank) && Objects.equals(_id, that._id) && Objects.equals(instituteCode, that.instituteCode) && Objects.equals(instituteName, that.instituteName) && Objects.equals(mlsStatus, that.mlsStatus) && Objects.equals(originSite, that.originSite) && Objects.equals(panel, that.panel) && Objects.equals(pedigree, that.pedigree) && Objects.equals(photo, that.photo) && Objects.equals(population, that.population) && Objects.equals(presenceStatus, that.presenceStatus) && Objects.equals(remarks, that.remarks) && Objects.equals(schemaName, that.schemaName) && Objects.equals(schemaId, that.schemaId) && Objects.equals(schemaCatalog, that.schemaCatalog) && Objects.equals(seedSource, that.seedSource) && Objects.equals(sourceUri, that.sourceUri) && Objects.equals(species, that.species) && Objects.equals(speciesAuthority, that.speciesAuthority) && Objects.equals(storageTypeCodes, that.storageTypeCodes) && Objects.equals(studyDbIds, that.studyDbIds) && Objects.equals(studyURIs, that.studyURIs) && Objects.equals(subtaxa, that.subtaxa) && Objects.equals(subtaxaAuthority, that.subtaxaAuthority) && Objects.equals(subtaxon, that.subtaxon) && Objects.equals(subtaxonAuthority, that.subtaxonAuthority) && Objects.equals(synonyms, that.synonyms) && Objects.equals(taxonCommonNames, that.taxonCommonNames) && Objects.equals(typeOfGermplasmStorageCode, that.typeOfGermplasmStorageCode) && Objects.equals(type, that.type); + return Objects.equals(accessionNames, that.accessionNames) && Objects.equals(accessionNumber, that.accessionNumber) && Objects.equals(acquisitionDate, that.acquisitionDate) && Objects.equals(acquisitionSourceCode, that.acquisitionSourceCode) && Objects.equals(alternateIDs, that.alternateIDs) && Objects.equals(ancestralData, that.ancestralData) && Objects.equals(biologicalStatusOfAccessionCode, that.biologicalStatusOfAccessionCode) && Objects.equals(breeder, that.breeder) && Objects.equals(children, that.children) && Objects.equals(collectingSite, that.collectingSite) && Objects.equals(collection, that.collection) && Objects.equals(collector, that.collector) && Objects.equals(commonCropName, that.commonCropName) && Objects.equals(countryOfOriginCode, that.countryOfOriginCode) && Objects.equals(distributors, that.distributors) && Objects.equals(defaultDisplayName, that.defaultDisplayName) && Objects.equals(url, that.url) && Objects.equals(documentationURL, that.documentationURL) && Objects.equals(donors, that.donors) && Objects.equals(evaluationSites, that.evaluationSites) && Objects.equals(genus, that.genus) && Objects.equals(genusSpecies, that.genusSpecies) && Objects.equals(genusSpeciesSubtaxa, that.genusSpeciesSubtaxa) && Objects.equals(germplasmDbId, that.germplasmDbId) && Objects.equals(germplasmName, that.germplasmName) && Objects.equals(germplasmPUI, that.germplasmPUI) && Objects.equals(groupId, that.groupId) && Objects.equals(germplasmURI, that.germplasmURI) && Objects.equals(id, that.id) && Objects.equals(holdingInstitute, that.holdingInstitute) && Objects.equals(holdingGenbank, that.holdingGenbank) && Objects.equals(_id, that._id) && Objects.equals(instituteCode, that.instituteCode) && Objects.equals(instituteName, that.instituteName) && Objects.equals(mlsStatus, that.mlsStatus) && Objects.equals(originSite, that.originSite) && Objects.equals(panel, that.panel) && Objects.equals(pedigree, that.pedigree) && Objects.equals(photo, that.photo) && Objects.equals(population, that.population) && Objects.equals(presenceStatus, that.presenceStatus) && Objects.equals(remarks, that.remarks) && Objects.equals(schemaName, that.schemaName) && Objects.equals(schemaId, that.schemaId) && Objects.equals(schemaCatalog, that.schemaCatalog) && Objects.equals(seedSource, that.seedSource) && Objects.equals(sourceUri, that.sourceUri) && Objects.equals(species, that.species) && Objects.equals(speciesAuthority, that.speciesAuthority) && Objects.equals(storageTypeCodes, that.storageTypeCodes) && Objects.equals(studyDbIds, that.studyDbIds) && Objects.equals(studyURIs, that.studyURIs) && Objects.equals(subtaxa, that.subtaxa) && Objects.equals(subtaxaAuthority, that.subtaxaAuthority) && Objects.equals(subtaxon, that.subtaxon) && Objects.equals(taxonIds, that.taxonIds) && Objects.equals(subtaxonAuthority, that.subtaxonAuthority) && Objects.equals(synonyms, that.synonyms) && Objects.equals(taxonCommonNames, that.taxonCommonNames) && Objects.equals(typeOfGermplasmStorageCode, that.typeOfGermplasmStorageCode) && Objects.equals(taxonComment, that.taxonComment) && Objects.equals(taxonSynonyms, that.taxonSynonyms) && Objects.equals(geneticNature, that.geneticNature) && Objects.equals(comment, that.comment) && Objects.equals(type, that.type); + } + + @Override + public int hashCode() { + return Objects.hash(accessionNames, accessionNumber, acquisitionDate, acquisitionSourceCode, alternateIDs, ancestralData, biologicalStatusOfAccessionCode, breeder, children, collectingSite, collection, collector, commonCropName, countryOfOriginCode, distributors, defaultDisplayName, url, documentationURL, donors, evaluationSites, genus, genusSpecies, genusSpeciesSubtaxa, germplasmDbId, germplasmName, germplasmPUI, groupId, germplasmURI, id, holdingInstitute, holdingGenbank, _id, instituteCode, instituteName, mlsStatus, originSite, panel, pedigree, photo, population, presenceStatus, remarks, schemaName, schemaId, schemaCatalog, seedSource, sourceUri, species, speciesAuthority, storageTypeCodes, studyDbIds, studyURIs, subtaxa, subtaxaAuthority, subtaxon, taxonIds, subtaxonAuthority, synonyms, taxonCommonNames, typeOfGermplasmStorageCode, taxonComment, taxonSynonyms, geneticNature, comment, type); + } + + public String getComment() { + return comment; + } + + public void setComment(String comment) { + this.comment = comment; + } + + public String getGeneticNature() { + return geneticNature; + } + + public void setGeneticNature(String geneticNature) { + this.geneticNature = geneticNature; + } + + public List<String> getTaxonSynonyms() { + return taxonSynonyms; + } + + public void setTaxonSynonyms(List<String> taxonSynonyms) { + this.taxonSynonyms = taxonSynonyms; + } + + public String getTaxonComment() { + return taxonComment; + } + + public void setTaxonComment(String taxonComment) { + this.taxonComment = taxonComment; + } + + public List<TaxonSourceVO> getTaxonIds() { + return taxonIds; + } + + public void setTaxonIds(List<TaxonSourceVO> taxonIds) { + this.taxonIds = taxonIds; } public List<String> getAccessionNames() { @@ -236,6 +295,14 @@ public final class GermplasmV1VO { this.documentationURL = documentationURL; } + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + public List<DonorVO> getDonors() { return donors; } @@ -316,8 +383,6 @@ public final class GermplasmV1VO { this.groupId = groupId; } - //private List<TaxonSource> taxonIds; TODO activate Taxonsource OK - public InstituteVO getHoldingGenbank() { return holdingGenbank; } @@ -566,11 +631,6 @@ public final class GermplasmV1VO { this.typeOfGermplasmStorageCode = typeOfGermplasmStorageCode; } - @Override - public int hashCode() { - return Objects.hash(accessionNames, accessionNumber, acquisitionDate, acquisitionSourceCode, alternateIDs, ancestralData, biologicalStatusOfAccessionCode, collection, commonCropName, countryOfOriginCode, defaultDisplayName, documentationURL, genus, genusSpecies, genusSpeciesSubtaxa, germplasmDbId, donors, evaluationSites, germplasmName, germplasmPUI, groupId, germplasmURI, id, holdingInstitute, holdingGenbank, _id, instituteCode, instituteName, mlsStatus, originSite, panel, pedigree, photo, population, presenceStatus, remarks, schemaName, schemaId, schemaCatalog, seedSource, sourceUri, species, speciesAuthority, storageTypeCodes, studyDbIds, studyURIs, subtaxa, subtaxaAuthority, subtaxon, subtaxonAuthority, synonyms, taxonCommonNames, typeOfGermplasmStorageCode, type); - } - @Override public String toString() { return "GermplasmV1VO{" + @@ -581,17 +641,23 @@ public final class GermplasmV1VO { ", alternateIDs=" + alternateIDs + ", ancestralData='" + ancestralData + '\'' + ", biologicalStatusOfAccessionCode='" + biologicalStatusOfAccessionCode + '\'' + + ", breeder=" + breeder + + ", children=" + children + + ", collectingSite=" + collectingSite + ", collection=" + collection + + ", collector=" + collector + ", commonCropName='" + commonCropName + '\'' + ", countryOfOriginCode='" + countryOfOriginCode + '\'' + + ", distributors=" + distributors + ", defaultDisplayName='" + defaultDisplayName + '\'' + + ", url='" + url + '\'' + ", documentationURL='" + documentationURL + '\'' + + ", donors=" + donors + + ", evaluationSites=" + evaluationSites + ", genus='" + genus + '\'' + ", genusSpecies='" + genusSpecies + '\'' + ", genusSpeciesSubtaxa='" + genusSpeciesSubtaxa + '\'' + ", germplasmDbId='" + germplasmDbId + '\'' + - ", donors=" + donors + - ", evaluationSites=" + evaluationSites + ", germplasmName='" + germplasmName + '\'' + ", germplasmPUI='" + germplasmPUI + '\'' + ", groupId=" + groupId + @@ -614,6 +680,7 @@ public final class GermplasmV1VO { ", schemaId='" + schemaId + '\'' + ", schemaCatalog='" + schemaCatalog + '\'' + ", seedSource='" + seedSource + '\'' + + ", sourceUri='" + sourceUri + '\'' + ", species='" + species + '\'' + ", speciesAuthority='" + speciesAuthority + '\'' + ", storageTypeCodes=" + storageTypeCodes + @@ -622,10 +689,15 @@ public final class GermplasmV1VO { ", subtaxa='" + subtaxa + '\'' + ", subtaxaAuthority='" + subtaxaAuthority + '\'' + ", subtaxon='" + subtaxon + '\'' + + ", taxonIds=" + taxonIds + ", subtaxonAuthority='" + subtaxonAuthority + '\'' + ", synonyms=" + synonyms + ", taxonCommonNames=" + taxonCommonNames + ", typeOfGermplasmStorageCode=" + typeOfGermplasmStorageCode + + ", taxonComment='" + taxonComment + '\'' + + ", taxonSynonyms=" + taxonSynonyms + + ", geneticNature='" + geneticNature + '\'' + + ", comment='" + comment + '\'' + ", type='" + type + '\'' + '}'; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1VO.java index 19719422a7bb4ce949fc1ce4dea0398accecba06..5cb0d4740143b6c1c07776dc5953a6073c2219f9 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1VO.java @@ -1,21 +1,25 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.*; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; +import java.time.LocalDate; import java.util.List; import java.util.Set; +@Import({ElasticSearchConfig.class}) @Document( - indexName = StudyV1VO.INDEX_NAME, - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('study', 0L)}", + createIndex = false ) public final class StudyV1VO { - public static final String INDEX_NAME = "faidare_study_dev-group0"; + //public static final String INDEX_NAME = "faidare_study_dev-group0"; private boolean active; @@ -23,7 +27,7 @@ public final class StudyV1VO { private String commonCropName; - private List<ContactVO> contact; + private List<ContactVO> contacts; private String culturalPractices; @@ -31,7 +35,7 @@ public final class StudyV1VO { private String documentationURL; - private String endDate; + private LocalDate endDate; private List<EnvironmentParametersVO> environmentParameters; @@ -70,7 +74,7 @@ public final class StudyV1VO { @Field("schema:includedInDataCatalog") private String sourceUri; - private String startDate; + private LocalDate startDate; private String studyCode; @@ -84,6 +88,15 @@ public final class StudyV1VO { private String trialDbId; private Set<String> trialsDbIds; private String trialName; + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } public String getCommonCropName() { return commonCropName; @@ -93,12 +106,12 @@ public final class StudyV1VO { this.commonCropName = commonCropName; } - public List<ContactVO> getContact() { - return contact; + public List<ContactVO> getContacts() { + return contacts; } - public void setContact(List<ContactVO> contact) { - this.contact = contact; + public void setContacts(List<ContactVO> contacts) { + this.contacts = contacts; } public String getCulturalPractices() { @@ -125,9 +138,9 @@ public final class StudyV1VO { this.documentationURL = documentationURL; } - public String getEndDate() { return endDate; } + public LocalDate getEndDate() { return endDate; } - public void setEndDate(String endDate) { this.endDate = endDate; } + public void setEndDate(LocalDate endDate) { this.endDate = endDate; } public List<EnvironmentParametersVO> getEnvironmentParameters() { return environmentParameters; @@ -261,11 +274,11 @@ public final class StudyV1VO { this.sourceUri = sourceUri; } - public String getStartDate() { + public LocalDate getStartDate() { return startDate; } - public void setStartDate(String startDate) { + public void setStartDate(LocalDate startDate) { this.startDate = startDate; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1miniVO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1miniVO.java index 391f6ac6571685aacd9ce62e039900f725084436..5449017af2cef0042f76a1da06a45f66f3975672 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1miniVO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/StudyV1miniVO.java @@ -1,15 +1,17 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import java.util.Objects; +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_study_dev-group0", - //indexName = "faidare_study_beta-group0", - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('study', 0L)}", + createIndex = false ) public final class StudyV1miniVO { diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/TrialV1VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/TrialV1VO.java index fb0a6eacc75ed94f31656ef7f29a1dfd1b35c423..25b724ec2f730b2aa254a7578bcd8295354225c6 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/TrialV1VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v1/TrialV1VO.java @@ -1,6 +1,8 @@ package fr.inrae.urgi.faidare.domain.brapi.v1; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.ContactVO; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; @@ -8,10 +10,10 @@ import org.springframework.data.elasticsearch.annotations.Field; import java.util.List; import java.util.Objects; +@Import({ElasticSearchConfig.class}) @Document( - indexName = "faidare_trial_dev-group0", - //indexName = "faidare_trial_beta-group0", - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('trial', 0L)}", + createIndex = false ) public class TrialV1VO { diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/GermplasmV2VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/GermplasmV2VO.java index a5ee13a15481884da85fdec1352f0aaf9ec7ae2e..b8c1f7d863b462b21a670ce2ce3f50f4136dcbb0 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/GermplasmV2VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/GermplasmV2VO.java @@ -1,20 +1,28 @@ package fr.inrae.urgi.faidare.domain.brapi.v2; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.config.FaidareProperties; import fr.inrae.urgi.faidare.domain.*; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; +import org.springframework.data.elasticsearch.annotations.FieldType; import java.util.List; import java.util.Objects; +//@Import({FaidareProperties.class}) + +@Import({ElasticSearchConfig.class}) @Document( - indexName = GermplasmV2VO.INDEX_NAME, + indexName = "#{@faidarePropertiesBean.getAliasName('germplasm', 0L)}", createIndex = false ) public class GermplasmV2VO { - public static final String INDEX_NAME = "faidare_germplasm_dev-group0"; + + //public static final String INDEX_NAME = "faidare_germplasm_dev-group0"; private String accessionNumber; @@ -33,7 +41,7 @@ public class GermplasmV2VO { private String breedingMethodName; private List<GenealogyVO> children; // GnpIS - + @Field(name = "originSite") private SiteVO collectingSite; //GnpIS private List<CollPopVO> collection; @@ -49,7 +57,7 @@ public class GermplasmV2VO { private String defaultDisplayName; private List<PuiNameValueVO> descriptors; //GnpIS - + @Field(name = "distributors") private List<GermplasmInstituteVO> distributors; //GnpIS private String documentationURL; @@ -124,7 +132,8 @@ public class GermplasmV2VO { private String subtaxaAuthority; - private List<String> synonyms; + @Field(name = "synonymsV2" ,type = FieldType.Nested) + private List<SynonymsVO> synonyms; private String taxonComment; //GnpIS @@ -543,11 +552,11 @@ public class GermplasmV2VO { this.subtaxaAuthority = subtaxaAuthority; } - public List<String> getSynonyms() { + public List<SynonymsVO> getSynonyms() { return synonyms; } - public void setSynonyms(List<String> synonyms) { + public void setSynonyms(List<SynonymsVO> synonyms) { this.synonyms = synonyms; } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/StudyV2VO.java b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/StudyV2VO.java index 9e0e490fa7e7ea23ef5d853dd46ba3c2ebf4f65a..1c9bb7745fa31847f40ce8623aed37020f62518e 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/StudyV2VO.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/domain/brapi/v2/StudyV2VO.java @@ -1,6 +1,8 @@ package fr.inrae.urgi.faidare.domain.brapi.v2; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; import fr.inrae.urgi.faidare.domain.*; +import org.springframework.context.annotation.Import; import org.springframework.data.annotation.Id; import org.springframework.data.elasticsearch.annotations.Document; import org.springframework.data.elasticsearch.annotations.Field; @@ -8,14 +10,14 @@ import org.springframework.data.elasticsearch.annotations.Field; import java.util.List; import java.util.Set; - +@Import({ElasticSearchConfig.class}) @Document( - indexName = StudyV2VO.INDEX_NAME, - createIndex = false + indexName = "#{@faidarePropertiesBean.getAliasName('study', 0L)}", + createIndex = false ) public final class StudyV2VO { - public static final String INDEX_NAME = "faidare_study_dev-group0"; + //public static final String INDEX_NAME = "faidare_study_dev-group0"; private boolean active; diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyController.java b/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyController.java index 32b8cd8db3a1394fabfb18c0d611058b8e4c08bf..22aa1046a52797ce2f7d8c148423a84c76dc4791 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyController.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyController.java @@ -88,7 +88,8 @@ public class StudyController { variables, trials, crossReferences, - location + location, + study.getUrl() ) ); } diff --git a/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyModel.java b/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyModel.java index e2f81a6b4b2780d834ddf5fcc549819dc652c09a..649bca7533a0b778789e9491342e16b8f27b8c7f 100644 --- a/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyModel.java +++ b/backend/src/main/java/fr/inrae/urgi/faidare/web/study/StudyModel.java @@ -29,6 +29,7 @@ public final class StudyModel { private final List<XRefDocumentVO> crossReferences; private final LocationVO location; private final List<Map.Entry<String, Object>> additionalInfoProperties; + private final String url; public StudyModel(StudyV1VO study, DataSource source, @@ -36,7 +37,8 @@ public final class StudyModel { List<ObservationVariableVO> variables, List<TrialV1VO> trials, List<XRefDocumentVO> crossReferences, - LocationVO location) { + LocationVO location, + String url) { this.study = study; this.source = source; this.germplasms = germplasms; @@ -44,6 +46,7 @@ public final class StudyModel { this.trials = trials; this.crossReferences = crossReferences; this.location = location; + this.url = url; // FIXME JBN uncomment this once study has additionalInfo // Map<String, Object> additionalInfo = @@ -81,6 +84,8 @@ public final class StudyModel { return trials; } + public String getUrl() { return url;} + public List<Map.Entry<String, Object>> getAdditionalInfoProperties() { return additionalInfoProperties; } diff --git a/backend/src/main/resources/calls.json b/backend/src/main/resources/calls.json new file mode 100644 index 0000000000000000000000000000000000000000..99c98acd2c1b3d68894c413ed7cfa9f8e63c838b --- /dev/null +++ b/backend/src/main/resources/calls.json @@ -0,0 +1,38 @@ +{ + "@context": [ + "https://brapi.org/jsonld/context/metadata.jsonld" + ], + "metadata": { + "datafiles": [], + "pagination": { + "currentPage": 0, + "pageSize": 1000, + "totalCount": 10, + "totalPages": 1 + }, + "status": [ + ] + }, + "result": { + "data": [ + { + "call": "allelematrices", + "dataTypes": [ + "application/json" + ], + "datatypes": [ + "application/json" + ], + "methods": [ + "GET" + ], + "versions": [ + "1.0", + "1.1", + "1.2", + "1.3" + ] + } + ] + } +} \ No newline at end of file diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/README.md b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/README.md new file mode 100644 index 0000000000000000000000000000000000000000..2f9592423d8b02ed41e5886235efb687c16ad346 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/README.md @@ -0,0 +1,10 @@ +This directory contains document mappings and index settings for FAIDARE Elasticsearch documents. + + +# Custom analyzers + +In the `settings.json` file, a custom analyzer is defined to index completion suggestion. + +The `index_suggester` is composed of a custom tokenizer named `special_tokenizer` and which uses a RegExp pattern to list all characters used to split tokens. The split characters includes: spaces, comas, dashes (low and high), parentheses (open and close), brackets (open and close) and curly brackets (open and close). The `index_suggester` is also composed of filters including the standard filter, the lowercase filter, the ascii folding filter and a NGram filter (with minimum of 1 and maximum of 20 characters starting on the front of a token). + +The `search_suggester` is the same as `index_suggester` but without the NGram filter. diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/datadiscovery_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/datadiscovery_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..a6f320ff698518aa6f70a01b94b5c851dde26f49 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/datadiscovery_mapping.json @@ -0,0 +1,92 @@ +{ + "dynamic": false, + "_source": { + "includes": [ + "@id", + "@type", + "schema:*", + "groupId" + ] + }, + "properties": { + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + }, + "schema:description": { + "type": "keyword" + }, + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "studyURIs": { + "type": "keyword" + }, + "studyDbIds": { + "type": "keyword" + }, + "germplasm": { + "type": "object", + "properties": { + "cropName": { + "type": "keyword", + "fields": { + "suggest": { + "type": "text", + "search_analyzer": "search_suggester", + "analyzer": "index_suggester" + } + } + }, + "germplasmList": { + "type": "keyword", + "fields": { + "suggest": { + "type": "text", + "search_analyzer": "search_suggester", + "analyzer": "index_suggester" + } + } + }, + "accession": { + "type": "keyword", + "fields": { + "suggest": { + "type": "text", + "search_analyzer": "search_suggester", + "analyzer": "index_suggester" + } + } + } + } + }, + "trait": { + "type": "object", + "properties": { + "observationVariableIds": { + "type": "keyword" + } + } + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmAttribute_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmAttribute_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..9b4883f83f4c94d02b7f06a09f9121731cd665d0 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmAttribute_mapping.json @@ -0,0 +1,65 @@ +{ + "dynamic": false, + "properties": { + "germplasmAttributeURI": { + "type": "keyword" + }, + "germplasmAttributeDbId": { + "type": "keyword" + }, + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "data": { + "type": "nested", + "properties": { + "attributeURI": { + "type": "keyword" + }, + "attributeDbId": { + "type": "keyword" + }, + "attributeCode": { + "type": "keyword" + }, + "attributeName": { + "type": "keyword" + }, + "determinedDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "value": { + "type": "keyword" + } + } + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmMcpd_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmMcpd_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..acface400a728cde1de8daf376b67e66ff4c1f31 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmMcpd_mapping.json @@ -0,0 +1,450 @@ +{ + "dynamic": false, + "properties": { + "germplasmURI": { + "type": "keyword" + }, + "germplasmName": { + "type": "keyword", + "doc_values": true + }, + "accessionNames": { + "type": "keyword", + "doc_values": true + }, + "accessionNumber": { + "type": "keyword", + "doc_values": true + }, + "acquisitionDate": { + "type": "integer" + }, + "acquisitionSourceCode": { + "type": "keyword" + }, + "alternateIDs": { + "type": "keyword" + }, + "ancestralData": { + "type": "keyword" + }, + "biologicalStatusOfAccessionCode": { + "type": "keyword" + }, + "breedingInstitutes": { + "properties": { + "instituteCode": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "breedingMethodDbId": { + "type": "keyword" + }, + "breederAccessionNumber": { + "type": "keyword" + }, + "breedingCreationYear": { + "type": "keyword" + }, + "catalogRegistrationYear": { + "type": "keyword" + }, + "catalogDeregistrationYear": { + "type": "keyword" + }, + "collectingInfo": { + "properties": { + "collectingDate": { + "type": "integer" + }, + "collectingInstitutes": { + "properties": { + "instituteCode": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "collectingMissionIdentifier": { + "type": "keyword" + }, + "collectingNumber": { + "type": "keyword" + }, + "collectors": { + "type": "keyword" + }, + "materialType": { + "type": "keyword" + }, + "collectingSite": { + "properties": { + "locationDbId": { + "type": "keyword" + }, + "locationName": { + "type": "keyword" + }, + "coordinateUncertainty": { + "type": "keyword" + }, + "elevation": { + "type": "keyword" + }, + "georeferencingMethod": { + "type": "keyword" + }, + "latitudeDecimal": { + "type": "keyword" + }, + "latitudeDegrees": { + "type": "keyword" + }, + "locationDescription": { + "type": "keyword" + }, + "longitudeDecimal": { + "type": "keyword" + }, + "longitudeDegrees": { + "type": "keyword" + }, + "spatialReferenceSystem": { + "type": "keyword" + }, + "locationURI": { + "type": "keyword" + } + } + } + } + }, + "commonCropName": { + "type": "keyword", + "doc_values": true + }, + "countryOfOrigin": { + "type": "keyword" + }, + "countryOfOriginCode": { + "type": "keyword" + }, + "originLocationDbId": { + "type": "keyword" + }, + "originLocationName": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "donors": { + "properties": { + "donorInstituteCode": { + "type": "keyword" + }, + "donorGermplasmPUI": { + "type": "keyword" + }, + "germplasmPUI": { + "type": "keyword" + }, + "donorAccessionNumber": { + "type": "keyword" + }, + "donorInstitute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "donationDate": { + "type": "integer" + } + } + }, + "donorInfo": { + "properties": { + "donorAccessionNumber": { + "type": "keyword" + }, + "donorAccessionPui": { + "type": "keyword" + }, + "donationDate": { + "type": "keyword" + }, + "donorInstitute": { + "properties": { + "instituteCode": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + } + } + }, + "genus": { + "type": "keyword", + "doc_values": true + }, + "genusSpecies": { + "type": "keyword", + "doc_values": true + }, + "germplasmDbId": { + "type": "keyword" + }, + "germplasmMcpdDbId": { + "type": "keyword" + }, + "germplasmMcpdURI": { + "type": "keyword" + }, + "germplasmGenus": { + "type": "keyword", + "doc_values": true + }, + "germplasmPUI": { + "type": "keyword" + }, + "germplasmSpecies": { + "type": "keyword", + "doc_values": true + }, + "holdingInstitute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "holdingGenbank": { + "properties": { + "instituteName": { + "type": "keyword", + "doc_values": true + }, + "instituteCode": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "distributorInfos": { + "properties": { + "institute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "accessionNumber": { + "type": "keyword" + }, + "distributionStatus": { + "type": "keyword" + } + } + }, + "instituteCode": { + "type": "keyword" + }, + "mlsStatus": { + "type": "keyword" + }, + "remarks": { + "type": "keyword" + }, + "safetyDuplicateInstitutes": { + "properties": { + "instituteCode": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + } + } + }, + "geneticNature": { + "type": "keyword" + }, + "species": { + "type": "keyword" + }, + "speciesAuthority": { + "type": "keyword" + }, + "storageTypeCodes": { + "type": "keyword" + }, + "subtaxon": { + "type": "keyword" + }, + "subtaxonAuthority": { + "type": "keyword" + }, + "subtaxaAuthority": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "presenceStatus": { + "type": "keyword" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmPedigree_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmPedigree_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..7e078c2d4e0e526881f682a03975d304a996dfe8 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmPedigree_mapping.json @@ -0,0 +1,93 @@ +{ + "dynamic": false, + "properties": { + "germplasmPedigreeURI": { + "type": "keyword" + }, + "germplasmPedigreeDbId": { + "type": "keyword" + }, + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + }, + "crossingPlan": { + "type": "keyword" + }, + "crossingYear": { + "type": "keyword" + }, + "familyCode": { + "type": "keyword" + }, + "parent1URI": { + "type": "keyword" + }, + "parent1DbId": { + "type": "keyword" + }, + "parent1Name": { + "type": "keyword" + }, + "parent1Type": { + "type": "keyword" + }, + "parent2URI": { + "type": "keyword" + }, + "parent2DbId": { + "type": "keyword" + }, + "parent2Name": { + "type": "keyword" + }, + "parent2Type": { + "type": "keyword" + }, + "pedigree": { + "type": "keyword" + }, + "siblings": { + "properties": { + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + } + } + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmProgeny_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmProgeny_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..cdc87f416d0d1bd204b311cca3327e01bb95aba6 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasmProgeny_mapping.json @@ -0,0 +1,60 @@ +{ + "dynamic": false, + "properties": { + "germplasmProgenyURI": { + "type": "keyword" + }, + "germplasmProgenyDbId": { + "type": "keyword" + }, + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + }, + "progeny": { + "properties": { + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + }, + "parentType": { + "type": "keyword" + } + } + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasm_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasm_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..9827e7d3104631ff2d642736d835921c1ec03a5f --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/germplasm_mapping.json @@ -0,0 +1,621 @@ +{ + "dynamic": false, + "properties": { + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "germplasmPUI": { + "type": "keyword" + }, + "germplasmName": { + "type": "keyword", + "doc_values": true + }, + "accessionNumber": { + "type": "keyword", + "doc_values": true + }, + "acquisitionDate": { + "type": "keyword" + }, + "biologicalStatusOfAccessionCode": { + "type": "keyword" + }, + "breedingMethodDbId": { + "type": "keyword" + }, + "commonCropName": { + "type": "keyword", + "doc_values": true + }, + "countryOfOriginCode": { + "type": "keyword" + }, + "countryOfOrigin": { + "type": "keyword" + }, + "defaultDisplayName": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "donors": { + "properties": { + "donorInstituteCode": { + "type": "keyword" + }, + "donorGermplasmPUI": { + "type": "keyword" + }, + "germplasmPUI": { + "type": "keyword" + }, + "donorAccessionNumber": { + "type": "keyword" + }, + "donorInstitute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "donationDate": { + "type": "integer" + } + } + }, + "genus": { + "type": "keyword", + "doc_values": true + }, + "germplasmGenus": { + "type": "keyword", + "doc_values": true + }, + "species": { + "type": "keyword" + }, + "germplasmSpecies": { + "type": "keyword", + "doc_values": true + }, + "genusSpecies": { + "type": "keyword", + "doc_values": true + }, + "speciesAuthority": { + "type": "keyword" + }, + "subtaxa": { + "type": "keyword" + }, + "subTaxa": { + "type": "keyword" + }, + "genusSpeciesSubtaxa": { + "type": "keyword", + "doc_values": true + }, + "subtaxaAuthority": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "pedigree": { + "type": "keyword" + }, + "seedSource": { + "type": "keyword" + }, + "SeedSource": { + "type": "keyword" + }, + "synonyms": { + "type": "keyword", + "doc_values": true + }, + "synonymsV2": { + "type": "nested", + "properties": { + "type": { "type": "keyword" }, + "synonym": { "type": "keyword" } + } + + }, + "taxonIds": { + "properties": { + "sourceName": { + "type": "keyword" + }, + "taxonId": { + "type": "keyword" + } + } + }, + "taxonSynonyms": { + "type": "keyword", + "doc_values": true + }, + "taxonCommonNames": { + "type": "keyword", + "doc_values": true + }, + "taxonComment": { + "type": "keyword" + }, + "typeOfGermplasmStorageCode": { + "type": "keyword" + }, + "geneticNature": { + "type": "keyword" + }, + "comment": { + "type": "keyword" + }, + "photo": { + "properties": { + "file": { + "type": "keyword" + }, + "thumbnailFile": { + "type": "keyword" + }, + "photoName": { + "type": "keyword" + }, + "description": { + "type": "keyword" + }, + "copyright": { + "type": "keyword" + } + } + }, + "holdingInstitute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "holdingGenbank": { + "properties": { + "instituteName": { + "type": "keyword", + "doc_values": true + }, + "instituteCode": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "presenceStatus": { + "type": "keyword" + }, + "genealogy": { + "properties": { + "crossingPlan": { + "type": "keyword" + }, + "crossingYear": { + "type": "keyword" + }, + "familyCode": { + "type": "keyword" + }, + "firstParentName": { + "type": "keyword" + }, + "firstParentPUI": { + "type": "keyword" + }, + "firstParentType": { + "type": "keyword" + }, + "secondParentName": { + "type": "keyword" + }, + "secondParentPUI": { + "type": "keyword" + }, + "secondParentType": { + "type": "keyword" + }, + "sibblings": { + "properties": { + "pui": { + "type": "keyword" + }, + "name": { + "type": "keyword" + } + } + } + } + }, + "children": { + "properties": { + "firstParentName": { + "type": "keyword" + }, + "firstParentPUI": { + "type": "keyword" + }, + "secondParentName": { + "type": "keyword" + }, + "secondParentPUI": { + "type": "keyword" + }, + "sibblings": { + "properties": { + "pui": { + "type": "keyword" + }, + "name": { + "type": "keyword" + } + } + } + } + }, + "descriptors": { + "properties": { + "name": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "originSite": { + "properties": { + "siteId": { + "type": "long" + }, + "siteName": { + "type": "keyword" + }, + "latitude": { + "type": "float" + }, + "longitude": { + "type": "float" + }, + "siteType": { + "type": "keyword" + } + } + }, + "collectingSite": { + "properties": { + "siteId": { + "type": "long" + }, + "siteName": { + "type": "keyword" + }, + "latitude": { + "type": "float" + }, + "longitude": { + "type": "float" + }, + "siteType": { + "type": "keyword" + } + } + }, + "evaluationSites": { + "properties": { + "siteId": { + "type": "long" + }, + "siteName": { + "type": "keyword" + }, + "latitude": { + "type": "float" + }, + "longitude": { + "type": "float" + }, + "siteType": { + "type": "keyword" + } + } + }, + "collector": { + "properties": { + "institute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "accessionNumber": { + "type": "keyword" + }, + "accessionCreationDate": { + "type": "integer" + }, + "materialType": { + "type": "keyword" + }, + "collectors": { + "type": "keyword" + } + } + }, + "breeder": { + "properties": { + "institute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "accessionNumber": { + "type": "keyword" + }, + "accessionCreationDate": { + "type": "integer" + }, + "registrationYear": { + "type": "integer" + }, + "deregistrationYear": { + "type": "integer" + } + } + }, + "distributors": { + "properties": { + "institute": { + "properties": { + "instituteName": { + "type": "keyword" + }, + "instituteCode": { + "type": "keyword" + }, + "acronym": { + "type": "keyword" + }, + "organisation": { + "type": "keyword" + }, + "instituteType": { + "type": "keyword" + }, + "webSite": { + "type": "keyword" + }, + "address": { + "type": "keyword" + }, + "logo": { + "type": "keyword" + } + } + }, + "accessionNumber": { + "type": "keyword" + }, + "distributionStatus": { + "type": "keyword" + } + } + }, + "panel": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword", + "doc_values": true + }, + "germplasmCount": { + "type": "integer" + } + } + }, + "collection": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword", + "doc_values": true + }, + "type": { + "type": "keyword" + }, + "germplasmCount": { + "type": "integer" + } + } + }, + "population": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword", + "doc_values": true + }, + "type": { + "type": "keyword" + }, + "germplasmRef": { + "properties": { + "pui": { + "type": "keyword" + }, + "name": { + "type": "keyword" + } + } + }, + "germplasmCount": { + "type": "integer" + } + } + }, + "xref": { + "properties": { + "id": { + "type": "keyword" + }, + "source": { + "type": "keyword" + } + } + }, + "additionalInfo": { + "dynamic": true, + "properties": {} + }, + "studyURIs": { + "type": "keyword" + }, + "studyDbIds": { + "type": "keyword" + }, + "studyURI": { + "type": "keyword" + }, + "studyDbId": { + "type": "keyword" + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/location_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/location_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..6944c53d0b3f276b57f57559d525d340809ae016 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/location_mapping.json @@ -0,0 +1,90 @@ +{ + "dynamic": false, + "properties": { + "locationURI": { + "type": "keyword" + }, + "locationDbId": { + "type": "keyword" + }, + "locationName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "abbreviation": { + "type": "keyword" + }, + "abreviation": { + "type": "keyword" + }, + "locationType": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "countryCode": { + "type": "keyword" + }, + "countryName": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "instituteAdress": { + "type": "keyword" + }, + "altitude": { + "type": "double" + }, + "latitude": { + "type": "double" + }, + "longitude": { + "type": "double" + }, + "additionalInfo": { + "dynamic": true, + "properties": {} + }, + "studyDbIds": { + "type": "keyword" + }, + "studyURIs": { + "type": "keyword" + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/observationUnit_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/observationUnit_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..8023c6a523f0f13876e73b52903456efb83fb8fd --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/observationUnit_mapping.json @@ -0,0 +1,241 @@ +{ + "dynamic": "false", + "properties": { + "observationUnitURI": { + "type": "keyword" + }, + "observationUnitDbId": { + "type": "keyword" + }, + "observationUnitName": { + "type": "keyword" + }, + "X": { + "type": "keyword" + }, + "Y": { + "type": "keyword" + }, + "Xname": { + "type": "keyword" + }, + "Yname": { + "type": "keyword" + }, + "Xm": { + "type": "keyword" + }, + "Ym": { + "type": "keyword" + }, + "blockNumber": { + "type": "keyword", + "index": false + }, + "entryNumber": { + "type": "keyword", + "index": false + }, + "entryType": { + "type": "keyword", + "index": false + }, + "germplasmURI": { + "type": "keyword" + }, + "germplasmDbId": { + "type": "keyword" + }, + "germplasmPUI": { + "type": "keyword" + }, + "germplasmName": { + "type": "keyword" + }, + "accessionNumber": { + "type": "keyword" + }, + "observationLevel": { + "type": "keyword" + }, + "observationLevels": { + "type": "keyword" + }, + "observationLevelDetails": { + "properties": { + "type": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "observationUnitXref": { + "properties": { + "id": { + "type": "keyword" + }, + "source": { + "type": "keyword" + } + } + }, + "observations": { + "type": "nested", + "properties": { + "observationURI": { + "type": "keyword" + }, + "observationDbId": { + "type": "keyword" + }, + "collector": { + "type": "keyword", + "index": false + }, + "observationTimeStamp": { + "type": "date", + "format": "yyyy-MM-dd'T'HH:mm:ss'Z'" + }, + "gdd": { + "type": "float" + }, + "observationVariableURI": { + "type": "keyword" + }, + "observationVariableDbId": { + "type": "keyword" + }, + "observationVariableName": { + "type": "keyword" + }, + "specificName": { + "type": "keyword" + }, + "season": { + "type": "keyword" + }, + "value": { + "type": "keyword" + }, + "isDataFile": { + "type": "boolean", + "index": false + } + } + }, + "plantNumber": { + "type": "keyword", + "index": false + }, + "plotNumber": { + "type": "keyword", + "index": false + }, + "programURI": { + "type": "keyword" + }, + "programDbId": { + "type": "keyword" + }, + "programName": { + "type": "keyword" + }, + "replicate": { + "type": "keyword", + "index": false + }, + "studyURI": { + "type": "keyword" + }, + "studyDbId": { + "type": "keyword" + }, + "studyName": { + "type": "keyword" + }, + "studyLocationURI": { + "type": "keyword" + }, + "studyLocationDbId": { + "type": "keyword" + }, + "studyLocation": { + "type": "keyword" + }, + "treatments": { + "properties": { + "factor": { + "type": "keyword" + }, + "modality": { + "type": "keyword" + } + } + }, + "trials": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword" + } + } + }, + "taxonScientificName": { + "type": "keyword" + }, + "germplasmGenus": { + "type": "keyword" + }, + "germplasmCollections": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword" + } + } + }, + "germplasmPanels": { + "properties": { + "id": { + "type": "long" + }, + "name": { + "type": "keyword" + } + } + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/program_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/program_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..83b07c0d5a4430bccac85d382c37a8a363ab0b27 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/program_mapping.json @@ -0,0 +1,74 @@ +{ + "dynamic": false, + "properties": { + "programURI": { + "type": "keyword" + }, + "programDbId": { + "type": "keyword" + }, + "programName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "abbreviation": { + "type": "keyword" + }, + "commonCropName": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "leadPerson": { + "type": "keyword" + }, + "leadPersonDbId": { + "type": "keyword" + }, + "leadPersonName": { + "type": "keyword" + }, + "objective": { + "type": "keyword" + }, + "trialDbIds": { + "type": "keyword" + }, + "trialURIs": { + "type": "keyword" + }, + "studyDbIds": { + "type": "keyword" + }, + "studyURIs": { + "type": "keyword" + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..c4cef5da29524b7efab7d8a46edbd1a3f6cb3f2b --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json @@ -0,0 +1,40 @@ +{ + "index" : { + "max_inner_result_window": 10000 + }, + "analysis": { + "filter": { + "1-20-edgeNGram": { + "type": "edge_ngram", + "side": "front", + "min_gram": 1, + "max_gram": 20 + } + }, + "tokenizer": { + "special_tokenizer": { + "type": "pattern", + "pattern": "\\s|,|-|\\(|\\)|\\[|\\]|\\{|\\}|_" + } + }, + "analyzer": { + "search_suggester": { + "type": "custom", + "tokenizer": "special_tokenizer", + "filter": [ + "lowercase", + "asciifolding" + ] + }, + "index_suggester": { + "type": "custom", + "tokenizer": "special_tokenizer", + "filter": [ + "lowercase", + "asciifolding", + "1-20-edgeNGram" + ] + } + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/study_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/study_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..5acc5504f528e4c01b6ccf0299b4629e72e460c9 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/study_mapping.json @@ -0,0 +1,272 @@ +{ + "dynamic": false, + "properties": { + "studyURI": { + "type": "keyword" + }, + "studyDbId": { + "type": "keyword" + }, + "studyName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "active": { + "type": "boolean" + }, + "commonCropName": { + "type": "keyword" + }, + "cropDbId": { + "type": "keyword" + }, + "statisticalDesign": { + "dynamic": true, + "properties": {} + }, + "description": { + "type": "keyword" + }, + "organism": { + "type": "keyword" + }, + "contactURIs": { + "type": "keyword" + }, + "contactDbIds": { + "type": "keyword" + }, + "contacts": { + "properties": { + "contactURI": { + "type": "keyword" + }, + "contactDbId": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "email": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "orcid": { + "type": "keyword" + } + } + }, + "dataLinks": { + "properties": { + "dataLinkName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "url": { + "type": "keyword" + } + } + }, + "documentationURL": { + "type": "keyword" + }, + "startDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "endDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "year": { + "type": "keyword" + }, + "lastUpdate": { + "properties": { + "version": { + "type": "keyword" + }, + "timestamp": { + "type": "date", + "format": "yyyy-MM-dd||yyyy-MM-dd'T'HH:mm:ss'Z'" + } + } + }, + "license": { + "type": "keyword" + }, + "locationURIs": { + "type": "keyword" + }, + "locationDbIds": { + "type": "keyword" + }, + "locationURI": { + "type": "keyword" + }, + "locationDbId": { + "type": "keyword" + }, + "locationName": { + "type": "keyword" + }, + "location": { + "properties": { + "locationURI": { + "type": "keyword" + }, + "locationDbId": { + "type": "keyword" + }, + "locationName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "abbreviation": { + "type": "keyword" + }, + "abreviation": { + "type": "keyword" + }, + "locationType": { + "type": "keyword" + }, + "countryCode": { + "type": "keyword" + }, + "countryName": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "instituteAddress": { + "type": "keyword" + }, + "instituteAdress": { + "type": "keyword" + }, + "altitude": { + "type": "double" + }, + "latitude": { + "type": "double" + }, + "longitude": { + "type": "double" + }, + "additionalInfo": { + "dynamic": true, + "type": "object", + "properties": {} + } + } + }, + "programURIs": { + "type": "keyword" + }, + "programDbIds": { + "type": "keyword" + }, + "programURI": { + "type": "keyword" + }, + "programDbId": { + "type": "keyword" + }, + "programName": { + "type": "keyword" + }, + "seasons": { + "type": "keyword" + }, + "studyDescription": { + "type": "keyword" + }, + "studyTypeURI": { + "type": "keyword" + }, + "studyTypeDbId": { + "type": "keyword" + }, + "studyType": { + "type": "keyword" + }, + "studyTypeName": { + "type": "keyword" + }, + "trialURIs": { + "type": "keyword" + }, + "trialDbIds": { + "type": "keyword" + }, + "trialURI": { + "type": "keyword" + }, + "trialDbId": { + "type": "keyword" + }, + "trialName": { + "type": "keyword" + }, + "germplasmURIs": { + "type": "keyword" + }, + "germplasmDbIds": { + "type": "keyword" + }, + "observationVariableURIs": { + "type": "keyword" + }, + "observationVariableDbIds": { + "type": "keyword" + }, + "additionalInfo": { + "dynamic": true, + "type": "object", + "properties": {} + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/trial_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/trial_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..f433ebb70ad1fc00d769cbb9a637cfab6c6e2606 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/trial_mapping.json @@ -0,0 +1,357 @@ +{ + "dynamic": false, + "properties": { + "trialURI": { + "type": "keyword" + }, + "trialDbId": { + "type": "keyword" + }, + "trialName": { + "type": "keyword" + }, + "trialPUI": { + "type": "keyword" + }, + "trialType": { + "type": "keyword" + }, + "active": { + "type": "boolean" + }, + "commonCropName": { + "type": "keyword" + }, + "cropDbId": { + "type": "keyword" + }, + "trialDescription": { + "type": "keyword" + }, + "documentationURL": { + "type": "keyword" + }, + "startDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "endDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "publications": { + "properties": { + "publicationReference": { + "type": "keyword" + }, + "publicationPUI": { + "type": "keyword" + } + } + }, + "programURIs": { + "type": "keyword" + }, + "programDbIds": { + "type": "keyword" + }, + "programURI": { + "type": "keyword" + }, + "programDbId": { + "type": "keyword" + }, + "programName": { + "type": "keyword" + }, + "studyURIs": { + "type": "keyword" + }, + "studyDbIds": { + "type": "keyword" + }, + "studies": { + "properties": { + "studyURI": { + "type": "keyword" + }, + "studyDbId": { + "type": "keyword" + }, + "studyName": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "studyDescription": { + "type": "keyword" + }, + "description": { + "type": "keyword" + }, + "locationURI": { + "type": "keyword" + }, + "locationDbId": { + "type": "keyword" + }, + "locationName": { + "type": "keyword" + }, + "active": { + "type": "boolean" + }, + "commonCropName": { + "type": "keyword" + }, + "cropDbId": { + "type": "keyword" + }, + "contactURIs": { + "type": "keyword" + }, + "contactDbIds": { + "type": "keyword" + }, + "dataLinks": { + "properties": { + "name": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "url": { + "type": "keyword" + } + } + }, + "documentationURL": { + "type": "keyword" + }, + "startDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "endDate": { + "type": "date", + "format": "YYYY-MM-dd" + }, + "lastUpdate": { + "dynamic": true, + "properties": {} + }, + "license": { + "type": "keyword" + }, + "programURIs": { + "type": "keyword" + }, + "programDbIds": { + "type": "keyword" + }, + "programURI": { + "type": "keyword" + }, + "programDbId": { + "type": "keyword" + }, + "programName": { + "type": "keyword" + }, + "seasons": { + "dynamic": true, + "properties": {} + }, + "studyType": { + "type": "keyword" + }, + "studyTypeName": { + "type": "keyword" + }, + "trialURIs": { + "type": "keyword" + }, + "trialDbIds": { + "type": "keyword" + }, + "trialURI": { + "type": "keyword" + }, + "trialDbId": { + "type": "keyword" + }, + "trialName": { + "type": "keyword" + }, + "germplasmURIs": { + "type": "keyword" + }, + "germplasmDbIds": { + "type": "keyword" + }, + "observationVariableURIs": { + "type": "keyword" + }, + "observationVariableDbIds": { + "type": "keyword" + }, + "locationURIs": { + "type": "keyword" + }, + "locationDbIds": { + "type": "keyword" + }, + "additionalInfo": { + "dynamic": true, + "type": "object", + "properties": {} + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } + }, + "datasetAuthorship": { + "properties": { + "license": { + "type": "keyword" + }, + "datasetPUI": { + "type": "keyword" + } + } + }, + "datasetAuthorships": { + "properties": { + "license": { + "type": "keyword" + }, + "datasetPUI": { + "type": "keyword" + } + } + }, + "contactURIs": { + "type": "keyword" + }, + "contactDbIds": { + "type": "keyword" + }, + "contacts": { + "properties": { + "contactURI": { + "type": "keyword" + }, + "contactDbId": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "instituteName": { + "type": "keyword" + }, + "institutionName": { + "type": "keyword" + }, + "email": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "orcid": { + "type": "keyword" + }, + "studyURIs": { + "type": "keyword" + }, + "studyDbIds": { + "type": "keyword" + }, + "trialURIs": { + "type": "keyword" + }, + "trialDbIds": { + "type": "keyword" + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } + }, + "additionalInfo": { + "dynamic": true, + "type": "object", + "properties": {} + }, + "source": { + "type": "keyword" + }, + "groupId": { + "type": "long" + }, + "@type": { + "type": "keyword" + }, + "@id": { + "type": "keyword" + }, + "schema:includedInDataCatalog": { + "type": "keyword" + }, + "schema:identifier": { + "type": "keyword" + }, + "schema:name": { + "type": "keyword" + }, + "schema:url": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/xref_mapping.json b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/xref_mapping.json new file mode 100644 index 0000000000000000000000000000000000000000..f7a05def483a981c7de315ccc0ef7fe3c90f6835 --- /dev/null +++ b/backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/xref_mapping.json @@ -0,0 +1,11 @@ +{ + "dynamic": "true", + "properties": { + "entryType": { + "type": "keyword" + }, + "linkedResourcesID": { + "type": "keyword" + } + } +} diff --git a/backend/src/main/resources/serverinfo.json b/backend/src/main/resources/serverinfo.json new file mode 100644 index 0000000000000000000000000000000000000000..315c103e7e65be621ed24a9d591bc39e2a3dfb8c --- /dev/null +++ b/backend/src/main/resources/serverinfo.json @@ -0,0 +1,92 @@ +{ + "@context": [ + "https://brapi.org/jsonld/context/metadata.jsonld" + ], + "metadata": { + "datafiles": [], + "pagination": { + "currentPage": 0, + "pageSize": 1000, + "totalCount": 10, + "totalPages": 1 + }, + "status": [ + { + "message": "Request accepted, response successful", + "messageType": "INFO" + } + ] + }, + "result": { + "calls": [ + { + "contentTypes": [ + "application/json" + ], + "dataTypes": [ + "application/json" + ], + "methods": [ + "GET" + ], + "service": "germplasm/{germplasmDbId}", + "versions": [ + "2.0", + "2.1" + ] + },{ + "contentTypes": [ + "application/json" + ], + "dataTypes": [ + "application/json" + ], + "methods": [ + "GET" + ], + "service": "collection", + "versions": [ + "2.0", + "2.1" + ] + },{ + "contentTypes": [ + "application/json" + ], + "dataTypes": [ + "application/json" + ], + "methods": [ + "GET" + ], + "service": "germplasm", + "versions": [ + "2.0", + "2.1" + ] + },{ + "contentTypes": [ + "application/json" + ], + "dataTypes": [ + "application/json" + ], + "methods": [ + "POST" + ], + "service": "search/germplasm", + "versions": [ + "2.0", + "2.1" + ] + } + ], + "contactEmail": "contact@institute.org", + "documentationURL": "institute.org/server", + "location": "FRA", + "organizationName": "INRAE", + "organizationURL": "institute.org/home", + "serverDescription": "FAIDARE Server", + "serverName": "FAIDARE Server" + } +} \ No newline at end of file diff --git a/backend/src/main/resources/templates/germplasm.html b/backend/src/main/resources/templates/germplasm.html index b4a9f9b14363cc85396e97f342731d730b7f5493..e4fada526c0e218c2773aa816f66c72391d7a2b0 100644 --- a/backend/src/main/resources/templates/germplasm.html +++ b/backend/src/main/resources/templates/germplasm.html @@ -737,7 +737,7 @@ <script th:inline="javascript"> faidare.initializePopovers(); faidare.initializeMap({ - contextPath: [[${#request.getContextPath()}]], + contextPath: [[${contextPath}]], locations: [[${model.mapLocations}]] }); </script> diff --git a/backend/src/main/resources/templates/site.html b/backend/src/main/resources/templates/site.html index db6aac97d0c6550bb1fe71328540aff0a27df355..883ad39a670f0fff34925149debf9066e67528b0 100644 --- a/backend/src/main/resources/templates/site.html +++ b/backend/src/main/resources/templates/site.html @@ -125,7 +125,7 @@ <script th:inline="javascript"> faidare.initializeMap({ - contextPath: [[${model.getContextPath()}]], + contextPath: [[${contextPath}]], locations: [[${model.mapLocations}]] }); </script> diff --git a/backend/src/main/resources/templates/study.html b/backend/src/main/resources/templates/study.html index 72d2a2486fc91a64ce1b0cc71cf2974fc1c259d5..37075fcdd45eef5692183b34bc49b75d0eb316bd 100644 --- a/backend/src/main/resources/templates/study.html +++ b/backend/src/main/resources/templates/study.html @@ -63,7 +63,7 @@ th:if="${model.study.startDate != null && model.study.endDate == null}" > <div - th:replace="fragments/row::text-row(label='Date', text=${'Started on ' + #dates.format(model.study.startDate, 'yyyy-MM-dd')})" + th:replace="fragments/row::text-row(label='Date', text=${'Started on ' + #temporals.format(model.study.startDate, 'yyyy-MM-dd')})" ></div> </th:block> @@ -289,7 +289,7 @@ <script th:inline="javascript"> faidare.initializeMap({ - contextPath: [[${#request.getContextPath()}]], + contextPath: [[${contextPath}]], locations: [[${model.mapLocations}]] }); </script> diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v1/GermplasmV1ControllerTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v1/GermplasmV1ControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..34c27ae5e6808e4f7baf66aa412076f10ebb6181 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v1/GermplasmV1ControllerTest.java @@ -0,0 +1,342 @@ +package fr.inrae.urgi.faidare.api.brapi.v1; + +/** + * Unit tests for {@link GermplasmController} + * + * @author Cpommier + */ + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.jayway.jsonpath.JsonPath; +import fr.inrae.urgi.faidare.Application; +import org.json.JSONObject; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.*; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.ResourceUtils; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + + +@ExtendWith(SpringExtension.class) +@SpringBootTest(classes = Application.class, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class GermplasmV1ControllerTest { + + @Value("${server.servlet.context-path}") + private String contextPath; + + @LocalServerPort + private int port; + + TestRestTemplate testRestTemplate = new TestRestTemplate(); + HttpHeaders headers = new HttpHeaders(); + + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + contextPath + uri; + } + + //TODO: maybe move in a fixture class + //NB: onlyt part of the actual data are copied, especially for the site and panels .... + // Use LENIET JSONAssert + private String APACHE_GERMPLASM = """ + { + "genus": "Triticum", + "panel": [ + { + "id": 8, + "name": "SMALL_GRAIN_CEREALS_NETWORK_COL", + "germplasmCount": 1728 + }, + { + "id": 11, + "name": "BREEDWHEAT_PANEL", + "germplasmCount": 3047 + } + ], + "source": "INRAE-URGI", + "groupId": 0, + "species": "aestivum", + "subtaxa": "subsp. aestivum", + "mlsStatus": "0", + "collection": [ + { + "id": 128, + "name": "SMALL_GRAIN_CEREALS_NETWORK_COL", + "type": null, + "germplasmCount": 1410 + } + ], + "studyDbIds": [ + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0NsZXJtb250LUZlcnJhbmRfMjAxNF9TZXRCMg==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0NsZXJtb250LUZlcnJhbmRfMjAxNF9URUNI", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0NsZXJtb250LUZlcnJhbmRfMjAxNV9TZXRBMg==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0Rpam9uXzIwMTRfU2V0QjI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0Rpam9uXzIwMTRfVEVDSA==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0Rpam9uXzIwMTVfU2V0QTI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMTRfU2V0QjI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMTRfVEVDSA==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMTVfU2V0QTI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDE0X1NldEIy", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDE0X1RFQ0g=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDE1X1NldEEy", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0x1c2lnbmFuXzIwMTRfU2V0QjI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0x1c2lnbmFuXzIwMTRfVEVDSA==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0x1c2lnbmFuXzIwMTVfU2V0QTI=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX09yZ2V2YWxfMjAxNF9TZXRCMg==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX09yZ2V2YWxfMjAxNV9TZXRBMg==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX1Jlbm5lc18yMDE0X1NldEIy", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX1Jlbm5lc18yMDE0X1NldEIyX1BJRVRJTi1WRVJTRQ==", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX1Jlbm5lc18yMDE0X1RFQ0g=", + "dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX1Jlbm5lc18yMDE1X1NldEEy" + ], + "genusSpecies": "Triticum aestivum", + "germplasmPUI": "https://doi.org/10.15454/T1DLTW", + "germplasmDbId": "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzYxMDM5", + "germplasmName": "AO14022", + "instituteCode": "FRA040", + "instituteName": "GDEC - UMR Génétique, Diversité et Ecophysiologie des Céréales", + "accessionNames": [ + "AO14022" + ], + "commonCropName": "Wheat", + "accessionNumber": "AO14022", + "evaluationSites": [ + { + "siteId": 1994, + "latitude": 45.773, + "siteName": "Clermont-Ferrand", + "siteType": "Breeding and Evaluation site", + "longitude": 3.144 + }, + { + "siteId": 32824, + "latitude": 46.4, + "siteName": "Lusignan", + "siteType": "Breeding and Evaluation site", + "longitude": 0.07 + }, + { + "siteId": 33428, + "latitude": 49.87857, + "siteName": "Estrées-Mons", + "siteType": "Evaluation site", + "longitude": 3.007548 + }, + { + "siteId": 33818, + "latitude": 47.277, + "siteName": "Dijon", + "siteType": "Collecting and Evaluation site", + "longitude": 5.094 + }, + { + "siteId": 33985, + "latitude": 48.106, + "siteName": "Rennes", + "siteType": "Collecting and Evaluation site", + "longitude": -1.791 + }, + { + "siteId": 34064, + "latitude": 48.711, + "siteName": "Le Moulon", + "siteType": "Evaluation site", + "longitude": 2.16 + }, + { + "siteId": 34065, + "latitude": 48.838, + "siteName": "Orgeval", + "siteType": "Evaluation site", + "longitude": 1.953 + } + ], + "holdingInstitute": { + "acronym": "INRAE_UMR_GDEC", + "address": "5 Chemin de Beaulieu, 63039 CLERMONT-FERRAND Cedex 2, France", + "webSite": "https://www6.clermont.inrae.fr/umr1095", + "organisation": "INRAE", + "instituteCode": "FRA040", + "instituteName": "GDEC - UMR Génétique, Diversité et Ecophysiologie des Céréales", + "instituteType": "Public-sector research organization" + }, + "taxonCommonNames": [ + "Blé tendre", + "Bread wheat", + "Soft wheat" + ], + "defaultDisplayName": "AO14022", + "genusSpeciesSubtaxa": "Triticum aestivum subsp. aestivum", + "safetyDuplicateInstitutes": { + "instituteCode": "FRA040", + "instituteName": "GDEC - UMR Génétique, Diversité et Ecophysiologie des Céréales" + }, + "schema:identifier": "61039", + "germplasmURI": "urn:INRAE-URGI/germplasm/61039", + "studyURIs": [ + "urn:INRAE-URGI/study/BTH_Clermont-Ferrand_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Clermont-Ferrand_2014_TECH", + "urn:INRAE-URGI/study/BTH_Clermont-Ferrand_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Dijon_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Dijon_2014_TECH", + "urn:INRAE-URGI/study/BTH_Dijon_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Estr%C3%A9es-Mons_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Estr%C3%A9es-Mons_2014_TECH", + "urn:INRAE-URGI/study/BTH_Estr%C3%A9es-Mons_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Le_Moulon_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Le_Moulon_2014_TECH", + "urn:INRAE-URGI/study/BTH_Le_Moulon_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Lusignan_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Lusignan_2014_TECH", + "urn:INRAE-URGI/study/BTH_Lusignan_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Orgeval_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Orgeval_2015_SetA2", + "urn:INRAE-URGI/study/BTH_Rennes_2014_SetB2", + "urn:INRAE-URGI/study/BTH_Rennes_2014_SetB2_PIETIN-VERSE", + "urn:INRAE-URGI/study/BTH_Rennes_2014_TECH", + "urn:INRAE-URGI/study/BTH_Rennes_2015_SetA2" + ], + "node": "INRAE-URGI", + "databaseName": "brapi@INRAE-URGI", + "schema:includedInDataCatalog": "https://urgi.versailles.inrae.fr/gnpis", + "schema:name": "AO14022", + "@id": "urn:INRAE-URGI/germplasm/61039", + "@type": "germplasm" + } + """; + + @Test + void should_call_calls() throws Exception { + + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/calls"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode serverInfoFileJson = mapper.readTree(ResourceUtils.getFile("classpath:calls.json")); + JSONAssert.assertEquals( + serverInfoFileJson.toString(), + response.getBody(), false); + + + } + + + @Test + void should_get_germplasm_by_germplasmDbId() throws Exception { + + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/germplasm/dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI3ODA3"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.accessionNumber"); + assertThat(accNumber).isEqualTo("36785"); + } + +// @Test +// void should_get_germplasm_by_germplasmDbId_full_check() throws Exception { +// +// HttpEntity<String> entity = new HttpEntity<>(null, headers); +// +// ResponseEntity<String> response = testRestTemplate.exchange( +// createURLWithPort("/brapi/v1/germplasm/dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzYxMDM5"), +// HttpMethod.GET, entity, String.class); +// assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); +// String accNumber = JsonPath.parse(response.getBody()).read("$.result.accessionNumber"); +// assertThat(accNumber).isEqualTo("AO14022"); +// JSONObject actualgermplasmJson = new JSONObject(response.getBody()).getJSONObject("result"); +// +// assertThat(actualgermplasmJson).isNotNull(); +// +// JSONAssert.assertEquals(APACHE_GERMPLASM, actualgermplasmJson, JSONCompareMode.LENIENT); +// +// } + + /*@Test + void should_get_germplasm_by_accessionNumber_by_page_O_pageSize_1() throws Exception { + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/germplasm?accessionNumber=IRGC53931&page=0&pageSize=1"), + HttpMethod.GET, entity, String.class); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.data.[0].accessionNumber"); + assertThat(accNumber).isEqualTo("IRGC53931"); + Integer pageSize = JsonPath.parse(response.getBody()).read("$.metadata.pagination.pageSize"); + assertThat(pageSize).isEqualTo(1); + } + + + @Test + void should_get_germplasm_by_accessionNumber() throws Exception { + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/germplasm?accessionNumber=IRGC53931"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.data.[0].accessionNumber"); + assertThat(accNumber).isEqualTo("IRGC53931"); + }*/ + + @Test + void should_search_germplasm_by_dbids() throws URISyntaxException { + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(List.of(MediaType.APPLICATION_JSON)); + HttpEntity<String> entity = new HttpEntity<>("{\"germplasmDbIds\": [\"dXJuOklCRVQvYmU0ZTljZGMtNTgwMC00NDU3LWE2YzgtNDA1NjNjMDI3ZGQ5\"]}", headers); + + URI uri = new URI(createURLWithPort("/brapi/v2/search/germplasm")); + ResponseEntity<String> response = testRestTemplate.postForEntity(uri, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + } + + @Test + void should_get_all_germplasm_first_page(){ + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/germplasm"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + Integer pageSize = JsonPath.parse(response.getBody()).read("$.metadata.pagination.pageSize"); + assertThat(pageSize).isEqualTo(10); + Integer page = JsonPath.parse(response.getBody()).read("$.metadata.pagination.currentPage"); + assertThat(page).isEqualTo(0); + } + + @Test + void should_get_all_germplasm_2nd_page(){ + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v1/germplasm?page=1"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + Integer pageSize = JsonPath.parse(response.getBody()).read("$.metadata.pagination.pageSize"); + assertThat(pageSize).isEqualTo(10); + Integer page = JsonPath.parse(response.getBody()).read("$.metadata.pagination.currentPage"); + assertThat(page).isEqualTo(1); + } + + @Test + void germplasmAttribute() { + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v2/GermplasmV2ControllerTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v2/GermplasmV2ControllerTest.java new file mode 100644 index 0000000000000000000000000000000000000000..75b5945aceda699c5b08b708f752ee4b5c95fd1b --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/api/brapi/v2/GermplasmV2ControllerTest.java @@ -0,0 +1,149 @@ +package fr.inrae.urgi.faidare.api.brapi.v2; + +/** + * Unit tests for {@link GermplasmController} + * @author Cpommier + */ + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.jayway.jsonpath.JsonPath; +import fr.inrae.urgi.faidare.Application; +import fr.inrae.urgi.faidare.dao.v2.GermplasmV2Dao; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.skyscreamer.jsonassert.JSONAssert; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.*; +import org.springframework.test.context.junit.jupiter.SpringExtension; +import org.springframework.util.ResourceUtils; + +import java.net.URI; +import java.net.URISyntaxException; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + + +@ExtendWith(SpringExtension.class) +@SpringBootTest(classes = Application.class, + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +class GermplasmV2ControllerTest { + + + @Autowired + protected GermplasmV2Dao germplasmDao; + + @Value("${server.servlet.context-path}") + private String contextPath; + + + @LocalServerPort + private int port; + + TestRestTemplate testRestTemplate = new TestRestTemplate(); + HttpHeaders headers = new HttpHeaders(); + + + private String createURLWithPort(String uri) { + return "http://localhost:" + port + contextPath + uri; + } + + @Test + void should_call_serverinfo() throws Exception{ + + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v2/serverinfo"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode serverInfoFileJson = mapper.readTree(ResourceUtils.getFile("classpath:serverinfo.json")); + JSONAssert.assertEquals( + serverInfoFileJson.toString(), + response.getBody(), false); + + + } + + + + @Test + void should_get_germplasm_by_germplasmDbId() throws Exception { + + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v2/germplasm/dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODkx"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.accessionNumber"); + assertThat(accNumber).isEqualTo("29814"); + } + + + + @Test + void should_get_germplasm_by_accessionNumber_by_page_O_pageSize_1() throws Exception { + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v2/germplasm?accessionNumber=32100&page=0&pageSize=1"), + HttpMethod.GET, entity, String.class); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.data.[0].accessionNumber"); + assertThat(accNumber).isEqualTo("32100"); + Integer pageSize = JsonPath.parse(response.getBody()).read("$.metadata.pagination.pageSize"); + assertThat(pageSize).isEqualTo(1); + } + + + @Test + void should_get_germplasm_by_accessionNumber() throws Exception { + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v2/germplasm?accessionNumber=29814"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + String accNumber = JsonPath.parse(response.getBody()).read("$.result.data.[0].accessionNumber"); + assertThat(accNumber).isEqualTo("29814"); + } + + @Test + void should_search_germplasm_by_dbids() throws URISyntaxException { + headers.setContentType(MediaType.APPLICATION_JSON); + headers.setAccept(List.of(MediaType.APPLICATION_JSON)); + HttpEntity<String> entity = new HttpEntity<>("{\"germplasmDbIds\": [\"dXJuOklCRVQvYmU0ZTljZGMtNTgwMC00NDU3LWE2YzgtNDA1NjNjMDI3ZGQ5\"]}", headers); + + URI uri = new URI(createURLWithPort("/brapi/v2/search/germplasm")); + ResponseEntity<String> response = testRestTemplate.postForEntity(uri, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + } + + + + @Test + void germplasmAttribute() { + } + + @Test + void should_get_collection(){ + HttpEntity<String> entity = new HttpEntity<>(null, headers); + + ResponseEntity<String> response = testRestTemplate.exchange( + createURLWithPort("/brapi/v2/collection"), + HttpMethod.GET, entity, String.class); + assertThat(response.getStatusCode().is2xxSuccessful()).isTrue(); + String collName = JsonPath.parse(response.getBody()).read("$.result.data.[0].name"); + assertThat(collName).isEqualTo("Collection blé INRA"); + } + +} + + diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/ColPopV2DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/ColPopV2DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c48af575d9ab99b9ddf7017acc53c878743099ea --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/ColPopV2DaoTest.java @@ -0,0 +1,29 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.api.brapi.v2.BrapiListResponse; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v2.CollectionV2Dao; +import fr.inrae.urgi.faidare.domain.CollPopVO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; + +import static org.assertj.core.api.Assertions.assertThat; + +@Import({ElasticSearchConfig.class}) +@DataElasticsearchTest +public class ColPopV2DaoTest { + + @Autowired + protected CollectionV2Dao dao; + + @Test + public void should_get_all_CollPops(){ + BrapiListResponse<CollPopVO> response = dao.getAllCollections(); + assertThat(response).isNotNull(); + assertThat(response.getMetadata().getPagination().getTotalCount()).isGreaterThan(11); + assertThat(response.getResult().getData()).anyMatch(collPop -> collPop.getName().equals("SMALL_GRAIN_CEREALS_NETWORK_COL")); + + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmMcpdDaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmMcpdDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..d9fd525f1a961a326838416e820943bc71b10667 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmMcpdDaoTest.java @@ -0,0 +1,47 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.dao.v2.GermplasmMcpdDao; +import fr.inrae.urgi.faidare.domain.GermplasmMcpdVO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; + +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +class GermplasmMcpdDaoTest { + + @Autowired + protected GermplasmMcpdDao germplasmMcpdDao; + + + @Test + void getByPUID() { + GermplasmMcpdVO germplasmVo = + germplasmMcpdDao.getByPUID("https://doi.org/10.15454/4NCDUP"); + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo).isInstanceOf(GermplasmMcpdVO.class); + assertThat(germplasmVo.getAncestralData()).isNotNull(); + assertThat(germplasmVo.getAncestralData()).isEqualTo("RE99102"); + + } + + @Test + void getByGermplasmDbId() { + GermplasmMcpdVO germplasmVo = + germplasmMcpdDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo).isInstanceOf(GermplasmMcpdVO.class); + assertThat(germplasmVo.getAncestralData()).isNotNull(); + assertThat(germplasmVo.getAncestralData()).isEqualTo("RECITAL"); + } + + @Test + void findByGermplasmDbIdIn() { + List<GermplasmMcpdVO> list = germplasmMcpdDao.findByGermplasmDbIdIn(Set.of("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5", "not-existing")).toList(); + assertThat(list).extracting(GermplasmMcpdVO::getGermplasmDbId).containsOnly("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmPedigreeV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmPedigreeV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..4f76620679f07d4590d9ee8678519865ad4800b1 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmPedigreeV1DaoTest.java @@ -0,0 +1,115 @@ +package fr.inrae.urgi.faidare.dao; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import fr.inrae.urgi.faidare.dao.v1.GermplasmPedigreeV1Dao; +import fr.inrae.urgi.faidare.domain.brapi.v1.GermplasmPedigreeV1VO; +import org.json.JSONException; +import org.junit.jupiter.api.Test; +import org.skyscreamer.jsonassert.JSONAssert; +import org.skyscreamer.jsonassert.JSONCompareMode; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +public class GermplasmPedigreeV1DaoTest { + + @Autowired + protected GermplasmPedigreeV1Dao dao; + String expectedPedigreeFull = """ + { + "groupId" : 0, + "germplasmDbId" : "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0LzZHRlc4VQ==", + "defaultDisplayName" : "661300425", + "crossingPlan" : "Factorial", + "familyCode" : "0504B", + "parent1DbId" : "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L1NQQTBRSQ==", + "parent1Name" : "73028-62", + "parent1Type" : "FEMALE", + "parent2DbId" : "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L0cwT1NVQg==", + "parent2Name" : "101-74", + "parent2Type" : "MALE", + "siblings" : [ + { + "germplasmDbId" : "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L0ZaWDhLTw==", + "defaultDisplayName" : "661302619", + "germplasmURI" : "https://doi.org/10.15454/FZX8KO" + }, + { + "germplasmDbId" : "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L1hZREs0TA==", + "defaultDisplayName" : "661302686", + "germplasmURI" : "https://doi.org/10.15454/XYDK4L" + } + ], + "germplasmPedigreeDbId" : "dXJuOlVSR0kvZ2VybXBsYXNtUGVkaWdyZWUvMTk4MzYyNjQxOA==", + "germplasmPedigreeURI" : "urn:URGI/germplasmPedigree/1983626418", + "@type" : "germplasmPedigree", + "@id" : "urn:URGI/germplasmPedigree/1983626418", + "schema:includedInDataCatalog" : "https://urgi.versailles.inrae.fr/gnpis", + "schema:identifier" : "1983626418", + "schema:name" : null, + "germplasmURI" : "https://doi.org/10.15454/6GFW8U", + "parent1URI" : "https://doi.org/10.15454/SPA0QI", + "parent2URI" : "https://doi.org/10.15454/G0OSUB" + } + """; + + String expectedPedigree = """ + { + "groupId": 0, + "germplasmDbId": "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQ1MDM3-test", + "defaultDisplayName": "661300238", + "crossingPlan": "Factorial", + "crossingYear": null, + "familyCode": "0504B", + "pedigree": null, + "parent1DbId": "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQzMTY1", + "parent1Name": "73028-62", + "parent1Type": "FEMALE", + "parent2DbId": "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQzMTQ4", + "parent2Name": "101-74", + "parent2Type": "MALE", + "siblings": [ + { + "germplasmDbId": "46452", + "defaultDisplayName": "661303513" + }, + { + "germplasmDbId": "46389", + "defaultDisplayName": "661303449" + } + ], + "germplasmPedigreeDbId": "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtUGVkaWdyZWUvNDE1MTAxODg4-test", + "germplasmPedigreeURI": "urn:INRAE-URGI/germplasmPedigree/415101888-test", + "germplasmURI": "urn:INRAE-URGI/germplasm/45037-test", + "parent1URI": "urn:INRAE-URGI/germplasm/43165", + "parent2URI": "urn:INRAE-URGI/germplasm/43148", + "@id": "urn:INRAE-URGI/germplasmPedigree/415101888-test", + "@type": "germplasmPedigree" + } + """; + + /** + * To use for GermplasmController{ + * germplasmRepository.findPedigree(germplasm.getGermplasmDbId()); + * } + */ + @Test + public void should_get_one_pedigree_perDbId(){ + GermplasmPedigreeV1VO vo = dao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQ1MDM3"); + assertThat(vo).isNotNull(); + assertThat(vo.getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQ1MDM3"); + ObjectMapper jacksonMapper = new ObjectMapper(); +// try { +// JSONAssert.assertEquals(expectedPedigree, jacksonMapper.writeValueAsString(vo), JSONCompareMode.LENIENT); +// } catch (JsonProcessingException e) { +// throw new RuntimeException(e); +// } catch (JSONException e) { +// throw new RuntimeException(e); +// } // too long as a document, find a better test case + + + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..c64b253c6ec839554cb09b223c44df4f79c981d6 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV1DaoTest.java @@ -0,0 +1,443 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v1.GermplasmV1Dao; +import fr.inrae.urgi.faidare.domain.PuiNameValueVO; +import fr.inrae.urgi.faidare.domain.brapi.GermplasmSitemapVO; +import fr.inrae.urgi.faidare.domain.brapi.v1.GermplasmV1VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.elasticsearch.core.SearchHitsIterator; + +import java.util.HashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +@Import({ElasticSearchConfig.class}) +class GermplasmV1DaoTest { + + @Autowired + protected GermplasmV1Dao germplasmDao; + + /** + Code tested For futur implementation in Faidare cards: + public ModelAndView get(@PathVariable("germplasmId") String germplasmId) { + GermplasmVO germplasm = germplasmDao.getByGermplasmDbId(germplasmId); + + @GetMapping(params = "id") + public ModelAndView getById(@RequestParam("id") String germplasmId) { + GermplasmVO germplasm = germplasmRepository.getByGermplasmDbId(germplasmId); + */ + @Test + void getByGermplasmDbId_should_return_one_result() { + GermplasmV1VO germplasmVo = + germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo.getGermplasmDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + } + + + /** + * Code tested For Faidare cards: + * @GetMapping(params = "pui") + * public ModelAndView getByPui(@RequestParam("pui") String pui) { + * GermplasmV1VO germplasmVo = + * germplasmDao.getByGermplasmPUI(pui); + */ + @Test + void getByGermplasmPUI_should_return_one_result() { + GermplasmV1VO germplasmVo = + germplasmDao.getByGermplasmPUI("https://doi.org/10.15454/4NCDUP"); + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo.getGermplasmPUI()) + .isEqualTo("https://doi.org/10.15454/4NCDUP"); + assertThat(germplasmVo.getGermplasmDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2MDAy"); + } + +// test : Iterator<GermplasmVO> scrollGermplasmsByIds(Set<String> ids, int fetchSize); + + /** + * Should be usable for backend/src/main/java/fr/inra/urgi/faidare/web/germplasm/GermplasmController.java + + @PostMapping("/exports/plant-material") + @ResponseBody + public ResponseEntity<StreamingResponseBody> export(@Validated @RequestBody GermplasmExportCommand command) { + List<GermplasmExportableField> fields = getFieldsToExport(command); + + StreamingResponseBody body = out -> { + Iterator<GermplasmVO> iterator = germplasmRepository.scrollGermplasmsByIds(command.getIds(), 1000); + germplasmExportService.export(out, iterator, fields); + + By using germplasmDao.scrollGermplasmsByGermplasmDbIds instead of germplasmRepository.scrollGermplasmsByIds + */ + @Test + void should_get_germplasms_by_id1(){ + Set<String> dbIds = Set.of("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5",//recital + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4",//soisson + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1");//TREMIE + SearchHitsIterator<GermplasmV1VO> gVoIter = germplasmDao.scrollGermplasmsByGermplasmDbIds(dbIds, 10); + assertThat(gVoIter).isNotNull(); + assertThat(gVoIter.getTotalHits()).isEqualTo(3); + GermplasmV1VO gVo = Objects.requireNonNull(gVoIter.stream() + .filter(gVoHit -> "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4".equals(gVoHit.getContent().getGermplasmDbId())) + .findAny().orElse(null)).getContent(); + assertThat(gVo).isNotNull(); + assertThat(gVo.getGermplasmName()).isEqualTo("SOISSONS"); + } + + /** + * Code to use in controllers for + * germplasmCriteria.setGermplasmDbIds(Lists.newArrayList(study.getGermplasmDbIds())); + * return germplasmRepository.find(germplasmCriteria) + * + */ + @Test + void should_get_germplasms_by_id2(){ + Set<String> dbIds = Set.of("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5",//recital + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4",//soisson + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1",//TREMIE + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI1NTg1",//ISENGRAIN + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI1NjEy",//APACHE + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI1ODk1",//CF00193 + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI1OTEz");//CAPHORN + SearchHitsIterator<GermplasmV1VO> gVoIter = germplasmDao.scrollGermplasmsByGermplasmDbIds(dbIds, 3); + assertThat(gVoIter).isNotNull(); + assertThat(gVoIter.getTotalHits()).isEqualTo(7); + Set<String> resultSet = new HashSet<>(); + while (gVoIter.hasNext()){ + GermplasmV1VO v1VO = gVoIter.next().getContent(); + resultSet.add( v1VO.getGermplasmDbId()); + } + assertThat(resultSet.size()).isEqualTo(7); + assertThat(resultSet).isEqualTo(dbIds); + } + + @Test + void findByGermplasmDbIdIn() { + String id = "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"; + List<GermplasmV1VO> list = germplasmDao.findByGermplasmDbIdIn(Set.of(id)).toList(); + assertThat(list).extracting(GermplasmV1VO::getGermplasmDbId).containsOnly(id); + } + + @Test + void findAllForSitemap() { + List<GermplasmSitemapVO> list = germplasmDao.findAllForSitemap().toList(); + assertThat(list.size()).isGreaterThan(1); + assertThat(list.get(0)).isInstanceOf(GermplasmSitemapVO.class); + assertThat(list.get(0).getGermplasmDbId()).isNotNull(); + } + + @Test + void should_find_by_germplasmId(){ + GermplasmV1VO gVo = germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + assertThat(gVo).isNotNull(); + assertThat(gVo.getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + assertThat(gVo.getGermplasmPUI()).isEqualTo("https://doi.org/10.15454/WL6NIE"); + assertThat(gVo.getGermplasmName()).isEqualTo("RECITAL"); + assertThat(gVo.getAccessionNames()).contains("RECITAL"); + } + + @Test + void should_find_by_germplasmId_with_collecting_site2(){ + GermplasmV1VO gVo = germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODU5"); + assertThat(gVo).isNotNull(); + assertThat(gVo.getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODU5"); + assertThat(gVo.getCollectingSite()).isNotNull(); + assertThat(gVo.getCollectingSite().getSiteId()).isEqualTo("1626"); + assertThat(gVo.getCollectingSite().getSiteName()).isEqualTo("France"); + assertThat(gVo.getCollectingSite().getLatitude()).isEqualTo(47.428085); + assertThat(gVo.getCollectingSite().getLongitude()).isEqualTo(2.680664); + assertThat(gVo.getCollectingSite().getSiteType()).isEqualTo("Origin, Breeding and Collecting site"); + } + + @Test + void should_get_by_germplasm_id_and_have_collector(){ + GermplasmV1VO gVo = germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODU3"); + assertThat(gVo).isNotNull(); + assertThat(gVo.getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODU3"); + assertThat(gVo.getCollector()).isNotNull(); + assertThat(gVo.getCollector().getInstitute().getAcronym()).isEqualTo("INRAE_UMR_GDEC"); + //assertThat(gVo.getCollector().getMaterialType()).isEqualTo("Cutting"); is null in this case + //assertThat(gVo.getCollector().getAccessionCreationDate()).isEqualTo(20091200); null also + } + + @Test + void should_get_by_germplasm_id_and_have_children(){ + GermplasmV1VO gVo = germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQzMTY1"); + assertThat(gVo).isNotNull(); + assertThat(gVo.getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQzMTY1"); + assertThat(gVo.getChildren()).isNotNull(); + assertThat(gVo.getChildren().size()).isEqualTo(11); + assertThat(gVo.getChildren().get(0).getFirstParentPUI()).isEqualTo("https://doi.org/10.15454/SPA0QI"); + PuiNameValueVO pnv = new PuiNameValueVO(); + pnv.setPui("https://doi.org/10.15454/OMH2PC"); + assertThat(gVo.getChildren().get(0).getSibblings()).isNotNull().isNotEmpty().contains(pnv); + } + //TODO: criteria search, to reactivate for full BrAPIV1 + /* + @Test + void custom_should_search_by_accessionNumber(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setAccessionNumber(List.of("IRGC53931")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getAccessionNumber()).isEqualTo("IRGC53931"); + } + + @Test + void custom_should_search_by_binomialNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setBinomialNames(List.of("Zea mays")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getGenusSpecies()).isEqualTo("Zea mays"); + } + + @Test + void custom_should_search_by_collection(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("Wheat INRA collection"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("Wheat INRA collection") ; + assertThat(germplasmVOs.getResult().getData().get(0).getCollection().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_panel(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("RIL"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("RIL") ; + assertThat(germplasmVOs.getResult().getData().get(0).getPanel().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_pop(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("ILN028"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("ILN028") ; + assertThat(germplasmVOs.getResult().getData().get(0).getPopulation().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_commonCropNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCommonCropNames(List.of("Maize")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + GermplasmV2VO toto = germplasmVOs.getResult().getData().get(0); + assertThat(toto.getCommonCropName()).isEqualTo("Maize"); + } + + void custom_should_search_by_externalReferenceIDs(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceIDs(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_externalReferenceIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_externalReferenceSources(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceSources(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + // assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_familyCodes(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setFamilyCodes(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_genus(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGenus(List.of("Oryza")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getGenus()).isEqualTo("Oryza"); + } + + @Test + void custom_should_search_by_genus_pageSize1(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGenus(List.of("Oryza")); + gCrit.setPageSize(1); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getPageSize()).isEqualTo(1); + assertThat(germplasmVOs.getMetadata().getPagination().getCurrentPage()).isEqualTo(0); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(60); + assertThat(germplasmVOs.getResult().getData().get(0).getGenus()).isEqualTo("Oryza"); + } + + @Test + void custom_should_search_by_germplasmDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmDbIds(List.of("dXJuOklCRVQvYmU0ZTljZGMtNTgwMC00NDU3LWE2YzgtNDA1NjNjMDI3ZGQ5", "aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L1NQQTBRSQ==")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(2); + assertThat(germplasmVOs.getResult().getData().get(0).getGermplasmDbId()).isEqualTo("dXJuOklCRVQvYmU0ZTljZGMtNTgwMC00NDU3LWE2YzgtNDA1NjNjMDI3ZGQ5"); + assertThat(germplasmVOs.getResult().getData().get(1).getGermplasmDbId()).isEqualTo("aHR0cHM6Ly9kb2kub3JnLzEwLjE1NDU0L1NQQTBRSQ=="); + } + + @Test + void custom_should_search_by_germplasmName(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmName(List.of("APACHE")); + BrapiListResponse<GermplasmV2VO> pgVo = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(pgVo).isNotNull(); + assertThat(pgVo.getResult().getData()).isNotEmpty(); + assertThat(pgVo.getResult().getData().get(0).getGermplasmName()).isEqualTo("APACHE"); + } + + @Test + void custom_should_search_by_germplasmPUIs(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmPUIs(List.of("27756e94-501e-41f4-8482-250c6f3527b7")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getGermplasmPUI()).isEqualTo("27756e94-501e-41f4-8482-250c6f3527b7"); + } + + @Test + void custom_should_search_by_instituteCodes(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setInstituteCodes(List.of("PHL001")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getInstituteCode()).isEqualTo("PHL001"); + } + + + void custom_should_search_by_parentDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setParentDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_progenyDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgenyDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_programDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgramDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_programNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgramNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_species(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setSpecies(List.of("aestivum")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getSpecies()).isEqualTo("aestivum"); + } + + + @Test + void custom_should_search_by_studyDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setStudyDbIds(List.of("dXJuOklCRVQvc3R1ZHkvMQ==")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getStudyDbIds()).contains("dXJuOklCRVQvc3R1ZHkvMQ=="); + } + + void custom_should_search_by_studyNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setStudyNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + //assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_synonyms(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setSynonyms(List.of("Hsinchu 103")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getSynonyms()).contains("Hsinchu 103"); + } + + void custom_should_search_by_trialDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setTrialDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_trialNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setTrialNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + // assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + */ +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV2DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV2DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..385617514469e33797e5f3f2fce0314af7d369ac --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/GermplasmV2DaoTest.java @@ -0,0 +1,385 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.api.brapi.v2.BrapiListResponse; +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.config.FaidareProperties; +import fr.inrae.urgi.faidare.dao.v2.GermplasmCriteria; +import fr.inrae.urgi.faidare.dao.v2.GermplasmV2Dao; +import fr.inrae.urgi.faidare.domain.CollPopVO; +import fr.inrae.urgi.faidare.domain.SynonymsVO; +import fr.inrae.urgi.faidare.domain.brapi.v2.GermplasmV2VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.elasticsearch.core.ElasticsearchOperations; +import org.springframework.data.elasticsearch.core.IndexOperations; +import org.springframework.data.elasticsearch.core.mapping.IndexCoordinates; + +import java.util.List; +import java.util.function.Predicate; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.jupiter.api.Assertions.assertNotNull; +@Import({ElasticSearchConfig.class}) +@DataElasticsearchTest +class GermplasmV2DaoTest { + + @Autowired + protected GermplasmV2Dao germplasmDao; + + @Autowired + private ElasticsearchOperations elasticsearchTemplate; + + +/* + @Test + void getByGermplasmDbId_Mcpd_flavor_test() { + GermplasmMcpdVO germplasmVo = + germplasmDao.getByGermplasmDbId("dXJuOklCRVQvNzc5OGU1N2QtNzZjYS00ZjJiLTliMDctYmI5NTI0ODZlYjFi"); + + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo).isInstanceOf(GermplasmMcpdVO.class); + assertThat(germplasmVo.getAccessionNames()).isNull(); + if (germplasmVo.getAccessionNames() != null) { + assertThat(germplasmVo.getAccessionNames()).isEmpty(); + } + + } */ + + @Test + void getByGermplasmDbId_should_return_one_result() { + GermplasmV2VO germplasmVo = + germplasmDao.getByGermplasmDbId("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1"); + + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo.getGermplasmDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1"); + } + + @Test + void getByGermplasmPUI_should_return_one_result() { + GermplasmV2VO germplasmVo = + germplasmDao.getByGermplasmPUI("https://doi.org/10.15454/WL6NIE"); + assertThat(germplasmVo).isNotNull(); + assertThat(germplasmVo.getGermplasmPUI()) + .isEqualTo("https://doi.org/10.15454/WL6NIE"); + assertThat(germplasmVo.getGermplasmDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + } + + @Test + void custom_should_search_by_accessionNumber(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setAccessionNumber(List.of("EM01324")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(1); + assertThat(germplasmVOs.getResult().getData().get(0).getAccessionNumber()).isEqualTo("EM01324"); + } + + @Test + void custom_should_search_by_binomialNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setBinomialNames(List.of("Triticum aestivum")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getGenusSpecies()).isEqualTo("Triticum aestivum"); + } + + @Test + void custom_should_search_by_collection(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("Wheat INRA collection"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(200); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("Wheat INRA collection") ; + assertThat(germplasmVOs.getResult().getData().get(0).getCollection().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_panel(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("RIL"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("RIL") ; + assertThat(germplasmVOs.getResult().getData().get(0).getPanel().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_pop(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCollections((List.of("ILN028"))); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + Predicate<CollPopVO> streamsPredicate = item -> item.getName().equals("ILN028") ; + assertThat(germplasmVOs.getResult().getData().get(0).getPopulation().stream().filter(streamsPredicate)).isNotEmpty(); + } + + @Test + void custom_should_search_by_commonCropNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setCommonCropNames(List.of("Wheat")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + GermplasmV2VO toto = germplasmVOs.getResult().getData().get(0); + assertThat(toto.getCommonCropName()).isEqualTo("Wheat"); + } + + void custom_should_search_by_externalReferenceIDs(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceIDs(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_externalReferenceIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_externalReferenceSources(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setExternalReferenceSources(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + // assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_familyCodes(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setFamilyCodes(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_genus(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGenus(List.of("Populus")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getGenus()).isEqualTo("Populus"); + } + + @Test + void custom_should_search_by_genus_pageSize1(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGenus(List.of("Triticum")); + gCrit.setPageSize(1); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getPageSize()).isEqualTo(1); + assertThat(germplasmVOs.getMetadata().getPagination().getCurrentPage()).isEqualTo(0); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(544); + assertThat(germplasmVOs.getResult().getData().get(0).getGenus()).isEqualTo("Triticum"); + } + + @Test + void custom_should_search_by_germplasmDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmDbIds(List.of( + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5",//recital + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4",//soisson + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1"//TREMIE + )); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(3); + // Elasticsearch does not guarantee the order of results, so we verify the IDs regardless of their order. + List<String> returnedDbIds = germplasmVOs.getResult().getData().stream() + .map(GermplasmV2VO::getGermplasmDbId).toList(); + assertThat(returnedDbIds).containsExactlyInAnyOrder( + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5", + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4", + "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0NTA1" + ); + //assertThat(germplasmVOs.getResult().getData().get(0).getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MDU5"); + //assertThat(germplasmVOs.getResult().getData().get(1).getGermplasmDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4"); + } + + @Test + void custom_should_search_by_germplasmName(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmName(List.of("APACHE")); + BrapiListResponse<GermplasmV2VO> pgVo = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(pgVo).isNotNull(); + assertThat(pgVo.getResult().getData()).isNotEmpty(); + assertThat(pgVo.getResult().getData().get(0).getGermplasmName()).isEqualTo("APACHE"); + } + + @Test + void custom_should_search_by_germplasmPUIs(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setGermplasmPUIs(List.of("gnpis_pui:holding-921_taxon-4898_accession-49472")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isEqualTo(1); + assertThat(germplasmVOs.getResult().getData().get(0).getGermplasmPUI()).isEqualTo("gnpis_pui:holding-921_taxon-4898_accession-49472"); + } + + @Test + void custom_should_search_by_instituteCodes(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setInstituteCodes(List.of("FRA095")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(10); + assertThat(germplasmVOs.getResult().getData().get(0).getInstituteCode()).isEqualTo("FRA095"); + } + + //might be unrelevant or badly implemented with V2, see pedigree call + void custom_should_search_by_parentDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setParentDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_progenyDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgenyDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_programDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgramDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_programNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setProgramNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_species(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setSpecies(List.of("aestivum")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + assertThat(germplasmVOs.getResult().getData().get(0).getSpecies()).isEqualTo("aestivum"); + } + + + @Test + void custom_should_search_by_studyDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setStudyDbIds(List.of("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDAyX1RFQ0g=")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(10); + assertThat(germplasmVOs.getResult().getData().get(0).getStudyDbIds()).contains("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDAyX1RFQ0g="); + } + + void custom_should_search_by_studyNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setStudyNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + //assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Test + void custom_should_search_by_synonyms(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + + SynonymsVO synonymsVO = new SynonymsVO(); + synonymsVO.setSynonym("DI01016"); + + gCrit.setSynonyms(List.of(synonymsVO)); + BrapiListResponse<GermplasmV2VO> germplasmVOs = + germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); +// assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()) +// .isGreaterThan(0); +// +// List<SynonymsVO> synonyms = germplasmVOs.getResult().getData().get(0).getSynonyms(); +// List<String> expectedSynonyms= List.of("DI01016"); +// +// assertThat(synonyms) +// .extracting(SynonymsVO::getSynonym) +// .isEqualTo(expectedSynonyms); +// assertThat(germplasmVOs.getResult().getData().get(0).getGermplasmDbId()) +// .isEqualTo("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI2ODkx"); + } + + void custom_should_search_by_trialDbIds(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setTrialDbIds(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); +// assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + + void custom_should_search_by_trialNames(){ + GermplasmCriteria gCrit = new GermplasmCriteria(); + gCrit.setTrialNames(List.of("")); + BrapiListResponse<GermplasmV2VO> germplasmVOs = germplasmDao.findGermplasmsByCriteria(gCrit); + assertThat(germplasmVOs).isNotNull(); + assertThat(germplasmVOs.getMetadata().getPagination().getTotalCount()).isGreaterThan(0); + // assertThat(germplasmVOs.getSearchHits().getSearchHit(0).getContent().get()).isEqualTo(""); + } + @Autowired + private FaidareProperties faidareProperties; + + @Test + public void integrationTestAliasName() { + String indexName = faidareProperties.getAliasName("germplasm", 0L); + assertThat(indexName).isEqualTo("faidare_germplasm_dev-group0"); + } + + @Test + public void testFaidarePropertiesQuerying() { + // Verify that the document has been correctly indexed in Elasticsearch + String germplasmId = "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI3ODA3"; + GermplasmV2VO indexedGermplasm = germplasmDao.getByGermplasmDbId(germplasmId); + + // Ensure the retrieved document is not null and validate its key fields + assertNotNull(indexedGermplasm, "The document must not be null"); + assertThat(indexedGermplasm.getGermplasmName()).isEqualTo("DI08011"); + assertThat(indexedGermplasm.getGermplasmPUI()).isEqualTo("https://doi.org/10.15454/E8FP9Y"); + + // Verify that the index name is correctly generated and exists in Elasticsearch + String expectedIndexName = faidareProperties.getAliasName("germplasm", 0L); + IndexCoordinates indexCoordinates = elasticsearchTemplate.getIndexCoordinatesFor(GermplasmV2VO.class); + + // Ensure the index name matches the expected name + assertThat(indexCoordinates.getIndexName()).isEqualTo(expectedIndexName); + + // Check that the index actually exists in the Elasticsearch cluster + IndexOperations indexOperations = elasticsearchTemplate.indexOps(indexCoordinates); + boolean indexExists = indexOperations.exists(); + assertThat(indexExists).isTrue(); + } + +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/LocationV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/LocationV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..a5600114af9ca9b359b7cbaad8ca5a564058f9aa --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/LocationV1DaoTest.java @@ -0,0 +1,38 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v1.LocationV1Dao; +import fr.inrae.urgi.faidare.domain.LocationVO; +import fr.inrae.urgi.faidare.domain.brapi.LocationSitemapVO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +@Import({ElasticSearchConfig.class}) +public class LocationV1DaoTest { + + @Autowired + protected LocationV1Dao locDao; + + @Test + public void should_get_one_location_perDbId(){ + LocationVO lVo = locDao.getByLocationDbId("dXJuOklOUkFFLVVSR0kvbG9jYXRpb24vMTk5NA=="); + assertThat(lVo).isNotNull(); + assertThat(lVo.getLocationDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvbG9jYXRpb24vMTk5NA=="); + assertThat(lVo.getLocationName()).isEqualTo("Clermont-Ferrand"); + } + + @Test + void findAllForSitemap() { + List<LocationSitemapVO> list = locDao.findAllForSitemap().toList(); + assertThat(list.size()).isGreaterThan(1); + assertThat(list.get(0)).isInstanceOf(LocationSitemapVO.class); + assertThat(list.get(0).getLocationDbId()).isNotNull(); + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..8fa935170aa6c08c6bdc7373ca616a6694ecd39f --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV1DaoTest.java @@ -0,0 +1,90 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v1.StudyV1Dao; +import fr.inrae.urgi.faidare.domain.brapi.StudySitemapVO; +import fr.inrae.urgi.faidare.domain.brapi.v1.StudyV1VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; + +import java.util.List; +import java.util.Set; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +@Import({ElasticSearchConfig.class}) +class StudyV1DaoTest { + + @Autowired + protected StudyV1Dao studyV1Dao; + + /** + * Code tested For futur implementation in Faidare cards: + * public ModelAndView get(@PathVariable("germplasmId") String germplasmId) { + * GermplasmVO germplasm = germplasmDao.getByGermplasmDbId(germplasmId); + * + * @GetMapping(params = "id") + * public ModelAndView getById(@RequestParam("id") String germplasmId) { + * GermplasmVO germplasm = germplasmRepository.getByGermplasmDbId(germplasmId); + */ + @Test + void getByStudyDbId_should_return_one_result() { + StudyV1VO sVo = + studyV1Dao.getByStudyDbId("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDA0X1RFQ0g="); + + assertThat(sVo).isNotNull(); + assertThat(sVo.getStudyDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0xlX01vdWxvbl8yMDA0X1RFQ0g="); + } + + @Test + void getByStudyDbId_should_return_lastUpdate() { + StudyV1VO sVo = + studyV1Dao.getByStudyDbId("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMDRfVEVDSA=="); + + assertThat(sVo).isNotNull(); + assertThat(sVo.getStudyDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMDRfVEVDSA=="); + assertThat(sVo.getLastUpdate().getTimestamp()).isNotNull().containsSubsequence("2017-02-21"); + } + + /** + * Present for historic reasons. + * replacement code for + * public Set<String> getVariableIds(String studyDbId) + */ + @Test + void should_get_variables_by_study_id(){ + StudyV1VO sVo = + studyV1Dao.getByStudyDbId("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMTBfVEVDSA=="); + + assertThat(sVo).isNotNull(); + assertThat(sVo.getStudyDbId()) + .isEqualTo("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMTBfVEVDSA=="); + Set<String> obsVarIds = Set.copyOf(sVo.getObservationVariableDbIds()); + assertThat(obsVarIds).isNotNull().isNotEmpty().hasSizeGreaterThan(10); + assertThat(obsVarIds).contains("CO_321:1000216"); + assertThat(obsVarIds).containsAll(List.of("CO_321:1000227", + "CO_321:1000228", + "CO_321:1000229", + "CO_321:1000230", + "CO_321:1000231", + "CO_321:1000236", + "CO_321:1000237", + "CO_321:1000238", + "CO_321:1000239", + "CO_321:1000240")); + assertThat(obsVarIds).doesNotContain("foo"); + } + + @Test + void findAllForSitemap() { + List<StudySitemapVO> list = studyV1Dao.findAllForSitemap().toList(); + assertThat(list.size()).isGreaterThan(1); + assertThat(list.get(0)).isInstanceOf(StudySitemapVO.class); + assertThat(list.get(0).getStudyDbId()).isNotNull(); + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV2DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV2DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..f0e29673703d53bd1046b1e7a13c3f3ba893b5c9 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/StudyV2DaoTest.java @@ -0,0 +1,229 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v2.StudyCriteria; +import fr.inrae.urgi.faidare.dao.v2.StudyV2Dao; +import fr.inrae.urgi.faidare.domain.brapi.v2.StudyV2VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; +import org.springframework.data.elasticsearch.core.SearchHits; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@Import({ElasticSearchConfig.class}) +@DataElasticsearchTest +class StudyV2DaoTest { + + /** + * StudyV1VO and StudyV2VO are compatible enough. + * Therefore, there is no studyV1DAO, only a StudyV2DAO that serves both + */ + + @Autowired + protected StudyV2Dao studyV2Dao; + + @Test + void getByStudyDbId_should_return_empty_result() { + StudyV2VO studyVO = + studyV2Dao.getByStudyDbId("foo"); + assertThat(studyVO).isNull(); + } + + @Test + void getByStudyDbID_studyDbId(){ + StudyV2VO studyVO = studyV2Dao.getByStudyDbId("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMDRfVEVDSA=="); + assertThat(studyVO).isNotNull(); + assertThat(studyVO.getStudyDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0VzdHIlQzMlQTllcy1Nb25zXzIwMDRfVEVDSA=="); + } + // TODO : There is no Rice, all the test studies docs have a null commonCropName +// @Test +// void custom_should_search_by_commonCropNames(){ +// StudyCriteria sCrit = new StudyCriteria(); +// sCrit.setCommonCropNames(List.of("Rice")); +// SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); +// assertThat(studyVOs).isNotNull().isNotEmpty(); +// assertThat(studyVOs.getSearchHit(0).getContent().getCommonCropNames()).isEqualTo("Rice"); +// } + + + //TODO : check if this is in the spec + void custom_should_search_by_externalReferenceIDs(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setExternalReferenceIDs(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); +// assertThat(studyVOs.getSearchHit(0).getContent().getExternalReferences()).contains(""); + } + + + //TODO : check if this is in the spec + void custom_should_search_by_externalReferenceSources(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setExternalReferenceSources(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + // assertThat(studyVOs.getSearchHit(0).getContent().get()).isEqualTo(""); + } + + @Test + void custom_should_search_by_germplasmDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setGermplasmDbIds((List.of("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4"))); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getGermplasmDbIds()).contains("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI0MzI4"); + } + + + + //TODO : check if this is in the spec + void custom_should_search_by_germplasmNames(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setGermplasmNames(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + // assertThat(studyVOs.getSearchHit(0).getContent().get()).isEqualTo(""); + } + + @Test + void custom_should_search_by_locationDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setLocationDbIds(List.of("dXJuOklOUkFFLVVSR0kvbG9jYXRpb24vMzQwNjQ=")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getLocationDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvbG9jYXRpb24vMzQwNjQ="); + } + + @Test + void custom_should_search_by_locationNames(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setLocationNames(List.of("Le Moulon")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getLocationName()).isEqualTo("Le Moulon"); + } + + @Test + void custom_should_search_by_observationVariableDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setObservationVariableDbIds(List.of("CO_321:1000070")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getObservationVariableDbIds()).contains("CO_321:1000070"); + } + + + //TODO : check if this is in the spec + void custom_should_search_by_observationVariableNames(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setObservationVariableNames(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); +// assertThat(studyVOs.getSearchHit(0).getContent().get()).isEqualTo(""); + } + + + //TODO : check if this is in the spec + void custom_should_search_by_observationVariablePUIs(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setObservationVariablePUIs(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); +// assertThat(studyVOs.getSearchHit(0).getContent().get()).isEqualTo(""); + } + + @Test + void custom_should_search_by_programDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setProgramDbIds(List.of("dXJuOklOUkFFLVVSR0kvcHJvZ3JhbS9JTlJBX1doZWF0X0JyZWVkaW5nX05ldHdvcms=")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getProgramDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvcHJvZ3JhbS9JTlJBX1doZWF0X0JyZWVkaW5nX05ldHdvcms="); + } + + @Test + void custom_should_search_by_programNames(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setProgramNames(List.of("INRA Wheat Breeding Network")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getProgramName()).isEqualTo("INRA Wheat Breeding Network"); + } + + //@Test + void custom_should_search_by_seasonDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setSeasonDbIds(List.of("2000")); + //TODO : test data is still V1 compliant + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getTotalHits()).isEqualTo(10); + } + + //@Test + void custom_should_search_by_studyCodes(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setStudyCodes(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getStudyCode()).isEqualTo(""); + } + + @Test + void custom_should_search_by_studyDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setStudyDbIds(List.of("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0NsZXJtb250LUZlcnJhbmRfMjAwNV9URUNI")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getStudyDbId()).isEqualTo("dXJuOklOUkFFLVVSR0kvc3R1ZHkvQlRIX0NsZXJtb250LUZlcnJhbmRfMjAwNV9URUNI"); + } + + @Test + void custom_should_search_by_studyName(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setStudyNames(List.of("BTH_Estrées-Mons_2005_TECH")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getStudyName()).isEqualTo("BTH_Estrées-Mons_2005_TECH"); + } + + void custom_should_search_by_studyPUIs(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setStudyPUIs(List.of("")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getStudyPUI()).isEqualTo(""); + } + + @Test + void custom_should_search_by_studyTypes(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setStudyTypes(List.of("Phenotyping Study")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getStudyType()).isEqualTo("Phenotyping Study"); + } + + @Test + void custom_should_search_by_trialDbIds(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setTrialDbIds(List.of("dXJuOklOUkFFLVVSR0kvdHJpYWwvNw==")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getTrialDbId()).contains("dXJuOklOUkFFLVVSR0kvdHJpYWwvNw=="); + } + + @Test + void custom_should_search_by_trialNames(){ + StudyCriteria sCrit = new StudyCriteria(); + sCrit.setTrialNames(List.of("INRA Wheat Network technological variables")); + SearchHits<StudyV2VO> studyVOs = studyV2Dao.findStudiesByCriteria(sCrit); + assertThat(studyVOs).isNotNull().isNotEmpty(); + assertThat(studyVOs.getSearchHit(0).getContent().getTrialName()).isEqualTo("INRA Wheat Network technological variables"); + } + +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/TrialV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/TrialV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7e93dce5fbf4e0993daffcc4bb6abc8e86e4c90e --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/TrialV1DaoTest.java @@ -0,0 +1,27 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.dao.v1.TrialV1Dao; +import fr.inrae.urgi.faidare.domain.brapi.v1.TrialV1VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +@Import({ElasticSearchConfig.class}) +public class TrialV1DaoTest { + + @Autowired + protected TrialV1Dao dao; + + @Test + public void should_get_one_location_perDbId(){ + TrialV1VO vo = dao.getByTrialDbId("dXJuOklOUkFFLVVSR0kvdHJpYWwvNw=="); + assertThat(vo).isNotNull(); + assertThat(vo.getTrialName()).isEqualTo("INRA Wheat Network technological variables"); + + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/XRefDaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/XRefDaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..fb4b158c8db800fb420cd18ff757a1fe669eae32 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/XRefDaoTest.java @@ -0,0 +1,37 @@ +package fr.inrae.urgi.faidare.dao; + +import fr.inrae.urgi.faidare.config.ElasticSearchConfig; +import fr.inrae.urgi.faidare.domain.XRefDocumentVO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; +import org.springframework.context.annotation.Import; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +@Import({ElasticSearchConfig.class}) +public class XRefDaoTest { + + @Autowired + protected XRefDocumentDao dao; + + /** + * To be used in thymeleaf controlers for the following code : + * List<XRefDocumentVO> crossReferences = xRefDocumentRepository.find( + * XRefDocumentSearchCriteria.forXRefId(study.getStudyDbId()) + */ + @Test + public void should_get_perDbId(){ + //TODO: problem between resources and ressources check what is realy produced byt the current ETL. + List<XRefDocumentVO> lVos = dao.findByLinkedResourcesID("dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzQ1MDI5"); + assertThat(lVos).hasSize(3); + assertThat(lVos).allMatch(vo -> !vo.getUrl().isBlank()); + assertThat(lVos).anyMatch(vo -> vo.getDatabaseName().equals("GnpIS")); + assertThat(lVos).anyMatch(vo -> vo.getEntryType().equals("Phenotyping study")); + assertThat(lVos).anyMatch(vo -> vo.getSpecies().get(0).equals("Populus deltoides")); + + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/dao/v1/GermplasmAttributeValueV1DaoTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/dao/v1/GermplasmAttributeValueV1DaoTest.java new file mode 100644 index 0000000000000000000000000000000000000000..7f3deb6ae66f346f94ef70f6929e08006cc70509 --- /dev/null +++ b/backend/src/test/java/fr/inrae/urgi/faidare/dao/v1/GermplasmAttributeValueV1DaoTest.java @@ -0,0 +1,33 @@ +package fr.inrae.urgi.faidare.dao.v1; + +import fr.inrae.urgi.faidare.domain.brapi.v1.GermplasmAttributeV1VO; +import fr.inrae.urgi.faidare.domain.brapi.v1.GermplasmAttributeValueV1VO; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.data.elasticsearch.DataElasticsearchTest; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataElasticsearchTest +class GermplasmAttributeValueV1DaoTest { + + @Autowired + GermplasmAttributeV1Dao dao; + + /** + * To be used in Faidare fr/inra/urgi/faidare/web/germplasm/GermplasmController.java + * private List<BrapiGermplasmAttributeValue> getAttributes(GermplasmVO germplasm) + */ + @Test + void should_getByGermplasmDbId() { + String germplasmDbId = "dXJuOklOUkFFLVVSR0kvZ2VybXBsYXNtLzI1NjEy"; + GermplasmAttributeV1VO result = dao.getByGermplasmDbId(germplasmDbId); + assertThat(result).isNotNull(); + assertThat(result.getGermplasmDbId()).isEqualTo(germplasmDbId); + List<GermplasmAttributeValueV1VO> attributeValues = result.getData(); + assertThat(attributeValues).isNotEmpty().hasSize(4); + assertThat(attributeValues.get(0).getAttributeName()).isEqualTo("Growth class"); + } +} diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/web/Fixtures.java b/backend/src/test/java/fr/inrae/urgi/faidare/web/Fixtures.java index ec9a7e88c3877d7dda4a526ed98d2d8032907933..740ca69f01b20e8af9cd9292700290b45500b1b1 100644 --- a/backend/src/test/java/fr/inrae/urgi/faidare/web/Fixtures.java +++ b/backend/src/test/java/fr/inrae/urgi/faidare/web/Fixtures.java @@ -66,9 +66,9 @@ public class Fixtures { study.setProgramName("Program 1"); study.setActive(true); // FIXME JBN study.startDate used to be a java.util.Date, it's now a String. What does it contain? - study.setStartDate(LocalDate.now().toString()); + study.setStartDate(LocalDate.now()); study.setDataLinks(List.of(createDataLink())); - study.setContact(List.of(createContact())); + study.setContacts(List.of(createContact())); // FIXME JBN uncomment this once study has additionalInfo // BrapiAdditionalInfo additionalInfo = new BrapiAdditionalInfo(); @@ -81,6 +81,7 @@ public class Fixtures { study.setLocationName("France"); study.setGermplasmDbIds(List.of("germplasm1")); study.setTrialsDbIds(Collections.singleton("trial1")); + study.setUrl("http://test.com/study/"); return study; } diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/web/site/SiteControllerTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/web/site/SiteControllerTest.java index e56e122b139d7e4c9a43288b494feb724753b73b..0af0dc0d7ddfbfb3ffaeafe65d303ef543379a94 100644 --- a/backend/src/test/java/fr/inrae/urgi/faidare/web/site/SiteControllerTest.java +++ b/backend/src/test/java/fr/inrae/urgi/faidare/web/site/SiteControllerTest.java @@ -71,8 +71,11 @@ public class SiteControllerTest { .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andExpect(htmlContent().hasTitle("Site France")) - .andExpect(htmlContent().containsH2s("Details", "Additional info", "Cross references")) + .andExpect(htmlContent().containsH2s("Details", "Cross references")) .andExpect(htmlContent().endsCorrectly()); + // TODO : add additionalInfo to LocationVO + // .andExpect(htmlContent().containsH2s("Details", "Additional info", "Cross references")) + } @Test diff --git a/backend/src/test/java/fr/inrae/urgi/faidare/web/study/StudyControllerTest.java b/backend/src/test/java/fr/inrae/urgi/faidare/web/study/StudyControllerTest.java index 2bd91204b68b2f170f5903bd40ad0806e50dc31e..940ef844c9df6872a2fa4bcb5611263fbc470aa2 100644 --- a/backend/src/test/java/fr/inrae/urgi/faidare/web/study/StudyControllerTest.java +++ b/backend/src/test/java/fr/inrae/urgi/faidare/web/study/StudyControllerTest.java @@ -20,9 +20,11 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.http.MediaType; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.web.servlet.ModelAndView; @@ -78,6 +80,7 @@ public class StudyControllerTest { private LocationVO location; private TrialV1VO trial; + @BeforeEach void prepare() { study = Fixtures.createStudy(); @@ -120,8 +123,8 @@ public class StudyControllerTest { .andExpect(status().isOk()) .andExpect(content().contentTypeCompatibleWith(MediaType.TEXT_HTML)) .andExpect(htmlContent().hasTitle("Study Doability: Study 1")) - .andExpect(htmlContent().containsH2s("Identification", "Genotype", "Variables", "Data Set", "Contact", "Additional information", "Cross references")) - .andExpect(htmlContent().endsCorrectly()); + .andExpect(htmlContent().containsH2s("Identification", "Genotype", "Data Set", "Contact", "Cross references")) + .andExpect(htmlContent().endsCorrectly()); } @Test diff --git a/build.gradle.kts b/build.gradle.kts index 1ae028070898a1653f83f409a6713348a66bbf23..a5544480a058bcd4cedc1cabc2c993f5b05966fb 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,11 @@ plugins { - id("org.sonarqube") version "3.2.0" + id("org.sonarqube") version "4.3.0.3225" } sonarqube { properties { property ("sonar.projectKey", "urgi-is_faidare_AXlGu_BxPgTGgvpuDgeB") property ("sonar.qualitygate.wait", false) + property("sonar.exclusions", "**/*.gradle.kts") } } diff --git a/data/test/json-bulk/IBET/contact-1.json.gz b/data/test/json-bulk/IBET/contact-1.json.gz deleted file mode 100644 index c1b6344d87f355632599e1831f0a1ee2ecfbed96..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/contact-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/datadiscovery-1.json.gz b/data/test/json-bulk/IBET/datadiscovery-1.json.gz deleted file mode 100644 index 0d669f734808c661111fad31b36089aefcb7e645..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/datadiscovery-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/germplasm-1.json.gz b/data/test/json-bulk/IBET/germplasm-1.json.gz deleted file mode 100644 index 1beb30992239f61e986a7d0dbe8b6ad38aa10090..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/germplasm-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/location-1.json.gz b/data/test/json-bulk/IBET/location-1.json.gz deleted file mode 100644 index 3641132aa4ab7ff200b32cd1d39ec55a41435877..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/location-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/observationVariable-1.json.gz b/data/test/json-bulk/IBET/observationVariable-1.json.gz deleted file mode 100644 index 2e6894648f30de88989ee0061d5b3eed3b685a80..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/observationVariable-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/ontology-1.json.gz b/data/test/json-bulk/IBET/ontology-1.json.gz deleted file mode 100644 index fb6947bb15fcf5ec5eba045523d6da8f414fab1a..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/ontology-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/program-1.json.gz b/data/test/json-bulk/IBET/program-1.json.gz deleted file mode 100644 index 66c4d54d549c33558497aaac15836b16efe7398b..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/program-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/study-1.json.gz b/data/test/json-bulk/IBET/study-1.json.gz deleted file mode 100644 index 97d4457c16859fdbcb17614654aeed1ad3f91770..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/study-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/IBET/trial-1.json.gz b/data/test/json-bulk/IBET/trial-1.json.gz deleted file mode 100644 index ee2a42e91f5e54310fd5054c102d8240e158170e..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/IBET/trial-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/INRAE-URGI/contact-1.json.gz b/data/test/json-bulk/INRAE-URGI/contact-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..aed75edd4f82c754eb71eacf744794ea8e41eb7b Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/contact-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/datadiscovery-1.json.gz b/data/test/json-bulk/INRAE-URGI/datadiscovery-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..0a533847fa2db35203178090a5183ab5de97954d Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/datadiscovery-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/germplasm-1.json.gz b/data/test/json-bulk/INRAE-URGI/germplasm-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..c79ed142080a816ef530e484bd78b80bc646e190 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/germplasm-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/germplasmAttribute-1.json.gz b/data/test/json-bulk/INRAE-URGI/germplasmAttribute-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..c42dff784e2b6aa99d93179fbe41fffe3806f6b5 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/germplasmAttribute-1.json.gz differ diff --git a/data/test/json-bulk/URGI/germplasmMcpd-1.json.gz b/data/test/json-bulk/INRAE-URGI/germplasmMcpd-1.json.gz similarity index 100% rename from data/test/json-bulk/URGI/germplasmMcpd-1.json.gz rename to data/test/json-bulk/INRAE-URGI/germplasmMcpd-1.json.gz diff --git a/data/test/json-bulk/INRAE-URGI/germplasmPedigree-1.json.gz b/data/test/json-bulk/INRAE-URGI/germplasmPedigree-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..77e79d4cf2787414eb97fb9cdfda42772b64b885 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/germplasmPedigree-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/germplasmProgeny-1.json.gz b/data/test/json-bulk/INRAE-URGI/germplasmProgeny-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..5db46a7af8e72c79ee4fb31f732a42ee484f3a89 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/germplasmProgeny-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/location-1.json.gz b/data/test/json-bulk/INRAE-URGI/location-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..686a877c5fc589af99e630fc18b32071b87f8c00 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/location-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/observationUnit-1.json.gz b/data/test/json-bulk/INRAE-URGI/observationUnit-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..5dafac732824aa98793c69d4db21e69d4de3403c Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/observationUnit-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/observationVariable-1.json.gz b/data/test/json-bulk/INRAE-URGI/observationVariable-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..dfb92451af41ab36dffd8ec41a8efe40324739e4 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/observationVariable-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/program-1.json.gz b/data/test/json-bulk/INRAE-URGI/program-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..78c27d48c23d6de6e88e72c800f279b2757fb2bc Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/program-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/study-1.json.gz b/data/test/json-bulk/INRAE-URGI/study-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..e8f65b40b28efdb2cb05bb9b1d3bc2f2f8632da5 Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/study-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/trial-1.json.gz b/data/test/json-bulk/INRAE-URGI/trial-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..a472d576efbbed4d3db5930360a46d8d09a83bba Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/trial-1.json.gz differ diff --git a/data/test/json-bulk/INRAE-URGI/xref-phenotyping-1.json.gz b/data/test/json-bulk/INRAE-URGI/xref-phenotyping-1.json.gz new file mode 100644 index 0000000000000000000000000000000000000000..c3221850033b9877104f620996628e2637e8339e Binary files /dev/null and b/data/test/json-bulk/INRAE-URGI/xref-phenotyping-1.json.gz differ diff --git a/data/test/json-bulk/NIB/datadiscovery-1.json.gz b/data/test/json-bulk/NIB/datadiscovery-1.json.gz deleted file mode 100644 index ce16a2225725825889d223cf2ae7a8a24ecb7661..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/datadiscovery-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/NIB/germplasm-1.json.gz b/data/test/json-bulk/NIB/germplasm-1.json.gz deleted file mode 100644 index d78ec183b19e741c0a0d07cc38b0004ccf6e18e8..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/germplasm-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/NIB/location-1.json.gz b/data/test/json-bulk/NIB/location-1.json.gz deleted file mode 100644 index cf45bfd7284fcfd1c71bca29cd7c1831c3476996..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/location-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/NIB/program-1.json.gz b/data/test/json-bulk/NIB/program-1.json.gz deleted file mode 100644 index ef2d384df7e031cd17d6f829e8c8fc17aeb76107..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/program-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/NIB/study-1.json.gz b/data/test/json-bulk/NIB/study-1.json.gz deleted file mode 100644 index bdd874019332aaca4abf1f4a3b7af098a33f940e..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/study-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/NIB/trial-1.json.gz b/data/test/json-bulk/NIB/trial-1.json.gz deleted file mode 100644 index d0c8b7f50c0a55adb87984f09d08f44df4f87c01..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/NIB/trial-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/datadiscovery-1.json.gz b/data/test/json-bulk/URGI/datadiscovery-1.json.gz deleted file mode 100644 index 6ac74719f5f4812c9305a67857eaeca758641cfd..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/datadiscovery-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/germplasm-1.json.gz b/data/test/json-bulk/URGI/germplasm-1.json.gz deleted file mode 100644 index 4182f9911e850dbf705867510a784b8c8b2ecfa1..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/germplasm-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/germplasmAttribute-1.json.gz b/data/test/json-bulk/URGI/germplasmAttribute-1.json.gz deleted file mode 100644 index 2fbdf922e61a6f255f6052c9897190d201b5046f..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/germplasmAttribute-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/germplasmPedigree-1.json.gz b/data/test/json-bulk/URGI/germplasmPedigree-1.json.gz deleted file mode 100644 index b265e2d8ff5806fa069feef69025c573d2e56435..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/germplasmPedigree-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/germplasmProgeny-1.json.gz b/data/test/json-bulk/URGI/germplasmProgeny-1.json.gz deleted file mode 100644 index 0a71aa221bd0ed854dc294b73050a21b9412301b..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/germplasmProgeny-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/location-1.json.gz b/data/test/json-bulk/URGI/location-1.json.gz deleted file mode 100644 index 9ee1c92b5c4f86999dfafd34c157cf24d092127b..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/location-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/location-2.json.gz b/data/test/json-bulk/URGI/location-2.json.gz deleted file mode 100644 index 52eb39da219fb55040b8a113615c168c87b35ec7..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/location-2.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/program-1.json.gz b/data/test/json-bulk/URGI/program-1.json.gz deleted file mode 100644 index 0a3c14b414e7cf2292b50d548125051e85e4fd26..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/program-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/study-1.json.gz b/data/test/json-bulk/URGI/study-1.json.gz deleted file mode 100644 index 46c09ea4cdb10a37cc5d0a29185cfe53551e3539..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/study-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/trial-1.json.gz b/data/test/json-bulk/URGI/trial-1.json.gz deleted file mode 100644 index 62b52333712c59eed3df6ea037a3c7a3ad8752cc..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/trial-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/URGI/xref-1.json.gz b/data/test/json-bulk/URGI/xref-1.json.gz deleted file mode 100644 index 5a9cfc6637a35c665533c8a3e3fe56f01d16dbe9..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/URGI/xref-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/contact-1.json.gz b/data/test/json-bulk/VIB/contact-1.json.gz deleted file mode 100644 index 54b1e12086ca58bd09c873f3b34a593808b63360..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/contact-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/datadiscovery-1.json.gz b/data/test/json-bulk/VIB/datadiscovery-1.json.gz deleted file mode 100644 index fea364e682a51449ce081047779b696e3ba7ec11..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/datadiscovery-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/germplasm-1.json.gz b/data/test/json-bulk/VIB/germplasm-1.json.gz deleted file mode 100644 index 6382ee91c3896c7a2b710966cf3bde1d8962a2f1..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/germplasm-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/location-1.json.gz b/data/test/json-bulk/VIB/location-1.json.gz deleted file mode 100644 index 11fd278b8b2f1c519dddb4b63d0e6102dbe0f63f..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/location-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/observationVariable-1.json.gz b/data/test/json-bulk/VIB/observationVariable-1.json.gz deleted file mode 100644 index 75a67505defa784a940fc0ad241c6e3dffc69f94..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/observationVariable-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/study-1.json.gz b/data/test/json-bulk/VIB/study-1.json.gz deleted file mode 100644 index 0cb0697649d8e110b39b7fb983252be938a15eeb..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/study-1.json.gz and /dev/null differ diff --git a/data/test/json-bulk/VIB/trial-1.json.gz b/data/test/json-bulk/VIB/trial-1.json.gz deleted file mode 100644 index d16a8f23f65017ace2bbb2a5f1056f4664088e17..0000000000000000000000000000000000000000 Binary files a/data/test/json-bulk/VIB/trial-1.json.gz and /dev/null differ diff --git a/scripts/harvest.sh b/scripts/harvest.sh index 183f9f479e7fe8995dac56da85997a470c4dcc37..3de28b0dffc8271bba6c28401e11080f2482f93a 100755 --- a/scripts/harvest.sh +++ b/scripts/harvest.sh @@ -153,8 +153,8 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do \"index_patterns\": [\"${INDEX_PATTERN}-*\"], \"order\": 101, \"mappings\": - $(cat "${BASEDIR}"/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/${DOCUMENT_TYPE}_mapping.json), - \"settings\": $(cat "${BASEDIR}"/../backend/src/test/resources/fr/inra/urgi/faidare/repository/es/setup/index/settings.json) + $(cat "${BASEDIR}"/../backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/${DOCUMENT_TYPE}_mapping.json), + \"settings\": $(cat "${BASEDIR}"/../backend/src/main/resources/fr/inrae/urgi/faidare/repository/es/setup/index/settings.json) }") check_acknowledgment "${LOG}" "create template" @@ -181,15 +181,16 @@ for DOCUMENT_TYPE in ${DOCUMENT_TYPES}; do # Check indexed data echo -e "* Check data indexed from ${DATA_DIR} into ${INDEX_NAME}..." - # skip some documents because they contain nested objects that distort the count - if [[ "${DOCUMENT_TYPE}" != "germplasmAttribute" && "${DOCUMENT_TYPE}" != "trial" && "${DOCUMENT_TYPE}" != "xref" && "${DOCUMENT_TYPE}" != "observationUnit" ]]; then + # Skipping xref document because it has no '@id' field. + if [ "${DOCUMENT_TYPE}" != "xref" ]; then COUNT_EXTRACTED_DOCS=0 for FILE in $(find ${DATA_DIR} -name "${DOCUMENT_TYPE}-*.json.gz"); do COUNT_FILE_DOCS=$(gunzip -c ${FILE} | grep -o "\"@id\"" | wc -l) COUNT_EXTRACTED_DOCS=$((COUNT_EXTRACTED_DOCS+COUNT_FILE_DOCS)) done curl -s -XGET "${ES_HOST}:${ES_PORT}/${INDEX_NAME}/_refresh" >/dev/null - COUNT_INDEXED_DOCS=$(curl -s -XGET "${ES_HOST}:${ES_PORT}/_cat/indices/${INDEX_NAME}?h=docs.count") + # Use index/_count instead of docs.count to exclude nested documents (synonyms) from the count. For more details: https://discuss.elastic.co/t/incorrect-doc-count-vs-index-total-returns-in-es/222182/2 + COUNT_INDEXED_DOCS=$(curl -s -XGET "${ES_HOST}:${ES_PORT}/${INDEX_NAME}/_count" | jq '.count') if [ "$COUNT_INDEXED_DOCS" != "$COUNT_EXTRACTED_DOCS" ]; then echo -e "${RED}ERROR: a problem occurred when indexing data from ${DATA_DIR} on FAIDARE ${ENV}.${NC}" echo -e "${ORANGE}Expected ${COUNT_EXTRACTED_DOCS} documents but got ${COUNT_INDEXED_DOCS} indexed documents.${NC}"