Hi,
i am writing a piece of logic which would save/remove attachments to an action. Frontend displays all possible attachments for this action and then the user has to select which attachment to save with that action. Selected attachments are saved in a different entity.
Upper layer provides me with a map of attachments (Map<Integer, Boolean> -> second parameter mean attachment selected/deselected). I am wondering how would you solve this situation. My procedure is following:
1) If attachmentId from map is selected, iterate through action.getActionAttachments(), and if it does not exist add it to the collection. 2) If attachmentId from map is selected and is found in action.getActionAttachments(), do not make any changes. 3) If attachmentId from map is not selected, find attachment in action.getActionAttachments() and remove it from the set. 4) actionDao.save(action)
Any other better solution/advice greatly appreciated.
|