From 3deb60bf2553c60e33b749eef0f2d91fe5d07ae5 Mon Sep 17 00:00:00 2001 From: mlm483 <128052931+mlm483@users.noreply.github.com> Date: Mon, 23 Dec 2024 17:17:03 -0500 Subject: [PATCH] [BI-2424] - refactored getObservationUnitsByDbId --- .../entity/PendingObservationUnit.java | 6 +++--- .../service/ObservationUnitService.java | 20 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/appendoverwrite/factory/entity/PendingObservationUnit.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/appendoverwrite/factory/entity/PendingObservationUnit.java index 6bb682ee2..f7c29264c 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/appendoverwrite/factory/entity/PendingObservationUnit.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/appendoverwrite/factory/entity/PendingObservationUnit.java @@ -95,11 +95,11 @@ public List brapiPost(List members) */ @Override public List brapiRead() throws ApiException { - // Collect deltabreed-generated exp unit ids listed in the import - Set expUnitIds = cache.getReferenceOUIds(); + // Collect deltabreed-generated obs unit ids listed in the import + Set obsUnitIds = cache.getReferenceOUIds(); // For each id fetch the observation unit from the brapi data store - return observationUnitService.getObservationUnitsByDbId(new HashSet<>(expUnitIds), importContext.getProgram()); + return observationUnitService.getObservationUnitsByDbId(new HashSet<>(obsUnitIds), importContext.getProgram()); } /** diff --git a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/service/ObservationUnitService.java b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/service/ObservationUnitService.java index e363f9d46..720c93d25 100644 --- a/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/service/ObservationUnitService.java +++ b/src/main/java/org/breedinginsight/brapps/importer/services/processors/experiment/service/ObservationUnitService.java @@ -49,27 +49,27 @@ public ObservationUnitService(BrAPIObservationUnitDAO brAPIObservationUnitDAO) { } /** - * Retrieves a list of BrAPI (Breeding API) observation units by their database IDs for a given set of experimental unit IDs and program. + * Retrieves a list of BrAPI (Breeding API) observation units by their database IDs for a given set of observation unit IDs and program. * - * This method queries the BrAPIObservationUnitDAO to retrieve BrAPI observation units based on the provided experimental unit IDs and program. - * If the database IDs of the retrieved BrAPI observation units do not match the provided experimental unit IDs, an IllegalStateException is thrown. + * This method queries the BrAPIObservationUnitDAO to retrieve BrAPI observation units based on the provided observation unit IDs and program. + * If the database IDs of the retrieved BrAPI observation units do not match the provided observation unit IDs, an IllegalStateException is thrown. * The exception includes information on the missing observation unit database IDs. * - * @param expUnitIds a set of experimental unit IDs for which to retrieve BrAPI observation units + * @param obsUnitIds a set of observation unit IDs for which to retrieve BrAPI observation units * @param program the program for which to retrieve BrAPI observation units - * @return a list of BrAPIObservationUnit objects corresponding to the provided experimental unit IDs + * @return a list of BrAPIObservationUnit objects corresponding to the provided observation unit IDs * @throws ApiException if an error occurs during the retrieval of observation units - * @throws IllegalStateException if the retrieved observation units do not match the provided experimental unit IDs + * @throws IllegalStateException if the retrieved observation units do not match the provided observation unit IDs */ - public List getObservationUnitsByDbId(Set expUnitIds, Program program) throws ApiException, IllegalStateException { + public List getObservationUnitsByDbId(Set obsUnitIds, Program program) throws ApiException, IllegalStateException { List brapiUnits = null; // Retrieve reference Observation Units based on IDs - brapiUnits = brAPIObservationUnitDAO.getObservationUnitsById(expUnitIds, program); + brapiUnits = brAPIObservationUnitDAO.getObservationUnitsById(obsUnitIds, program); // If no BrAPI units are found, throw an IllegalStateException with an error message - if (expUnitIds.size() != brapiUnits.size()) { - Set missingIds = new HashSet<>(expUnitIds); + if (obsUnitIds.size() != brapiUnits.size()) { + Set missingIds = new HashSet<>(obsUnitIds); // Calculate missing IDs based on retrieved BrAPI units missingIds.removeAll(brapiUnits.stream().map(BrAPIObservationUnit::getObservationUnitDbId).collect(Collectors.toSet()));