quiet migration tasks during tests
also add description to schema initialization tasks
This commit is contained in:
parent
8d1d3cee75
commit
38bae8866b
|
@ -40,7 +40,7 @@ public class InitializeSchemaTask extends BaseTask<InitializeSchemaTask> {
|
||||||
public InitializeSchemaTask(String theProductVersion, String theSchemaVersion, ISchemaInitializationProvider theSchemaInitializationProvider) {
|
public InitializeSchemaTask(String theProductVersion, String theSchemaVersion, ISchemaInitializationProvider theSchemaInitializationProvider) {
|
||||||
super(theProductVersion, theSchemaVersion);
|
super(theProductVersion, theSchemaVersion);
|
||||||
mySchemaInitializationProvider = theSchemaInitializationProvider;
|
mySchemaInitializationProvider = theSchemaInitializationProvider;
|
||||||
setDescription("Initialize schema");
|
setDescription("Initialize schema for " + mySchemaInitializationProvider.getSchemaDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,13 +59,15 @@ public class InitializeSchemaTask extends BaseTask<InitializeSchemaTask> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
logInfo(ourLog, "Initializing schema for {}", driverType);
|
logInfo(ourLog, "Initializing {} schema for {}", driverType, mySchemaInitializationProvider.getSchemaDescription());
|
||||||
|
|
||||||
List<String> sqlStatements = mySchemaInitializationProvider.getSqlStatements(driverType);
|
List<String> sqlStatements = mySchemaInitializationProvider.getSqlStatements(driverType);
|
||||||
|
|
||||||
for (String nextSql : sqlStatements) {
|
for (String nextSql : sqlStatements) {
|
||||||
executeSql(null, nextSql);
|
executeSql(null, nextSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logInfo(ourLog, "{} schema for {} initialized successfully", driverType, mySchemaInitializationProvider.getSchemaDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -904,7 +904,7 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
||||||
protected void init330() { // 20180114 - 20180329
|
protected void init330() { // 20180114 - 20180329
|
||||||
Builder version = forVersion(VersionEnum.V3_3_0);
|
Builder version = forVersion(VersionEnum.V3_3_0);
|
||||||
|
|
||||||
version.initializeSchema("20180115.0", new SchemaInitializationProvider("/ca/uhn/hapi/fhir/jpa/docs/database", "HFJ_RESOURCE"));
|
version.initializeSchema("20180115.0", new SchemaInitializationProvider("HAPI FHIR", "/ca/uhn/hapi/fhir/jpa/docs/database", "HFJ_RESOURCE"));
|
||||||
|
|
||||||
Builder.BuilderWithTableName hfjResource = version.onTable("HFJ_RESOURCE");
|
Builder.BuilderWithTableName hfjResource = version.onTable("HFJ_RESOURCE");
|
||||||
version.startSectionWithMessage("Starting work on table: " + hfjResource.getTableName());
|
version.startSectionWithMessage("Starting work on table: " + hfjResource.getTableName());
|
||||||
|
|
|
@ -38,13 +38,16 @@ import static org.apache.commons.lang3.StringUtils.isBlank;
|
||||||
public class SchemaInitializationProvider implements ISchemaInitializationProvider {
|
public class SchemaInitializationProvider implements ISchemaInitializationProvider {
|
||||||
|
|
||||||
private String mySchemaFileClassPath;
|
private String mySchemaFileClassPath;
|
||||||
|
|
||||||
|
private String mySchemaDescription;
|
||||||
private final String mySchemaExistsIndicatorTable;
|
private final String mySchemaExistsIndicatorTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param theSchemaFileClassPath pathname to script used to initialize schema
|
* @param theSchemaFileClassPath pathname to script used to initialize schema
|
||||||
* @param theSchemaExistsIndicatorTable a table name we can use to determine if this schema has already been initialized
|
* @param theSchemaExistsIndicatorTable a table name we can use to determine if this schema has already been initialized
|
||||||
*/
|
*/
|
||||||
public SchemaInitializationProvider(String theSchemaFileClassPath, String theSchemaExistsIndicatorTable) {
|
public SchemaInitializationProvider(String theSchemaDescription, String theSchemaFileClassPath, String theSchemaExistsIndicatorTable) {
|
||||||
|
mySchemaDescription = theSchemaDescription;
|
||||||
mySchemaFileClassPath = theSchemaFileClassPath;
|
mySchemaFileClassPath = theSchemaFileClassPath;
|
||||||
mySchemaExistsIndicatorTable = theSchemaExistsIndicatorTable;
|
mySchemaExistsIndicatorTable = theSchemaExistsIndicatorTable;
|
||||||
}
|
}
|
||||||
|
@ -115,5 +118,16 @@ public class SchemaInitializationProvider implements ISchemaInitializationProvid
|
||||||
mySchemaFileClassPath = theSchemaFileClassPath;
|
mySchemaFileClassPath = theSchemaFileClassPath;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSchemaDescription() {
|
||||||
|
return mySchemaDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SchemaInitializationProvider setSchemaDescription(String theSchemaDescription) {
|
||||||
|
mySchemaDescription = theSchemaDescription;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.jpa.migrate.tasks.api;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
import ca.uhn.fhir.jpa.migrate.DriverTypeEnum;
|
||||||
|
import ca.uhn.fhir.jpa.migrate.tasks.SchemaInitializationProvider;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -28,4 +29,8 @@ public interface ISchemaInitializationProvider {
|
||||||
List<String> getSqlStatements(DriverTypeEnum theDriverType);
|
List<String> getSqlStatements(DriverTypeEnum theDriverType);
|
||||||
|
|
||||||
String getSchemaExistsIndicatorTable();
|
String getSchemaExistsIndicatorTable();
|
||||||
|
|
||||||
|
String getSchemaDescription();
|
||||||
|
|
||||||
|
SchemaInitializationProvider setSchemaDescription(String theSchemaDescription);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,11 @@ public class InitializeSchemaTaskTest extends BaseTest {
|
||||||
return "DONT_MATCH_ME";
|
return "DONT_MATCH_ME";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getSchemaDescription() {
|
||||||
|
return "TEST";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object theO) {
|
public boolean equals(Object theO) {
|
||||||
if (this == theO) return true;
|
if (this == theO) return true;
|
||||||
|
|
Loading…
Reference in New Issue