Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -406,7 +406,7 @@ private void createUserMapping(User mUser, JSONObject resMap, JSONObject service
JSONArray roles = previlegeObj.getJSONObject(serv).getJSONArray("roles");
// roles.put(new JSONObject(m_UserServiceRoleMapping.getM_Role().toString()));
JSONObject roleObject = new JSONObject(m_UserServiceRoleMapping.getM_Role().toString());
roleObject.put("isSanjeevani", m_UserServiceRoleMapping.getIsSanjeevani());
roleObject.put("teleConsultation", m_UserServiceRoleMapping.getTeleConsultation());
roles.put(roleObject);
}
}
Expand Down
44 changes: 2 additions & 42 deletions src/main/java/com/iemr/common/data/users/Role.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,8 @@ public class Role

@Expose
@Transient
private Boolean isSanjeevani;
private String teleConsultation;

// protected Role() {
// }
//
public Role createRole(Integer roleID, String roleName, String roleDesc, Boolean deleted, String createdBy,
Timestamp createdDate, String modifiedBy, Timestamp lastModDate,
Set<UserServiceRoleMapping> m_UserServiceRoleMapping)
Expand All @@ -124,35 +121,7 @@ public Role createRole(Integer roleID, String roleName, String roleDesc, Boolean
return this;
}

// public Integer getRoleID()
// {
// return this.RoleID;
// }
//
// public void setRoleID(int roleID)
// {
// this.RoleID = Integer.valueOf(roleID);
// }
//
// public String getRoleName()
// {
// return this.RoleName;
// }
//
// public void setRoleName(String roleName)
// {
// this.RoleName = roleName;
// }
//
// public String getRoleDesc()
// {
// return this.RoleDesc;
// }
//
// public void setRoleDesc(String roleDesc)
// {
// this.RoleDesc = roleDesc;
// }


public boolean isDeleted()
{
Expand Down Expand Up @@ -204,15 +173,6 @@ public void setLastModDate(Timestamp lastModDate)
this.LastModDate = lastModDate;
}

// public Set<UserServiceRoleMapping> getM_UserServiceRoleMapping()
// {
// return this.m_UserServiceRoleMapping;
// }
//
// public void setM_UserServiceRoleMapping(Set<UserServiceRoleMapping> m_UserServiceRoleMapping)
// {
// this.m_UserServiceRoleMapping = m_UserServiceRoleMapping;
// }

public void setServiceRoleScreenMappings(List<ServiceRoleScreenMapping> serviceRoleScreenMappings)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public class UserServiceRoleMapping
private Boolean outbound;

@Expose
@Column(name = "isSanjeevani")
private Boolean isSanjeevani;
@Column(name = "teleConsultation")
private String teleConsultation;


// @Expose
Expand Down Expand Up @@ -302,7 +302,7 @@ public String toString()

public static UserServiceRoleMapping initializeUserRoleMappingObjs(Long USRMappingID, Long UserID, Integer roleID,
Role m_Role, Integer providerServiceMapID, ProviderServiceMapping m_ProviderServiceMapping,
String agentID,Boolean inbound, Boolean outbound, Boolean isSanjeevani, String agentPassword, Integer workingLocationID,
String agentID,Boolean inbound, Boolean outbound, String teleConsultation, String agentPassword, Integer workingLocationID,
ProviderServiceAddressMapping providerServiceAddressMapping)
{
UserServiceRoleMapping userRoleMapping = new UserServiceRoleMapping();
Expand All @@ -317,7 +317,7 @@ public static UserServiceRoleMapping initializeUserRoleMappingObjs(Long USRMappi
userRoleMapping.agentID = agentID;
userRoleMapping.inbound = inbound;
userRoleMapping.outbound = outbound;
userRoleMapping.isSanjeevani = isSanjeevani;
userRoleMapping.teleConsultation = teleConsultation;
userRoleMapping.agentPassword = agentPassword;
userRoleMapping.workingLocationID = workingLocationID;
userRoleMapping.m_Role.setWorkingLocationID(workingLocationID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public interface UserRoleMappingRepository extends CrudRepository<UserServiceRoleMapping, Long>
{
@Query("select map.USRMappingID, map.UserID, map.RoleID, map.m_Role, map.providerServiceMapID, "
+ "map.agentID, map.inbound, map.outbound, map.isSanjeevani, map.agentPassword, map.workingLocationID, map.providerServiceAddressMapping from "
+ "map.agentID, map.inbound, map.outbound, map.teleConsultation, map.agentPassword, map.workingLocationID, map.providerServiceAddressMapping from "
+ "UserServiceRoleMapping map left join map.m_ProviderServiceMapping psm left join psm.serviceProvider sp "
Comment on lines 38 to 40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

πŸ› οΈ Refactor suggestion

Index shift introduces downstream risk – update consuming code accordingly

The projection now returns 12 columns (the new map.teleConsultation at position 9).
Down-stream loops in IEMRAdminUserServiceImpl still guard with object.length >= 11 but subsequently dereference object[11], which will throw ArrayIndexOutOfBoundsException if a shorter result is ever returned (e.g., due to LEFT JOIN nulls).

Either:

- if (object != null && object.length >= 11) {
+ if (object != null && object.length >= 12) {

or switch to a DTO/result-class projection to remove this brittle positional coupling.

Committable suggestion skipped: line range outside the PR's diff.

πŸ€– Prompt for AI Agents
In src/main/java/com/iemr/common/repository/users/UserRoleMappingRepository.java
around lines 38 to 40, the query projection now returns 12 columns due to the
addition of map.teleConsultation, but downstream code in
IEMRAdminUserServiceImpl still checks for object length >= 11 and accesses
object[11], risking ArrayIndexOutOfBoundsException. To fix this, update the
downstream code to check for object length >= 12 before accessing object[11], or
refactor the query and consuming code to use a DTO or result-class projection to
avoid brittle positional indexing.

+ "left join map.m_Role left join map.providerServiceAddressMapping "
+ "where map.Deleted = false and UserID = :UserID and sp.statusID in (1,2) "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public void updateCTIPasswordForUser(Long userID, String password) {
.initializeUserRoleMappingObjs((Long) object[0], (Long) object[1], (Integer) object[2],
(Role) object[3], (Integer) object[4],
getUserProviderServiceRoleMapping((Integer) object[4]), (String) object[5],
(Boolean) object[6], (Boolean) object[7], (Boolean) object[8], (String) object[9],
(Boolean) object[6], (Boolean) object[7], (String) object[8], (String) object[9],
(Integer) object[10], (ProviderServiceAddressMapping) object[11]);
userRoles.add(userServiceRoleMapping);
}
Expand Down Expand Up @@ -670,7 +670,7 @@ public List<UserServiceRoleMapping> getUserServiceRoleMapping(Long userID) throw
UserServiceRoleMapping userServiceRoleMapping = UserServiceRoleMapping.initializeUserRoleMappingObjs(
(Long) object[0], (Long) object[1], (Integer) object[2], (Role) object[3], (Integer) object[4],
getUserProviderServiceRoleMapping((Integer) object[4]), (String) object[5], (Boolean) object[6],
(Boolean) object[7], (Boolean) object[8], (String) object[9], (Integer) object[10],
(Boolean) object[7], (String) object[8], (String) object[9], (Integer) object[10],
(ProviderServiceAddressMapping) object[11]);
List<ServiceRoleScreenMapping> serviceRoleScreenMappings = getActiveScreenMappings(
userServiceRoleMapping.getProviderServiceMapID(), userServiceRoleMapping.getRoleID());
Expand Down
Loading