So I've the following Domain:
- Applications and Versions, they are actually software applications
- Devices, the devices on which the applications are installed
- Installed Applications on Devices
- Notification Subscription by installed Applications
So far, I've end up with the following model:
-
Application
entity, which is defined by a name, an os and a type -
Version
value object, which basically wraps version informations (major, minor, etc.) -
Release
entity, which is a composed object referencing an Application entity and embedding a Version value object -
Device
entity, which is identified by a serial number -
NotitificationSubscription
entity (to allow me to Query by attribute)
Now I'm wondering how to "associate" Device
entity, Release
and the NotificationSubscription
because it should be associated to an "installed" Release
on a Device
and include some extra information (like an authentication token).
Given the limitation of my ORM (Doctrine2) & RDMS (MySQL) I'm stuck at how to find a good design.
Imagine the following workflow:
- I fetch the
Device
entity from Database identified by its Serial Number - I determine if the
Release
theDevice
is running from is already associated with it, if no, I create an association - I need then to add or remove a
NotificationSubscription
for the current Device Release association
My problem is I end up with much indirection.
To allow me to set extra data to the association, I created an Association Class which is itself an Entity referencing both a Device and a Release.
A device may have different Release installed and running on it, so for example, I don't know how to query the following information: "Fetches all the notification subscriptions for the current release for the current device"
I obviously added a method in a Repository findSubscriptionsByDeviceAndRelease($device, $release);
which means that I can query this information by both using the repository and through the graph $device->getInstalledReleases()->filter($identifiedRelease)->getNotificationSubscriptions();
Any ideas?