diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/RelationClass.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/RelationClass.kt index afc4e1ae4..1eb1b93e8 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/RelationClass.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/model/RelationClass.kt @@ -20,8 +20,8 @@ package org.eclipse.tractusx.bpdm.common.model enum class RelationClass(private val typeName: String) : NamedType { - CDQ_HIERARCHY("SaaS Hierarchy"), - CDQ_TRANSITION("SaaS Transition"), + SAAS_HIERARCHY("SaaS Hierarchy"), + SAAS_TRANSITION("SaaS Transition"), CX_HIERARCHY("Catena-X"), DNB_HIERARCHY("DNB"), LEI_HIERARCHY("LEI"); diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt index f7bc8d060..b0b7c8afc 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasController.kt @@ -28,7 +28,7 @@ import org.eclipse.tractusx.bpdm.pool.dto.response.SyncResponse import org.springframework.web.bind.annotation.* @RestController -@RequestMapping("/api/cdq") +@RequestMapping("/api/saas") class SaasController( val partnerImportService: ImportStarterService ) { diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt index 2bff821b3..5570151e5 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/ImportStarterService.kt @@ -61,7 +61,7 @@ class ImportStarterService( * Fetch a [SyncResponse] about the state of the current import */ fun getImportStatus(): SyncResponse { - return syncRecordService.getOrCreateRecord(SyncType.CDQ_IMPORT).toDto() + return syncRecordService.getOrCreateRecord(SyncType.SAAS_IMPORT).toDto() } fun getImportIdEntries(importIdentifiers: Collection): ImportIdEntriesResponse { @@ -71,7 +71,7 @@ class ImportStarterService( } private fun startImport(inSync: Boolean): SyncResponse { - val record = syncRecordService.setSynchronizationStart(SyncType.CDQ_IMPORT) + val record = syncRecordService.setSynchronizationStart(SyncType.SAAS_IMPORT) logger.debug { "Initializing SaaS import starting with ID ${record.errorSave}' for modified records from '${record.fromTime}' with async: ${!inSync}" } if (inSync) diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportService.kt index 49e8153c9..f6933d408 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportService.kt @@ -65,11 +65,11 @@ class PartnerImportService( val updatedCount = response.legalEntities.updated.size + response.sites.updated.size + response.addresses.updated.size importedCount += createdCount + updatedCount val progress = importedCount / response.totalElements.toFloat() - syncRecordService.setProgress(SyncType.CDQ_IMPORT, importedCount, progress) + syncRecordService.setProgress(SyncType.SAAS_IMPORT, importedCount, progress) } catch (exception: RuntimeException) { logger.error(exception) { "Exception encountered on SaaS import" } syncRecordService.setSynchronizationError( - SyncType.CDQ_IMPORT, + SyncType.SAAS_IMPORT, exception.message ?: "No Message", startAfter ) @@ -80,7 +80,7 @@ class PartnerImportService( entityManager.clear() } while (startAfter != null) - syncRecordService.setSynchronizationSuccess(SyncType.CDQ_IMPORT) + syncRecordService.setSynchronizationSuccess(SyncType.SAAS_IMPORT) logger.info { "SaaS import finished successfully" } } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt index 7c434bac8..0de42a3eb 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/entity/SyncRecord.kt @@ -50,7 +50,7 @@ class SyncRecord( enum class SyncType{ OPENSEARCH, - CDQ_IMPORT + SAAS_IMPORT } enum class SyncStatus{ diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SyncRecordService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SyncRecordService.kt index bb1e96fbe..d6b8c123e 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SyncRecordService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/SyncRecordService.kt @@ -66,7 +66,7 @@ class SyncRecordService( val record = getOrCreateRecord(type) if (record.status == SyncStatus.RUNNING) - throw BpdmSyncConflictException(SyncType.CDQ_IMPORT) + throw BpdmSyncConflictException(SyncType.SAAS_IMPORT) logger.debug { "Set sync of type ${record.type} to status ${SyncStatus.RUNNING}" } diff --git a/bpdm-pool/src/main/resources/db/migration/V3_0_3_0__rename_saas_enum.sql b/bpdm-pool/src/main/resources/db/migration/V3_0_3_0__rename_saas_enum.sql new file mode 100644 index 000000000..c9e252c17 --- /dev/null +++ b/bpdm-pool/src/main/resources/db/migration/V3_0_3_0__rename_saas_enum.sql @@ -0,0 +1,6 @@ +delete from sync_records + where type = 'SAAS_IMPORT'; + +update sync_records + set type = 'SAAS_IMPORT' + where type = 'CDQ_IMPORT'; diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt index 395028182..5b8c57b19 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/EndpointValues.kt @@ -47,7 +47,7 @@ object EndpointValues { const val CATENA_SITE_SEARCH_PATH = "$CATENA_SITES_PATH/search" const val CATENA_SITE_MAIN_ADDRESS_SEARCH_PATH = "$CATENA_SITES_PATH/main-addresses/search" - const val SAAS_SYNCH_PATH = "/api/cdq/business-partner/sync" + const val SAAS_SYNCH_PATH = "/api/saas/business-partner/sync" const val OPENSEARCH_SYNC_PATH = "api/opensearch/business-partner" diff --git a/docs/api/gate.json b/docs/api/gate.json index 9e6371a78..2e4c4f009 100644 --- a/docs/api/gate.json +++ b/docs/api/gate.json @@ -3790,8 +3790,8 @@ "technicalKey": { "type": "string", "enum": [ - "CDQ_HIERARCHY", - "CDQ_TRANSITION", + "SAAS_HIERARCHY", + "SAAS_TRANSITION", "CX_HIERARCHY", "DNB_HIERARCHY", "LEI_HIERARCHY" diff --git a/docs/api/gate.yaml b/docs/api/gate.yaml index 1744a939d..0d633626b 100644 --- a/docs/api/gate.yaml +++ b/docs/api/gate.yaml @@ -3129,8 +3129,8 @@ components: technicalKey: type: string enum: - - CDQ_HIERARCHY - - CDQ_TRANSITION + - SAAS_HIERARCHY + - SAAS_TRANSITION - CX_HIERARCHY - DNB_HIERARCHY - LEI_HIERARCHY diff --git a/docs/api/pool.json b/docs/api/pool.json index 70fbfc8e1..43347f5f6 100644 --- a/docs/api/pool.json +++ b/docs/api/pool.json @@ -98,7 +98,7 @@ "legal-entity-controller" ], "summary": "Get page of legal entity business partners matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20.", + "description": "This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", "operationId": "getLegalEntities", "parameters": [ { @@ -331,7 +331,7 @@ "address-controller" ], "summary": "Get page of addresses matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20.", + "description": "This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", "operationId": "getAddresses_1", "parameters": [ { @@ -790,17 +790,17 @@ } } }, - "/api/opensearch/business-partner": { + "/api/saas/business-partner/sync": { "get": { "tags": [ - "open-search-controller" + "saas-controller" ], - "summary": "Fetch information about the latest OpenSearch export", - "description": "Fetch information about the latest export (either ongoing or already finished)", - "operationId": "getBusinessPartners", + "summary": "Fetch information about the SaaS synchronization", + "description": "Fetch information about the latest import (either ongoing or already finished)", + "operationId": "getSyncStatus", "responses": { "200": { - "description": "Export information found", + "description": "Import information found", "content": { "*/*": { "schema": { @@ -816,14 +816,14 @@ }, "post": { "tags": [ - "open-search-controller" + "saas-controller" ], - "summary": "Index new business partner records on OpenSearch", - "description": "Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ", - "operationId": "export", + "summary": "Import new business partner records from SaaS", + "description": "Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import.", + "operationId": "importBusinessPartners", "responses": { "200": { - "description": "Export of records successfully", + "description": "Import successfully started", "content": { "*/*": { "schema": { @@ -832,39 +832,33 @@ } } }, - "500": { - "description": "Export failed (no connection to OpenSearch or database)" - } - } - }, - "delete": { - "tags": [ - "open-search-controller" - ], - "summary": "Clear business partner index on OpenSearch", - "description": "Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export.", - "operationId": "clear", - "responses": { - "200": { - "description": "Index successfully cleared" + "409": { + "description": "Import already running", + "content": { + "*/*": { + "schema": { + "$ref": "#/components/schemas/SyncResponse" + } + } + } }, "500": { - "description": "Clearing failed (no connection to OpenSearch or database)" + "description": "Import couldn't start to unexpected error" } } } }, - "/api/cdq/business-partner/sync": { + "/api/opensearch/business-partner": { "get": { "tags": [ - "saas-controller" + "open-search-controller" ], - "summary": "Fetch information about the SaaS synchronization", - "description": "Fetch information about the latest import (either ongoing or already finished)", - "operationId": "getSyncStatus", + "summary": "Fetch information about the latest OpenSearch export", + "description": "Fetch information about the latest export (either ongoing or already finished)", + "operationId": "getBusinessPartners", "responses": { "200": { - "description": "Import information found", + "description": "Export information found", "content": { "*/*": { "schema": { @@ -880,14 +874,14 @@ }, "post": { "tags": [ - "saas-controller" + "open-search-controller" ], - "summary": "Import new business partner records from SaaS", - "description": "Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import.", - "operationId": "importBusinessPartners", + "summary": "Index new business partner records on OpenSearch", + "description": "Triggers an asynchronous export of business partner records from BPDM to OpenSearch. Only exports records which have been updated since the last export. ", + "operationId": "export", "responses": { "200": { - "description": "Import successfully started", + "description": "Export of records successfully", "content": { "*/*": { "schema": { @@ -896,18 +890,24 @@ } } }, - "409": { - "description": "Import already running", - "content": { - "*/*": { - "schema": { - "$ref": "#/components/schemas/SyncResponse" - } - } - } + "500": { + "description": "Export failed (no connection to OpenSearch or database)" + } + } + }, + "delete": { + "tags": [ + "open-search-controller" + ], + "summary": "Clear business partner index on OpenSearch", + "description": "Deletes all business partner records in the OpenSearch index. Also resets the timestamp from the last export.", + "operationId": "clear", + "responses": { + "200": { + "description": "Index successfully cleared" }, "500": { - "description": "Import couldn't start to unexpected error" + "description": "Clearing failed (no connection to OpenSearch or database)" } } } @@ -3870,7 +3870,7 @@ "business-partner-legacy-controller" ], "summary": "Get page of business partners matching the search criteria", - "description": "This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.Note that when using search parameters the max page is 20.", + "description": "This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.", "operationId": "searchBusinessPartners", "parameters": [ { @@ -7636,7 +7636,7 @@ "type": "string", "enum": [ "OPENSEARCH", - "CDQ_IMPORT" + "SAAS_IMPORT" ] }, "status": { @@ -8446,8 +8446,8 @@ "technicalKey": { "type": "string", "enum": [ - "CDQ_HIERARCHY", - "CDQ_TRANSITION", + "SAAS_HIERARCHY", + "SAAS_TRANSITION", "CX_HIERARCHY", "DNB_HIERARCHY", "LEI_HIERARCHY" diff --git a/docs/api/pool.yaml b/docs/api/pool.yaml index dfa92aff4..cd367a811 100644 --- a/docs/api/pool.yaml +++ b/docs/api/pool.yaml @@ -63,7 +63,7 @@ paths: tags: - legal-entity-controller summary: Get page of legal entity business partners matching the search criteria - description: This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20. + description: This endpoint tries to find matches among all existing business partners of type legal entity, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. operationId: getLegalEntities parameters: - name: name @@ -217,7 +217,7 @@ paths: tags: - address-controller summary: Get page of addresses matching the search criteria - description: This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. Note that when using search parameters the max page is 20. + description: This endpoint tries to find matches among all existing business partners of type address, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. operationId: getAddresses_1 parameters: - name: administrativeArea @@ -611,6 +611,43 @@ paths: $ref: '#/components/schemas/AddressPartnerCreateResponse' '400': description: On malformed requests + /api/saas/business-partner/sync: + get: + tags: + - saas-controller + summary: Fetch information about the SaaS synchronization + description: Fetch information about the latest import (either ongoing or already finished) + operationId: getSyncStatus + responses: + '200': + description: Import information found + content: + '*/*': + schema: + $ref: '#/components/schemas/SyncResponse' + '500': + description: Fetching failed (no connection to database) + post: + tags: + - saas-controller + summary: Import new business partner records from SaaS + description: Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import. + operationId: importBusinessPartners + responses: + '200': + description: Import successfully started + content: + '*/*': + schema: + $ref: '#/components/schemas/SyncResponse' + '409': + description: Import already running + content: + '*/*': + schema: + $ref: '#/components/schemas/SyncResponse' + '500': + description: Import couldn't start to unexpected error /api/opensearch/business-partner: get: tags: @@ -653,43 +690,6 @@ paths: description: Index successfully cleared '500': description: Clearing failed (no connection to OpenSearch or database) - /api/cdq/business-partner/sync: - get: - tags: - - saas-controller - summary: Fetch information about the SaaS synchronization - description: Fetch information about the latest import (either ongoing or already finished) - operationId: getSyncStatus - responses: - '200': - description: Import information found - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Fetching failed (no connection to database) - post: - tags: - - saas-controller - summary: Import new business partner records from SaaS - description: Triggers an asynchronous import of new business partner records from SaaS. A SaaS record counts as new when it does not have a BPN and the BPDM service does not already have a record with the same SaaS ID. This import only regards records with a modifiedAfter timestamp since the last import. - operationId: importBusinessPartners - responses: - '200': - description: Import successfully started - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '409': - description: Import already running - content: - '*/*': - schema: - $ref: '#/components/schemas/SyncResponse' - '500': - description: Import couldn't start to unexpected error /api/catena/sites/search: post: tags: @@ -2753,7 +2753,7 @@ paths: tags: - business-partner-legacy-controller summary: Get page of business partners matching the search criteria - description: This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score.Note that when using search parameters the max page is 20. + description: This endpoint tries to find matches among all existing business partners, filtering out partners which entirely do not match and ranking the remaining partners according to the accuracy of the match. The match of a partner is better the higher its relevancy score. operationId: searchBusinessPartners parameters: - name: name @@ -5833,7 +5833,7 @@ components: type: string enum: - OPENSEARCH - - CDQ_IMPORT + - SAAS_IMPORT status: type: string enum: @@ -6594,8 +6594,8 @@ components: technicalKey: type: string enum: - - CDQ_HIERARCHY - - CDQ_TRANSITION + - SAAS_HIERARCHY + - SAAS_TRANSITION - CX_HIERARCHY - DNB_HIERARCHY - LEI_HIERARCHY diff --git a/docs/model/datamodel-LegalEntity.puml b/docs/model/datamodel-LegalEntity.puml index ff190971f..48f80a452 100644 --- a/docs/model/datamodel-LegalEntity.puml +++ b/docs/model/datamodel-LegalEntity.puml @@ -209,8 +209,8 @@ class Relation_Class { } enum Relation_Class_Key{ - CDQ_HIERARCHY - CDQ_TRANSITION + SAAS_HIERARCHY + SAAS_TRANSITION CX_HIERARCHY DNB_HIERARCHY LEI_HIERARCHY