FieldUtil { public static Map<String, Object> getRequiredAttributes(Class<?> clazz) throws SecurityException, NoSuchFieldException, RMObjectBuildingException { Class objectClass = substituteGeneric(clazz); Map<String, Attribute> thismap = builder.getAttributes(objectClass); Map<String, Class<?>> classMap = builder.getAttributeTypes(objectClass); Map<String, Object> retmap = new HashMap<String, Object>(); for (Attribute attr : thismap.values()) { if (attr.required()) { Class attrClass = classMap.get(attr.name()); if (attrClass.getName().startsWith("java.lang")) { Map<String, Object> defMap = new HashMap<>(); retmap.put(attr.name(), defMap); defMap.put("type", attrClass.getSimpleName().toUpperCase()); } else if (attrClass.getName().contains(RMBuilder.OPENEHR_RM_PACKAGE)) { Map<String, Object> submap = getRequiredAttributes(attrClass); submap.put("type", new SnakeCase(attrClass.getSimpleName()).camelToUpperSnake()); retmap.put(attr.name(), submap); } else { Map<String, Object> defMap = new HashMap<>(); retmap.put(attr.name(), defMap); defMap.put("type", attrClass.getSimpleName().toUpperCase()); } } } return retmap; }  static Map<String, Object> getScalarAttributes(Class<?> clazz); static Map<String, Object> getRequiredAttributes(Class<?> clazz); static Map<String, Object> getAttributes(Object object); static Map<String, String> flatten(Map<String, Object> map); static List<Object> flatten(Map<String, String> resultMap, String key, Map<String, Object> map); static Class<?> getFieldClass(Class<?> clazz, String name);  }
@Test public void testStructuralEvaluation() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("EVALUATION")); assertNotNull(requiredParameters); }
@Test public void testStructuralObservation() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("OBSERVATION")); assertNotNull(requiredParameters); }
@Test public void testStructuralAction() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("ACTION")); assertNotNull(requiredParameters); }
@Test public void testStructuralInstruction() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("ACTION")); assertNotNull(requiredParameters); }
@Test public void testStructuralHistory() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("HISTORY")); assertNotNull(requiredParameters); }
@Test public void testStructuralComposition() throws Exception { RMBuilder rmObjectBuilder = new RMBuilder(); Map<String, Object> requiredParameters = FieldUtil.getRequiredAttributes(rmObjectBuilder.retrieveRMType("COMPOSITION")); assertNotNull(requiredParameters); }