From 3a586f3d108e2d5c7080aafcad8d8277c9eb8cc1 Mon Sep 17 00:00:00 2001 From: wolandscat Date: Fri, 23 Aug 2024 16:06:42 -0600 Subject: [PATCH] Correct initialisation error for BMM enum types. Without this, BMM-based validation of archetype CString and CInteger types fails, if no itemValues have been explicitly set in the BMM source files. --- .../openehr/bmm/core/BmmEnumerationInteger.java | 17 +++++++++++++++++ .../openehr/bmm/core/BmmEnumerationString.java | 13 +++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java index e319b68d6..11f0d200a 100644 --- a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java +++ b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationInteger.java @@ -22,6 +22,8 @@ */ import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * Integer-based enumeration type. @@ -39,5 +41,20 @@ public BmmEnumerationInteger() { super(); } + /** + * Sets the list of names of the enumeration. If no values are supplied, the values + * 0...N are used where N+1 is the size of itemNames + * + * @param itemNames + */ + @Override + public void setItemNames(List itemNames) { + super.setItemNames(itemNames); + ArrayList vals = new ArrayList<>(); + for (int i = 0; i < itemNames.size(); i++ ) + vals.add(i); + + setItemValues(vals); + } } diff --git a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java index 8030d5637..005c360cf 100644 --- a/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java +++ b/bmm/src/main/java/org/openehr/bmm/core/BmmEnumerationString.java @@ -22,6 +22,8 @@ */ import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; /** * String-based enumeration type. @@ -39,4 +41,15 @@ public BmmEnumerationString() { super(); } + /** + * Sets the list of names of the enumeration. If no values are supplied, the string values + * mimicking the literals are assumed + * + * @param itemNames + */ + @Override + public void setItemNames(List itemNames) { + super.setItemNames(itemNames); + setItemValues(new ArrayList<>(itemNames)); + } }