Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
5929619
#220: refactor(backend): Remove duplicated string literals by introd…
yasminehilout Mar 25, 2025
4266d4e
#220: refactor(backend): Enhance logging for configuration file opera…
yasminehilout Mar 25, 2025
ab7cd1a
#220: refactor(tests): : Remove unused values in GeoTIFFServiceTests
yasminehilout Mar 25, 2025
5cd71d3
Merge branch 'dev' of https://github.com/XavierGuertin/WildfireVisual…
yasminehilout Mar 25, 2025
75557d3
Merge branch 'dev' into 220/chore-backend-maintainability-fix
yasminehilout Mar 30, 2025
87ebf43
#220: fix(backend): : Remove useless assignment and unused local vari…
yasminehilout Mar 30, 2025
a817806
#220: refactor(backend): Move workspaces path to application.properties
yasminehilout Mar 30, 2025
d104132
#220: fix(backend): Update GeoServerService to use configurable works…
yasminehilout Mar 30, 2025
6f705dc
#220 - test(backend): Refactor GeoServerServiceTests to use configura…
yasminehilout Mar 30, 2025
51e4d2e
#220 - refactor(backend): Reduce cognitive complexity in fetchData() …
yasminehilout Mar 30, 2025
cc8784b
#220 - refactor(backend): Simplify asset processing in DataService by…
yasminehilout Mar 31, 2025
03783f5
#220 - refactor(backend): Replace hardcoded success message with a co…
yasminehilout Mar 31, 2025
25edca5
#220 - refactor(backend): Replace Thread.sleep with Awaitility for as…
yasminehilout Mar 31, 2025
42f740b
Merge branch 'dev' of https://github.com/XavierGuertin/WildfireVisual…
yasminehilout Apr 6, 2025
3367364
Merge branch 'dev' into 220/chore-backend-maintainability-fix
yasminehilout Apr 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ public class DataController {

private static final Logger logger = LoggerFactory.getLogger(DataController.class);

private static final String LOG_RECEIVED_REMOVE_ALL_ITEMS = "Received request to remove all items";
private static final String LOG_SUCCESSFULLY_REMOVED_ALL_ITEMS = "successfully removed all items";

private final DataService dataService;

public DataController(DataService dataService) {
Expand All @@ -35,8 +38,7 @@ public DataController(DataService dataService) {

@GetMapping("/api/load-assets/{collectionId}")
public ResponseEntity<String> loadAssets(
@PathVariable String collectionId
) {
@PathVariable String collectionId) {
logger.info("Received request to load assets asynchronously for collection: {}", collectionId);
try {
// Run the processing task asynchronously
Expand Down Expand Up @@ -68,7 +70,6 @@ public ResponseEntity<List<Map<String, Object>>> getLoadedLayers() {
return ResponseEntity.ok(dataService.getLoadedLayers());
}


/**
* Parses a bounding box (BBOX) string from a request parameter.
* The BBOX format is "minX,minY,maxX,maxY".
Expand Down Expand Up @@ -250,9 +251,9 @@ public ResponseEntity<List<Map<String, Object>>> getItem(@PathVariable("id") Str
*/
@DeleteMapping("/api/remove-all-items")
public ResponseEntity<String> removeAllItems() {
logger.info("Received request to remove all items");
logger.info(LOG_RECEIVED_REMOVE_ALL_ITEMS);
String result = dataService.removeAllItems();
logger.debug("Successfully removed all items");
logger.debug(LOG_SUCCESSFULLY_REMOVED_ALL_ITEMS);
return ResponseEntity.ok(result);
}

Expand All @@ -266,9 +267,9 @@ public ResponseEntity<String> removeAllItems() {
*/
@DeleteMapping("/api/remove-items-from-collection/{collectionId}")
public ResponseEntity<String> removeItemsFromCollection(@PathVariable("collectionId") String collectionId) {
logger.info("Received request to remove all items");
logger.info(LOG_RECEIVED_REMOVE_ALL_ITEMS);
String result = dataService.removeItemsFromCollection(collectionId);
logger.debug("Successfully removed all items");
logger.debug(LOG_SUCCESSFULLY_REMOVED_ALL_ITEMS);
return ResponseEntity.ok(result);
}

Expand All @@ -284,9 +285,9 @@ public ResponseEntity<String> removeItemsFromCollection(@PathVariable("collectio
@DeleteMapping("/api/remove-item/{id}/{collection}")
public ResponseEntity<String> removeItem(@PathVariable("id") String itemId,
@PathVariable("collection") String collectionId) {
logger.info("Received request to remove all items");
logger.info(LOG_RECEIVED_REMOVE_ALL_ITEMS);
String result = dataService.removeItem(itemId, collectionId);
logger.debug("Successfully removed all items");
logger.debug(LOG_SUCCESSFULLY_REMOVED_ALL_ITEMS);
return ResponseEntity.ok(result);
}

Expand Down Expand Up @@ -332,17 +333,20 @@ public ResponseEntity<String> resetItems() {
}

/**
* Fetches collections sorted by name, optionally filtering by a bounding box (BBOX)
* Fetches collections sorted by name, optionally filtering by a bounding box
* (BBOX)
* with specified sort direction.
*
* @param bboxStr The bounding box string in "minX,minY,maxX,maxY" format (optional).
* @param sortDirection The direction to sort collections ("asc" or "desc"). Default is "asc".
* @param bboxStr The bounding box string in "minX,minY,maxX,maxY" format
* (optional).
* @param sortDirection The direction to sort collections ("asc" or "desc").
* Default is "asc".
* @return A ResponseEntity containing a list of collections sorted by name.
*/
@GetMapping("/api/get-collections-by-name")
public ResponseEntity<List<Map<String, Object>>> getCollectionsByName(
@RequestParam(value = "bbox", required = false) String bboxStr,
@RequestParam(value = "sortDirection", defaultValue = "asc") String sortDirection) {
@RequestParam(value = "bbox", required = false) String bboxStr,
@RequestParam(value = "sortDirection", defaultValue = "asc") String sortDirection) {
logger.info("Processing request to fetch collections sorted by name with direction: {}", sortDirection);

double[] bbox = parseBbox(bboxStr);
Expand All @@ -354,15 +358,15 @@ public ResponseEntity<List<Map<String, Object>>> getCollectionsByName(
* Fetches collections sorted by date, optionally filtering by a bounding box
* (BBOX) with specified sort direction.
*
* @param bboxStr The bounding box string in "minX,minY,maxX,maxY" format
* (optional).
* @param bboxStr The bounding box string in "minX,minY,maxX,maxY" format
* (optional).
* @param sortDirection The direction to sort ("asc" or "desc").
* @return A ResponseEntity containing a list of collections sorted by date.
*/
@GetMapping("/api/get-collections-by-date")
public ResponseEntity<List<Map<String, Object>>> getCollectionsByDate(
@RequestParam(value = "bbox", required = false) String bboxStr,
@RequestParam(value = "sortDirection", defaultValue = "asc") String sortDirection) {
@RequestParam(value = "bbox", required = false) String bboxStr,
@RequestParam(value = "sortDirection", defaultValue = "asc") String sortDirection) {
logger.info("Processing request to fetch collections sorted by date with direction: {}", sortDirection);

double[] bbox = parseBbox(bboxStr);
Expand Down Expand Up @@ -427,7 +431,7 @@ public ResponseEntity<String> resetItemAssets() {
return ResponseEntity.ok("Item asset layers reset successfully.");
} else {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to reset item asset layers.");
.body("Failed to reset item asset layers.");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class StacRepository {
private static final Logger logger = LoggerFactory.getLogger(StacRepository.class);
private static final String FETCHING_ALL_COLLECTIONS = "Fetching all collections";
private static final String FETCHING_WITH_BBOX = "Fetching collections with bbox: ";
private static final String QUERY_RETURNED_RESULTS = "Query returned {} results";

private final JdbcTemplate jdbcTemplate;

Expand Down Expand Up @@ -121,7 +122,7 @@ public List<Map<String, Object>> queryCollection(String collectionId) {
try {
String sql = "SELECT * FROM pgstac.collections WHERE id = ?";
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql, collectionId);
logger.debug("Query returned {} results", results.size());
logger.debug(QUERY_RETURNED_RESULTS, results.size());
return results;
} catch (DataAccessException e) {
logger.error("Error querying collection: {}", e.getMessage(), e);
Expand Down Expand Up @@ -376,7 +377,8 @@ public List<Map<String, Object>> getAllItems(String collectionId) {
" }'::jsonb" +
")";
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql);
logger.debug("Query returned {} results", results.size());

logger.debug(QUERY_RETURNED_RESULTS, results.size());
return results;
} catch (DataAccessException e) {
logger.error("Error fetching items: {}", e.getMessage(), e);
Expand Down Expand Up @@ -416,7 +418,7 @@ public List<Map<String, Object>> getItem(String id) {
try {
String sql = "SELECT pgstac.get_item('" + id + "');";
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql);
logger.debug("Query returned {} results", results.size());
logger.debug(QUERY_RETURNED_RESULTS, results.size());
return results;
} catch (DataAccessException e) {
logger.error("Error fetching item: {}", e.getMessage(), e);
Expand All @@ -439,7 +441,7 @@ public List<Map<String, Object>> getItem(String id, String collection) {
try {
String sql = "SELECT pgstac.get_item('" + id + "', '" + collection + "');";
List<Map<String, Object>> results = jdbcTemplate.queryForList(sql);
logger.debug("Query returned {} results", results.size());
logger.debug(QUERY_RETURNED_RESULTS, results.size());
return results;
} catch (DataAccessException e) {
logger.error("Error fetching item: {}", e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ public Map<String, Object> getConfig() {
try {
File configFile = new File(CONFIG_FILE_PATH);
if (configFile.exists()) {
logger.info("Reading configuration from file: {}", CONFIG_FILE_PATH);
return objectMapper.readValue(configFile, Map.class);
} else {
return Map.of();
}
} catch (Exception e) {
logger.error("Failed to retrieve configuration from {}: {}", CONFIG_FILE_PATH, e.getMessage(), e);
throw new ConfigException("Failed to retrieve configuration", e);
}
}
Expand All @@ -50,8 +52,11 @@ public Map<String, Object> getConfig() {
*/
public void saveConfig(Map<String, Object> config) {
try {
logger.info("Saving configuration to file: {}", CONFIG_FILE_PATH);
objectMapper.writeValue(new File(CONFIG_FILE_PATH), config);
logger.debug("Configuration saved successfully");
} catch (Exception e) {
logger.error("Failed to save configuration to {}: {}", CONFIG_FILE_PATH, e.getMessage(), e);
throw new ConfigException("Failed to save configuration", e);
}
}
Expand Down
Loading
Loading