diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/AbstractImportExportCsvConceptMapCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/AbstractImportExportCsvConceptMapCommand.java index c740d90385c..f9241f29c90 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/AbstractImportExportCsvConceptMapCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/AbstractImportExportCsvConceptMapCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/App.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/App.java index d46c621144f..047944c29d5 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/App.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/App.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java index a77041fd8d3..31aea0978f6 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseApp.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -112,7 +112,6 @@ public abstract class BaseApp { PrintWriter pw = new PrintWriter(System.out); fmt.printOptions(pw, columns, theCommand.getOptions(), 2, 2); pw.flush(); - pw.close(); // That's it! System.out.println(); @@ -199,7 +198,9 @@ public abstract class BaseApp { } } if (command == null) { - System.err.println("Unknown command: " + theArgs[1]); + String message = "Unknown command: " + theArgs[1]; + System.err.println(message); + exitDueToProblem(message); return; } logCommandUsage(command); @@ -215,9 +216,11 @@ public abstract class BaseApp { } if (command == null) { - System.out.println("Unrecognized command: " + ansi().bold().fg(Ansi.Color.RED) + theArgs[0] + ansi().boldOff().fg(Ansi.Color.WHITE)); + String message = "Unrecognized command: " + ansi().bold().fg(Ansi.Color.RED) + theArgs[0] + ansi().boldOff().fg(Ansi.Color.WHITE); + System.out.println(message); System.out.println(); logUsage(); + exitDueToProblem(message); return; } @@ -250,7 +253,9 @@ public abstract class BaseApp { } } catch (ParseException e) { - loggingConfigOff(); + if (!"true".equals(System.getProperty("test"))) { + loggingConfigOff(); + } System.err.println("Invalid command options for command: " + command.getCommandName()); System.err.println(" " + ansi().fg(Ansi.Color.RED).bold() + e.getMessage()); System.err.println("" + ansi().fg(Ansi.Color.WHITE).boldOff()); @@ -269,6 +274,14 @@ public abstract class BaseApp { } + private void exitDueToProblem(String theDescription) { + if ("true".equals(System.getProperty("test"))) { + throw new Error(theDescription); + } else { + System.exit(1); + } + } + private void exitDueToException(Throwable e) { if ("true".equals(System.getProperty("test"))) { if (e instanceof CommandFailureException) { @@ -323,7 +336,7 @@ public abstract class BaseApp { private class MyShutdownHook extends Thread { private final BaseCommand myFinalCommand; - public MyShutdownHook(BaseCommand theFinalCommand) { + MyShutdownHook(BaseCommand theFinalCommand) { myFinalCommand = theFinalCommand; } diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseCommand.java index 168b6ced1b1..889f3838433 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseMigrateDatabaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseMigrateDatabaseCommand.java index 3b9e73761e2..826aec3b39e 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseMigrateDatabaseCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/BaseMigrateDatabaseCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java index be748abab5c..ce2b1a6d3e7 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/CommandFailureException.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java index 266d6d76667..01a60cd2cfb 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExampleDataUploader.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java index ad27999243c..3409453b31a 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ExportConceptMapToCsvCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiMigrateDatabaseCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiMigrateDatabaseCommand.java index 6be5b241110..b92adcb9fe8 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiMigrateDatabaseCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/HapiMigrateDatabaseCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/IgPackUploader.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/IgPackUploader.java index 496b133af37..0c34f5bed13 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/IgPackUploader.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/IgPackUploader.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java index 7a55a98d5ba..dc075491f4c 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ImportCsvToConceptMapCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java index 5d62186ef5d..56bbf84f773 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu2.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java index c5825017477..6f562364e37 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportDstu3.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportR4.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportR4.java index 62da68ea91f..4df8b05ec71 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportR4.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/LoadingValidationSupportR4.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java index d97a5557b98..01072862046 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/RunServerCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java index 5179a03afbc..b558dac875f 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/UploadTerminologyCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java index 5ba197404a4..ff4dcbb26d2 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidateCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java index 6a38ecc918d..a89348032a3 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/ValidationDataUploader.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java index 47d3554b288..43a0e3e5128 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/main/java/ca/uhn/fhir/cli/WebsocketSubscribeCommand.java @@ -4,7 +4,7 @@ package ca.uhn.fhir.cli; * #%L * HAPI FHIR - Command Line Client - API * %% - * Copyright (C) 2014 - 2018 University Health Network + * Copyright (C) 2014 - 2019 University Health Network * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java index 0aab8ba3a54..40dd61e0a29 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java @@ -80,6 +80,7 @@ import org.hl7.fhir.instance.model.api.IIdType; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Component; +import org.thymeleaf.util.ListUtils; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -2060,7 +2061,8 @@ public class SearchBuilder implements ISearchBuilder { String targetResourceType = defaultString(nextInclude.getParamTargetType(), null); for (String nextPath : paths) { String sql; - boolean haveTargetTypesDefinedByParam = param != null && param.getTargets() != null && param.getTargets().isEmpty() == false; + + boolean haveTargetTypesDefinedByParam = param.getTargets() != null && param.getTargets().isEmpty() == false; if (targetResourceType != null) { sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids) AND r.myTargetResourceType = :target_resource_type"; } else if (haveTargetTypesDefinedByParam) { @@ -2068,6 +2070,7 @@ public class SearchBuilder implements ISearchBuilder { } else { sql = "SELECT r FROM ResourceLink r WHERE r.mySourcePath = :src_path AND r." + searchFieldName + " IN (:target_pids)"; } + TypedQuery q = theEntityManager.createQuery(sql, ResourceLink.class); q.setParameter("src_path", nextPath); q.setParameter("target_pids", nextRoundMatches);