Anti-corruption layer and copying data into local context
"raymond_kolbe" <[email protected]>
| Newsgroups | gmane.comp.programming.domain-driven-design |
|---|---|
| Message-ID | <[email protected]> |
I feel I have a pretty good idea of how an ACL works and when to use it. However, I'm struggling with this case. Much like my previous post(s), I have a few BCs in my domain. I'll keep my example very narrow to 2 BCs; Incident Context and HumanResource Context (HR Context for short). Incident context contains my core domain. HR Context can also be thought of as the Identity & Access Context. The Incident context relies on the HR context to grab employee information, such as employee ID, name, and contact information. However, on a nightly basis (batch process), employees can go missing from the HR context, which means they are no longer employees in our organization. This implementation is out of my hands :-/ However, I need to keep them in the Incident Context so we know who was a contributor for an incident. Here is a sequence diagram of how I think this ACL would work (please comment as this could be a poor solution): Sequence Diagram <http://raymondkolbe.com/wp-content/uploads/2013/04/EmployeeACL.png> - I apologize if there is a way to attach images in posts--I just don't know how to. Let me outline the process in case the image is no longer hosted in the future ;-) The classifier role "Create Incident" is just the process of fulfilling new Incident()'s dependencies.1. A call to IncidentDomainService->getSafetyOfficer(id) is called.2. which calls EmployeeAdapter->getSafetyOfficer(id)3. Within our adapter routine, we query our local database first to see if the employee exists. If so, return, if not, check the remote database in the HR Context to see if they are there. If so, then create them in our Incident Context's database.5. If EmployeeAdapter receives false, then it could throw exception or return null (I haven't decided).6. "Translation" doesn't really happen. More or less we would query a repository to return the Safety Officer, so we return an Entity instead of a VO I suppose. Also, at some point in the adapter we must call our permission system to make sure this person is in fact a safety officer.7. Return object to the client for consumption. Does it make sense to have a database insert be called when we use an ACL? My concern is that a failure to insert at this point will cause problems. For instance, after creating an instance of Incident() we will be pointing to a non-existent entity in the Incident Context. Suggestions?