List<Comment> checkListItemCommentsList = new ArrayList<Comment>();
if(checklistItemIdsList.size() > 1000){
while(checklistItemIdsList.size()>1000){
List<String> subList = checklistItemIdsList.subList(0, 1000);
checkListItemCommentsList.addAll(commentDao.getCommentByEntities(subList,
GlobalConstant.ENTITY_MODIFIED_INSTANCE_CHECKLIST_ITEM, !userAccess ? "E" : "I"));
checklistItemIdsList.subList(0, 1000).clear();
}
}
checkListItemCommentsList.addAll(commentDao.getCommentByEntities(checklistItemIdsList,
GlobalConstant.ENTITY_MODIFIED_INSTANCE_CHECKLIST_ITEM, !userAccess ? "E" : "I"));
Map<String, Boolean> hasComments = new HashMap<String, Boolean>();
if(!CollectionUtils.isEmpty(checkListItemCommentsList)){
for(Comment comment : checkListItemCommentsList){
key = comment.getEntityId() + "_" + comment.getEntityType();
if(!hasComments.containsKey(key)){
hasComments.put(key, true);
}
}
}
List<PendingCheckListItemsTO> pendingCheckListItems = new ArrayList<>();
if(!CollectionUtils.isEmpty(pendingCheckListItemTaskTOs)){
//map the comment to checklist item comment respectively
for(PendingCheckListItemsTO pendingChecklistItemTO : pendingCheckListItemTaskTOs){
Long checklistItemId = pendingChecklistItemTO.getCheckListItemId();
if(checklistItemId != null){
key = checklistItemId + "_" + GlobalConstant.ENTITY_MODIFIED_INSTANCE_CHECKLIST_ITEM;
}
if(hasComments.containsKey(key)){
pendingChecklistItemTO.setCommentAvailable(hasComments.get(key));
}
pendingCheckListItems.add(pendingChecklistItemTO);
}
}