Skip to content

Commit

Permalink
Merge pull request #49 from catenax-ng/refactor/rename_cdq_saas_breaking
Browse files Browse the repository at this point in the history
Refactor/rename cdq saas - BREAKING API CHANGES
  • Loading branch information
nicoprow authored Feb 23, 2023
2 parents c418f4c + 9e9d3b7 commit c1e9001
Show file tree
Hide file tree
Showing 13 changed files with 120 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>): ImportIdEntriesResponse {
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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" }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SyncRecord(

enum class SyncType{
OPENSEARCH,
CDQ_IMPORT
SAAS_IMPORT
}

enum class SyncStatus{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}" }

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
delete from sync_records
where type = 'SAAS_IMPORT';

update sync_records
set type = 'SAAS_IMPORT'
where type = 'CDQ_IMPORT';
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
4 changes: 2 additions & 2 deletions docs/api/gate.json
Original file line number Diff line number Diff line change
Expand Up @@ -3790,8 +3790,8 @@
"technicalKey": {
"type": "string",
"enum": [
"CDQ_HIERARCHY",
"CDQ_TRANSITION",
"SAAS_HIERARCHY",
"SAAS_TRANSITION",
"CX_HIERARCHY",
"DNB_HIERARCHY",
"LEI_HIERARCHY"
Expand Down
4 changes: 2 additions & 2 deletions docs/api/gate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3129,8 +3129,8 @@ components:
technicalKey:
type: string
enum:
- CDQ_HIERARCHY
- CDQ_TRANSITION
- SAAS_HIERARCHY
- SAAS_TRANSITION
- CX_HIERARCHY
- DNB_HIERARCHY
- LEI_HIERARCHY
Expand Down
108 changes: 54 additions & 54 deletions docs/api/pool.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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)"
}
}
}
Expand Down Expand Up @@ -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": [
{
Expand Down Expand Up @@ -7636,7 +7636,7 @@
"type": "string",
"enum": [
"OPENSEARCH",
"CDQ_IMPORT"
"SAAS_IMPORT"
]
},
"status": {
Expand Down Expand Up @@ -8446,8 +8446,8 @@
"technicalKey": {
"type": "string",
"enum": [
"CDQ_HIERARCHY",
"CDQ_TRANSITION",
"SAAS_HIERARCHY",
"SAAS_TRANSITION",
"CX_HIERARCHY",
"DNB_HIERARCHY",
"LEI_HIERARCHY"
Expand Down
Loading

0 comments on commit c1e9001

Please sign in to comment.