I'm wondering if anyone has encountered this challenge, or has any ideas. We've been asked if OPA could output a string containing the concatenation of values of a text attribute stored across instances of an entity. The number of instances is variable in general.
Example: Let's assume the attribute is "DayOfWeek", and we have an entity called "Appointment", with instances:
appointment_1 (DayOfWeek = "Monday")
appointment_2 (DayOfWeek = "Thursday")
appointment_3 (DayOfWeek = "Sunday")
... we need to output a string "AllAppointmentDays" = "Monday, Thursday, Sunday".
We don't think this is possible without either: (a) some external system to generate the concatenated string based on rulebase output, or (b) using the ordering approach from the Oracle whitepaper from Nov 2012 (Approaches to Limits, Thresholds and Preferences), combined with hard-coding and constraints on the length of the string.
I was wondering if there was a more efficient way to do this without external scripting, or constraints / hard-coding.
I don' t know that an external implementation would necessarily be easier but it could be more efficient if well written. Either internal or external, you will need to decide how you want to rank or order the entities before concatenation. The ordering will need to be absolute (i.e. no ties). The policies to "set" the first entity's output string and the policy to concatenate a string to produce this entity's output string = the "prior" entity + ", " + this entity's attribute are fairly straightforward.
I guess the short answer is: There isn't necessarily a more efficient way to do this in OPM and I don't think there are constraints nor should a more efficient solution be required unless you already know you will be working with very large numbers of entities and/or very long strings.