From 8a8e55c7b226133dddb23f044f9574ee18a91d89 Mon Sep 17 00:00:00 2001 From: Manuel Soulier Date: Fri, 6 Sep 2024 09:25:33 +0200 Subject: [PATCH] feat: refactor createFamilyMappingTables --- ...ortStep1InitializeClientTablesService.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java index d9f999ce..42e53125 100644 --- a/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java +++ b/arc-ws/src/main/java/fr/insee/arc/ws/services/importServlet/ImportStep1InitializeClientTablesService.java @@ -55,7 +55,7 @@ public void execute(SendResponse resp) throws ArcException { createWsTables(); // create tables to retrieve family data table - createMetaFamilyTables(); + createFamilyMappingTables(); // create data table in an asynchronous parallel thread startTableCreationInParallel(); @@ -72,22 +72,28 @@ public void execute(SendResponse resp) throws ArcException { * 3. return the list of family data table to retrieve * @throws ArcException */ - private void createMetaFamilyTables() throws ArcException { - if (!arcClientIdentifier.getEnvironnement().equalsIgnoreCase(SchemaEnum.ARC_METADATA.getSchemaName())) { - - if (!clientDao.verificationClientFamille()) { - throw new ArcException(ArcExceptionMessage.WS_RETRIEVE_DATA_FAMILY_FORBIDDEN); - } - - clientDao.createTableOfIdSource(); - tablesMetierNames = clientDao.selectBusinessDataTables(); - - // filter Mapping tables if any filter declared - if (!arcClientIdentifier.getMappingTablesFilter().isEmpty()) - { - tablesMetierNames.retainAll(arcClientIdentifier.getMappingTablesFilter()); - } - + private void createFamilyMappingTables() throws ArcException { + + // mapping tables can only be requested on sandbox environments + if (arcClientIdentifier.getEnvironnement().equalsIgnoreCase(SchemaEnum.ARC_METADATA.getSchemaName())) { + return; + } + + // check if client is allowed to retrieve family data + if (!clientDao.verificationClientFamille()) { + throw new ArcException(ArcExceptionMessage.WS_RETRIEVE_DATA_FAMILY_FORBIDDEN); + } + + // create the table that contains the list of files to be retrieved + clientDao.createTableOfIdSource(); + + // get the family mapping tables name to be retrieved + tablesMetierNames = clientDao.selectBusinessDataTables(); + + // filter the mapping tables if any filter declared + if (!arcClientIdentifier.getMappingTablesFilter().isEmpty()) + { + tablesMetierNames.retainAll(arcClientIdentifier.getMappingTablesFilter()); } }