@Test public void testUpdate_OPT() throws Exception { String templateId = "ECIS EVALUATION TEST"; GsonBuilder builder = new GsonBuilder(); Gson gson = builder.setPrettyPrinting().create(); I_ContentBuilder contentBuilder = I_ContentBuilder.getInstance(knowledge, templateId); Composition composition = contentBuilder.generateNewComposition(); assertNotNull(composition); PathValue pathValue = new PathValue(contentBuilder, knowledge, templateId, new Properties()); Map<String, Object> updateValues = new HashMap<>(); updateValues.put("/context/end_time", "2014-09-28T11:18:17.352+07:00"); updateValues.put("/context/participation|function", "Cantine"); updateValues.put("/context/participation|name", "Joe"); updateValues.put("/context/participation|identifier", "99999-222"); updateValues.put("/context/participation|mode", "openehr::216|face-to-face communication"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0001]/items[at0003]", "at0004|Type 1|"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0001]/items[at0008]", "true"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0001]/items[at0007]", "2010-09-24"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0002]/items[at0003]", "at0005|Type 2|"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0002]/items[at0008]", "true"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/data[at0001]/items[at0002]/items[openEHR-EHR-CLUSTER.diabetes.v1]/items[at0002]/items[at0007]", "2015-09-24"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:0|function", "Oncologist"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:0|identifier", "1345678"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:0|mode", "openehr::216|face-to-face communication"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:0|name", "Dr. Knock"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:1|function", "Oncologist"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:1|identifier", "999999-8"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:1|mode", "openehr::216|evil cabinet"); updateValues.put("/content[openEHR-EHR-EVALUATION.verbal_examination.v1]/participation:1|name", "Dr. Caligari"); boolean result = pathValue.update(composition, updateValues); assertTrue(result); Map<String, String> testRetMap = new EcisFlattener().render(composition); String jsonString = gson.toJson(testRetMap); System.out.println(jsonString); byte[] xmlbytes = contentBuilder.exportCanonicalXML(composition, true); System.out.print(new String(xmlbytes)); kvPairs.clear(); kvPairs.put("/context/participation:0|function", "Oncologist"); kvPairs.put("/context/participation:0|name", "Dr. Marcus Johnson"); kvPairs.put("/context/participation:0|identifier", "1345678"); kvPairs.put("/context/participation:0|mode", "openehr::216|face-to-face communication"); kvPairs.put("/context/participation:1|function", "Pediatric"); kvPairs.put("/context/participation:1|name", "Dr. Mabuse"); kvPairs.put("/context/participation:1|identifier", "99999-123"); kvPairs.put("/context/participation:1|mode", "openehr::216|face-to-face communication"); result = pathValue.update(composition, kvPairs); assertTrue(result); testRetMap = new EcisFlattener().render(composition); jsonString = gson.toJson(testRetMap); System.out.println(jsonString); }
public Boolean update(Composition composition, Map<String, Object> keyValues) throws Exception { modifiedContent = modifiedAttributes = modifiedContext = false; if (composition.getContext() == null){ EventContext context = ContextHelper.createDummyContext(); composition.setContext(context); } modifiedContext = updateEventContext(composition.getContext(), keyValues); modifiedAttributes = updateCompositionAttributes(composition, keyValues); modifiedContent = assignItemStructure(CONTENT_TAG, composition, keyValues); return modifiedContext || modifiedAttributes || modifiedContent; }
PathValue implements I_PathValue { public Boolean update(Composition composition, Map<String, Object> keyValues) throws Exception { modifiedContent = modifiedAttributes = modifiedContext = false; if (composition.getContext() == null){ EventContext context = ContextHelper.createDummyContext(); composition.setContext(context); } modifiedContext = updateEventContext(composition.getContext(), keyValues); modifiedAttributes = updateCompositionAttributes(composition, keyValues); modifiedContent = assignItemStructure(CONTENT_TAG, composition, keyValues); return modifiedContext || modifiedAttributes || modifiedContent; } }
PathValue implements I_PathValue { public Boolean update(Composition composition, Map<String, Object> keyValues) throws Exception { modifiedContent = modifiedAttributes = modifiedContext = false; if (composition.getContext() == null){ EventContext context = ContextHelper.createDummyContext(); composition.setContext(context); } modifiedContext = updateEventContext(composition.getContext(), keyValues); modifiedAttributes = updateCompositionAttributes(composition, keyValues); modifiedContent = assignItemStructure(CONTENT_TAG, composition, keyValues); return modifiedContext || modifiedAttributes || modifiedContent; } 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 Boolean update(Composition composition, Map<String, Object> keyValues) throws Exception { modifiedContent = modifiedAttributes = modifiedContext = false; if (composition.getContext() == null){ EventContext context = ContextHelper.createDummyContext(); composition.setContext(context); } modifiedContext = updateEventContext(composition.getContext(), keyValues); modifiedAttributes = updateCompositionAttributes(composition, keyValues); modifiedContent = assignItemStructure(CONTENT_TAG, composition, keyValues); return modifiedContext || modifiedAttributes || modifiedContent; } 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 Boolean update(Composition composition, Map<String, Object> keyValues) throws Exception { modifiedContent = modifiedAttributes = modifiedContext = false; if (composition.getContext() == null){ EventContext context = ContextHelper.createDummyContext(); composition.setContext(context); } modifiedContext = updateEventContext(composition.getContext(), keyValues); modifiedAttributes = updateCompositionAttributes(composition, keyValues); modifiedContent = assignItemStructure(CONTENT_TAG, composition, keyValues); return modifiedContext || modifiedAttributes || modifiedContent; } 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);  }