diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/DescribedEnumEndpoint.java b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/DescribedEnumEndpoint.java index 012abced6..cf7192c03 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/DescribedEnumEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/DescribedEnumEndpoint.java @@ -1,5 +1,6 @@ package ca.bc.gov.backendstartapi.endpoint; +import ca.bc.gov.backendstartapi.config.SparLog; import ca.bc.gov.backendstartapi.dto.DescribedEnumDto; import ca.bc.gov.backendstartapi.enums.DescribedEnum; import io.swagger.v3.oas.annotations.Operation; @@ -9,6 +10,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import java.util.Arrays; import java.util.List; +import java.util.Optional; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; @@ -44,8 +46,11 @@ interface DescribedEnumEndpoint & DescribedEnum> { description = "A list of all the codes and their descriptions.") }) default ResponseEntity>> fetchAll() { + String simpleName = enumClass().getSimpleName(); + SparLog.info("Fetching all codes and descriptions for {} class", simpleName); var valueDtos = Arrays.stream(enumClass().getEnumConstants()).map(DescribedEnumDto::new).toList(); + SparLog.info("{} records found for class {}", valueDtos.size(), simpleName); return ResponseEntity.ok(valueDtos); } @@ -66,11 +71,22 @@ default ResponseEntity>> fetchAll() { }) default ResponseEntity> fetch( @Parameter(description = "The code to be fetched.") @PathVariable("code") String code) { - var valueDto = + SparLog.info( + "Fetching code and description from class {} with code {}", + enumClass().getSimpleName(), + code); + Optional> valueDto = Arrays.stream(enumClass().getEnumConstants()) .dropWhile(v -> !v.name().equals(code)) .findFirst() .map(DescribedEnumDto::new); + String simpleName = enumClass().getSimpleName(); + valueDto.ifPresent( + values -> + SparLog.info("Record for code {} found in class {}", code, simpleName)); + if (valueDto.isEmpty()) { + SparLog.warn("Record for code {} not found in class {}", code, simpleName); + } return ResponseEntity.of(valueDto); } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticClassEndpoint.java b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticClassEndpoint.java index 5a738239d..63e7e5de6 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticClassEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticClassEndpoint.java @@ -14,6 +14,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; +import org.springframework.lang.NonNull; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; @@ -23,9 +24,7 @@ /** This class exposes resources to handle all genetic class codes. */ @RestController @RequestMapping(path = "/api/genetic-classes", produces = "application/json") -@Tag( - name = "GeneticClasses", - description = "Resources to handle all genetic classes") +@Tag(name = "GeneticClasses", description = "Resources to handle all genetic classes") public class GeneticClassEndpoint { private GeneticClassService geneticClassService; @@ -101,7 +100,9 @@ public CodeDescriptionDto getOrchardById( @Parameter( name = "code", in = ParameterIn.PATH, + required = true, description = "Identifier of the genetic class.") + @NonNull String code) { return geneticClassService.getGeneticClassByCode(code); } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticWorthEndpoint.java b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticWorthEndpoint.java index 87757a969..44449b2f5 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticWorthEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/GeneticWorthEndpoint.java @@ -20,6 +20,7 @@ import jakarta.validation.Valid; import java.util.List; import org.springframework.http.MediaType; +import org.springframework.lang.NonNull; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; @@ -107,8 +108,9 @@ public CodeDescriptionDto getGeneticWorthByCode( @Parameter( name = "code", in = ParameterIn.PATH, - description = "Identifier of the genetic worth.") - String code) { + description = "Identifier of the genetic worth.", + required = true) + @NonNull String code) { return geneticWorthService.getGeneticWorthByCode(code); } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/SeedlotEndpoint.java b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/SeedlotEndpoint.java index 70a62e66b..71d01452e 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/SeedlotEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/endpoint/SeedlotEndpoint.java @@ -36,6 +36,7 @@ import org.springframework.http.MediaType; import org.springframework.http.ProblemDetail; import org.springframework.http.ResponseEntity; +import org.springframework.lang.NonNull; import org.springframework.util.MimeTypeUtils; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -405,6 +406,7 @@ public ResponseEntity saveFormProgressClassA( required = true, schema = @Schema(type = "integer", format = "int64")) @PathVariable + @NonNull String seedlotNumber, @RequestBody SaveSeedlotFormDtoClassA data) { @@ -438,6 +440,7 @@ public SaveSeedlotFormDtoClassA getFormProgressClassA( required = true, schema = @Schema(type = "integer", format = "int64")) @PathVariable + @NonNull String seedlotNumber) { return saveSeedlotFormService.getFormClassA(seedlotNumber); diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/entity/FavouriteActivityEntity.java b/backend/src/main/java/ca/bc/gov/backendstartapi/entity/FavouriteActivityEntity.java index 49580fdeb..6d8ab1b8c 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/entity/FavouriteActivityEntity.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/entity/FavouriteActivityEntity.java @@ -10,13 +10,11 @@ import lombok.AllArgsConstructor; import lombok.Getter; import lombok.Setter; -import lombok.With; /** This class represents a user's favorite activity in the database. */ @Entity @Getter @Setter -@With @AllArgsConstructor @Table(name = "favourite_activity") @Schema(description = "An object representing a user's favourite activity in the database") diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/exception/InvalidActivityException.java b/backend/src/main/java/ca/bc/gov/backendstartapi/exception/InvalidActivityException.java index f8990af94..6bf30fd8e 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/exception/InvalidActivityException.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/exception/InvalidActivityException.java @@ -9,6 +9,6 @@ public class InvalidActivityException extends ResponseStatusException { public InvalidActivityException() { - super(HttpStatus.NOT_FOUND, "Invalid activity or page name!"); + super(HttpStatus.NOT_FOUND, "Invalid or not found activity id!"); } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/exception/JsonParsingException.java b/backend/src/main/java/ca/bc/gov/backendstartapi/exception/JsonParsingException.java index 4998bfbc6..17bb7c2a7 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/exception/JsonParsingException.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/exception/JsonParsingException.java @@ -5,11 +5,11 @@ import org.springframework.web.server.ResponseStatusException; /** This class represents a failed json parsing exception and will trigger a RuntimeException. */ -@ResponseStatus(value = HttpStatus.NOT_FOUND) +@ResponseStatus(value = HttpStatus.BAD_REQUEST) public class JsonParsingException extends ResponseStatusException { /** Constructor. */ public JsonParsingException() { - super(HttpStatus.INTERNAL_SERVER_ERROR, "Failed to process requested JSON value."); + super(HttpStatus.BAD_REQUEST, "Failed to process requested JSON value."); } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/ConeCollectionMethodService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/ConeCollectionMethodService.java index 3477c0978..55021c83f 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/ConeCollectionMethodService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/ConeCollectionMethodService.java @@ -33,6 +33,7 @@ public List getAllConeCollectionMethods() { resultList.add(methodToAdd); }); + SparLog.info("{} Cone Collection Methods found.", resultList.size()); return resultList; } @@ -43,6 +44,10 @@ public List getAllConeCollectionMethods() { */ public List getAllValidConeCollectionMethods() { SparLog.info("Fetching all Cone Collection Methods for ConeCollectionMethodEntity"); - return coneCollectionMethodRepository.findAll().stream().filter(x -> x.isValid()).toList(); + + List list = + coneCollectionMethodRepository.findAll().stream().filter(x -> x.isValid()).toList(); + SparLog.info("{} Cone Collection Methods found.", list.size()); + return list; } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/FavouriteActivityService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/FavouriteActivityService.java index daec1e333..489f13baf 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/FavouriteActivityService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/FavouriteActivityService.java @@ -12,6 +12,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; /** This class contains all routines and database access to a users' favorite activity. */ @@ -58,7 +59,10 @@ public FavouriteActivityEntity createUserActivity(FavouriteActivityCreateDto act FavouriteActivityEntity activityEntity = new FavouriteActivityEntity(); activityEntity.setUserId(userId); activityEntity.setActivity(activityDto.activity()); - return favouriteActivityRepository.save(activityEntity); + + FavouriteActivityEntity activityEntitySaved = favouriteActivityRepository.save(activityEntity); + SparLog.info("Activity {} created for user {}", activityDto.activity(), userId); + return activityEntitySaved; } /** @@ -69,7 +73,11 @@ public FavouriteActivityEntity createUserActivity(FavouriteActivityCreateDto act public List getAllUserFavoriteActivities() { String userId = loggedUserService.getLoggedUserId(); SparLog.info("Retrieving all favorite activities for user {}", userId); - return favouriteActivityRepository.findAllByUserId(userId); + + List list = favouriteActivityRepository.findAllByUserId(userId); + SparLog.info("{} favourite activity(ies) for user {}", list.size(), userId); + + return list; } /** @@ -81,7 +89,8 @@ public List getAllUserFavoriteActivities() { * @throws InvalidActivityException if the activity doesn't exist */ @Transactional - public FavouriteActivityEntity updateUserActivity(Long id, FavouriteActivityUpdateDto updateDto) { + public FavouriteActivityEntity updateUserActivity( + @NonNull Long id, FavouriteActivityUpdateDto updateDto) { String userId = loggedUserService.getLoggedUserId(); SparLog.info("Updating activity id {} for user {}", id, userId); @@ -93,9 +102,12 @@ public FavouriteActivityEntity updateUserActivity(Long id, FavouriteActivityUpda favouriteActivityRepository.removeAllHighlightedByUser(userId); } - FavouriteActivityEntity entity = activityEntity.withHighlighted(updateDto.highlighted()); + activityEntity.setHighlighted(updateDto.highlighted()); + + FavouriteActivityEntity activityEntitySaved = favouriteActivityRepository.save(activityEntity); + SparLog.info("Activity id {} updated for user {}", id, userId); - return favouriteActivityRepository.save(entity); + return activityEntitySaved; } /** @@ -103,7 +115,7 @@ public FavouriteActivityEntity updateUserActivity(Long id, FavouriteActivityUpda * * @param id A {@link Long} value as the id of the activity */ - public void deleteUserActivity(Long id) { + public void deleteUserActivity(@NonNull Long id) { String userId = loggedUserService.getLoggedUserId(); SparLog.info("Deleting activity id {} for user {}", id, userId); @@ -113,5 +125,6 @@ public void deleteUserActivity(Long id) { } favouriteActivityRepository.deleteById(id); + SparLog.info("Activity id {} deleted for user {}", id, userId); } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GameticMethodologyService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GameticMethodologyService.java index 221546f76..4499f6275 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GameticMethodologyService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GameticMethodologyService.java @@ -33,6 +33,7 @@ public List getAllGameticMethodologies() { resultList.add(methodToAdd); }); + SparLog.info("{} gametic methodologies found.", resultList.size()); return resultList; } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticClassService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticClassService.java index d3c7553d6..43f1cc1e6 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticClassService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticClassService.java @@ -2,10 +2,13 @@ import ca.bc.gov.backendstartapi.config.SparLog; import ca.bc.gov.backendstartapi.dto.CodeDescriptionDto; +import ca.bc.gov.backendstartapi.entity.GeneticClassEntity; import ca.bc.gov.backendstartapi.exception.NoGeneticWorthException; import ca.bc.gov.backendstartapi.repository.GeneticClassRepository; import java.util.ArrayList; import java.util.List; +import java.util.Optional; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; /** This class contains all routines and database access to a list of genetic class. */ @@ -19,7 +22,7 @@ public GeneticClassService(GeneticClassRepository geneticClassRepository) { /** Fetch all valid genetic class from the repository. */ public List getAllGeneticClass() { - SparLog.info("Fetching all genetic class"); + SparLog.info("Fetching all genetic classes"); List resultList = new ArrayList<>(); geneticClassRepository.findAll().stream() .filter(method -> method.isValid()) @@ -30,15 +33,18 @@ public List getAllGeneticClass() { resultList.add(methodToAdd); }); + SparLog.info("{} genetic classes found.", resultList.size()); return resultList; } /** Fetch a single genetic class by code. */ - public CodeDescriptionDto getGeneticClassByCode(String code) { - SparLog.info("Fetching genetic class with code {}", code); + public CodeDescriptionDto getGeneticClassByCode(@NonNull String code) { + SparLog.info("Fetching genetic class for code {}", code); - return geneticClassRepository - .findById(code) + Optional gceOptional = geneticClassRepository.findById(code); + gceOptional.ifPresent(entity -> SparLog.info("Genetic class {} found.", code)); + + return gceOptional .map( entity -> new CodeDescriptionDto(entity.getGeneticClassCode(), entity.getDescription())) .orElseThrow(NoGeneticWorthException::new); diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticWorthService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticWorthService.java index 299602aab..477486905 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticWorthService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/GeneticWorthService.java @@ -5,6 +5,7 @@ import ca.bc.gov.backendstartapi.dto.GeneticWorthSummaryDto; import ca.bc.gov.backendstartapi.dto.GeneticWorthTraitsDto; import ca.bc.gov.backendstartapi.dto.GeneticWorthTraitsRequestDto; +import ca.bc.gov.backendstartapi.entity.GeneticWorthEntity; import ca.bc.gov.backendstartapi.exception.NoGeneticWorthException; import ca.bc.gov.backendstartapi.repository.GeneticWorthRepository; import java.math.BigDecimal; @@ -13,6 +14,7 @@ import java.util.List; import java.util.Objects; import java.util.Optional; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; /** This class contains all routines and database access to a list of genetic worth. */ @@ -38,15 +40,18 @@ public List getAllGeneticWorth() { resultList.add(methodToAdd); }); + SparLog.info("{} genetic worth found.", resultList.size()); return resultList; } /** Fetch a genetic worth from the repository by code. */ - public CodeDescriptionDto getGeneticWorthByCode(String code) { - SparLog.info("Fetching genetic worth with code %s", code); + public CodeDescriptionDto getGeneticWorthByCode(@NonNull String code) { + SparLog.info("Fetching genetic worth with code {}", code); - return geneticWorthRepository - .findById(code) + Optional gweOptional = geneticWorthRepository.findById(code); + gweOptional.ifPresent(entity -> SparLog.info("Genetic worth {} found.", code)); + + return gweOptional .map( entity -> new CodeDescriptionDto(entity.getGeneticWorthCode(), entity.getDescription())) .orElseThrow(NoGeneticWorthException::new); @@ -62,6 +67,7 @@ public CodeDescriptionDto getGeneticWorthByCode(String code) { */ public GeneticWorthSummaryDto calculateGeneticWorth( List traitsDto) { + SparLog.info("Starting Genetic Worth calculations"); BigDecimal minimumThreshold = new BigDecimal("0.7"); BigDecimal neValue = calculateNe(traitsDto); @@ -77,6 +83,9 @@ public GeneticWorthSummaryDto calculateGeneticWorth( if (percentage.compareTo(minimumThreshold) >= 0) { SparLog.info("Calculating Genetic Worth for {} trait", trait.code()); calculatedValue = calculateTraitGeneticWorth(traitsDto, trait); + } else { + SparLog.info( + "No Genetic Worth calculations for trait {}, threshold not met.", trait.code()); } GeneticWorthTraitsDto traitResponse = diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/MethodOfPaymentService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/MethodOfPaymentService.java index a7f33966c..9a3c3e6a1 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/MethodOfPaymentService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/MethodOfPaymentService.java @@ -31,6 +31,7 @@ public List getAllMethodOfPayment() { resultList.add(methodToAdd); }); + SparLog.info("{} valid payment method found for MethodOfPaymentDto.", resultList.size()); return resultList; } @@ -41,6 +42,11 @@ public List getAllMethodOfPayment() { */ public List getAllValidMethodOfPayments() { SparLog.info("Fetching all method of payment for MethodOfPaymentEntity"); - return methodOfPaymentRepository.findAll().stream().filter(x -> x.isValid()).toList(); + + List list = + methodOfPaymentRepository.findAll().stream().filter(x -> x.isValid()).toList(); + SparLog.info("{} valid payment method found for MethodOfPaymentEntity.", list.size()); + + return list; } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java index a5012c871..6dc92b7fa 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java @@ -39,6 +39,7 @@ public class OrchardService { * @return A {@link List} of {@link ActiveOrchardSpuEntity} or an empty list. */ public List findSpuIdByOrchard(String orchardId) { + SparLog.info("Finding SPU id for orchard id {}", orchardId); return findSpuIdByOrchardWithActive(orchardId, true); } @@ -49,7 +50,13 @@ public List findSpuIdByOrchard(String orchardId) { * @return A {@link List} of {@link ActiveOrchardSpuEntity} or an empty list. */ public List findAllSpu(boolean active) { - return activeOrchardSeedPlanningUnitRepository.findAllByActive(active); + SparLog.info("Finding all orchard seed planning unit by active state {}", active); + + List list = + activeOrchardSeedPlanningUnitRepository.findAllByActive(active); + SparLog.info("{} orchard seed planning unit by active state found", list.size()); + + return list; } /** @@ -61,7 +68,13 @@ public List findAllSpu(boolean active) { */ public List findSpuIdByOrchardWithActive( String orchardId, boolean active) { - return activeOrchardSeedPlanningUnitRepository.findByOrchardIdAndActive(orchardId, active); + SparLog.info("Finding SPU id for orchard id {} and active {}", orchardId, active); + + List list = + activeOrchardSeedPlanningUnitRepository.findByOrchardIdAndActive(orchardId, active); + SparLog.info("{} Orchards by spu found.", list.size()); + + return list; } /** @@ -96,7 +109,11 @@ public OrchardSpuDto findParentTreeGeneticQualityData(String orchardId) { * @return An {@link List} of {@link OrchardDto} from oracle-api */ public List findOrchardsByVegCode(String vegCode) { - return oracleApiProvider.findOrchardsByVegCode(vegCode.toUpperCase()); + SparLog.info("Finding all orchards by veg code for code {}", vegCode); + + List list = oracleApiProvider.findOrchardsByVegCode(vegCode.toUpperCase()); + SparLog.info("{} orchards found for veg code {}", list.size(), vegCode); + return list; } /** @@ -106,6 +123,7 @@ public List findOrchardsByVegCode(String vegCode) { * @return An {@link List} of {@link SameSpeciesTreeDto} from oracle-api */ public List findParentTreesByVegCode(String vegCode) { + SparLog.info("Finding parent trees by veg code with code {}", vegCode); List spuList = findAllSpu(true); Map orchardSpuMap = new HashMap<>(); @@ -115,6 +133,9 @@ public List findParentTreesByVegCode(String vegCode) { orchardSpuMap.put( spuObj.getOrchardId(), String.valueOf(spuObj.getSeedPlanningUnitId()))); - return oracleApiProvider.findParentTreesByVegCode(vegCode.toUpperCase(), orchardSpuMap); + List list = + oracleApiProvider.findParentTreesByVegCode(vegCode.toUpperCase(), orchardSpuMap); + SparLog.info("{} parent tree by veg code found.", list.size()); + return list; } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SaveSeedlotFormService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SaveSeedlotFormService.java index 64054d581..128609915 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SaveSeedlotFormService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SaveSeedlotFormService.java @@ -17,6 +17,7 @@ import java.util.Map; import java.util.Optional; import lombok.RequiredArgsConstructor; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; /** This class contains methods to handle seedlot registration form saving requests. */ @@ -30,8 +31,8 @@ public class SaveSeedlotFormService { private final LoggedUserService loggedUserService; /** Saves the {@link SaveSeedlotFormDtoClassA} to table. */ - public void saveFormClassA(String seedlotNumber, SaveSeedlotFormDtoClassA data) { - SparLog.info("Saving A-Class seedlot progress for seedlot number: {} ...", seedlotNumber); + public void saveFormClassA(@NonNull String seedlotNumber, SaveSeedlotFormDtoClassA data) { + SparLog.info("Saving A-Class seedlot progress for seedlot number: {}", seedlotNumber); Seedlot relatedSeedlot = seedlotRepository.findById(seedlotNumber).orElseThrow(SeedlotNotFoundException::new); @@ -47,6 +48,8 @@ public void saveFormClassA(String seedlotNumber, SaveSeedlotFormDtoClassA data) SaveSeedlotProgressEntityClassA entityToSave; // If an entity exist then update the values, otherwise make a new entity. if (optionalEntityToSave.isEmpty()) { + SparLog.info( + "First time saving A-class seedlot progress for seedlot number {}", seedlotNumber); entityToSave = new SaveSeedlotProgressEntityClassA( relatedSeedlot, @@ -54,8 +57,8 @@ public void saveFormClassA(String seedlotNumber, SaveSeedlotFormDtoClassA data) parsedProgressStatus, loggedUserService.createAuditCurrentUser()); } else { - SparLog.info( - "A-class seedlot progress for seedlot number {} exists, replacing with new values ...", + SparLog.warn( + "A-class seedlot progress for seedlot number {} exists, replacing with new values", seedlotNumber); entityToSave = optionalEntityToSave.get(); entityToSave.setAllStepData(parsedAllStepData); @@ -63,6 +66,7 @@ public void saveFormClassA(String seedlotNumber, SaveSeedlotFormDtoClassA data) } saveSeedlotProgressRepositoryClassA.save(entityToSave); + SparLog.info("A-class seedlot progress for seedlot number {} saved!", seedlotNumber); return; } @@ -70,12 +74,19 @@ public void saveFormClassA(String seedlotNumber, SaveSeedlotFormDtoClassA data) * Retreives a {@link SaveSeedlotProgressEntityClassA} then convert it to {@link * SaveSeedlotFormDtoClassA} upon return. */ - public SaveSeedlotFormDtoClassA getFormClassA(String seedlotNumber) { - SparLog.info("Retrieving A-class seedlot progress for seedlot number: {} ...", seedlotNumber); + public SaveSeedlotFormDtoClassA getFormClassA(@NonNull String seedlotNumber) { + SparLog.info("Retrieving A-class seedlot progress for seedlot number {}", seedlotNumber); + ObjectMapper mapper = new ObjectMapper(); - return saveSeedlotProgressRepositoryClassA - .findById(seedlotNumber) - .map( + + Optional form = + saveSeedlotProgressRepositoryClassA.findById(seedlotNumber); + + if (form.isPresent()) { + SparLog.info("A-class seedlot progress found for seedlot number {}", seedlotNumber); + } + + return form.map( savedEntity -> new SaveSeedlotFormDtoClassA( mapper.convertValue(savedEntity.getAllStepData(), JsonNode.class), @@ -86,20 +97,25 @@ public SaveSeedlotFormDtoClassA getFormClassA(String seedlotNumber) { /** Retrieves the progress_status column then return it as a json object. */ public JsonNode getFormStatusClassA(String seedlotNumber) { SparLog.info( - "Retrieving A-class seedlot progress status for seedlot number: {} ...", seedlotNumber); + "Retrieving A-class seedlot progress status for seedlot number {}", seedlotNumber); ObjectMapper mapper = new ObjectMapper(); - Object progressStatus = - saveSeedlotProgressRepositoryClassA - .getStatusById(seedlotNumber) - .orElseThrow(SeedlotFormProgressNotFoundException::new); + Optional form = saveSeedlotProgressRepositoryClassA.getStatusById(seedlotNumber); + + if (form.isPresent()) { + SparLog.info("A-class seedlot progress status found for seedlot number {}", seedlotNumber); + } + + Object progressStatus = form.orElseThrow(SeedlotFormProgressNotFoundException::new); // This needs to be converted again with readTree, otherwise it'll return a string value even // without doing the asText(). String statusString = mapper.convertValue(progressStatus, JsonNode.class).asText(); try { - return mapper.readTree(statusString); + JsonNode json = mapper.readTree(statusString); + SparLog.info("A-class seedlot progress status successfully converted to json"); + return json; } catch (JsonProcessingException e) { throw new JsonParsingException(); } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotService.java index 70586348a..ce28f1e0e 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotService.java @@ -34,6 +34,7 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort.Direction; +import org.springframework.lang.NonNull; import org.springframework.stereotype.Service; /** This class contains methods for handling Seedlots in the database. */ @@ -122,10 +123,10 @@ public SeedlotCreateResponseDto createSeedlot(SeedlotCreateDto createDto) { * @throws InvalidSeedlotRequestException in case of errors. */ private String nextSeedlotNumber(Character seedlotClassCode) { - SparLog.info("Retrieving the next class {} Seedlot number", seedlotClassCode); + SparLog.info("Retrieving next seedlot number for class-{}", seedlotClassCode); if (seedlotClassCode.equals('B')) { - SparLog.error("Class B Seedlots not implemented yet!"); + SparLog.error("Class-b seedlots not implemented yet!"); throw new InvalidSeedlotRequestException(); } @@ -139,7 +140,7 @@ private String nextSeedlotNumber(Character seedlotClassCode) { seedlotNumber += 1; - SparLog.debug("Next class {} seedlot number: {}", seedlotNumber); + SparLog.info("Next seedlot number for class-{} {}", seedlotClassCode, seedlotNumber); return String.valueOf(seedlotNumber); } @@ -152,15 +153,21 @@ private String nextSeedlotNumber(Character seedlotClassCode) { * @return a list of the user's seedlots */ public Optional> getUserSeedlots(String userId, int pageNumber, int pageSize) { + SparLog.info("Retrieving paginated list of seedlots for the user {}", userId); if (pageSize == 0) { + SparLog.info("No given value for the page size, using default 10."); pageSize = 10; } + SparLog.info("Pagination settings: pageNumber {}, pageSize {}", pageNumber, pageSize); Pageable sortedPageable = PageRequest.of( pageNumber, pageSize, Sort.by(Direction.DESC, "AuditInformation_UpdateTimestamp")); - return Optional.of( - seedlotRepository.findAllByAuditInformation_EntryUserId(userId, sortedPageable)); + + Page seedlotPage = + seedlotRepository.findAllByAuditInformation_EntryUserId(userId, sortedPageable); + SparLog.info("{} results and {} pages", seedlotPage.getNumber(), seedlotPage.getTotalPages()); + return Optional.of(seedlotPage); } /** @@ -170,18 +177,13 @@ public Optional> getUserSeedlots(String userId, int pageNumber, in * @return A Seedlot entity. * @throws SeedlotNotFoundException in case of errors. */ - public Seedlot getSingleSeedlotInfo(String seedlotNumber) { + public Seedlot getSingleSeedlotInfo(@NonNull String seedlotNumber) { SparLog.info("Retrieving information for Seedlot number {}", seedlotNumber); Seedlot seedlotInfo = - seedlotRepository - .findById(seedlotNumber) - .orElseThrow( - () -> { - SparLog.error("Nothing found for seedlot number: {}", seedlotNumber); - return new SeedlotNotFoundException(); - }); + seedlotRepository.findById(seedlotNumber).orElseThrow(SeedlotNotFoundException::new); + SparLog.info("Seedlot number {} found", seedlotNumber); return seedlotInfo; } @@ -193,31 +195,21 @@ public Seedlot getSingleSeedlotInfo(String seedlotNumber) { * @throws SeedlotNotFoundException in case of seedlot not found error. * @throws SeedlotSourceNotFoundException in case of seedlot source not found error. */ - public Seedlot patchApplicantionInfo(String seedlotNumber, SeedlotApplicationPatchDto patchDto) { + public Seedlot patchApplicantionInfo( + @NonNull String seedlotNumber, SeedlotApplicationPatchDto patchDto) { SparLog.info("Patching seedlot entry for seedlot number {}", seedlotNumber); Seedlot seedlotInfo = - seedlotRepository - .findById(seedlotNumber) - .orElseThrow( - () -> { - SparLog.error("Nothing found for seedlot number: {}", seedlotNumber); - return new SeedlotNotFoundException(); - }); + seedlotRepository.findById(seedlotNumber).orElseThrow(SeedlotNotFoundException::new); + + SparLog.info("Seedlot number {} found", seedlotNumber); seedlotInfo.setApplicantEmailAddress(patchDto.applicantEmailAddress()); SeedlotSourceEntity updatedSource = seedlotSourceRepository .findById(patchDto.seedlotSourceCode()) - .orElseThrow( - () -> { - SparLog.error( - "Seedlot source not found while patching in patchApplicantionInfo for seedlot" - + " number: {}", - seedlotNumber); - return new SeedlotSourceNotFoundException(); - }); + .orElseThrow(SeedlotSourceNotFoundException::new); seedlotInfo.setSeedlotSource(updatedSource); @@ -226,7 +218,9 @@ public Seedlot patchApplicantionInfo(String seedlotNumber, SeedlotApplicationPat // The field intendedForCrownLand == to be registered indicator. seedlotInfo.setIntendedForCrownLand(patchDto.toBeRegistrdInd()); - return seedlotRepository.save(seedlotInfo); + Seedlot seedlotSaved = seedlotRepository.save(seedlotInfo); + SparLog.info("Seedlot number {} successfully patched", seedlotNumber); + return seedlotSaved; } /** @@ -270,6 +264,7 @@ public SeedlotCreateResponseDto submitSeedlotForm( SparLog.info("Saving the Seedlot Entity for seedlot number {}", seedlotNumber); seedlotRepository.save(seedlot); + SparLog.info("Seedlot entity and related tables successfully saved."); return new SeedlotCreateResponseDto( seedlotNumber, seedlot.getSeedlotStatus().getSeedlotStatusCode()); } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotSourceService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotSourceService.java index c79463802..8eec8afa4 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotSourceService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotSourceService.java @@ -32,6 +32,7 @@ public List getAllSeedlotSource() { resultList.add(methodToAdd); }); + SparLog.info("{} valid seedlot sources found.", resultList.size()); return resultList; } } diff --git a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotStatusService.java b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotStatusService.java index 71c5d7c97..3298da4e2 100644 --- a/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotStatusService.java +++ b/backend/src/main/java/ca/bc/gov/backendstartapi/service/SeedlotStatusService.java @@ -30,6 +30,7 @@ public List getAllValidSeedlotStatusDto() { resultList.add(methodToAdd); }); + SparLog.info("{} valid seedlot statuses found for CodeDescriptionDto", resultList.size()); return resultList; } @@ -40,7 +41,12 @@ public List getAllValidSeedlotStatusDto() { */ public List getAllValidSeedlotStatusEntity() { SparLog.info("Fetching all seedlot statuses for SeedlotStatusEntity"); - return seedlotStatusRepository.findAll().stream().filter(method -> method.isValid()).toList(); + + List list = + seedlotStatusRepository.findAll().stream().filter(method -> method.isValid()).toList(); + SparLog.info("{} valid seedlot statuses found for SeedlotStatusEntity", list.size()); + + return list; } /** @@ -51,8 +57,19 @@ public List getAllValidSeedlotStatusEntity() { */ public Optional getValidSeedlotStatus(String statusCode) { SparLog.info("Get a single valid seedlot status for SeedlotStatusEntity code {}", statusCode); - return getAllValidSeedlotStatusEntity().stream() - .filter(x -> x.getSeedlotStatusCode().equals(statusCode)) - .findFirst(); + + Optional optionalSeedlot = + getAllValidSeedlotStatusEntity().stream() + .filter(x -> x.getSeedlotStatusCode().equals(statusCode)) + .findFirst(); + + String empty = ""; + if (optionalSeedlot.isEmpty()) { + empty = "not"; + } + + SparLog.info("Single seedlot status " + empty + " found for code {}", statusCode); + + return optionalSeedlot; } } diff --git a/backend/src/main/resources/logback-spring.xml b/backend/src/main/resources/logback-spring.xml index b4829182f..c1525717b 100644 --- a/backend/src/main/resources/logback-spring.xml +++ b/backend/src/main/resources/logback-spring.xml @@ -47,19 +47,11 @@ - - - - - + - - - - diff --git a/backend/src/test/java/ca/bc/gov/backendstartapi/endpoint/FavouriteActivityEndpointTest.java b/backend/src/test/java/ca/bc/gov/backendstartapi/endpoint/FavouriteActivityEndpointTest.java index 28fb1fe26..b5f2a237d 100644 --- a/backend/src/test/java/ca/bc/gov/backendstartapi/endpoint/FavouriteActivityEndpointTest.java +++ b/backend/src/test/java/ca/bc/gov/backendstartapi/endpoint/FavouriteActivityEndpointTest.java @@ -173,9 +173,9 @@ void updateUserFavoriteActivity() throws Exception { .andExpect(jsonPath("$.highlighted").value("false")) .andReturn(); - FavouriteActivityEntity activityUpdated = activityEntity.withHighlighted(true); + activityEntity.setHighlighted(true); - when(favouriteActivityService.updateUserActivity(any(), any())).thenReturn(activityUpdated); + when(favouriteActivityService.updateUserActivity(any(), any())).thenReturn(activityEntity); String stringifyUpdate = "{\"highlighted\":\"true\",\"enabled\":\"true\"}"; @@ -213,13 +213,13 @@ void deleteUserFavoriteActivity() throws Exception { .andExpect(jsonPath("$.highlighted").value("false")) .andReturn(); - FavouriteActivityEntity activityUpdated = activityEntity.withHighlighted(true); + activityEntity.setHighlighted(true); doNothing().when(favouriteActivityService).deleteUserActivity(any()); mockMvc .perform( - delete(API_PATH + "/{id}", activityUpdated.getId()) + delete(API_PATH + "/{id}", activityEntity.getId()) .with(csrf().asHeader()) .header(CONTENT_HEADER, JSON) .accept(MediaType.APPLICATION_JSON)) diff --git a/backend/src/test/java/ca/bc/gov/backendstartapi/service/FavouriteActivityServiceTest.java b/backend/src/test/java/ca/bc/gov/backendstartapi/service/FavouriteActivityServiceTest.java index bef7b3d0a..8f1556c7e 100644 --- a/backend/src/test/java/ca/bc/gov/backendstartapi/service/FavouriteActivityServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/backendstartapi/service/FavouriteActivityServiceTest.java @@ -75,7 +75,7 @@ void createUserActivityExceptionTest() { () -> favouriteActivityService.createUserActivity(createDto)); Assertions.assertEquals( - "404 NOT_FOUND \"Invalid activity or page name!\"", notFoundExc.getMessage()); + "404 NOT_FOUND \"Invalid or not found activity id!\"", notFoundExc.getMessage()); List userFavList = List.of(entity); when(favouriteActivityRepository.findAllByUserId(any())).thenReturn(userFavList); @@ -147,7 +147,7 @@ void updateUserActivityExceptionTest() { InvalidActivityException.class, () -> favouriteActivityService.updateUserActivity(1L, updateDto)); - Assertions.assertEquals("404 NOT_FOUND \"Invalid activity or page name!\"", e.getMessage()); + Assertions.assertEquals("404 NOT_FOUND \"Invalid or not found activity id!\"", e.getMessage()); } @Test @@ -184,6 +184,6 @@ void deleteUserActivityExceptionTest() { Assertions.assertThrows( InvalidActivityException.class, () -> favouriteActivityService.deleteUserActivity(1L)); - Assertions.assertEquals("404 NOT_FOUND \"Invalid activity or page name!\"", e.getMessage()); + Assertions.assertEquals("404 NOT_FOUND \"Invalid or not found activity id!\"", e.getMessage()); } } diff --git a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FacilityTypesEndpoint.java b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FacilityTypesEndpoint.java index 01243820c..e80de87c0 100644 --- a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FacilityTypesEndpoint.java +++ b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FacilityTypesEndpoint.java @@ -1,11 +1,5 @@ package ca.bc.gov.backendstartapi.endpoint; -import java.util.List; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - import ca.bc.gov.backendstartapi.config.SparLog; import ca.bc.gov.backendstartapi.entity.FacilityTypes; import ca.bc.gov.backendstartapi.repository.FacilityTypesRepository; @@ -15,10 +9,17 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +/** This class holds resources to provide {@link FacilityTypes} data. */ @RestController @RequestMapping("/api/facility-types") -@Tag(name = "facilityTypes", description = "Resource to retrieve Facility Types for Interim Agencies") +@Tag( + name = "facilityTypes", + description = "Resource to retrieve Facility Types for Interim Agencies") public class FacilityTypesEndpoint { private FacilityTypesRepository facilityTypesRepository; @@ -28,37 +29,36 @@ public class FacilityTypesEndpoint { } /** - * Retrieve all valid facility types + * Retrieve all valid facility types. * * @return a list of {@link FacilityTypes} with all found result */ @GetMapping(produces = "application/json") @Operation( - summary = "Retrieve all valid facility types", - description = - "Retrieve all valid (non expired) facility types based on effectiveDate " - + "and expiryDate, where 'today >= effectiveDate' and 'today < expiryDate'." - ) + summary = "Retrieve all valid facility types", + description = + "Retrieve all valid (non expired) facility types based on effectiveDate " + + "and expiryDate, where 'today >= effectiveDate' and 'today < expiryDate'.") @ApiResponses( - value = { - @ApiResponse( - responseCode = "200", - description = "Returns a list containing all facility types", - content = - @Content( - mediaType = "application/json", - schema = @Schema(implementation = FacilityTypes.class) - ) - ), - @ApiResponse( - responseCode = "401", - description = "Access token is missing or invalid", - content = @Content(schema = @Schema(implementation = Void.class)) - ) - } - ) - public List getAllValidFacilityTypes() { + value = { + @ApiResponse( + responseCode = "200", + description = "Returns a list containing all facility types", + content = + @Content( + mediaType = "application/json", + schema = @Schema(implementation = FacilityTypes.class))), + @ApiResponse( + responseCode = "401", + description = "Access token is missing or invalid", + content = @Content(schema = @Schema(implementation = Void.class))) + }) + public List getAllValidFacilityTypes() { SparLog.info("Fetching all valid facility types"); - return facilityTypesRepository.findAllValid(); + + List resultList = facilityTypesRepository.findAllValid(); + SparLog.info("{} valid facillity type found", resultList.size()); + + return resultList; } } diff --git a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FundingSourceEndpoint.java b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FundingSourceEndpoint.java index 87635b69b..479031a2d 100644 --- a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FundingSourceEndpoint.java +++ b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/FundingSourceEndpoint.java @@ -52,7 +52,11 @@ public class FundingSourceEndpoint { content = @Content(schema = @Schema(implementation = Void.class))) }) public List getAllValidFundingSources() { - SparLog.info("Fetching all valid Funding Sources"); - return fundingSourceRepository.findAllValid(); + SparLog.info("Fetching all valid funding sources"); + + List resultList = fundingSourceRepository.findAllValid(); + SparLog.info("{} valid funding sources found.", resultList.size()); + + return resultList; } } diff --git a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/VegetationCodeEndpoint.java b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/VegetationCodeEndpoint.java index 77a44f29b..5c14eac3d 100644 --- a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/VegetationCodeEndpoint.java +++ b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/endpoint/VegetationCodeEndpoint.java @@ -68,6 +68,9 @@ public VegetationCode findByCode( String code) { SparLog.info("Fetching information to vegetation code: {}", code); var retrievalResult = vegetationCodeRepository.findById(code); + if (retrievalResult.isPresent()) { + SparLog.info("Vegetation code found for code {}", code); + } return retrievalResult.orElseThrow( () -> new ResponseStatusException( @@ -121,6 +124,8 @@ public List findEffectiveByCodeOrDescription( if (Objects.isNull(vegetationPage)) { return List.of(); } + SparLog.info( + "{} Vegetation codes found for search {}", vegetationPage.getNumberOfElements(), search); return vegetationPage.getContent(); } } diff --git a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java index a581e2d84..753d9ce82 100644 --- a/oracle-api/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java +++ b/oracle-api/src/main/java/ca/bc/gov/backendstartapi/service/OrchardService.java @@ -62,7 +62,7 @@ public Optional findNotRetiredOrchardValidLotType( if (orchard.isPresent()) { OrchardLotTypeCode orchardLotTypeCode = orchard.get().getOrchardLotTypeCode(); if (Objects.isNull(orchardLotTypeCode) || !orchardLotTypeCode.isValid()) { - SparLog.info("Orchard lot type is not valid!"); + SparLog.warn("Orchard lot type is not valid!"); return Optional.empty(); } @@ -74,9 +74,12 @@ public Optional findNotRetiredOrchardValidLotType( orchardLotTypeCode.getCode(), orchardLotTypeCode.getDescription(), orchard.get().getStageCode()); + + SparLog.info("Valid not retired Orchard found for id: {}", id); return Optional.of(descriptionDto); } + SparLog.info("Valid not retired Orchard not found for id: {}", id); return Optional.empty(); } @@ -100,9 +103,12 @@ public Optional findParentTreeGeneticQualityData( SparLog.debug("Time elapsed querying orchard by id: {}", endingOne - starting); if (orchard.isEmpty()) { + SparLog.info("Orchard not found for id {}", orchardId); return Optional.empty(); } + SparLog.info("Orchard found for id {}, fetching orchard parent tree data", orchardId); + // Orchard OrchardParentTreeDto orchardParentTreeDto = new OrchardParentTreeDto(); orchardParentTreeDto.setOrchardId(orchard.get().getId()); @@ -117,6 +123,7 @@ public Optional findParentTreeGeneticQualityData( long ending = Instant.now().toEpochMilli(); SparLog.debug("Time elapsed final: {}", ending - starting); + SparLog.info("Orchard parent tree data fetched successfully"); return Optional.of(orchardParentTreeDto); } @@ -151,8 +158,11 @@ public Optional> findNotRetOrchardsByVegCode( }); if (resultList.isEmpty()) { + SparLog.info("No records for not retired Orchard for VegCode: {}", vegCode); return Optional.empty(); } + + SparLog.info("{} records for not retired Orchard for VegCode: {}", resultList.size(), vegCode); return Optional.of(resultList); } @@ -194,6 +204,7 @@ public List findParentTreesWithVegCode( .equals(Long.valueOf(orchardSpuMap.get(treeDto.getOrchardId())))) .toList(); + SparLog.info("{} parent trees found under VegCode: {}", resultList.size(), vegCode); return resultList; } diff --git a/oracle-api/src/main/resources/logback-spring.xml b/oracle-api/src/main/resources/logback-spring.xml index a39369b5d..68befe3ba 100644 --- a/oracle-api/src/main/resources/logback-spring.xml +++ b/oracle-api/src/main/resources/logback-spring.xml @@ -47,8 +47,8 @@ - - + + diff --git a/oracle-api/src/test/java/ca/bc/gov/backendstartapi/repository/FacilityTypesRepositoryTest.java b/oracle-api/src/test/java/ca/bc/gov/backendstartapi/repository/FacilityTypesRepositoryTest.java index 0c1df008a..314586ec3 100644 --- a/oracle-api/src/test/java/ca/bc/gov/backendstartapi/repository/FacilityTypesRepositoryTest.java +++ b/oracle-api/src/test/java/ca/bc/gov/backendstartapi/repository/FacilityTypesRepositoryTest.java @@ -1,7 +1,6 @@ package ca.bc.gov.backendstartapi.repository; import ca.bc.gov.backendstartapi.entity.FacilityTypes; - import java.time.LocalDate; import java.util.List; import org.junit.jupiter.api.Assertions;