Skip to content

Commit

Permalink
fix to issue openEHR#7
Browse files Browse the repository at this point in the history
  • Loading branch information
ppazos committed Dec 10, 2013
1 parent d6cef55 commit f474ae8
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion adl-parser/src/main/javacc/adl.jj
Original file line number Diff line number Diff line change
Expand Up @@ -2305,7 +2305,7 @@ CObject c_object(String path, CAttribute parent) :
ConstraintRef constraint_ref_obj(String path, CAttribute parent) :
{
String reference;
String rmTypeName = "CodePhrase";
String rmTypeName = "CODE_PHRASE";
Interval<Integer> occurrences = new Interval<Integer>(1, 1);
String nodeId = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
public class TypedObjectBlockTest extends ParserTestBase {

public void testParseTypedDvQuantity() throws Exception {
DADLParser parser = new DADLParser(loadFromClasspath(
"typed_dv_quantity.dadl"));
DADLParser parser = new DADLParser(loadFromClasspath("typed_dv_quantity.dadl"));
ContentObject obj = parser.parse();

assertNotNull("contentObj null", obj);
assertEquals("type identifier missing", "DvQuantity",

// message, expected, actual
assertEquals("type identifier missing", "DV_QUANTITY",
obj.getComplexObjectBlock().getTypeIdentifier());
}
}
2 changes: 1 addition & 1 deletion dadl-parser/src/test/resources/typed_dv_quantity.dadl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(DvQuantity) <
(DV_QUANTITY) <
magnitude = <120.0>
units = <"mmHg">
>
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public CDate(String pattern) {
* @return name of the type
*/
public String getType() {
return "DvDate";
return "DV_DATE";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public CDateTime(String pattern) {
* @return name of the type
*/
public String getType() {
return "DvDateTime";
return "DV_DATE_TIME";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public CDuration(DvDuration value, Interval<DvDuration> interval,
* @return name of the type
*/
public String getType() {
return "DvDuration";
return "DV_DURATION";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public CTime(String pattern) {
* @return name of the type
*/
public String getType() {
return "DvTime";
return "DV_TIME";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CDvState extends CDomainType<DvState> {
public CDvState(String path, Interval<Integer> occurrences, String nodeId,
CAttribute parent, StateMachine value) {

super(false, path, "DvState", occurrences, nodeId, parent);
super(false, path, "DV_STATE", occurrences, nodeId, parent);

if(value == null) {
throw new IllegalArgumentException("value null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public CDvOrdinal(String path, Interval<Integer> occurrences,
String nodeID, CAttribute parent, Set<Ordinal> list,
Ordinal defaultValue, Ordinal assumedValue) {

super(list == null, path, "DvOrdinal", occurrences, nodeID, defaultValue,
super(list == null, path, "DV_ORDINAL", occurrences, nodeID, defaultValue,
assumedValue, parent);

if (list != null && list.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public CDvQuantity(String path, Interval<Integer> occurrences,
CodePhrase property, DvQuantity defaultValue,
DvQuantity assumedValue) {

super(list == null && property == null, path, "DvQuantity",
super(list == null && property == null, path, "DV_QUANTITY",
occurrences, nodeId, defaultValue, assumedValue, parent);

if (list != null && list.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public CComplexObject standardEquivalent() {
return null;
}

private static final String CODE_PHRASE = "CodePhrase";
private static final String CODE_PHRASE = "CODE_PHRASE";

private TerminologyID terminologyId;
private List<String> codeList;
Expand Down
11 changes: 6 additions & 5 deletions rm-builder/src/main/java/org/openehr/build/RMObjectBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public RMObject construct(String rmClassName, Map<String, Object> valueMap)
throws RMObjectBuildingException {

Class rmClass = retrieveRMType(rmClassName);
// replace underscore separated names with camel case
Map<String, Object> filteredMap = new HashMap<String, Object>();
for (String name : valueMap.keySet()) {
Expand Down Expand Up @@ -411,6 +411,7 @@ else if (value != null && !type.isPrimitive()) {
}

Object ret = null;

try {
// OG added hack
if (rmClassName.equalsIgnoreCase("DVCOUNT")) {
Expand All @@ -425,7 +426,7 @@ else if (value != null && value.getClass().equals(Long.class))
}
ret = constructor.newInstance(valueArray);
} catch (Exception e) {
if (log.isDebugEnabled()) {
e.printStackTrace();
}
Expand Down Expand Up @@ -672,13 +673,13 @@ private Object defaultValue(Class type) {
// loaded rm type map
private Map<String, Class> typeMap;
private Map<String, Class> upperCaseMap;
private static final Set<String> stringParsingTypes;
private static final Set<String> stringParsingTypes; // These should be rm_type_names not Java class names.

static {
// so far only types from quantity.datetime
stringParsingTypes = new HashSet<String>();
String[] types = { "DvDate", "DvDateTime", "DvTime", "DvDuration",
"DvPartialDate", "DvPartialTime" };
//String[] types = { "DvDate", "DvDateTime", "DvTime", "DvDuration", "DvPartialDate", "DvPartialTime" };
String[] types = { "DV_DATE", "DV_DATE_TIME", "DV_TIME", "DV_DURATION", "DV_PARTIAL_DATE", "DV_PARTIAL_TIME" };
stringParsingTypes.addAll(Arrays.asList(types));
}
}
Expand Down
29 changes: 16 additions & 13 deletions rm-builder/src/test/java/org/openehr/build/DataTypesBuildTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class DataTypesBuildTest extends BuildTestBase {

// test classes from datatypes.basic package
public void testBuildDvBoolean() throws Exception {
String type = "DvBoolean";
String type = "DV_BOOLEAN";
Map<String, Object> values = new HashMap<String, Object>();

// true value
Expand All @@ -57,7 +57,7 @@ public void testBuildDvBoolean() throws Exception {
}

public void testBuildDvState() throws Exception {
String type = "DvState";
String type = "DV_STATE";
Map<String, Object> values = new HashMap<String, Object>();
DvCodedText codedText = new DvCodedText("some text", lang, charset,
new CodePhrase("test terms", "00001"), ts);
Expand All @@ -81,7 +81,7 @@ public void testBuildDvState() throws Exception {

// test classes from datatypes.text package
public void testBuildDvText() throws Exception {
String type = "DvText";
String type = "DV_TEXT";
Map<String, Object> values = new HashMap<String, Object>();
String value = "test text value";
values.put("value", value);
Expand All @@ -93,7 +93,7 @@ public void testBuildDvText() throws Exception {
}

public void testBuildCodePhrase() throws Exception {
String type = "CodePhrase";
String type = "CODE_PHRASE";
Map<String, Object> values = new HashMap<String, Object>();
TerminologyID id = new TerminologyID("openehr");
values.put("terminologyId", id);
Expand All @@ -108,7 +108,7 @@ public void testBuildCodePhrase() throws Exception {
}

public void testBuildDvCodeText() throws Exception {
String type = "DvCodedText";
String type = "DV_CODED_TEXT";
Map<String, Object> values = new HashMap<String, Object>();
String value = "test text value";
CodePhrase definingCode = new CodePhrase("local", "at0001");
Expand All @@ -124,7 +124,7 @@ public void testBuildDvCodeText() throws Exception {
}

public void testBuildDvParagraph() throws Exception {
String type = "DvParagraph";
String type = "DV_PARAGRAPH";
Map<String, Object> values = new HashMap<String, Object>();
List<DvText> items = new ArrayList<DvText>();
CodePhrase definingCode = new CodePhrase("local", "at0001");
Expand All @@ -145,7 +145,7 @@ public void testBuildDvParagraph() throws Exception {
}

public void testBuildOrdinal() throws Exception {
String type = "DvOrdinal";
String type = "DV_ORDINAL";
Map<String, Object> values = new HashMap<String, Object>();
DvCodedText symbol = new DvCodedText("test text", lang,
charset, new CodePhrase("test terms", "00001"),
Expand All @@ -160,7 +160,7 @@ charset, new CodePhrase("test terms", "00001"),
}

public void testBuildQuantity() throws Exception {
String type = "DvQuantity";
String type = "DV_QUANTITY";
Map<String, Object> values = new HashMap<String, Object>();
values.put("units", "kg/L");
values.put("magnitude", new Double(100.0));
Expand Down Expand Up @@ -191,7 +191,7 @@ public void testBuildQuantity() throws Exception {

// test datatypes.quantity.datetime classes
public void testBuildDvDate() throws Exception {
String type = "DvDate";
String type = "DV_DATE";

// with good string value and no referenceRanges
Map<String, Object> values = new HashMap<String, Object>();
Expand All @@ -211,6 +211,9 @@ public void testBuildDvDate() throws Exception {
obj = builder.construct(type, values);
fail("attribute format exception should be thrown here");
} catch (Exception e) {

System.err.println("testBuildDvDate exception: "+ e.getClass().toString() +" "+ e.getMessage());

assertTrue(e instanceof AttributeFormatException);
}

Expand All @@ -225,7 +228,7 @@ public void testBuildDvDate() throws Exception {
}

public void testBuildDvDateTime() throws Exception {
String type = "DvDateTime";
String type = "DV_DATE_TIME";

// without referenceRanges
Map<String, Object> values = new HashMap<String, Object>();
Expand All @@ -243,7 +246,7 @@ public void testBuildDvDateTime() throws Exception {
}

public void testBuildDvTime() throws Exception {
String type = "DvTime";
String type = "DV_TIME";

// without referenceRanges
Map<String, Object> values = new HashMap<String, Object>();
Expand All @@ -258,7 +261,7 @@ public void testBuildDvTime() throws Exception {
}

public void testBuildDvDuration() throws Exception {
String type = "DvDuration";
String type = "DV_DURATION";

// without referenceRanges
Map<String, Object> values = new HashMap<String, Object>();
Expand All @@ -276,7 +279,7 @@ public void testBuildDvDuration() throws Exception {

// test datatypes.encapsulated classes
public void testBuildParsable() throws Exception {
String type = "DvParsable";
String type = "DV_PARSABLE";
Map<String, Object> values = new HashMap<String, Object>();
values.put("formalism", "GLIF3");
values.put("value", "guideline text");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ public void setUp() {
public void testMatchDvQuantityValues() {
valueMap.put("units", "mmHg");
valueMap.put("magnitude", 120.0);
assertMatchedRMClass("DvQuantity");
assertMatchedRMClass("DvQuantity"); // This is the Java class, not the rm_type_name
}

public void testMatchCodePhrase() {
valueMap.put("terminologyId", new TerminologyID("openehr"));
valueMap.put("codeString", "234");
assertMatchedRMClass("CodePhrase");
assertMatchedRMClass("CodePhrase"); // This is the Java class, not the rm_type_name
}

public void testMatchElement() {
Expand Down

0 comments on commit f474ae8

Please sign in to comment.