Best practice to represent array association in Domain Model
1
Greetings Experts ! We have a set of ReST services that return back JSON response and most of these have nested JSON objects in them. For example: { "serviceType": "alarmService", "alarmsConfiguration": { "emailIdToReceiveNotification": "abc@xyz.com", "alarmsRules": [ { "metric": "CPUUtilization", "threshold": 80, "checkMetricInXTimesForPeriod": 2, "period": 60 }, { "metric": "MemoryUtilization", "threshold": 80, "checkMetricInXTimesForPeriod": 2, "period": 60 }, { "metric": "RequestCount", "threshold": 4000, "checkMetricInXTimesForPeriod": 2, "period": 60 }, { "metric": "UnHealthyHostCount", "threshold": 1, "checkMetricInXTimesForPeriod": 2, "period": 60 } ] } } The response has alarmsConfiguration which in turn conains alarmRules as a array of JSON objects. What is the best way of representing this response in the Domain Model? Approach 1: AlarmService Response :: 1:1 :: Alarms Configuration :: 1: * :: AlarmRule Apporach 2: AlarmService Response :: 1:1 :: Alarms Configuration :: 1:1 :: AlarmRules :: 1: * :: AlarmRule We are using JSON structure definitions and import/export mappings. But we are not able to finalize on use of the intermediate AlarmRules. Thanks, Amey
asked
Amey Bhide
2 answers
4
You should be able to just not use the AlarmRules entity that’s in between. You can just uncheck it in “select elements”.
answered
Andreas Blaesius
2
I agree with Andreas. These extra entities have never served any purpose but to make my life harder. Uncheck them in the mapping.