Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HCMPRE-586] plan facility search API #899

Open
wants to merge 3 commits into
base: microplanning-dev
Choose a base branch
from

Conversation

palak-egov
Copy link
Collaborator

@palak-egov palak-egov commented Sep 24, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a comprehensive plan facility management system, including creation, search, and update functionalities.
    • Added a new endpoint for searching plan facilities via a POST request.
  • Bug Fixes

    • Updated database connection properties for improved security.
  • Database Changes

    • Created a new plan_facility_linkage table to manage the linkage between plans and facilities.
  • Documentation

    • Enhanced request and response model classes for better data handling.

Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The changes introduce a new set of classes and interfaces for managing plan facilities within a health services application. Key components include the PlanFacilityRepository interface, its implementation PlanFacilityRepositoryImpl, and various supporting classes for data transfer, querying, and response handling. A new database table plan_facility_linkage is created to store facility data, and modifications to configuration files are made to support these changes.

Changes

Files Change Summary
.../repository/PlanFacilityRepository.java Added PlanFacilityRepository interface with methods for creating, searching, and updating plan facilities.
.../repository/impl/PlanFacilityRepositoryImpl.java Implemented PlanFacilityRepositoryImpl class with methods for searching plan facilities and a stub for creating facilities.
.../repository/querybuilder/PlanFacilityQueryBuilder.java Introduced PlanFacilityQueryBuilder class for constructing SQL queries related to plan facilities.
.../repository/rowmapper/PlanFacilityRowMapper.java Added PlanFacilityRowMapper class for mapping SQL ResultSet to PlanFacility objects.
.../service/PlanFacilityService.java Created PlanFacilityService class to handle search requests for plan facilities.
.../web/controllers/PlanFacilityController.java Introduced PlanFacilityController class with a method for handling POST requests to search for facilities.
.../models/PlanFacility.java Added PlanFacility class to represent facility data with various attributes.
.../models/PlanFacilityRequest.java Created PlanFacilityRequest class for encapsulating requests related to plan facilities.
.../models/PlanFacilityResponse.java Introduced PlanFacilityResponse class for structuring responses containing plan facility data.
.../models/PlanFacilitySearchCriteria.java Added PlanFacilitySearchCriteria class to encapsulate search criteria for facilities.
.../models/PlanFacilitySearchRequest.java Created PlanFacilitySearchRequest class for encapsulating search requests.
.../resources/application.properties Updated the spring.datasource.password property from postgres to 123.
.../resources/db/migrate.sh Changed Flyway command in migrate.sh from migrate to repair.
.../migration/main/V20240923113045__plan_facility_create_ddl.sql Introduced a new SQL file to create the plan_facility_linkage table with specified columns and constraints.

Possibly related PRs

  • Adding plan-service folder for master merge #783: This PR introduces the PlanFacilityRepository interface and its implementation, which directly relates to the changes made in the main PR regarding the creation, searching, and updating of plan facilities.
  • hcm v1.5 : dev to master  #855: Although this PR primarily focuses on version updates in various pom.xml files, it does not directly relate to the specific changes made in the main PR regarding the PlanFacilityRepository and its associated methods.

🐰 In a world where plans unite,
Facilities hop with pure delight.
New tables bloom, queries take flight,
With each new class, the code feels right.
So let us cheer, for changes are bright!
🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@palak-egov palak-egov closed this Sep 25, 2024
@palak-egov palak-egov reopened this Sep 25, 2024
@palak-egov palak-egov changed the title plan facility search API [HCMPRE-586] plan facility search API Sep 25, 2024
@palak-egov
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 26, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@palak-egov
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Sep 27, 2024

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 28

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 096c580 and 6ebb122.

📒 Files selected for processing (15)
  • health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanFacilityQueryBuilder.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanFacilityRowMapper.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/service/PlanFacilityService.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/util/ServiceUtil.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanFacilityRequest.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanFacilityResponse.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanFacilitySearchCriteria.java (1 hunks)
  • health-services/plan-service/src/main/java/digit/web/models/PlanFacilitySearchRequest.java (1 hunks)
  • health-services/plan-service/src/main/resources/application.properties (1 hunks)
  • health-services/plan-service/src/main/resources/db/migrate.sh (1 hunks)
  • health-services/plan-service/src/main/resources/db/migration/main/V20240923113045__plan_facility_create_ddl.sql (1 hunks)
🧰 Additional context used
📓 Learnings (6)
health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java (2)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java:22-33
Timestamp: 2024-09-26T13:12:05.028Z
Learning: In this codebase, exception handling in repositories follows a consistent approach across files. Enhancements to exception handling are deferred to maintain uniformity.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java:10-12
Timestamp: 2024-09-26T08:10:11.360Z
Learning: In this codebase, `update` methods in repositories are designed not to return any value.
health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java (2)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java:22-33
Timestamp: 2024-09-26T13:12:05.028Z
Learning: In this codebase, exception handling in repositories follows a consistent approach across files. Enhancements to exception handling are deferred to maintain uniformity.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java:10-12
Timestamp: 2024-09-26T08:10:11.360Z
Learning: In this codebase, `update` methods in repositories are designed not to return any value.
health-services/plan-service/src/main/java/digit/service/PlanFacilityService.java (4)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java:22-33
Timestamp: 2024-09-26T13:12:05.028Z
Learning: In this codebase, exception handling in repositories follows a consistent approach across files. Enhancements to exception handling are deferred to maintain uniformity.
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/service/PlanFacilityService.java:13-19
Timestamp: 2024-09-26T14:26:23.995Z
Learning: In this codebase, the `final` keyword is not required for dependency-injected fields in services.
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java:26-36
Timestamp: 2024-09-26T18:13:52.611Z
Learning: In this codebase, when creating resources via POST requests, HTTP status 202 Accepted is intentionally used as per the requirements.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java:10-12
Timestamp: 2024-09-26T08:10:11.360Z
Learning: In this codebase, `update` methods in repositories are designed not to return any value.
health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java (3)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java:26-36
Timestamp: 2024-09-26T18:13:52.611Z
Learning: In this codebase, when creating resources via POST requests, HTTP status 202 Accepted is intentionally used as per the requirements.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java:24-34
Timestamp: 2024-09-26T11:15:18.213Z
Learning: In this codebase, when updating plan facilities, `HttpStatus.ACCEPTED` (202) is intentionally used in `PlanFacilityController` as per the requirements.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java:30-34
Timestamp: 2024-09-26T11:00:34.017Z
Learning: In this codebase, exceptions are already handled globally, so explicit error handling in controllers is not necessary.
health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java (4)
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java:61-67
Timestamp: 2024-09-27T04:31:09.991Z
Learning: In the `addServiceBoundariesItem` method in `PlanFacility.java`, it's acceptable to initialize `serviceBoundaries` if it's null without adding a null check for `serviceBoundariesItem`.
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java:1-69
Timestamp: 2024-09-27T02:31:33.207Z
Learning: In the `PlanFacility` model, the `active` field is set to `true` during creation, so it does not need to be initialized to `true` in the class definition.
Learnt from: Saloni-eGov
PR: egovernments/health-campaign-services#906
File: health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java:28-59
Timestamp: 2024-09-27T04:33:06.202Z
Learning: In this project, the `additionalDetails` field is intentionally typed as `Object`, and it's the accepted approach.
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/service/PlanFacilityService.java:13-19
Timestamp: 2024-09-26T14:26:23.995Z
Learning: In this codebase, the `final` keyword is not required for dependency-injected fields in services.
health-services/plan-service/src/main/java/digit/web/models/PlanFacilitySearchRequest.java (1)
Learnt from: Taniya-eGov
PR: egovernments/health-campaign-services#914
File: health-services/plan-service/src/main/java/digit/web/models/facility/FacilitySearchRequest.java:15-19
Timestamp: 2024-09-27T04:37:54.293Z
Learning: In the `FacilitySearchRequest` class, the JSON property for `facilitySearchCriteria` should remain as `Facility` to maintain consistency with the existing API contract and avoid confusing existing API consumers.
🪛 Shellcheck
health-services/plan-service/src/main/resources/db/migrate.sh

[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)

🔇 Additional comments (43)
health-services/plan-service/src/main/resources/db/migrate.sh (1)

3-3: ⚠️ Potential issue

Clarify the reason for changing from 'migrate' to 'repair'

The Flyway command has been changed from 'migrate' to 'repair'. This is a significant alteration that changes the behavior of the script:

  • 'migrate' applies pending migrations to the database.
  • 'repair' fixes the schema history table without applying migrations.

This change could have substantial impacts on the database state and migration process. Could you please provide the rationale behind this modification? Are there specific issues with the schema history table that necessitate this change?

To understand the current state of migrations, please run the following command:

This will provide information about applied and pending migrations, which can help in determining whether 'repair' is necessary.

🧰 Tools
🪛 Shellcheck

[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)


[info] 3-3: Double quote to prevent globbing and word splitting.

(SC2086)

health-services/plan-service/src/main/java/digit/repository/PlanFacilityRepository.java (5)

1-5: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are correctly defined and relevant to the interface's purpose.


7-7: LGTM: Interface declaration is well-defined.

The PlanFacilityRepository interface is properly declared as public and follows Java naming conventions.


8-8: LGTM: create method signature is appropriate.

The create method is correctly defined as a void method, which aligns with the repository pattern and the codebase's conventions for similar operations.


10-12: LGTM: search and update methods are well-defined.

Both method signatures are appropriate for their respective operations:

  • The search method returns a List<PlanFacility> and takes a PlanFacilitySearchCriteria parameter, which is suitable for a search operation.
  • The update method is correctly defined as void, aligning with the codebase's conventions for update operations.

It's good to see that the previous feedback about renaming the planSearchCriteria parameter has been addressed.


1-13: Overall assessment: Well-structured repository interface.

The PlanFacilityRepository interface is well-designed and adheres to Java conventions and the codebase's patterns. It provides a clear contract for implementing classes, covering the essential operations for plan facilities (create, search, and update). The method signatures are consistent with the established conventions in the project.

Good job on implementing the feedback from previous reviews and maintaining consistency with the codebase's standards.

health-services/plan-service/src/main/resources/db/migration/main/V20240923113045__plan_facility_create_ddl.sql (3)

1-3: LGTM: Table creation and primary key constraint.

The table name plan_facility_linkage accurately reflects its purpose. The id column as varchar(64) is suitable for UUID storage, which is a good practice for distributed systems. The primary key constraint is correctly defined.

Also applies to: 15-15


3-8: Addressing past comment on varchar usage.

Regarding the past comment questioning the use of varchar for a specific column, it's worth noting that varchar is used consistently across multiple columns in this table. This is a common practice, especially for columns that might store UUIDs or other string-based identifiers.

If there are concerns about the use of varchar for any specific column, please clarify which column is in question and provide more context about the expected data type or storage requirements.


4-7: Verify the residing_boundary column definition.

The column definitions and foreign key constraints for tenant_id, plan_configuration_id, and facility_id look good. The use of varchar(64) is consistent and appropriate for these columns.

However, the residing_boundary column is defined similarly but doesn't have a foreign key constraint. If this column is supposed to reference another table (e.g., a boundaries table), consider adding a foreign key constraint. If it's intentionally not referencing another table, please confirm that this is the desired behavior.

To verify if there's a boundaries table that residing_boundary should reference, run:

Also applies to: 16-17

✅ Verification successful

The residing_boundary column is correctly defined without a foreign key constraint.

The residing_boundary column is defined as varchar(64) and does not reference another table, as confirmed by the codebase analysis. If this is the intended design, no further action is required.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for existence of a boundaries table
rg --type sql 'CREATE TABLE.*boundar(y|ies)'

Length of output: 46


Script:

#!/bin/bash
# Check for foreign key constraints referencing 'residing_boundary'
rg --type sql 'FOREIGN KEY.*residing_boundary'

Length of output: 48

health-services/plan-service/src/main/java/digit/web/models/PlanFacilityRequest.java (3)

1-11: LGTM: Package declaration and imports are correct.

The package declaration and imports are appropriate for the class requirements. All necessary imports are present, and there are no unused imports.


15-20: LGTM: Appropriate use of annotations.

The class-level annotations are well-chosen:

  • @Validated enables validation support.
  • Lombok annotations (@Data, @AllArgsConstructor, @NoArgsConstructor, @Builder) effectively reduce boilerplate code.
    This combination is suitable for a DTO (Data Transfer Object) class.

1-30: Formatting looks good: Addressing past review comment.

Regarding the previous comment about formatting the class with proper spaces:

  • The current formatting appears consistent and follows standard Java conventions.
  • There are no obvious formatting issues in the provided code.

If there were specific formatting concerns in the previous version, they seem to have been addressed in this iteration.

health-services/plan-service/src/main/java/digit/web/models/PlanFacilitySearchRequest.java (2)

1-11: LGTM: Package declaration and imports are correct.

The package declaration and imports are appropriate for the class being defined.


1-30: Formatting issues have been resolved.

The formatting issues mentioned in the previous review (two spaces at the end and no space at the top) have been addressed in this version of the file. The overall formatting of the class looks good now.

health-services/plan-service/src/main/java/digit/util/ServiceUtil.java (2)

1-7: LGTM: Package declaration and imports are appropriate.

The package declaration and imports are correctly specified for the intended functionality. Good job on including only the necessary imports.


1-23: 🧹 Nitpick (assertive)

Consider moving this functionality to an existing utility class.

A previous review comment suggested moving this function to an existing commonUtil class. This could improve code organization and reduce duplication. However, we need more information about the commonUtil class and its location.

To make an informed decision, please run the following script to locate the commonUtil class and examine its contents:

After reviewing the results, consider whether it's appropriate to move the validateStringAgainstRegex method to the commonUtil class. If you decide to move it, ensure to update all references to this method in other parts of the codebase.

health-services/plan-service/src/main/java/digit/web/models/PlanFacilitySearchCriteria.java (4)

1-12: LGTM: Package declaration and imports are correct and well-organized.

The package declaration and imports are appropriate for the class implementation. All necessary dependencies are included without any redundant or unused imports.


1-39: LGTM: Overall structure and design are well-suited for a search criteria class.

The PlanFacilitySearchCriteria class is well-structured and follows good design principles:

  1. Encapsulation is maintained with private fields and Lombok-generated accessors.
  2. The builder pattern (via @builder) allows for flexible and readable object creation.
  3. Immutability is ensured by default through the @DaTa annotation, which is suitable for a criteria object.
  4. The use of Set for ids is efficient for unique id searches.

The class effectively serves its purpose as a search criteria object for plan facilities.


39-39: Resolved: New line added at the end of the file.

The previous comment about a missing new line at the end of the file has been addressed. The file now correctly ends with a new line, which is a good practice for version control systems and some compilers.


1-39: Overall assessment: Well-implemented search criteria class with room for minor enhancements.

The PlanFacilitySearchCriteria class is well-designed and implements the necessary functionality for searching plan facilities. It makes good use of Lombok, Jackson, and validation annotations to create a clean and functional search criteria object.

Key strengths:

  1. Appropriate use of annotations for JSON mapping, validation, and boilerplate code generation.
  2. Well-structured fields with clear purposes.
  3. Use of generics and appropriate data structures (e.g., Set for ids).

Suggested enhancements:

  1. Add more specific validation constraints to ensure data integrity.
  2. Include Javadoc comments for better code documentation.
  3. Consider using @JsonInclude to optimize JSON output.
  4. Add @ToString.Exclude for potentially large collections to prevent performance issues in logging.

These enhancements would further improve the robustness, maintainability, and efficiency of the class. Overall, the implementation provides a solid foundation for the plan facility search API.

health-services/plan-service/src/main/java/digit/web/models/PlanFacilityResponse.java (3)

1-23: LGTM: Class structure and annotations are well-defined.

The class structure is appropriate for a response model. The use of Lombok annotations (@Data, @AllArgsConstructor, @NoArgsConstructor, @Builder) effectively reduces boilerplate code. The @Validated annotation is a good practice for ensuring data integrity in validation contexts.


25-30: LGTM: Fields are well-defined and properly annotated.

The responseInfo and planFacility fields are appropriately defined for a response model. The use of @JsonProperty ensures proper JSON handling, and the @Valid annotation on planFacility allows for cascading validation, which is a good practice.


1-44: Overall, well-structured response model with minor improvements suggested.

The PlanFacilityResponse class is well-designed for its purpose as a response model. It uses appropriate annotations, has well-defined fields, and provides a clear structure for the response data. The main suggestion for improvement is to remove the redundant builder methods and rely on the Lombok-generated builder, which would simplify the class without losing functionality.

To further enhance the class:

  1. Consider adding documentation comments for the fields to improve code readability.
  2. If specific validation rules are required, consider adding validation annotations (e.g., @NotNull, @Size) to the fields.
  3. Ensure that the PlanFacility class (not shown in this file) is also well-structured and properly annotated.
health-services/plan-service/src/main/java/digit/web/controllers/PlanFacilityController.java (3)

18-20: LGTM: Class declaration and annotations are correct.

The PlanFacilityController class is properly annotated with @Controller and @RequestMapping("plan"), following best practices for Spring MVC controllers.


1-28: Overall, the implementation of PlanFacilityController is well-structured and follows Spring MVC best practices.

The controller correctly handles the plan facility search operation. A few minor improvements were suggested:

  1. Consider using constructor injection for PlanFacilityService.
  2. Verify the HTTP status code usage for consistency with other search endpoints in the codebase.

These suggestions aim to enhance the code's maintainability and consistency but don't impact the current functionality.


23-27: LGTM: Method implementation is correct. Verify HTTP status usage.

The searchPost method is well-implemented with proper request mapping, validation, and response handling. However, there's a consideration regarding HTTP status codes:

  • The current implementation uses HttpStatus.OK (200), which is appropriate for successful search operations.
  • Previous learnings indicate that HttpStatus.ACCEPTED (202) is intentionally used for creating resources via POST requests in this codebase.

Since this is a search operation and not a resource creation, the current status (200) seems appropriate. However, it might be worth verifying if there are any specific requirements for using 202 in search operations as well.

To ensure consistency across the codebase, you may want to check other search endpoints:

health-services/plan-service/src/main/java/digit/service/PlanFacilityService.java (3)

11-14: LGTM!

The class declaration and field look good. The @Service annotation is correctly applied, and the PlanFacilityRepository field follows the codebase conventions for dependency injection.


16-18: LGTM!

The constructor is well-implemented, properly injecting the PlanFacilityRepository dependency.


26-33: LGTM!

The core implementation of the searchPlanFacility method looks good. It correctly delegates the search to the repository and builds the response using the ResponseInfoUtil.

health-services/plan-service/src/main/java/digit/web/models/PlanFacility.java (5)

20-25: LGTM: Class structure and annotations are appropriate.

The use of Lombok annotations (@validated, @DaTa, @AllArgsConstructor, @NoArgsConstructor, @builder) is appropriate for this model class, reducing boilerplate code and ensuring proper validation.


51-52: LGTM: Use of Object type for 'additionalDetails'.

The use of Object type for the 'additionalDetails' field is appropriate in this context, as it allows for flexible additional data storage. This approach is consistent with the project's conventions.


61-67: LGTM: addServiceBoundariesItem method implementation.

The method correctly initializes the list if it's null and adds the new item. Returning 'this' allows for method chaining, which is a good practice. This implementation is consistent with the project's conventions.


3-15: LGTM: Import statements are appropriate.

The import statements include all necessary dependencies for Jakarta validation, Jackson annotations, Lombok, Spring validation, and the AuditDetails model. These imports are consistent with the class requirements.


59-60: 🧹 Nitpick (assertive)

Remove extra blank line.

There's an unnecessary blank line at line 60. Consider removing it to maintain consistent formatting throughout the file.

     private AuditDetails auditDetails = null;

-
     public PlanFacility addServiceBoundariesItem(String serviceBoundariesItem) {

Likely invalid or redundant comment.

health-services/plan-service/src/main/resources/application.properties (1)

12-12: ⚠️ Potential issue

Security and configuration management concerns

The change to the database password raises several issues:

  1. Hardcoding passwords in configuration files is a security risk and violates best practices.
  2. Committing environment-specific configurations (like local setup changes) to version control can lead to issues in different environments.
  3. The Flyway password (line 16) hasn't been updated, which could cause inconsistencies.

Consider the following recommendations:

  1. Use environment variables or a secure vault system for sensitive information like passwords.
  2. Keep environment-specific configurations separate from the main application.properties file.
  3. Ensure consistency across all database-related configurations.

Example of using environment variables:

spring.datasource.password=${DB_PASSWORD}
spring.flyway.password=${DB_PASSWORD}

Then set the DB_PASSWORD environment variable in your local setup or deployment environment.

This change appears to be a local setup modification, which aligns with the previous reviewer's concern about committing such changes.

To check if this is an isolated change or if there are other potential issues, let's scan the repository for hardcoded passwords:

#!/bin/bash
# Search for potential hardcoded passwords in properties files
echo "Searching for potential hardcoded passwords in properties files:"
rg --type properties 'password\s*=\s*[^${}]' --glob '!**/target/**'

# Search for potential hardcoded passwords in Java files
echo "Searching for potential hardcoded passwords in Java files:"
rg --type java 'setPassword\(' --glob '!**/target/**'

This script will help identify if there are other instances of hardcoded passwords in the codebase that need to be addressed.

health-services/plan-service/src/main/java/digit/repository/impl/PlanFacilityRepositoryImpl.java (5)

20-37: LGTM: Class structure and initialization look good.

The class is properly annotated as a repository and uses constructor injection for dependency management, which is a good practice. The spacing issues mentioned in past comments seem to have been addressed.


39-42: Clarify the empty implementation of the create method.

The create method is currently empty. If this is intentional (e.g., to be implemented later), consider adding a TODO comment. If not, please provide the implementation.


66-69: Clarify the empty implementation of the update method.

The update method is currently empty. If this is intentional (e.g., to be implemented later), consider adding a TODO comment. If not, please provide the implementation.


1-94: Consistent approach to exception handling noted.

The implementation follows a consistent approach to exception handling across repository files, as noted in the learnings. This allows for centralized error handling at a higher level in the application architecture.


1-94: Overall, the implementation looks good with some minor improvements suggested.

The PlanFacilityRepositoryImpl class provides a solid implementation of the PlanFacilityRepository interface. It follows good practices such as constructor injection, use of query builders, and custom row mappers. The two-step search process in the search method is an interesting approach that could benefit from a brief explanation.

Key points for improvement:

  1. Clarify the empty implementations of create and update methods.
  2. Consider using debug level for SQL query logging to enhance security in production environments.
  3. Add a brief comment explaining the rationale behind the two-step search process in the search method.

These minor adjustments will enhance the code's clarity and maintainability.

health-services/plan-service/src/main/java/digit/repository/rowmapper/PlanFacilityRowMapper.java (1)

29-62: Overall, the 'extractData' method is well-implemented

The method efficiently maps the ResultSet to a list of PlanFacility objects, correctly handling audit details and additional fields.

health-services/plan-service/src/main/java/digit/repository/querybuilder/PlanFacilityQueryBuilder.java (2)

42-43: Add a blank line between methods for consistency.

To maintain consistent formatting, please add a blank line between the closing brace of one method and the declaration of the next method.


68-69: Verify the necessity of using LinkedHashSet for residing boundaries.

In the buildPlanFacilitySearchQuery method, residing boundaries are converted to a LinkedHashSet before being added to the prepared statement. This removes duplicate boundaries but maintains insertion order. Please verify if eliminating duplicates is the intended behavior and if the order of boundaries affects the query results.

Run the following script to check how residingBoundaries are populated and whether duplicates are possible:

Comment on lines +8 to +10
service_boundaries varchar(2048),
additional_details JSONB,
active boolean,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

Consider the structure of service_boundaries.

The additional_details column as JSONB and the active boolean column are well-defined and follow good practices.

However, the service_boundaries column is defined as varchar(2048), which is quite large. This suggests it might store multiple values or a complex structure. Consider if this data would be better stored in a separate table with a one-to-many relationship, or as a JSONB column for better querying capabilities.

If service_boundaries indeed stores multiple values, consider this alternative structure:

CREATE TABLE plan_facility_service_boundary (
  id varchar(64) PRIMARY KEY,
  plan_facility_linkage_id varchar(64),
  boundary_id varchar(64),
  FOREIGN KEY (plan_facility_linkage_id) REFERENCES plan_facility_linkage(id),
  FOREIGN KEY (boundary_id) REFERENCES boundaries(id) -- Assuming a boundaries table exists
);

This structure would allow for better data normalization and easier querying of individual service boundaries.

Comment on lines +11 to +14
created_by varchar(64),
created_time bigint,
last_modified_by varchar(64),
last_modified_time bigint,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick (assertive)

LGTM: Audit columns with a suggestion.

The audit columns (created_by, created_time, last_modified_by, last_modified_time) are well-defined and follow a common pattern for tracking creation and modification metadata.

While using bigint for timestamp storage is common and works well for Unix timestamps, consider using a native timestamp type for better readability and built-in date/time functions support.

Consider using TIMESTAMP WITH TIME ZONE for created_time and last_modified_time:

created_time TIMESTAMP WITH TIME ZONE,
last_modified_time TIMESTAMP WITH TIME ZONE,

This change would provide better date/time manipulation capabilities and timezone awareness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants