@Test() public void testBuildCompositeBundle() { try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); PrintStream out = new PrintStream(outputStream);) { CompartmentUtil.buildCompositeBundle(out); String o = outputStream.toString("UTF8"); assertNotNull(o); assertFalse(o.isEmpty()); } catch (Exception e) { e.printStackTrace(); fail(); } }
public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException { Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION); for (String compartmentDefintion : compartmentDefinitions) { try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) { CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader); build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build()); } catch (FHIRException e) { log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion)); } catch (IOException e1) { log.warning(String.format(IO_EXCEPTION, compartmentDefintion)); } } Bundle bundle = build.build(); FHIRGenerator.generator(Format.JSON, true).generate(bundle, out); out.println(bundle.toString()); }
CompartmentUtil { public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException { Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION); for (String compartmentDefintion : compartmentDefinitions) { try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) { CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader); build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build()); } catch (FHIRException e) { log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion)); } catch (IOException e1) { log.warning(String.format(IO_EXCEPTION, compartmentDefintion)); } } Bundle bundle = build.build(); FHIRGenerator.generator(Format.JSON, true).generate(bundle, out); out.println(bundle.toString()); } }
CompartmentUtil { public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException { Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION); for (String compartmentDefintion : compartmentDefinitions) { try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) { CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader); build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build()); } catch (FHIRException e) { log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion)); } catch (IOException e1) { log.warning(String.format(IO_EXCEPTION, compartmentDefintion)); } } Bundle bundle = build.build(); FHIRGenerator.generator(Format.JSON, true).generate(bundle, out); out.println(bundle.toString()); } private  CompartmentUtil(); }
CompartmentUtil { public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException { Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION); for (String compartmentDefintion : compartmentDefinitions) { try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) { CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader); build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build()); } catch (FHIRException e) { log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion)); } catch (IOException e1) { log.warning(String.format(IO_EXCEPTION, compartmentDefintion)); } } Bundle bundle = build.build(); FHIRGenerator.generator(Format.JSON, true).generate(bundle, out); out.println(bundle.toString()); } private  CompartmentUtil(); static void init(); static final Map<String, CompartmentCache> buildCompartmentMap(); static List<String> getCompartmentResourceTypes(final String compartment); static List<String> getCompartmentResourceTypeInclusionCriteria(final String compartment, final String resourceType); static void checkValidCompartment(final String compartment); static void checkValidCompartmentAndResource(final String compartment, final String resourceType); static void buildCompositeBundle(PrintStream out); }
CompartmentUtil { public static void buildCompositeBundle(PrintStream out) throws FHIRGeneratorException { Bundle.Builder build = Bundle.builder().type(BundleType.COLLECTION); for (String compartmentDefintion : compartmentDefinitions) { try (InputStreamReader reader = new InputStreamReader(CompartmentUtil.class.getResourceAsStream(compartmentDefintion))) { CompartmentDefinition compartmentDefinitionResource = FHIRParser.parser(Format.JSON).parse(reader); build.entry(Bundle.Entry.builder().resource(compartmentDefinitionResource).build()); } catch (FHIRException e) { log.warning(String.format(PARSE_EXCEPTION, compartmentDefintion)); } catch (IOException e1) { log.warning(String.format(IO_EXCEPTION, compartmentDefintion)); } } Bundle bundle = build.build(); FHIRGenerator.generator(Format.JSON, true).generate(bundle, out); out.println(bundle.toString()); } private  CompartmentUtil(); static void init(); static final Map<String, CompartmentCache> buildCompartmentMap(); static List<String> getCompartmentResourceTypes(final String compartment); static List<String> getCompartmentResourceTypeInclusionCriteria(final String compartment, final String resourceType); static void checkValidCompartment(final String compartment); static void checkValidCompartmentAndResource(final String compartment, final String resourceType); static void buildCompositeBundle(PrintStream out); static final String FHIR_PATH_BUNDLE_ENTRY; static final String RESOURCE; static final String PARSE_EXCEPTION; static final String IO_EXCEPTION; static final String INVALID_COMPARTMENT; static final String INVALID_COMPARTMENT_AND_RESOURCE; static final String FROM_STREAM; }