Skip to content

Commit

Permalink
[MODLISTS-129] Use migration DTOs from shared repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ncovercash committed Oct 3, 2024
1 parent 21acd55 commit f389b60
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 99 deletions.
14 changes: 4 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,10 @@
<supportingFilesToGenerate>ApiUtil.java</supportingFilesToGenerate>
<generateModelDocumentation>true</generateModelDocumentation>
<skipIfSpecIsUnchanged>true</skipIfSpecIsUnchanged>
<schemaMappings>
<schemaMapping>FqmMigrateRequest=org.folio.querytool.domain.dto.FqmMigrateRequest</schemaMapping>
<schemaMapping>FqmMigrateResponse=org.folio.querytool.domain.dto.FqmMigrateResponse</schemaMapping>
</schemaMappings>
<configOptions>
<java8>true</java8>
<dateLibrary>java</dateLibrary>
Expand All @@ -333,16 +337,6 @@
</configOptions>
</configuration>
</execution>
<execution>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${mod-fqm-manager.yaml.file}</inputSpec>
<output>${project.build.directory}/docs/mod-fqm-manager</output>
<generatorName>html2</generatorName>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/folio/fqm/migration/warnings/Warning.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.folio.fqm.migration.warnings;

import jakarta.validation.constraints.NotNull;
import javax.annotation.CheckForNull;
import lombok.RequiredArgsConstructor;
import org.folio.fqm.service.LocalizationService;
import org.folio.spring.i18n.service.TranslationService;

public interface Warning {
@NotNull
WarningType getType();

@NotNull
String getDescription(TranslationService translationService);

public static String getDescriptionByAlternativeAndFql(
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/org/folio/fqm/resource/MigrationController.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.folio.fqm.resource;

import lombok.RequiredArgsConstructor;
import org.folio.fqm.domain.dto.FqmMigrateRequest;
import org.folio.fqm.domain.dto.FqmMigrateResponse;
import org.folio.fqm.domain.dto.FqmMigrateResponseWarningsInner;

import org.apache.commons.lang3.StringUtils;
import org.folio.fqm.migration.MigratableQueryInformation;
import org.folio.fqm.service.MigrationService;
import org.folio.querytool.domain.dto.FqmMigrateRequest;
import org.folio.querytool.domain.dto.FqmMigrateResponse;
import org.folio.querytool.domain.dto.FqmMigrateWarning;
import org.folio.spring.i18n.service.TranslationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -39,11 +41,9 @@ public ResponseEntity<FqmMigrateResponse> fqmMigrate(FqmMigrateRequest fqmMigrat
.fqlQuery(updatedQueryInfo.fqlQuery())
.fields(updatedQueryInfo.fields())
.warnings(updatedQueryInfo.warnings().stream()
.map(warning -> new FqmMigrateResponseWarningsInner()
.type(warning.getType() != null ? warning.getType().toString() : null)
.description(warning.getDescription(translationService) != null ?
warning.getDescription(translationService) : "No description provided"
)
.map(warning -> new FqmMigrateWarning()
.type(warning.getType().toString())
.description(warning.getDescription(translationService))
)
.toList()
);
Expand Down
12 changes: 5 additions & 7 deletions src/main/resources/swagger.api/mod-fqm-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,16 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/fqmMigrateRequest'
description: Mapped to schemas in folio-query-tool-metadata
type: FqmMigrateRequest
responses:
'200':
description: 'FQM version updated successfully'
description: 'FQM version updated successfully'
content:
application/json:
schema:
$ref: '#/components/schemas/fqmMigrateResponse'
description: Mapped to schemas in folio-query-tool-metadata
type: FqmMigrateResponse
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
Expand Down Expand Up @@ -157,10 +159,6 @@ components:
type: array
items:
type: string
fqmMigrateRequest:
$ref: schemas/FqmMigrateRequest.json
fqmMigrateResponse:
$ref: schemas/FqmMigrateResponse.json

responses:
badRequestResponse:
Expand Down
27 changes: 0 additions & 27 deletions src/main/resources/swagger.api/schemas/FqmMigrateRequest.json

This file was deleted.

46 changes: 0 additions & 46 deletions src/main/resources/swagger.api/schemas/FqmMigrateResponse.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package org.folio.fqm.controller;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.folio.fqm.domain.dto.FqmMigrateRequest;
import org.folio.fqm.migration.MigratableQueryInformation;
import org.folio.fqm.migration.warnings.DeprecatedEntityWarning;
import org.folio.fqm.migration.warnings.Warning;
import org.folio.fqm.resource.MigrationController;
import org.folio.fqm.service.MigrationService;
import org.folio.querytool.domain.dto.FqmMigrateRequest;
import org.folio.spring.FolioExecutionContext;
import org.folio.spring.i18n.service.TranslationService;
import org.folio.spring.integration.XOkapiHeaders;
Expand Down

0 comments on commit f389b60

Please sign in to comment.