@Test public void testDvQuantity() throws Exception { kvPairs.clear(); kvPairs.put("magnitude", 4.5+""); kvPairs.put("units", "kg"); kvPairs.put("precision", 2+""); dataValue = (DataValue)PathValue.decodeValue("DvQuantity", FieldUtil.flatten(FieldUtil.getAttributes(DvQuantityVBean.generate())), kvPairs); assertEquals(((DvQuantity) dataValue).getMagnitude(), 4.5, 0); }
public static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args) throws Exception { Map<String, Object> values = new HashMap<>(); for (String atributeName: args.keySet()){ if (dvMap.containsKey(atributeName)){ String attributeClassName = dvMap.get(atributeName); if (attributeClassName.contains("java.lang.")){ Class clazz = ClassUtils.getClass(attributeClassName); Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } else if (attributeClassName.contains(RMBuilder.OPENEHR_RM_PACKAGE)) { String attrClassSimpleName = attributeClassName.substring(attributeClassName.lastIndexOf(".")+1); Class attributeInstrument = VBeanUtil.findInstrumentalizedClass(attrClassSimpleName); if (attributeInstrument != null) { Method generate = attributeInstrument.getDeclaredMethod("generate", null); Object generated = generate.invoke(null, null); Constructor constructor = attributeInstrument.getDeclaredConstructor(new Class[]{generated.getClass()}); Object instrumentalized = constructor.newInstance(generated); Method parser = attributeInstrument.getDeclaredMethod("parse", new Class[]{String.class, String[].class}); Object value = parser.invoke(instrumentalized, args.get(atributeName), (String)null); values.put(atributeName, value); } else { log.info("possible primitive?" + attrClassSimpleName); values.put(atributeName, args.get(atributeName)); } } else { Class clazz = ClassUtils.getClass(attributeClassName); Class wrapperClass = ClassUtils.primitiveToWrapper(clazz); Constructor constructor = wrapperClass.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } } } Class mainInstrument = VBeanUtil.findInstrumentalizedClass(dvClassName); Method instanceGetter = mainInstrument.getDeclaredMethod("getInstance", new Class[]{Map.class}); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, values); Object generated = instanceGetter.invoke(null, valueMap); if (generated instanceof DataValue) return (DataValue)generated; return generated; }
PathValue implements I_PathValue { public static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args) throws Exception { Map<String, Object> values = new HashMap<>(); for (String atributeName: args.keySet()){ if (dvMap.containsKey(atributeName)){ String attributeClassName = dvMap.get(atributeName); if (attributeClassName.contains("java.lang.")){ Class clazz = ClassUtils.getClass(attributeClassName); Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } else if (attributeClassName.contains(RMBuilder.OPENEHR_RM_PACKAGE)) { String attrClassSimpleName = attributeClassName.substring(attributeClassName.lastIndexOf(".")+1); Class attributeInstrument = VBeanUtil.findInstrumentalizedClass(attrClassSimpleName); if (attributeInstrument != null) { Method generate = attributeInstrument.getDeclaredMethod("generate", null); Object generated = generate.invoke(null, null); Constructor constructor = attributeInstrument.getDeclaredConstructor(new Class[]{generated.getClass()}); Object instrumentalized = constructor.newInstance(generated); Method parser = attributeInstrument.getDeclaredMethod("parse", new Class[]{String.class, String[].class}); Object value = parser.invoke(instrumentalized, args.get(atributeName), (String)null); values.put(atributeName, value); } else { log.info("possible primitive?" + attrClassSimpleName); values.put(atributeName, args.get(atributeName)); } } else { Class clazz = ClassUtils.getClass(attributeClassName); Class wrapperClass = ClassUtils.primitiveToWrapper(clazz); Constructor constructor = wrapperClass.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } } } Class mainInstrument = VBeanUtil.findInstrumentalizedClass(dvClassName); Method instanceGetter = mainInstrument.getDeclaredMethod("getInstance", new Class[]{Map.class}); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, values); Object generated = instanceGetter.invoke(null, valueMap); if (generated instanceof DataValue) return (DataValue)generated; return generated; } }
PathValue implements I_PathValue { public static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args) throws Exception { Map<String, Object> values = new HashMap<>(); for (String atributeName: args.keySet()){ if (dvMap.containsKey(atributeName)){ String attributeClassName = dvMap.get(atributeName); if (attributeClassName.contains("java.lang.")){ Class clazz = ClassUtils.getClass(attributeClassName); Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } else if (attributeClassName.contains(RMBuilder.OPENEHR_RM_PACKAGE)) { String attrClassSimpleName = attributeClassName.substring(attributeClassName.lastIndexOf(".")+1); Class attributeInstrument = VBeanUtil.findInstrumentalizedClass(attrClassSimpleName); if (attributeInstrument != null) { Method generate = attributeInstrument.getDeclaredMethod("generate", null); Object generated = generate.invoke(null, null); Constructor constructor = attributeInstrument.getDeclaredConstructor(new Class[]{generated.getClass()}); Object instrumentalized = constructor.newInstance(generated); Method parser = attributeInstrument.getDeclaredMethod("parse", new Class[]{String.class, String[].class}); Object value = parser.invoke(instrumentalized, args.get(atributeName), (String)null); values.put(atributeName, value); } else { log.info("possible primitive?" + attrClassSimpleName); values.put(atributeName, args.get(atributeName)); } } else { Class clazz = ClassUtils.getClass(attributeClassName); Class wrapperClass = ClassUtils.primitiveToWrapper(clazz); Constructor constructor = wrapperClass.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } } } Class mainInstrument = VBeanUtil.findInstrumentalizedClass(dvClassName); Method instanceGetter = mainInstrument.getDeclaredMethod("getInstance", new Class[]{Map.class}); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, values); Object generated = instanceGetter.invoke(null, valueMap); if (generated instanceof DataValue) return (DataValue)generated; return generated; } PathValue(I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(I_ContentBuilder contentBuilder, I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(Properties properties); }
PathValue implements I_PathValue { public static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args) throws Exception { Map<String, Object> values = new HashMap<>(); for (String atributeName: args.keySet()){ if (dvMap.containsKey(atributeName)){ String attributeClassName = dvMap.get(atributeName); if (attributeClassName.contains("java.lang.")){ Class clazz = ClassUtils.getClass(attributeClassName); Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } else if (attributeClassName.contains(RMBuilder.OPENEHR_RM_PACKAGE)) { String attrClassSimpleName = attributeClassName.substring(attributeClassName.lastIndexOf(".")+1); Class attributeInstrument = VBeanUtil.findInstrumentalizedClass(attrClassSimpleName); if (attributeInstrument != null) { Method generate = attributeInstrument.getDeclaredMethod("generate", null); Object generated = generate.invoke(null, null); Constructor constructor = attributeInstrument.getDeclaredConstructor(new Class[]{generated.getClass()}); Object instrumentalized = constructor.newInstance(generated); Method parser = attributeInstrument.getDeclaredMethod("parse", new Class[]{String.class, String[].class}); Object value = parser.invoke(instrumentalized, args.get(atributeName), (String)null); values.put(atributeName, value); } else { log.info("possible primitive?" + attrClassSimpleName); values.put(atributeName, args.get(atributeName)); } } else { Class clazz = ClassUtils.getClass(attributeClassName); Class wrapperClass = ClassUtils.primitiveToWrapper(clazz); Constructor constructor = wrapperClass.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } } } Class mainInstrument = VBeanUtil.findInstrumentalizedClass(dvClassName); Method instanceGetter = mainInstrument.getDeclaredMethod("getInstance", new Class[]{Map.class}); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, values); Object generated = instanceGetter.invoke(null, valueMap); if (generated instanceof DataValue) return (DataValue)generated; return generated; } PathValue(I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(I_ContentBuilder contentBuilder, I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(Properties properties); Composition assign(Map<String, Object> keyValues); Boolean update(Composition composition, Map<String, Object> keyValues); Boolean updateEventContext(EventContext eventContext, Map<String, Object> keyValues); boolean assignItemStructure(String filterTag, Locatable locatable, Map<String, Object> pathValues); static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args); @Override boolean isModifiedContext(); @Override boolean isModifiedAttributes(); @Override boolean isModifiedContent(); @Override void setLenient(Boolean lenient); }
PathValue implements I_PathValue { public static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args) throws Exception { Map<String, Object> values = new HashMap<>(); for (String atributeName: args.keySet()){ if (dvMap.containsKey(atributeName)){ String attributeClassName = dvMap.get(atributeName); if (attributeClassName.contains("java.lang.")){ Class clazz = ClassUtils.getClass(attributeClassName); Constructor constructor = clazz.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } else if (attributeClassName.contains(RMBuilder.OPENEHR_RM_PACKAGE)) { String attrClassSimpleName = attributeClassName.substring(attributeClassName.lastIndexOf(".")+1); Class attributeInstrument = VBeanUtil.findInstrumentalizedClass(attrClassSimpleName); if (attributeInstrument != null) { Method generate = attributeInstrument.getDeclaredMethod("generate", null); Object generated = generate.invoke(null, null); Constructor constructor = attributeInstrument.getDeclaredConstructor(new Class[]{generated.getClass()}); Object instrumentalized = constructor.newInstance(generated); Method parser = attributeInstrument.getDeclaredMethod("parse", new Class[]{String.class, String[].class}); Object value = parser.invoke(instrumentalized, args.get(atributeName), (String)null); values.put(atributeName, value); } else { log.info("possible primitive?" + attrClassSimpleName); values.put(atributeName, args.get(atributeName)); } } else { Class clazz = ClassUtils.getClass(attributeClassName); Class wrapperClass = ClassUtils.primitiveToWrapper(clazz); Constructor constructor = wrapperClass.getDeclaredConstructor(new Class[]{String.class}); Object value = constructor.newInstance(args.get(atributeName)); values.put(atributeName, value); } } } Class mainInstrument = VBeanUtil.findInstrumentalizedClass(dvClassName); Method instanceGetter = mainInstrument.getDeclaredMethod("getInstance", new Class[]{Map.class}); Map<String, Object> valueMap = new HashMap<>(); valueMap.put(CompositionSerializer.TAG_VALUE, values); Object generated = instanceGetter.invoke(null, valueMap); if (generated instanceof DataValue) return (DataValue)generated; return generated; } PathValue(I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(I_ContentBuilder contentBuilder, I_KnowledgeCache cache, String templateId, Properties properties);  PathValue(Properties properties); Composition assign(Map<String, Object> keyValues); Boolean update(Composition composition, Map<String, Object> keyValues); Boolean updateEventContext(EventContext eventContext, Map<String, Object> keyValues); boolean assignItemStructure(String filterTag, Locatable locatable, Map<String, Object> pathValues); static Object decodeValue(String dvClassName, Map<String, String> dvMap, Map<String, Object> args); @Override boolean isModifiedContext(); @Override boolean isModifiedAttributes(); @Override boolean isModifiedContent(); @Override void setLenient(Boolean lenient);  }