getSearchParamNamesForResourceType(@Nonnull String theResourceType) {
+ return myResourceTypeToParameterCodeMap.computeIfAbsent(theResourceType.toLowerCase(), (key) -> new HashSet<>());
+ }
+}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/AppliesTypeEnum.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/AppliesTypeEnum.java
index d3df71d8687..a878f0fb5de 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/AppliesTypeEnum.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/AppliesTypeEnum.java
@@ -22,7 +22,4 @@ package ca.uhn.fhir.rest.server.interceptor.auth;
enum AppliesTypeEnum {
ALL_RESOURCES, TYPES, INSTANCES
-
-
-
}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderRuleOpClassifier.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderRuleOpClassifier.java
index 6c3ceaab9a9..401d281b6ee 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderRuleOpClassifier.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/IAuthRuleBuilderRuleOpClassifier.java
@@ -21,6 +21,7 @@ package ca.uhn.fhir.rest.server.interceptor.auth;
*/
import java.util.Collection;
+import java.util.List;
import org.hl7.fhir.instance.model.api.IIdType;
@@ -42,6 +43,30 @@ public interface IAuthRuleBuilderRuleOpClassifier {
*/
IAuthRuleBuilderRuleOpClassifierFinished inCompartment(String theCompartmentName, IIdType theOwner);
+ /**
+ * Rule applies to resources in the given compartment.
+ *
+ * For example, to apply the rule to any observations in the patient compartment
+ * belonging to patient "123", you would invoke this with
+ * inCompartment("Patient", new IdType("Patient", "123"))
+ *
+ * This call also allows you to pass additional search parameters that count as being included in the given compartment,
+ * passed in as a list of `resourceType:search-parameter-name`. For example, if you select a compartment name of "patient",
+ * you could pass in a singleton list consisting of the string "device:patient", which would cause any devices belonging
+ * to the patient to be permitted by the authorization rule.
+ *
+ *
+ *
+ * This call completes the rule and adds the rule to the chain.
+ *
+ *
+ * @param theCompartmentName The name of the compartment (must not be null or blank)
+ * @param theOwner The owner of the compartment. Note that both the resource type and ID must be populated in this ID.
+ * @param theAdditionalTypeSearchParamNames A list of strings for additional resource types and search parameters which count as being in the compartment, in the form "resourcetype:search-parameter-name".
+ */
+ IAuthRuleBuilderRuleOpClassifierFinished inCompartmentWithAdditionalSearchParams(String theCompartmentName, IIdType theOwner, AdditionalCompartmentSearchParameters theAdditionalTypeSearchParamNames);
+
+
/**
* Rule applies to resources in the given compartment.
*
@@ -58,6 +83,32 @@ public interface IAuthRuleBuilderRuleOpClassifier {
*/
IAuthRuleBuilderRuleOpClassifierFinished inCompartment(String theCompartmentName, Collection extends IIdType> theOwners);
+
+ /**
+ * Rule applies to resources in the given compartment.
+ *
+ * For example, to apply the rule to any observations in the patient compartment
+ * belonging to patient "123", you would invoke this with
+ * inCompartment("Patient", new IdType("Patient", "123"))
+ *
+ * This call also allows you to pass additional search parameters that count as being included in the given compartment,
+ * passed in as a list of `resourceType:search-parameter-name`. For example, if you select a compartment name of "patient",
+ * you could pass in a singleton list consisting of the string "device:patient", which would cause any devices belonging
+ * to the patient to be permitted by the authorization rule.
+ *
+ *
+ *
+ * This call completes the rule and adds the rule to the chain.
+ *
+ *
+ * @param theCompartmentName The name of the compartment (must not be null or blank)
+ * @param theOwners The owners of the compartment. Note that both the resource type and ID must be populated in these IDs.
+ * @param theAdditionalTypeSearchParamNames A {@link AdditionalCompartmentSearchParameters} which allows you to expand the search space for what is considered "in" the compartment.
+ *
+ **/
+ IAuthRuleBuilderRuleOpClassifierFinished inCompartmentWithAdditionalSearchParams(String theCompartmentName, Collection extends IIdType> theOwners, AdditionalCompartmentSearchParameters theAdditionalTypeSearchParamNames);
+
+
/**
* Rule applies to any resource instances
*
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleBuilder.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleBuilder.java
index 086797a8ef7..92587a062b9 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleBuilder.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleBuilder.java
@@ -451,6 +451,7 @@ public class RuleBuilder implements IAuthRuleBuilder {
private Collection extends IIdType> myInCompartmentOwners;
private Collection myAppliesToInstances;
private RuleImplOp myRule;
+ private AdditionalCompartmentSearchParameters myAdditionalSearchParamsForCompartmentTypes = new AdditionalCompartmentSearchParameters();
/**
* Constructor
@@ -483,6 +484,7 @@ public class RuleBuilder implements IAuthRuleBuilder {
myRule.setClassifierCompartmentOwners(myInCompartmentOwners);
myRule.setAppliesToDeleteCascade(myOnCascade);
myRule.setAppliesToDeleteExpunge(myOnExpunge);
+ myRule.setAdditionalSearchParamsForCompartmentTypes(myAdditionalSearchParamsForCompartmentTypes);
myRules.add(myRule);
return new RuleBuilderFinished(myRule);
@@ -490,6 +492,11 @@ public class RuleBuilder implements IAuthRuleBuilder {
@Override
public IAuthRuleBuilderRuleOpClassifierFinished inCompartment(String theCompartmentName, Collection extends IIdType> theOwners) {
+ return inCompartmentWithAdditionalSearchParams(theCompartmentName, theOwners, new AdditionalCompartmentSearchParameters());
+ }
+
+ @Override
+ public IAuthRuleBuilderRuleOpClassifierFinished inCompartmentWithAdditionalSearchParams(String theCompartmentName, Collection extends IIdType> theOwners, AdditionalCompartmentSearchParameters theAdditionalTypeSearchParams) {
Validate.notBlank(theCompartmentName, "theCompartmentName must not be null");
Validate.notNull(theOwners, "theOwners must not be null");
Validate.noNullElements(theOwners, "theOwners must not contain any null elements");
@@ -498,20 +505,28 @@ public class RuleBuilder implements IAuthRuleBuilder {
}
myInCompartmentName = theCompartmentName;
myInCompartmentOwners = theOwners;
+ myAdditionalSearchParamsForCompartmentTypes = theAdditionalTypeSearchParams;
myClassifierType = ClassifierTypeEnum.IN_COMPARTMENT;
return finished();
}
@Override
public IAuthRuleBuilderRuleOpClassifierFinished inCompartment(String theCompartmentName, IIdType theOwner) {
+ return inCompartmentWithAdditionalSearchParams(theCompartmentName, theOwner, new AdditionalCompartmentSearchParameters());
+ }
+
+ @Override
+ public IAuthRuleBuilderRuleOpClassifierFinished inCompartmentWithAdditionalSearchParams(String theCompartmentName, IIdType theOwner, AdditionalCompartmentSearchParameters theAdditionalTypeSearchParamNames) {
Validate.notBlank(theCompartmentName, "theCompartmentName must not be null");
Validate.notNull(theOwner, "theOwner must not be null");
validateOwner(theOwner);
myClassifierType = ClassifierTypeEnum.IN_COMPARTMENT;
myInCompartmentName = theCompartmentName;
+ myAdditionalSearchParamsForCompartmentTypes = theAdditionalTypeSearchParamNames;
Optional oRule = findMatchingRule();
if (oRule.isPresent()) {
RuleImplOp rule = oRule.get();
+ rule.setAdditionalSearchParamsForCompartmentTypes(myAdditionalSearchParamsForCompartmentTypes);
rule.addClassifierCompartmentOwner(theOwner);
return new RuleBuilderFinished(rule);
}
@@ -519,6 +534,7 @@ public class RuleBuilder implements IAuthRuleBuilder {
return finished();
}
+
private Optional findMatchingRule() {
return myRules.stream()
.filter(RuleImplOp.class::isInstance)
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleImplOp.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleImplOp.java
index 0810235f2ac..fa5841be869 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleImplOp.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/interceptor/auth/RuleImplOp.java
@@ -30,7 +30,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
+import java.util.stream.Collectors;
import static org.apache.commons.lang3.StringUtils.defaultString;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
@@ -69,6 +71,7 @@ class RuleImplOp extends BaseRule /* implements IAuthRule */ {
private Collection myAppliesToInstances;
private boolean myAppliesToDeleteCascade;
private boolean myAppliesToDeleteExpunge;
+ private AdditionalCompartmentSearchParameters myAdditionalCompartmentSearchParamMap;
/**
* Constructor
@@ -337,7 +340,12 @@ class RuleImplOp extends BaseRule /* implements IAuthRule */ {
for (IIdType next : myClassifierCompartmentOwners) {
if (target.resource != null) {
- if (t.isSourceInCompartmentForTarget(myClassifierCompartmentName, target.resource, next)) {
+
+ Set additionalSearchParamNames = null;
+ if (myAdditionalCompartmentSearchParamMap != null) {
+ additionalSearchParamNames = myAdditionalCompartmentSearchParamMap.getSearchParamNamesForResourceType(ctx.getResourceType(target.resource));
+ }
+ if (t.isSourceInCompartmentForTarget(myClassifierCompartmentName, target.resource, next, additionalSearchParamNames)) {
foundMatch = true;
break;
}
@@ -371,7 +379,17 @@ class RuleImplOp extends BaseRule /* implements IAuthRule */ {
RuntimeResourceDefinition sourceDef = theRequestDetails.getFhirContext().getResourceDefinition(target.resourceType);
String compartmentOwnerResourceType = next.getResourceType();
if (!StringUtils.equals(target.resourceType, compartmentOwnerResourceType)) {
+
List params = sourceDef.getSearchParamsForCompartmentName(compartmentOwnerResourceType);
+
+ Set additionalParamNames = myAdditionalCompartmentSearchParamMap.getSearchParamNamesForResourceType(sourceDef.getName());
+ List additionalParams = additionalParamNames.stream().map(sourceDef::getSearchParam).filter(Objects::nonNull).collect(Collectors.toList());
+ if (params == null || params.isEmpty()) {
+ params = additionalParams;
+ } else {
+ params.addAll(additionalParams);
+ }
+
if (!params.isEmpty()) {
/*
@@ -681,4 +699,8 @@ class RuleImplOp extends BaseRule /* implements IAuthRule */ {
return false;
}
}
+
+ public void setAdditionalSearchParamsForCompartmentTypes(AdditionalCompartmentSearchParameters theAdditionalParameters) {
+ myAdditionalCompartmentSearchParamMap = theAdditionalParameters;
+ }
}
diff --git a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ProviderConstants.java b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ProviderConstants.java
index f9296160b36..365393697ce 100644
--- a/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ProviderConstants.java
+++ b/hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/provider/ProviderConstants.java
@@ -170,4 +170,13 @@ public class ProviderConstants {
* The Spring Batch job id of the delete expunge job created by a $delete-expunge operation
*/
public static final String OPERATION_REINDEX_RESPONSE_JOB_ID = "jobId";
+
+ @Deprecated
+ public static final String MARK_ALL_RESOURCES_FOR_REINDEXING = "$mark-all-resources-for-reindexing";
+ /**
+ * @see ProviderConstants#OPERATION_REINDEX
+ * @deprecated
+ */
+ @Deprecated
+ public static final String PERFORM_REINDEXING_PASS = "$perform-reindexing-pass";
}
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
index 53e0d08a968..3447508f8a1 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
index 1bc5de61f40..7e39b57ee6a 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
hapi-fhir-spring-boot-sample-client-apache
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
index 7e30b65d2b7..2bc8878adba 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
hapi-fhir-spring-boot-sample-client-okhttp
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
index a76318684c6..672ce4ae812 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot-samples
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
hapi-fhir-spring-boot-sample-server-jersey
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
index 4f824c60db2..86d5f76bf7d 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir-spring-boot
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
hapi-fhir-spring-boot-samples
diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
index d0d3f5e065f..ecf05d548c6 100644
--- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
+++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
../../hapi-deployable-pom/pom.xml
diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml
index 04d9e96e88d..01db97a81f7 100644
--- a/hapi-fhir-spring-boot/pom.xml
+++ b/hapi-fhir-spring-boot/pom.xml
@@ -5,7 +5,7 @@
ca.uhn.hapi.fhir
hapi-fhir
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
../pom.xml
diff --git a/hapi-fhir-jpaserver-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml
similarity index 86%
rename from hapi-fhir-jpaserver-migrate/pom.xml
rename to hapi-fhir-sql-migrate/pom.xml
index 6381faf35c4..e995ed778ee 100644
--- a/hapi-fhir-jpaserver-migrate/pom.xml
+++ b/hapi-fhir-sql-migrate/pom.xml
@@ -1,31 +1,25 @@
-
+
4.0.0
ca.uhn.hapi.fhir
hapi-deployable-pom
- 5.6.0-PRE5-SNAPSHOT
+ 5.6.0-PRE6-SNAPSHOT
../hapi-deployable-pom/pom.xml
- hapi-fhir-jpaserver-migrate
+ hapi-fhir-sql-migrate
jar
- HAPI FHIR JPA Server - Migration
+ HAPI FHIR Server - SQL Migration
+ Tooling for migrating SQL schemas.
mysql
mysql-connector-java
-
-
org.springframework
spring-jdbc
@@ -34,13 +28,15 @@
org.apache.commons
commons-dbcp2
-
-
ca.uhn.hapi.fhir
- hapi-fhir-jpaserver-base
+ hapi-fhir-base
${project.version}
+
+ org.hibernate
+ hibernate-core
+
com.h2database
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java
index 9991b57859d..18ed02ade1d 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/BaseMigrator.java
@@ -32,9 +32,9 @@ import java.util.List;
import java.util.Objects;
public abstract class BaseMigrator implements IMigrator {
+ private final List myExecutedStatements = new ArrayList<>();
private boolean myDryRun;
private boolean myNoColumnShrink;
- private final List myExecutedStatements = new ArrayList<>();
private boolean mySchemaWasInitialized;
private DriverTypeEnum myDriverType;
private DataSource myDataSource;
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java
similarity index 99%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java
index e3ffc87b834..89369665502 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/DriverTypeEnum.java
@@ -67,6 +67,15 @@ public enum DriverTypeEnum {
myDerby = theDerby;
}
+ public static DriverTypeEnum fromDriverClassName(String theDriverClassName) {
+ for (DriverTypeEnum driverTypeEnum : DriverTypeEnum.values()) {
+ if (driverTypeEnum.myDriverClassName.equals(theDriverClassName)) {
+ return driverTypeEnum;
+ }
+ }
+ return null;
+ }
+
public String getDriverClassName() {
return myDriverClassName;
}
@@ -99,18 +108,9 @@ public enum DriverTypeEnum {
return retval;
}
- public static DriverTypeEnum fromDriverClassName(String theDriverClassName) {
- for (DriverTypeEnum driverTypeEnum : DriverTypeEnum.values()) {
- if (driverTypeEnum.myDriverClassName.equals(theDriverClassName)) {
- return driverTypeEnum;
- }
- }
- return null;
- }
-
public ConnectionProperties newConnectionProperties(String theUrl, String theUsername, String thePassword) {
- BasicDataSource dataSource = new BasicDataSource(){
+ BasicDataSource dataSource = new BasicDataSource() {
@Override
public Connection getConnection() throws SQLException {
ourLog.debug("Creating new DB connection");
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java
similarity index 98%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java
index 7889e45933e..176b97a1e06 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrationTask.java
@@ -21,7 +21,6 @@ package ca.uhn.fhir.jpa.migrate;
*/
import ca.uhn.fhir.jpa.migrate.taskdef.BaseTask;
-import ca.uhn.fhir.jpa.migrate.taskdef.InitializeSchemaTask;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import org.flywaydb.core.api.MigrationVersion;
import org.flywaydb.core.api.migration.Context;
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/IMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/IMigrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/IMigrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/IMigrator.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java
similarity index 94%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java
index fb4af862dd6..df3c904f687 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/JdbcUtils.java
@@ -62,78 +62,9 @@ import java.util.Locale;
import java.util.Objects;
import java.util.Set;
-import static org.thymeleaf.util.StringUtils.toUpperCase;
-
public class JdbcUtils {
private static final Logger ourLog = LoggerFactory.getLogger(JdbcUtils.class);
- public static class ColumnType {
- private final ColumnTypeEnum myColumnTypeEnum;
- private final Long myLength;
-
- public ColumnType(ColumnTypeEnum theColumnType, Long theLength) {
- myColumnTypeEnum = theColumnType;
- myLength = theLength;
- }
-
- public ColumnType(ColumnTypeEnum theColumnType, int theLength) {
- this(theColumnType, (long) theLength);
- }
-
- public ColumnType(ColumnTypeEnum theColumnType) {
- this(theColumnType, null);
- }
-
- @Override
- public boolean equals(Object theO) {
- if (this == theO) {
- return true;
- }
-
- if (theO == null || getClass() != theO.getClass()) {
- return false;
- }
-
- ColumnType that = (ColumnType) theO;
-
- return new EqualsBuilder()
- .append(myColumnTypeEnum, that.myColumnTypeEnum)
- .append(myLength, that.myLength)
- .isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder(17, 37)
- .append(myColumnTypeEnum)
- .append(myLength)
- .toHashCode();
- }
-
- @Override
- public String toString() {
- ToStringBuilder b = new ToStringBuilder(this);
- b.append("type", myColumnTypeEnum);
- if (myLength != null) {
- b.append("length", myLength);
- }
- return b.toString();
- }
-
- public ColumnTypeEnum getColumnTypeEnum() {
- return myColumnTypeEnum;
- }
-
- public Long getLength() {
- return myLength;
- }
-
- public boolean equals(ColumnTypeEnum theTaskColumnType, Long theTaskColumnLength) {
- ourLog.debug("Comparing existing {} {} to new {} {}", myColumnTypeEnum, myLength, theTaskColumnType, theTaskColumnLength);
- return myColumnTypeEnum == theTaskColumnType && (theTaskColumnLength == null || theTaskColumnLength.equals(myLength));
- }
- }
-
/**
* Retrieve all index names
*/
@@ -155,7 +86,7 @@ public class JdbcUtils {
while (indexes.next()) {
ourLog.debug("*** Next index: {}", new ColumnMapRowMapper().mapRow(indexes, 0));
String indexName = indexes.getString("INDEX_NAME");
- indexName = toUpperCase(indexName, Locale.US);
+ indexName = indexName.toUpperCase(Locale.US);
indexNames.add(indexName);
}
@@ -163,7 +94,7 @@ public class JdbcUtils {
while (indexes.next()) {
ourLog.debug("*** Next index: {}", new ColumnMapRowMapper().mapRow(indexes, 0));
String indexName = indexes.getString("INDEX_NAME");
- indexName = toUpperCase(indexName, Locale.US);
+ indexName = indexName.toUpperCase(Locale.US);
indexNames.add(indexName);
}
@@ -226,11 +157,11 @@ public class JdbcUtils {
while (indexes.next()) {
- String tableName = toUpperCase(indexes.getString("TABLE_NAME"), Locale.US);
+ String tableName = indexes.getString("TABLE_NAME").toUpperCase(Locale.US);
if (!theTableName.equalsIgnoreCase(tableName)) {
continue;
}
- String columnName = toUpperCase(indexes.getString("COLUMN_NAME"), Locale.US);
+ String columnName = indexes.getString("COLUMN_NAME").toUpperCase(Locale.US);
if (!theColumnName.equalsIgnoreCase(columnName)) {
continue;
}
@@ -254,6 +185,13 @@ public class JdbcUtils {
return new ColumnType(ColumnTypeEnum.DATE_TIMESTAMP, length);
case Types.BLOB:
return new ColumnType(ColumnTypeEnum.BLOB, length);
+ case Types.VARBINARY:
+ if (DriverTypeEnum.MSSQL_2012.equals(theConnectionProperties.getDriverType())) {
+ // MS SQLServer seems to be mapping BLOB to VARBINARY under the covers, so we need to reverse that mapping
+ return new ColumnType(ColumnTypeEnum.BLOB, length);
+ } else {
+ throw new IllegalArgumentException("Don't know how to handle datatype " + dataType + " for column " + theColumnName + " on table " + theTableName);
+ }
case Types.CLOB:
return new ColumnType(ColumnTypeEnum.CLOB, length);
case Types.DOUBLE:
@@ -308,7 +246,7 @@ public class JdbcUtils {
while (indexes.next()) {
String fkName = indexes.getString("FK_NAME");
- fkName = toUpperCase(fkName, Locale.US);
+ fkName = fkName.toUpperCase(Locale.US);
fkNames.add(fkName);
}
}
@@ -348,7 +286,7 @@ public class JdbcUtils {
while (indexes.next()) {
if (theForeignKeyColumn.equals(indexes.getString("FKCOLUMN_NAME"))) {
String fkName = indexes.getString("FK_NAME");
- fkName = toUpperCase(fkName, Locale.US);
+ fkName = fkName.toUpperCase(Locale.US);
fkNames.add(fkName);
}
}
@@ -376,13 +314,13 @@ public class JdbcUtils {
Set columnNames = new HashSet<>();
while (indexes.next()) {
- String tableName = toUpperCase(indexes.getString("TABLE_NAME"), Locale.US);
+ String tableName = indexes.getString("TABLE_NAME").toUpperCase(Locale.US);
if (!theTableName.equalsIgnoreCase(tableName)) {
continue;
}
String columnName = indexes.getString("COLUMN_NAME");
- columnName = toUpperCase(columnName, Locale.US);
+ columnName = columnName.toUpperCase(Locale.US);
columnNames.add(columnName);
}
@@ -499,7 +437,7 @@ public class JdbcUtils {
Set columnNames = new HashSet<>();
while (tables.next()) {
String tableName = tables.getString("TABLE_NAME");
- tableName = toUpperCase(tableName, Locale.US);
+ tableName = tableName.toUpperCase(Locale.US);
String tableType = tables.getString("TABLE_TYPE");
if ("SYSTEM TABLE".equalsIgnoreCase(tableType)) {
@@ -531,7 +469,7 @@ public class JdbcUtils {
ResultSet tables = metadata.getColumns(connection.getCatalog(), connection.getSchema(), massageIdentifier(metadata, theTableName), null);
while (tables.next()) {
- String tableName = toUpperCase(tables.getString("TABLE_NAME"), Locale.US);
+ String tableName = tables.getString("TABLE_NAME").toUpperCase(Locale.US);
if (!theTableName.equalsIgnoreCase(tableName)) {
continue;
}
@@ -567,4 +505,71 @@ public class JdbcUtils {
}
return retVal;
}
+
+ public static class ColumnType {
+ private final ColumnTypeEnum myColumnTypeEnum;
+ private final Long myLength;
+
+ public ColumnType(ColumnTypeEnum theColumnType, Long theLength) {
+ myColumnTypeEnum = theColumnType;
+ myLength = theLength;
+ }
+
+ public ColumnType(ColumnTypeEnum theColumnType, int theLength) {
+ this(theColumnType, (long) theLength);
+ }
+
+ public ColumnType(ColumnTypeEnum theColumnType) {
+ this(theColumnType, null);
+ }
+
+ @Override
+ public boolean equals(Object theO) {
+ if (this == theO) {
+ return true;
+ }
+
+ if (theO == null || getClass() != theO.getClass()) {
+ return false;
+ }
+
+ ColumnType that = (ColumnType) theO;
+
+ return new EqualsBuilder()
+ .append(myColumnTypeEnum, that.myColumnTypeEnum)
+ .append(myLength, that.myLength)
+ .isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37)
+ .append(myColumnTypeEnum)
+ .append(myLength)
+ .toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this);
+ b.append("type", myColumnTypeEnum);
+ if (myLength != null) {
+ b.append("length", myLength);
+ }
+ return b.toString();
+ }
+
+ public ColumnTypeEnum getColumnTypeEnum() {
+ return myColumnTypeEnum;
+ }
+
+ public Long getLength() {
+ return myLength;
+ }
+
+ public boolean equals(ColumnTypeEnum theTaskColumnType, Long theTaskColumnLength) {
+ ourLog.debug("Comparing existing {} {} to new {} {}", myColumnTypeEnum, myLength, theTaskColumnType, theTaskColumnLength);
+ return myColumnTypeEnum == theTaskColumnType && (theTaskColumnLength == null || theTaskColumnLength.equals(myLength));
+ }
+ }
}
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/MigrationTaskSkipper.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/Migrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/Migrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/Migrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/Migrator.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/SchemaMigrator.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/TaskOnlyMigrator.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/TaskOnlyMigrator.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/TaskOnlyMigrator.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/TaskOnlyMigrator.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddColumnTask.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java
similarity index 100%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java
similarity index 95%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java
index c00aa23e008..99e199d46a8 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java
@@ -27,7 +27,6 @@ import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.thymeleaf.util.StringUtils;
import javax.annotation.Nonnull;
import java.sql.SQLException;
@@ -50,7 +49,7 @@ public class AddIndexTask extends BaseTableTask {
}
public void setIndexName(String theIndexName) {
- myIndexName = StringUtils.toUpperCase(theIndexName, Locale.US);
+ myIndexName = theIndexName.toUpperCase(Locale.US);
}
public void setColumns(List theColumns) {
@@ -104,7 +103,7 @@ public class AddIndexTask extends BaseTableTask {
switch (getDriverType()) {
case POSTGRES_9_4:
case MSSQL_2012:
- includeClause = " INCLUDE (" + StringUtils.join(myIncludeColumns, ", ") + ")";
+ includeClause = " INCLUDE (" + String.join(", ", myIncludeColumns) + ")";
break;
case H2_EMBEDDED:
case DERBY_EMBEDDED:
@@ -119,7 +118,7 @@ public class AddIndexTask extends BaseTableTask {
}
if (myUnique && getDriverType() == DriverTypeEnum.MSSQL_2012) {
mssqlWhereClause = " WHERE (";
- for (int i = 0; i 0);
}
}
-
- private static class TableAndColumn {
- private final String myTable;
- private final String myColumn;
-
- private TableAndColumn(String theTable, String theColumn) {
- myTable = theTable;
- myColumn = theColumn;
- }
-
- public String getTable() {
- return myTable;
- }
-
- public String getColumn() {
- return myColumn;
- }
- }
}
diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java
similarity index 99%
rename from hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java
rename to hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java
index 4bacbc4eef6..4a5163cb398 100644
--- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java
+++ b/hapi-fhir-sql-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseColumnCalculatorTask.java
@@ -211,40 +211,6 @@ public abstract class BaseColumnCalculatorTask extends BaseTableColumnTask {
return myExecutor.submit(task);
}
- private class MyRowCallbackHandler implements RowCallbackHandler {
-
- private List