I have an excel file that keeps user role and permission as shown below (some fields are omitted for brevity):
User Role | Permission Uuid
----------|----------------
0 | a465433f...
0 | 43db5a33...
1 | 610e9040...
0 | 94e85bef...
1 | 34e85f32...
I am reading an excel file row by row and need to pass a request as shown below to create imported data:
public class PermissionRequest {
private UserRole userRole;
private List<UUID> permissionUuidList;
}
I think that I need to map each Permission Uuid by User Role and for this reason I tried to use Map<Integer, List<UUID>>
as shown below:
Map<Integer, List<UUID>> userRolePermissionMap = new HashMap<>();
userRolePermissionMap.put(Integer.parseInt(cellList.get(USER_ROLE)),
Collections.singletonList(UUID.fromString(cellList.get(PERMISSON_UUID))));
But I think it it not correct. So, as the User Role is not sorted in the excel file, should I need a sort or grouping by User Role and then send PermissionRequest
to the repository in a loop for create operation? Or should I use a TreeMap
for this purpose? If so, how can I use?