104: Add Call Activity Details Section for Outbound Calls#65
104: Add Call Activity Details Section for Outbound Calls#65vanitha1822 wants to merge 10 commits intorelease-3.7.0from
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe PR introduces outbound call activity management functionality with new entity, repository, service, and controller layers across the codebase. Additionally, Redis configuration is updated to broaden value type handling and add StringRedisTemplate support, with Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant Controller as OutboundCallActivityController
participant Service as OutboundCallActivityServiceImpl
participant ActivityRepo as OutboundCallActivityRepository
participant DetailRepo as CoMoOutboundCallRepository
participant Database as Database
Client->>Controller: POST /outbound/saveActivity (activity data)
Controller->>Service: saveActivity(OutboundCallActivity)
Service->>ActivityRepo: save(activity)
ActivityRepo->>Database: INSERT INTO OutboundCallActivity
Database-->>ActivityRepo: Activity ID
ActivityRepo-->>Service: OutboundCallActivity
Service-->>Controller: OutboundCallActivity
Controller-->>Client: OutputResponse (success)
Client->>Controller: POST /outbound/saveCallDetails (call details)
Controller->>Service: saveCallDetails(T_104CoMoOutboundCallDetails)
Service->>Service: validateCallStatus(callStatus)
Service->>ActivityRepo: findAllActiveActivitiesAsList()
ActivityRepo->>Database: SELECT * FROM OutboundCallActivity
Database-->>ActivityRepo: List<OutboundCallActivity>
ActivityRepo-->>Service: Activities (for mapping)
Service->>DetailRepo: save(callDetails)
DetailRepo->>Database: INSERT INTO T_104CoMoOutboundCallDetails
Database-->>DetailRepo: Persisted
DetailRepo-->>Service: T_104CoMoOutboundCallDetails
Service-->>Controller: T_104CoMoOutboundCallDetails
Controller-->>Client: OutputResponse (success)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
0941f26 to
3f23334
Compare
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 8
🧹 Nitpick comments (2)
src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java (1)
83-89: Method naming/comment and behavior are out of sync.Line 83 and method name
getAllActiveActivitiesimply active-only results, but Line 88 callsgetAllActivities()(active + inactive). Rename/update comment to avoid API confusion.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java` around lines 83 - 89, The method getAllActiveActivities (and its comment "Get ALL active activities") is misleading because it calls activityService.getAllActivities() which returns all activities; either change the service call to the active-only variant (e.g., activityService.getActiveActivities()) or rename the controller method and comment to reflect that it returns all activities (e.g., getAllActivities / "Get ALL activities"); update the method name, Javadoc/comment and any references to the controller endpoint to keep them consistent with the chosen behavior.src/main/java/com/iemr/helpline104/repository/comoOutbound/CoMoOutboundCallRepository.java (1)
50-83: Activity persistence concerns are duplicated across repositories.Lines 50-83 replicate activity methods already present in
OutboundCallActivityRepository. Keeping activity operations in one repository will reduce divergence and maintenance risk.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/main/java/com/iemr/helpline104/repository/comoOutbound/CoMoOutboundCallRepository.java` around lines 50 - 83, The CoMoOutboundCallRepository duplicates activity operations defined in OutboundCallActivityRepository; remove the duplicated methods (findActiveActivitiesByProvider, findAllActiveActivitiesAsList, findAllActiveActivities, updateActivityName, toggleActivityStatus) from CoMoOutboundCallRepository and instead delegate activity persistence to OutboundCallActivityRepository (inject/use OutboundCallActivityRepository where those operations are needed in service/manager code), or call its equivalent methods for queries and `@Modifying` updates; ensure any callers are updated to reference OutboundCallActivityRepository methods and retain transactional/modifying semantics at the service layer if needed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/com/iemr/helpline104/config/RedisConfig.java`:
- Around line 47-56: The RedisTemplate is declared as RedisTemplate<String,
Object> but uses Jackson2JsonRedisSerializer<M_User>, causing runtime type
mismatches; either change the template signature to RedisTemplate<String,
M_User> (and keep the Jackson2JsonRedisSerializer<M_User>) or replace the
hardcoded Jackson2JsonRedisSerializer<M_User> with a polymorphic Object
serializer (e.g., a Jackson2JsonRedisSerializer<Object> with defaultTyping or a
GenericJackson2JsonRedisSerializer configured on the ObjectMapper) so
deserialization works for multiple types; also explicitly set a
StringRedisSerializer for keys via template.setKeySerializer(...) to avoid
binary-prefixed keys.
- Around line 61-65: Fix the indentation of the StringRedisTemplate bean method:
reformat the lines inside the stringRedisTemplate(RedisConnectionFactory
factory) bean to use tabs to match the file's existing indentation style (method
name: stringRedisTemplate, return type: StringRedisTemplate). Also, if the
application relies on Spring declarative caching, uncomment the
`@EnableCaching`(proxyTargetClass = true) annotation in the main application class
(App.java) to enable `@Cacheable/`@CacheEvict behavior; otherwise leave it
commented since the StringRedisTemplate bean works for direct Redis operations.
In
`@src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java`:
- Around line 98-103: The controller is currently deserializing full
OutboundCallActivity/related entities from client JSON (saveActivity,
saveCallDetails) and trusting client-supplied audit/persistence fields
(activityID, modifiedBy, createdBy, timestamps), which allows ID spoofing and
audit tampering; change the handlers to (1) parse only a DTO or Map and manually
map/whitelist writable fields into a new OutboundCallActivity instance, (2)
ignore any client-provided ID or audit fields (activityID, createdBy,
modifiedBy, createdAt, updatedAt), (3) derive the actor/user from the
authenticated token/context instead of request values and set
modifiedBy/createdBy server-side before calling activityService.saveActivity
(and equivalent service methods), and (4) ensure update paths load the existing
entity by ID from the DB and apply only allowed setters rather than replacing
the entity from the request.
- Around line 162-171: In getActiveCallDetails in
OutboundCallActivityController, the token extraction only checks cookie
"Jwttoken" and header "JwtToken" and misses standard "Authorization: Bearer ..."
requests; update the extraction logic (around cookieUtil.getCookieValue and
httpRequest.getHeader calls) to first read the "Authorization" header, strip the
"Bearer " prefix if present to obtain the JWT, then fallback to "JwtToken"
header and the "Jwttoken" cookie; throw the same IllegalArgumentException only
if none are present so the existing header contract headers="Authorization" is
honored.
In
`@src/main/java/com/iemr/helpline104/data/comoOutbound/OutboundCallActivity.java`:
- Around line 35-36: Replace the class-level `@Data` on OutboundCallActivity with
explicit Lombok annotations to avoid including the transient helper field in
equality: remove `@Data` and add `@Getter`, `@Setter`, and
`@EqualsAndHashCode`(onlyExplicitlyIncluded = true) on the class, then annotate
the primary identifier field (the `@Id` field) with `@EqualsAndHashCode.Include` so
equals() and hashCode() are based only on the entity identity; ensure the
transient field outputMapper remains unannotated for inclusion in equality.
In
`@src/main/java/com/iemr/helpline104/data/comoOutbound/T_104CoMoOutboundCallDetails.java`:
- Around line 58-60: In T_104CoMoOutboundCallDetails, remove the Java
'transient' modifier from the field named 'activity' annotated with
`@ManyToOne`(fetch = FetchType.LAZY) and `@JoinColumn`(...) so JPA can manage and
hydrate the lazy relation to OutboundCallActivity; locate the declaration
"private transient OutboundCallActivity activity" and change it to a regular
private field (e.g., "private OutboundCallActivity activity") so the ORM will
persist and load the association correctly.
In
`@src/main/java/com/iemr/helpline104/service/outbound/OutboundCallActivityServiceImpl.java`:
- Around line 48-52: The validation currently checks the raw callStatus string
against VALID_CALL_STATUSES, causing values with extra whitespace/case
differences (e.g., "Answered ") to be rejected and rebuilding Arrays.asList each
call; update the logic to normalize the incoming callStatus (trim() and, if
desired, normalize case) before validating and replace the per-call
Arrays.asList check with a precomputed immutable Set constant (e.g.,
VALID_CALL_STATUSES_SET) so lookups are O(1); adjust the validation in the
method that references callStatus to use the trimmed/normalized value and the
new Set.
- Around line 98-100: The method saveCallDetails currently dereferences
callDetails (callDetails.getCallStatus(), callDetails.getDeleted()) without a
null check; add an early guard at the start of saveCallDetails that checks if
callDetails is null and throws a clear client-facing exception (e.g.,
IllegalArgumentException or your API's BadRequest/InvalidInput exception) with a
descriptive message, then proceed to call validateCallStatus(...) and the
existing logic; reference the saveCallDetails method and the calls to
callDetails.getCallStatus and callDetails.getDeleted when adding the guard.
---
Nitpick comments:
In
`@src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java`:
- Around line 83-89: The method getAllActiveActivities (and its comment "Get ALL
active activities") is misleading because it calls
activityService.getAllActivities() which returns all activities; either change
the service call to the active-only variant (e.g.,
activityService.getActiveActivities()) or rename the controller method and
comment to reflect that it returns all activities (e.g., getAllActivities / "Get
ALL activities"); update the method name, Javadoc/comment and any references to
the controller endpoint to keep them consistent with the chosen behavior.
In
`@src/main/java/com/iemr/helpline104/repository/comoOutbound/CoMoOutboundCallRepository.java`:
- Around line 50-83: The CoMoOutboundCallRepository duplicates activity
operations defined in OutboundCallActivityRepository; remove the duplicated
methods (findActiveActivitiesByProvider, findAllActiveActivitiesAsList,
findAllActiveActivities, updateActivityName, toggleActivityStatus) from
CoMoOutboundCallRepository and instead delegate activity persistence to
OutboundCallActivityRepository (inject/use OutboundCallActivityRepository where
those operations are needed in service/manager code), or call its equivalent
methods for queries and `@Modifying` updates; ensure any callers are updated to
reference OutboundCallActivityRepository methods and retain
transactional/modifying semantics at the service layer if needed.
ℹ️ Review info
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
pom.xmlsrc/main/java/com/iemr/helpline104/config/RedisConfig.javasrc/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.javasrc/main/java/com/iemr/helpline104/data/comoOutbound/OutboundCallActivity.javasrc/main/java/com/iemr/helpline104/data/comoOutbound/T_104CoMoOutboundCallDetails.javasrc/main/java/com/iemr/helpline104/repository/comoOutbound/CoMoOutboundCallRepository.javasrc/main/java/com/iemr/helpline104/repository/comoOutbound/OutboundCallActivityRepository.javasrc/main/java/com/iemr/helpline104/service/outbound/OutboundCallActivityService.javasrc/main/java/com/iemr/helpline104/service/outbound/OutboundCallActivityServiceImpl.java
src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java
Show resolved
Hide resolved
src/main/java/com/iemr/helpline104/controller/outbound/OutboundCallActivityController.java
Show resolved
Hide resolved
src/main/java/com/iemr/helpline104/data/comoOutbound/OutboundCallActivity.java
Show resolved
Hide resolved
src/main/java/com/iemr/helpline104/data/comoOutbound/T_104CoMoOutboundCallDetails.java
Outdated
Show resolved
Hide resolved
src/main/java/com/iemr/helpline104/service/outbound/OutboundCallActivityServiceImpl.java
Show resolved
Hide resolved
src/main/java/com/iemr/helpline104/service/outbound/OutboundCallActivityServiceImpl.java
Show resolved
Hide resolved
|



📋 Description
JIRA ID:
AMM-2083
✅ Type of Change
Summary by CodeRabbit
Chores
New Features