Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODFQMMGR-392:Add endpoint to upgrade a provided query #365

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.folio.fqm.resource;

import lombok.RequiredArgsConstructor;
import org.folio.fqm.domain.dto.FqmMigrateResponse;
import org.folio.fqm.migration.MigratableQueryInformation;
import org.folio.fqm.service.MigrationService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -10,9 +12,14 @@
@RequiredArgsConstructor
public class MigrationController implements FqmVersionApi {
private final MigrationService migrationService;

private final MigratableQueryInformation migratableQueryInformation;
@Override
public ResponseEntity<String> getFqmVersion() {
return new ResponseEntity<>(migrationService.getLatestVersion(), HttpStatus.OK);
}
@Override
public ResponseEntity<FqmMigrateResponse> fqmMigrate() {
MigratableQueryInformation migratedQueryInformation = migrationService.migrate(migratableQueryInformation);
return ResponseEntity.ok(migratedQueryInformation);
}
}
1 change: 0 additions & 1 deletion src/main/java/org/folio/fqm/service/MigrationService.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class MigrationService {
public String getLatestVersion() {
return CURRENT_VERSION;
}

public boolean isMigrationNeeded(@CheckForNull String fqlQuery) {
return !this.getLatestVersion().equals(getVersion(fqlQuery));
}
Expand Down
22 changes: 20 additions & 2 deletions src/main/resources/swagger.api/mod-fqm-manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ paths:
operationId: getFqmVersion
tags:
- fqmVersion
description: Get version of the fqm.
description: Get version of the fqm
responses:
'200':
description: 'Version of the fqm'
Expand All @@ -79,7 +79,23 @@ paths:
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/internalServerErrorResponse'

/fqm/migrate:
post:
operationId: fqmMigrate
tags:
- fqmVersion
description: perform a migration of the FQM from the legacy version to the updated version.
responses:
'200':
description: 'FQM version updated successfully'
content:
application/json:
schema:
$ref: '#/components/schemas/fqmMigrateResponse'
'400':
$ref: '#/components/responses/badRequestResponse'
'500':
$ref: '#/components/responses/internalServerErrorResponse'
components:
parameters:
entity-type-id:
Expand Down Expand Up @@ -137,6 +153,8 @@ components:
type: array
items:
type: string
fqmMigrateResponse:
$ref: schemas/FqmMigrate.json

responses:
badRequestResponse:
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/swagger.api/schemas/FqmMigrate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Entity Upgrade Request",
"description": "Schema for a request to upgrade an entity payload, including an entity type ID, FQL query, and list of fields.",
"type": "object",
"properties": {
"entityTypeId": {
"description": "ID of the entity type to be upgraded",
"type": "string",
"format": "UUID"
},
"fqlQuery": {
"description": "FQL query string to be used for the upgrade",
"type": "string"
},
"fields": {
"description": "List of fields to be included in the upgrade",
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"entityTypeId"
]
}
Loading