Skip to content

Conversation

@srishtigrp78
Copy link
Contributor

@srishtigrp78 srishtigrp78 commented Jun 27, 2025

📋 Description

JIRA ID: 997

Please provide a summary of the change and the motivation behind it. Include relevant context and details.
Only a single file was being fetched per subcategory , because the file UID was overwritten in subcategory table everytime the new file was added to the subcategory. So, a table change was required to add Subcategory id as a foreign key in km file manager table. And code changes were required to fetch all files linked to a particular subcategory.

✅ Type of Change

  • 🐞 Bug fix (non-breaking change which resolves an issue)
  • New feature (non-breaking change which adds functionality)
  • 🔥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 🛠 Refactor (change that is neither a fix nor a new feature)
  • ⚙️ Config change (configuration file or build script updates)
  • 📚 Documentation (updates to docs or readme)
  • 🧪 Tests (adding new or updating existing tests)
  • 🎨 UI/UX (changes that affect the user interface)
  • 🚀 Performance (improves performance)
  • 🧹 Chore (miscellaneous changes that don't modify src or test files)

ℹ️ Additional Information

Please describe how the changes were tested, and include any relevant screenshots, logs, or other information that provides additional context.

Summary by CodeRabbit

  • New Features

    • Users can now access all files associated with each subcategory, rather than just a single file, when viewing subcategory details.
  • Bug Fixes

    • Ensured that file lists for subcategories exclude deleted files.
  • Refactor

    • Improved how subcategory file information is retrieved and displayed, providing more comprehensive file details per subcategory.
    • Enhanced data persistence to support subcategory file associations more effectively.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

Walkthrough

The changes update the persistence and retrieval of subcategory file data. The subCategoryID field in the KMFileManager entity is now stored in the database. A repository query method was added to fetch files by subcategory. The service logic was refactored to attach all files to each subcategory, rather than just one.

Changes

File(s) Change Summary
.../KMFileManager.java Made subCategoryID a persistent field mapped to the database column instead of transient.
.../KMFileManagerRepository.java Added getFilesBySubCategoryID method to fetch files by subcategory ID and not deleted.
.../KMFileManagerServiceImpl.java Minor formatting; redundantly sets SubCategoryID after persisting file, no logic changes.
.../CommonServiceImpl.java Refactored getSubCategories: now attaches all files per subcategory, not just one.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant CommonServiceImpl
    participant KMFileManagerRepository
    participant SubCategoryDetails

    Client->>CommonServiceImpl: getSubCategories(request)
    CommonServiceImpl->>KMFileManagerRepository: find subcategories by category ID
    loop For each subcategory
        CommonServiceImpl->>KMFileManagerRepository: getFilesBySubCategoryID(subCategoryID)
        KMFileManagerRepository-->>CommonServiceImpl: List<KMFileManager>
        CommonServiceImpl->>SubCategoryDetails: Attach file list and representative file info
    end
    CommonServiceImpl-->>Client: List<SubCategoryDetails> (each with file list)
Loading

Poem

In the warren of code, a new path’s unfurled,
Now subcategories hold all their files, flags unfurled.
No longer just one, but a list for each ear,
With database columns mapped, the intent is clear.
Hopping through queries, our rabbit feels proud—
File lists for all, and carrots abound! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eef6bb3 and 7be3796.

📒 Files selected for processing (2)
  • src/main/java/com/iemr/common/data/kmfilemanager/KMFileManager.java (1 hunks)
  • src/main/java/com/iemr/common/repository/kmfilemanager/KMFileManagerRepository.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/java/com/iemr/common/data/kmfilemanager/KMFileManager.java
  • src/main/java/com/iemr/common/repository/kmfilemanager/KMFileManagerRepository.java
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: style-check / checkstyle
  • GitHub Check: Build
  • GitHub Check: Package-test
  • GitHub Check: Analyze (java)
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

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: 0

🧹 Nitpick comments (2)
src/main/java/com/iemr/common/service/kmfilemanager/KMFileManagerServiceImpl.java (1)

179-181: Remove redundant assignment.

The line kmFileManager.setSubCategoryID(kmFileManager.getSubCategoryID()); is redundant as it sets the field to its current value without any transformation or validation.

-					
-					kmFileManager.setSubCategoryID(kmFileManager.getSubCategoryID());
-					
src/main/java/com/iemr/common/service/services/CommonServiceImpl.java (1)

137-173: Excellent refactoring with minor suggestions for improvement.

The refactored getSubCategories method correctly implements the requirement to retrieve multiple files per subcategory. The logic is sound and maintains backward compatibility by setting representative file metadata.

Consider these improvements for robustness:

 // Fetch all files under this subcategory from KMFileManager
 List<KMFileManager> files = kmFileManagerRepository.getFilesBySubCategoryID(subCatId);
 ArrayList<KMFileManager> fileList = new ArrayList<>(files);

 String fileURL = null;
 String fileNameWithExtension = null;

 if (!fileList.isEmpty()) {
     KMFileManager firstFile = fileList.get(0); // Just for representative file URL and name
-    fileURL = getFilePath(firstFile.getFileUID());
-    fileNameWithExtension = firstFile.getFileName() + firstFile.getFileExtension();
+    if (firstFile.getFileUID() != null) {
+        fileURL = getFilePath(firstFile.getFileUID());
+    }
+    if (firstFile.getFileName() != null && firstFile.getFileExtension() != null) {
+        fileNameWithExtension = firstFile.getFileName() + firstFile.getFileExtension();
+    }
 }

This adds null safety checks for file properties to prevent potential null pointer exceptions.

Additionally, consider the performance impact if subcategories have a large number of files, as this will now load all files eagerly rather than on-demand.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5846036 and eef6bb3.

📒 Files selected for processing (4)
  • src/main/java/com/iemr/common/data/kmfilemanager/KMFileManager.java (1 hunks)
  • src/main/java/com/iemr/common/repository/kmfilemanager/KMFileManagerRepository.java (1 hunks)
  • src/main/java/com/iemr/common/service/kmfilemanager/KMFileManagerServiceImpl.java (3 hunks)
  • src/main/java/com/iemr/common/service/services/CommonServiceImpl.java (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/main/java/com/iemr/common/service/services/CommonServiceImpl.java (1)
Learnt from: helenKaryamsetty
PR: PSMRI/Common-API#145
File: src/main/java/com/iemr/common/service/abdmfacility/AbdmFacilityServiceImpl.java:16-20
Timestamp: 2024-12-18T08:53:22.725Z
Learning: In AbdmFacilityServiceImpl, no exceptions are thrown because the UI layer takes responsibility for handling all error scenarios and directly uses the raw response returned by the repository.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: style-check / checkstyle
  • GitHub Check: Package-test
  • GitHub Check: Build
  • GitHub Check: Analyze (java)
🔇 Additional comments (5)
src/main/java/com/iemr/common/service/kmfilemanager/KMFileManagerServiceImpl.java (2)

128-128: LGTM - Improved code readability.

The blank line addition improves code readability by separating methods.


204-204: LGTM - Improved code readability.

The blank line addition improves code readability by separating methods.

src/main/java/com/iemr/common/repository/kmfilemanager/KMFileManagerRepository.java (1)

77-80: LGTM - Well-implemented repository method.

The new getFilesBySubCategoryID method correctly implements the requirement to retrieve multiple files per subcategory. The query properly filters by subcategory ID and excludes deleted records, which aligns with the PR objectives.

src/main/java/com/iemr/common/data/kmfilemanager/KMFileManager.java (1)

113-119: ```shell
#!/bin/bash

Search for Liquibase changelog definitions

rg -Hni "changeSet" --glob '.xml' --glob '.yml' --glob '*.yaml'

Search for any migration scripts referencing SubCategoryID

rg -Hni "SubCategoryID" --glob '.sql' --glob '.xml' --glob '.yml' --glob '.yaml'


</details>
<details>
<summary>src/main/java/com/iemr/common/service/services/CommonServiceImpl.java (1)</summary>

`60-60`: **LGTM - Necessary import added.**

The import for `KMFileManager` is correctly added to support the new functionality.

</details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

@Expose
private Integer categoryID;
@Transient
// @Transient
Copy link
Member

Choose a reason for hiding this comment

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

please remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done Mithun

+ "where kmFileManager.fileUID = :fileUID")
List<Object[]> getFileNameByUID(@Param("fileUID") String fileUID);

//newChange
Copy link
Member

Choose a reason for hiding this comment

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

remove unnecessary comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done Mithun

@drtechie drtechie requested a review from vanitha1822 June 30, 2025 06:08
@sonarqubecloud
Copy link

@drtechie drtechie merged commit 17007e4 into PSMRI:develop Jul 2, 2025
7 checks passed
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