@Test public void testConvert() throws Exception { c = new VistaDataChunkToPOMObjectConverter(); Map<String, Object> data = new HashMap<String, Object>(); data.put("uid", UidUtils.getUserUid("ABCD", "42")); Person person = new Person(data); VistaDataChunk chunk = VistaDataChunk.createVistaDataChunk("ABCD", "/foo/bar", convertObjectToNode(person), "person", 0, 1); IPOMObject o = c.convert(chunk); assertThat(o, is(instanceOf(Person.class))); Person p = (Person) o; assertThat(p.getUid(), is(UidUtils.getUserUid("ABCD", "42"))); }
@Override public IPOMObject convert(VistaDataChunk chunk) { try { Map<String, Object> data = POMUtils.parseJSONtoMap(chunk.getContent()); if (data == null) throw new ImportException("Reading chunk JSON resulted in a null Map", chunk); if (StringUtils.hasText(chunk.getPatientId())) { data.put("pid", chunk.getPatientId()); } String uid = (String) data.get("uid"); if (!StringUtils.hasText(uid)) throw new ImportException("No UID found in import chunk", chunk); Class<? extends IPOMObject> domainClass = UidUtils.getDomainClassByUid(uid); if (domainClass == null) throw new ImportException("No domain class found for item '" + uid + "' and domain '" + chunk.getDomain() + "'. Verify there is a corresponding UID pattern in " + UidUtils.class, chunk); IPOMObject obj = POMUtils.newInstance(domainClass, data); IImportPostProcessor importPostProcessor = postProcessors.get(obj.getClass()); if (importPostProcessor != null) { obj = importPostProcessor.postProcess(obj); } return obj; } catch (Exception e) { throw new ImportException(chunk, e); } }
VistaDataChunkToPOMObjectConverter implements Converter<VistaDataChunk, IPOMObject> { @Override public IPOMObject convert(VistaDataChunk chunk) { try { Map<String, Object> data = POMUtils.parseJSONtoMap(chunk.getContent()); if (data == null) throw new ImportException("Reading chunk JSON resulted in a null Map", chunk); if (StringUtils.hasText(chunk.getPatientId())) { data.put("pid", chunk.getPatientId()); } String uid = (String) data.get("uid"); if (!StringUtils.hasText(uid)) throw new ImportException("No UID found in import chunk", chunk); Class<? extends IPOMObject> domainClass = UidUtils.getDomainClassByUid(uid); if (domainClass == null) throw new ImportException("No domain class found for item '" + uid + "' and domain '" + chunk.getDomain() + "'. Verify there is a corresponding UID pattern in " + UidUtils.class, chunk); IPOMObject obj = POMUtils.newInstance(domainClass, data); IImportPostProcessor importPostProcessor = postProcessors.get(obj.getClass()); if (importPostProcessor != null) { obj = importPostProcessor.postProcess(obj); } return obj; } catch (Exception e) { throw new ImportException(chunk, e); } } }
VistaDataChunkToPOMObjectConverter implements Converter<VistaDataChunk, IPOMObject> { @Override public IPOMObject convert(VistaDataChunk chunk) { try { Map<String, Object> data = POMUtils.parseJSONtoMap(chunk.getContent()); if (data == null) throw new ImportException("Reading chunk JSON resulted in a null Map", chunk); if (StringUtils.hasText(chunk.getPatientId())) { data.put("pid", chunk.getPatientId()); } String uid = (String) data.get("uid"); if (!StringUtils.hasText(uid)) throw new ImportException("No UID found in import chunk", chunk); Class<? extends IPOMObject> domainClass = UidUtils.getDomainClassByUid(uid); if (domainClass == null) throw new ImportException("No domain class found for item '" + uid + "' and domain '" + chunk.getDomain() + "'. Verify there is a corresponding UID pattern in " + UidUtils.class, chunk); IPOMObject obj = POMUtils.newInstance(domainClass, data); IImportPostProcessor importPostProcessor = postProcessors.get(obj.getClass()); if (importPostProcessor != null) { obj = importPostProcessor.postProcess(obj); } return obj; } catch (Exception e) { throw new ImportException(chunk, e); } } VistaDataChunkToPOMObjectConverter();  VistaDataChunkToPOMObjectConverter(Map<Class<? extends IPOMObject>, IImportPostProcessor> postProcessors); }
VistaDataChunkToPOMObjectConverter implements Converter<VistaDataChunk, IPOMObject> { @Override public IPOMObject convert(VistaDataChunk chunk) { try { Map<String, Object> data = POMUtils.parseJSONtoMap(chunk.getContent()); if (data == null) throw new ImportException("Reading chunk JSON resulted in a null Map", chunk); if (StringUtils.hasText(chunk.getPatientId())) { data.put("pid", chunk.getPatientId()); } String uid = (String) data.get("uid"); if (!StringUtils.hasText(uid)) throw new ImportException("No UID found in import chunk", chunk); Class<? extends IPOMObject> domainClass = UidUtils.getDomainClassByUid(uid); if (domainClass == null) throw new ImportException("No domain class found for item '" + uid + "' and domain '" + chunk.getDomain() + "'. Verify there is a corresponding UID pattern in " + UidUtils.class, chunk); IPOMObject obj = POMUtils.newInstance(domainClass, data); IImportPostProcessor importPostProcessor = postProcessors.get(obj.getClass()); if (importPostProcessor != null) { obj = importPostProcessor.postProcess(obj); } return obj; } catch (Exception e) { throw new ImportException(chunk, e); } } VistaDataChunkToPOMObjectConverter();  VistaDataChunkToPOMObjectConverter(Map<Class<? extends IPOMObject>, IImportPostProcessor> postProcessors); @Override IPOMObject convert(VistaDataChunk chunk); }
VistaDataChunkToPOMObjectConverter implements Converter<VistaDataChunk, IPOMObject> { @Override public IPOMObject convert(VistaDataChunk chunk) { try { Map<String, Object> data = POMUtils.parseJSONtoMap(chunk.getContent()); if (data == null) throw new ImportException("Reading chunk JSON resulted in a null Map", chunk); if (StringUtils.hasText(chunk.getPatientId())) { data.put("pid", chunk.getPatientId()); } String uid = (String) data.get("uid"); if (!StringUtils.hasText(uid)) throw new ImportException("No UID found in import chunk", chunk); Class<? extends IPOMObject> domainClass = UidUtils.getDomainClassByUid(uid); if (domainClass == null) throw new ImportException("No domain class found for item '" + uid + "' and domain '" + chunk.getDomain() + "'. Verify there is a corresponding UID pattern in " + UidUtils.class, chunk); IPOMObject obj = POMUtils.newInstance(domainClass, data); IImportPostProcessor importPostProcessor = postProcessors.get(obj.getClass()); if (importPostProcessor != null) { obj = importPostProcessor.postProcess(obj); } return obj; } catch (Exception e) { throw new ImportException(chunk, e); } } VistaDataChunkToPOMObjectConverter();  VistaDataChunkToPOMObjectConverter(Map<Class<? extends IPOMObject>, IImportPostProcessor> postProcessors); @Override IPOMObject convert(VistaDataChunk chunk);  }