Fix broken build

This commit is contained in:
James Agnew 2019-03-12 13:13:13 -04:00
parent 3433ecfd14
commit 00a8f8c759
22 changed files with 55 additions and 82 deletions
example-projects
hapi-fhir-jpaserver-dynamic/src/main/java/ca/uhn/fhir/jpa/demo
hapi-fhir-jpaserver-example-postgres/src/main/java/ca/uhn/fhir/jpa/demo
examples/src/main/java/example
hapi-fhir-base/src/main/java/ca/uhn/fhir
hapi-fhir-cli/hapi-fhir-cli-jpaserver/src/main/java/ca/uhn/fhir/jpa/demo
hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider
hapi-fhir-jpaserver-example/src/main/java/ca/uhn/fhir/jpa/demo
hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest
hapi-fhir-structures-dstu2.1/src/test/java/ca/uhn/fhir/parser
hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir
hapi-fhir-structures-dstu3/src/test/java/ca/uhn/fhir/narrative2
restful-server-example/src/main/java/ca/uhn/example/servlet

View File

@ -108,7 +108,7 @@ public class JpaServerDemo extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to JSON and pretty printing

View File

@ -108,7 +108,7 @@ public class JpaServerDemoDstu2 extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to JSON and pretty printing

View File

@ -75,7 +75,7 @@ public class JpaServerDemo extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to JSON and pretty printing

View File

@ -1,16 +1,15 @@
package example;
import java.io.IOException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.valueset.NarrativeStatusEnum;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
import ca.uhn.fhir.parser.DataFormatException;
@SuppressWarnings("unused")
public class Narrative {
public static void main(String[] args) throws DataFormatException, IOException {
public static void main(String[] args) throws DataFormatException {
//START SNIPPET: example1
Patient patient = new Patient();
@ -21,7 +20,7 @@ patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").set
FhirContext ctx = FhirContext.forDstu2();
// Use the narrative generator
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ctx));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
// Encode the output, including the narrative
String output = ctx.newJsonParser().setPrettyPrint(true).encodeResourceToString(patient);

View File

@ -1,18 +1,17 @@
package example;
import java.io.IOException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.narrative.CustomThymeleafNarrativeGenerator;
@SuppressWarnings("unused")
public class NarrativeGenerator {
public void testGenerator() throws IOException {
public void testGenerator() {
//START SNIPPET: gen
FhirContext ctx = FhirContext.forDstu2();
String propFile = "classpath:/com/foo/customnarrative.properties";
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(ctx, propFile);
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile);
ctx.setNarrativeGenerator(gen);
//END SNIPPET: gen

View File

@ -36,7 +36,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative
/**
* Constructor
*/
public BaseThymeleafNarrativeGenerator() {
protected BaseThymeleafNarrativeGenerator() {
super();
}
@ -58,7 +58,7 @@ public abstract class BaseThymeleafNarrativeGenerator extends ThymeleafNarrative
List<String> propFileName = getPropertyFile();
try {
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(propFileName);
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents(propFileName);
setManifest(manifest);
} catch (IOException e) {
throw new InternalErrorException(e);

View File

@ -23,7 +23,6 @@ package ca.uhn.fhir.narrative;
import java.util.Arrays;
import java.util.List;
import ca.uhn.fhir.context.FhirContext;
import org.apache.commons.lang3.Validate;
public class CustomThymeleafNarrativeGenerator extends BaseThymeleafNarrativeGenerator {

View File

@ -92,22 +92,6 @@ public class NarrativeTemplateManifest implements INarrativeTemplateManifest {
}
}
public static NarrativeTemplateManifest forManifestFileLocation(FhirContext theFhirContext, String... thePropertyFilePaths) throws IOException {
return forManifestFileLocation(Arrays.asList(thePropertyFilePaths));
}
public static NarrativeTemplateManifest forManifestFileLocation(Collection<String> thePropertyFilePaths) throws IOException {
ourLog.debug("Loading narrative properties file(s): {}", thePropertyFilePaths);
List<String> manifestFileContents = new ArrayList<>(thePropertyFilePaths.size());
for (String next : thePropertyFilePaths) {
String resource = loadResource(next);
manifestFileContents.add(resource);
}
return forManifestFileContents(manifestFileContents);
}
public static NarrativeTemplateManifest forManifestFileContents(String... theResources) throws IOException {
return forManifestFileContents(Arrays.asList(theResources));
}

View File

@ -125,7 +125,7 @@ public class JpaServerDemo extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to XML and pretty printing

View File

@ -74,9 +74,9 @@ public abstract class BaseResourceProviderDstu2Test extends BaseJpaDstu2Test {
ourRestServer.setResourceProviders((List)myResourceProviders);
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
ourRestServer.setPlainProviders(mySystemProvider);
ourRestServer.registerProvider(mySystemProvider);
JpaConformanceProviderDstu2 confProvider = new JpaConformanceProviderDstu2(ourRestServer, mySystemDao, myDaoConfig);
confProvider.setImplementationDescription("THIS IS THE DESC");

View File

@ -92,10 +92,10 @@ public abstract class BaseResourceProviderDstu3Test extends BaseJpaDstu3Test {
ourRestServer.setResourceProviders((List) myResourceProviders);
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderDstu3.class);
ourRestServer.setPlainProviders(mySystemProvider, myTerminologyUploaderProvider);
ourRestServer.registerProviders(mySystemProvider, myTerminologyUploaderProvider);
SubscriptionTriggeringProvider subscriptionTriggeringProvider = myAppCtx.getBean(SubscriptionTriggeringProvider.class);
ourRestServer.registerProvider(subscriptionTriggeringProvider);

View File

@ -99,12 +99,12 @@ public abstract class BaseResourceProviderR4Test extends BaseJpaR4Test {
ourRestServer.setResourceProviders((List) myResourceProviders);
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(myFhirCtx));
ourRestServer.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
myTerminologyUploaderProvider = myAppCtx.getBean(TerminologyUploaderProviderR4.class);
ourGraphQLProvider = myAppCtx.getBean("myGraphQLProvider");
ourRestServer.setPlainProviders(mySystemProvider, myTerminologyUploaderProvider, ourGraphQLProvider);
ourRestServer.registerProviders(mySystemProvider, myTerminologyUploaderProvider, ourGraphQLProvider);
JpaConformanceProviderR4 confProvider = new JpaConformanceProviderR4(ourRestServer, mySystemDao, myDaoConfig);
confProvider.setImplementationDescription("THIS IS THE DESC");

View File

@ -109,7 +109,7 @@ public class JpaServerDemo extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to JSON and pretty printing

View File

@ -108,7 +108,7 @@ public class JpaServerDemoDstu2 extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* Default to JSON and pretty printing

View File

@ -159,7 +159,7 @@ public class TestRestfulServer extends RestfulServer {
* This server tries to dynamically generate narratives
*/
FhirContext ctx = getFhirContext();
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(getFhirContext()));
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
/*
* The resource and system providers (which actually implement the various FHIR
@ -171,7 +171,7 @@ public class TestRestfulServer extends RestfulServer {
}
setResourceProviders(beans);
setPlainProviders(plainProviders);
registerProviders(plainProviders);
/*
* Enable CORS

View File

@ -1020,7 +1020,7 @@ public class JsonParserDstu2_1Test {
Patient p = new Patient();
p.addName().addFamily("Smith").addGiven("John");
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
String output = ourCtx.newJsonParser().encodeResourceToString(p);
ourLog.info(output);

View File

@ -1695,7 +1695,7 @@ public class XmlParserDstu2_1Test {
Patient p = new Patient();
p.addName().addFamily("Smith").addGiven("John");
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
ourCtx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
String output = ourCtx.newXmlParser().encodeResourceToString(p);
ourLog.info(output);

View File

@ -26,7 +26,7 @@ public class CustomThymeleafNarrativeGeneratorDstu2Test {
public void testGenerator() {
// CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(ourCtx,"classpath:narrative/customnarrative_dstu2.properties");
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("classpath:narrative/customnarrative_dstu2.properties");
ourCtx.setNarrativeGenerator(gen);
Practitioner p = new Practitioner();
@ -35,7 +35,7 @@ public class CustomThymeleafNarrativeGeneratorDstu2Test {
p.addAddress().addLine("line1").addLine("line2");
p.getName().addFamily("fam1").addGiven("given");
gen.populateResourceNarrative(p);
gen.populateResourceNarrative(ourCtx, p);
String actual = p.getText().getDiv().getValueAsString();
ourLog.info(actual);

View File

@ -1,32 +1,12 @@
package ca.uhn.fhir.narrative;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.util.Date;
import org.hamcrest.core.StringContains;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.QuantityDt;
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu2.composite.SimpleQuantityDt;
import ca.uhn.fhir.model.dstu2.resource.DiagnosticReport;
import ca.uhn.fhir.model.dstu2.resource.Medication;
import ca.uhn.fhir.model.dstu2.resource.MedicationOrder;
import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu2.resource.Parameters;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.resource.*;
import ca.uhn.fhir.model.dstu2.valueset.DiagnosticReportStatusEnum;
import ca.uhn.fhir.model.dstu2.valueset.MedicationOrderStatusEnum;
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
@ -34,6 +14,18 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
import ca.uhn.fhir.util.TestUtil;
import org.hamcrest.core.StringContains;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import java.util.Date;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
public class DefaultThymeleafNarrativeGeneratorDstu2Test {
private static FhirContext ourCtx = FhirContext.forDstu2();
@ -48,7 +40,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
@Before
public void before() {
myGen = new DefaultThymeleafNarrativeGenerator(ourCtx);
myGen = new DefaultThymeleafNarrativeGenerator();
myGen.setUseHapiServerConformanceNarrative(true);
ourCtx.setNarrativeGenerator(myGen);
@ -65,7 +57,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
value.setBirthDate(new Date(), TemporalPrecisionEnum.DAY);
myGen.populateResourceNarrative(value);
myGen.populateResourceNarrative(ourCtx, value);
String output = value.getText().getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, StringContains.containsString("<div class=\"hapiHeaderText\">joe john <b>BLOW </b></div>"));
@ -77,7 +69,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
Parameters value = new Parameters();
value.setId("123");
myGen.populateResourceNarrative(value);
myGen.populateResourceNarrative(ourCtx, value);
String output = value.getText().getDiv().getValueAsString();
ourLog.info(output);
assertThat(output, not(containsString("narrative")));
@ -99,7 +91,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, parse);
myGen.populateResourceNarrative(oo);
myGen.populateResourceNarrative(ourCtx, oo);
String output = oo.getText().getDiv().getValueAsString();
ourLog.info(output);
@ -137,7 +129,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
value.addResult().setResource(obs);
}
myGen.populateResourceNarrative(value);
myGen.populateResourceNarrative(ourCtx, value);
String output = value.getText().getDiv().getValueAsString();
ourLog.info(output);
@ -162,11 +154,11 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
mp.setStatus(MedicationOrderStatusEnum.ACTIVE);
mp.setDateWritten(new DateTimeDt("2014-09-01"));
myGen.populateResourceNarrative(mp);
myGen.populateResourceNarrative(ourCtx, mp);
String output = mp.getText().getDiv().getValueAsString();
assertTrue("Expected medication name of ciprofloaxin within narrative: " + output, output.indexOf("ciprofloaxin") > -1);
assertTrue("Expected string status of ACTIVE within narrative: " + output, output.indexOf("ACTIVE") > -1);
assertTrue("Expected medication name of ciprofloaxin within narrative: " + output, output.contains("ciprofloaxin"));
assertTrue("Expected string status of ACTIVE within narrative: " + output, output.contains("ACTIVE"));
}
@ -175,7 +167,7 @@ public class DefaultThymeleafNarrativeGeneratorDstu2Test {
Medication med = new Medication();
med.getCode().setText("ciproflaxin");
myGen.populateResourceNarrative(med);
myGen.populateResourceNarrative(ourCtx, med);
String output = med.getText().getDiv().getValueAsString();
assertThat(output, containsString("ciproflaxin"));

View File

@ -71,7 +71,7 @@ public class BundleTypeInResponseTest {
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer(ourCtx);
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator(ourCtx));
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);

View File

@ -58,13 +58,13 @@ public class ThymeleafNarrativeGeneratorTest {
ref.setReference("DiagnosticReport/1").setResource(dr1);
sect.getEntry().add(ref);
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(myCtx, "classpath:narrative2/narratives.properties");
ThymeleafNarrativeGenerator gen = new ThymeleafNarrativeGenerator(myCtx);
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties");
ThymeleafNarrativeGenerator gen = new ThymeleafNarrativeGenerator();
gen.setManifest(manifest);
gen.populateResourceNarrative(composition);
gen.populateResourceNarrative(myCtx, composition);
// Firt narrative should be empty
// First narrative should be empty
String narrative = composition.getSection().get(0).getText().getDiv().getValueAsString();
assertThat(narrative, Matchers.emptyOrNullString());
@ -78,7 +78,7 @@ public class ThymeleafNarrativeGeneratorTest {
@Test
public void testTemplateCount() throws IOException {
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileLocation(myCtx, "classpath:narrative2/narratives.properties");
NarrativeTemplateManifest manifest = NarrativeTemplateManifest.forManifestFileContents("classpath:narrative2/narratives.properties");
assertEquals(4, manifest.getNamedTemplateCount());
}

View File

@ -48,7 +48,7 @@ public class ExampleRestfulServlet extends RestfulServer {
* but can be useful as it causes HAPI to generate narratives for
* resources which don't otherwise have one.
*/
INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator(getFhirContext());
INarrativeGenerator narrativeGen = new DefaultThymeleafNarrativeGenerator();
getFhirContext().setNarrativeGenerator(narrativeGen);
/*