Syntax fixes for the JPA migrator
This commit is contained in:
parent
650872cd3e
commit
b2179b1696
|
@ -127,7 +127,9 @@ public class JdbcUtils {
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
case Types.VARCHAR:
|
case Types.VARCHAR:
|
||||||
return BaseTableColumnTypeTask.ColumnTypeEnum.STRING.getDescriptor(length);
|
return BaseTableColumnTypeTask.ColumnTypeEnum.STRING.getDescriptor(length);
|
||||||
|
case Types.NUMERIC:
|
||||||
case Types.BIGINT:
|
case Types.BIGINT:
|
||||||
|
case Types.DECIMAL:
|
||||||
return BaseTableColumnTypeTask.ColumnTypeEnum.LONG.getDescriptor(null);
|
return BaseTableColumnTypeTask.ColumnTypeEnum.LONG.getDescriptor(null);
|
||||||
case Types.INTEGER:
|
case Types.INTEGER:
|
||||||
return BaseTableColumnTypeTask.ColumnTypeEnum.INT.getDescriptor(null);
|
return BaseTableColumnTypeTask.ColumnTypeEnum.INT.getDescriptor(null);
|
||||||
|
@ -135,7 +137,7 @@ public class JdbcUtils {
|
||||||
case Types.TIMESTAMP_WITH_TIMEZONE:
|
case Types.TIMESTAMP_WITH_TIMEZONE:
|
||||||
return BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP.getDescriptor(null);
|
return BaseTableColumnTypeTask.ColumnTypeEnum.DATE_TIMESTAMP.getDescriptor(null);
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Don't know how to handle datatype: " + dataType);
|
throw new IllegalArgumentException("Don't know how to handle datatype " + dataType + " for column " + theColumnName + " on table " + theTableName);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class ArbitrarySqlTask extends BaseTask<ArbitrarySqlTask> {
|
||||||
private List<Task> myTask = new ArrayList<>();
|
private List<Task> myTask = new ArrayList<>();
|
||||||
private int myBatchSize = 1000;
|
private int myBatchSize = 1000;
|
||||||
private String myExecuteOnlyIfTableExists;
|
private String myExecuteOnlyIfTableExists;
|
||||||
|
private List<TableAndColumn> myConditionalOnExistenceOf = new ArrayList<>();
|
||||||
|
|
||||||
public ArbitrarySqlTask(String theTableName, String theDescription) {
|
public ArbitrarySqlTask(String theTableName, String theDescription) {
|
||||||
myTableName = theTableName;
|
myTableName = theTableName;
|
||||||
|
@ -69,6 +70,14 @@ public class ArbitrarySqlTask extends BaseTask<ArbitrarySqlTask> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (TableAndColumn next : myConditionalOnExistenceOf) {
|
||||||
|
String columnType = JdbcUtils.getColumnType(getConnectionProperties(), next.getTable(), next.getColumn());
|
||||||
|
if (columnType == null) {
|
||||||
|
ourLog.info("Table {} does not have column {} - No action performed", next.getTable(), next.getColumn());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (Task next : myTask) {
|
for (Task next : myTask) {
|
||||||
next.execute();
|
next.execute();
|
||||||
}
|
}
|
||||||
|
@ -83,6 +92,13 @@ public class ArbitrarySqlTask extends BaseTask<ArbitrarySqlTask> {
|
||||||
myExecuteOnlyIfTableExists = theExecuteOnlyIfTableExists;
|
myExecuteOnlyIfTableExists = theExecuteOnlyIfTableExists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This task will only execute if the following column exists
|
||||||
|
*/
|
||||||
|
public void addExecuteOnlyIfColumnExists(String theTableName, String theColumnName) {
|
||||||
|
myConditionalOnExistenceOf.add(new TableAndColumn(theTableName, theColumnName));
|
||||||
|
}
|
||||||
|
|
||||||
public enum QueryModeEnum {
|
public enum QueryModeEnum {
|
||||||
BATCH_UNTIL_NO_MORE
|
BATCH_UNTIL_NO_MORE
|
||||||
}
|
}
|
||||||
|
@ -129,4 +145,22 @@ public class ArbitrarySqlTask extends BaseTask<ArbitrarySqlTask> {
|
||||||
} while (rows.size() > 0);
|
} while (rows.size() > 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@SuppressWarnings({"UnstableApiUsage", "SqlNoDataSourceInspection", "SpellCheckingInspection"})
|
@SuppressWarnings({"SqlNoDataSourceInspection", "SpellCheckingInspection"})
|
||||||
public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
|
|
||||||
private final Set<FlagEnum> myFlags;
|
private final Set<FlagEnum> myFlags;
|
||||||
|
@ -90,10 +90,12 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
// Forced ID changes
|
// Forced ID changes
|
||||||
Builder.BuilderWithTableName forcedId = version.onTable("HFJ_FORCED_ID");
|
Builder.BuilderWithTableName forcedId = version.onTable("HFJ_FORCED_ID");
|
||||||
version.startSectionWithMessage("Starting work on table: " + forcedId.getTableName());
|
version.startSectionWithMessage("Starting work on table: " + forcedId.getTableName());
|
||||||
|
|
||||||
forcedId
|
forcedId
|
||||||
.dropIndex("IDX_FORCEDID_TYPE_FORCEDID");
|
.dropIndex("IDX_FORCEDID_TYPE_FORCEDID");
|
||||||
forcedId
|
forcedId
|
||||||
.dropIndex("IDX_FORCEDID_TYPE_RESID");
|
.dropIndex("IDX_FORCEDID_TYPE_RESID");
|
||||||
|
|
||||||
forcedId
|
forcedId
|
||||||
.addIndex("IDX_FORCEDID_TYPE_FID")
|
.addIndex("IDX_FORCEDID_TYPE_FID")
|
||||||
.unique(true)
|
.unique(true)
|
||||||
|
@ -332,9 +334,10 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
"from HFJ_RES_PARAM_PRESENT " +
|
"from HFJ_RES_PARAM_PRESENT " +
|
||||||
"join HFJ_SEARCH_PARM ON (HFJ_SEARCH_PARM.PID = HFJ_RES_PARAM_PRESENT.SP_ID) " +
|
"join HFJ_SEARCH_PARM ON (HFJ_SEARCH_PARM.PID = HFJ_RES_PARAM_PRESENT.SP_ID) " +
|
||||||
"where HFJ_RES_PARAM_PRESENT.HASH_PRESENCE is null";
|
"where HFJ_RES_PARAM_PRESENT.HASH_PRESENCE is null";
|
||||||
|
consolidateSearchParamPresenceIndexesTask.addExecuteOnlyIfColumnExists("HFJ_RES_PARAM_PRESENT", "SP_ID");
|
||||||
consolidateSearchParamPresenceIndexesTask.addQuery(sql, ArbitrarySqlTask.QueryModeEnum.BATCH_UNTIL_NO_MORE, t -> {
|
consolidateSearchParamPresenceIndexesTask.addQuery(sql, ArbitrarySqlTask.QueryModeEnum.BATCH_UNTIL_NO_MORE, t -> {
|
||||||
Long pid = (Long) t.get("PID");
|
Number pid = (Number) t.get("PID");
|
||||||
Boolean present = (Boolean) t.get("SP_PRESENT");
|
Boolean present = columnToBoolean(t.get("SP_PRESENT"));
|
||||||
String resType = (String) t.get("RES_TYPE");
|
String resType = (String) t.get("RES_TYPE");
|
||||||
String paramName = (String) t.get("PARAM_NAME");
|
String paramName = (String) t.get("PARAM_NAME");
|
||||||
Long hash = SearchParamPresent.calculateHashPresence(resType, paramName, present);
|
Long hash = SearchParamPresent.calculateHashPresence(resType, paramName, present);
|
||||||
|
@ -494,6 +497,18 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
.addSql(DriverTypeEnum.MSSQL_2012, "alter table TRM_CONCEPT_MAP_GRP_ELM_TGT add constraint FK_TCMGETARGET_ELEMENT foreign key (CONCEPT_MAP_GRP_ELM_PID) references TRM_CONCEPT_MAP_GRP_ELEMENT");
|
.addSql(DriverTypeEnum.MSSQL_2012, "alter table TRM_CONCEPT_MAP_GRP_ELM_TGT add constraint FK_TCMGETARGET_ELEMENT foreign key (CONCEPT_MAP_GRP_ELM_PID) references TRM_CONCEPT_MAP_GRP_ELEMENT");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Boolean columnToBoolean(Object theValue) {
|
||||||
|
if (theValue == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (theValue instanceof Boolean) {
|
||||||
|
return (Boolean) theValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
long longValue = ((Number) theValue).longValue();
|
||||||
|
return longValue == 1L;
|
||||||
|
}
|
||||||
|
|
||||||
private void init340() {
|
private void init340() {
|
||||||
Builder version = forVersion(VersionEnum.V3_4_0);
|
Builder version = forVersion(VersionEnum.V3_4_0);
|
||||||
|
|
||||||
|
@ -537,10 +552,6 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
myCommandLineValue = theCommandLineValue;
|
myCommandLineValue = theCommandLineValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCommandLineValue() {
|
|
||||||
return myCommandLineValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FlagEnum fromCommandLineValue(String theCommandLineValue) {
|
public static FlagEnum fromCommandLineValue(String theCommandLineValue) {
|
||||||
Optional<FlagEnum> retVal = Arrays.stream(values()).filter(t -> t.myCommandLineValue.equals(theCommandLineValue)).findFirst();
|
Optional<FlagEnum> retVal = Arrays.stream(values()).filter(t -> t.myCommandLineValue.equals(theCommandLineValue)).findFirst();
|
||||||
return retVal.orElseThrow(() -> {
|
return retVal.orElseThrow(() -> {
|
||||||
|
|
|
@ -121,6 +121,9 @@ drop table hfj_search_result cascade constraints;
|
||||||
drop table hfj_search_include cascade constraints;
|
drop table hfj_search_include cascade constraints;
|
||||||
drop table hfj_search cascade constraints;
|
drop table hfj_search cascade constraints;
|
||||||
drop table hfj_res_param_present cascade constraints;
|
drop table hfj_res_param_present cascade constraints;
|
||||||
|
DROP TABLE HFJ_RES_REINDEX_JOB cascade constraints;
|
||||||
|
DROP TABLE HFJ_SEARCH_PARM cascade constraints;
|
||||||
|
DROP TABLE HFJ_TAG_DEF cascade CONSTRAINTS;
|
||||||
drop table hfj_idx_cmp_string_uniq cascade constraints;
|
drop table hfj_idx_cmp_string_uniq cascade constraints;
|
||||||
drop table hfj_subscription_stats cascade constraints;
|
drop table hfj_subscription_stats cascade constraints;
|
||||||
drop table trm_concept_property cascade constraints;
|
drop table trm_concept_property cascade constraints;
|
||||||
|
@ -130,11 +133,11 @@ drop table trm_codesystem_ver cascade constraints;
|
||||||
drop table trm_codesystem cascade constraints;
|
drop table trm_codesystem cascade constraints;
|
||||||
DROP TABLE hfj_resource CASCADE CONSTRAINTS;
|
DROP TABLE hfj_resource CASCADE CONSTRAINTS;
|
||||||
DROP TABLE hfj_res_ver CASCADE CONSTRAINTS;
|
DROP TABLE hfj_res_ver CASCADE CONSTRAINTS;
|
||||||
drop table cdr_audit_evt_target_module cascade constraints;
|
DROP TABLE TRM_CONCEPT_DESIG CASCADE CONSTRAINTS;
|
||||||
drop table cdr_audit_evt_target_res cascade constraints;
|
DROP TABLE TRM_CONCEPT_MAP CASCADE CONSTRAINTS;
|
||||||
drop table cdr_audit_evt_target_user cascade constraints;
|
DROP TABLE TRM_CONCEPT_MAP_GROUP CASCADE CONSTRAINTS;
|
||||||
drop table cdr_xact_log_step cascade constraints;
|
DROP TABLE TRM_CONCEPT_MAP_GRP_ELEMENT CASCADE CONSTRAINTS;
|
||||||
drop table cdr_xact_log cascade constraints;
|
DROP TABLE TRM_CONCEPT_MAP_GRP_ELM_TGT CASCADE CONSTRAINTS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
package ca.uhn.fhir.rest.server.interceptor.auth;
|
package ca.uhn.fhir.rest.server.interceptor.auth;
|
||||||
|
|
||||||
|
/*-
|
||||||
|
* #%L
|
||||||
|
* HAPI FHIR - Server Framework
|
||||||
|
* %%
|
||||||
|
* Copyright (C) 2014 - 2018 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.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* #L%
|
||||||
|
*/
|
||||||
|
|
||||||
public interface IAuthRuleBuilderOperationNamedAndScoped {
|
public interface IAuthRuleBuilderOperationNamedAndScoped {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue