use of liquibase.exception.CustomPreconditionFailedException in project libresonic by Libresonic.
the class DbmsVersionPrecondition method check.
@Override
public void check(Database database) throws CustomPreconditionFailedException, CustomPreconditionErrorException {
try {
int dbMajor = database.getDatabaseMajorVersion();
int dbMinor = database.getDatabaseMinorVersion();
if (major != null && !major.equals(dbMajor)) {
throw new CustomPreconditionFailedException("DBMS Major Version Precondition failed: expected " + major + ", got " + dbMajor);
}
if (minor != null && !minor.equals(dbMinor)) {
throw new CustomPreconditionFailedException("DBMS Minor Version Precondition failed: expected " + minor + ", got " + dbMinor);
}
} catch (DatabaseException e) {
throw new CustomPreconditionErrorException(e.getMessage());
}
}
use of liquibase.exception.CustomPreconditionFailedException in project openmrs-core by openmrs.
the class CheckDrugOrderUnitAndFrequencyTextNotMappedToConcepts method check.
@Override
public void check(Database database) throws CustomPreconditionFailedException, CustomPreconditionErrorException {
JdbcConnection connection = (JdbcConnection) database.getConnection();
try {
Set<String> doseUnits = DatabaseUtil.getUniqueNonNullColumnValues("units", "drug_order", String.class, connection.getUnderlyingConnection());
Set<String> unmappedDoseUnits = getUnMappedText(doseUnits, connection);
if (!unmappedDoseUnits.isEmpty()) {
throw new CustomPreconditionFailedException("Upgrade failed because of the following unmapped drug order dose units that were found: [" + StringUtils.join(unmappedDoseUnits, ", ") + "]. Please make sure you have mapped all free text dose units and " + "frequencies via the global property named orderEntry.unitsToConceptsMappings" + " or use 1.10 upgrade helper module to map them");
}
Set<String> frequencies = DatabaseUtil.getUniqueNonNullColumnValues("frequency", "drug_order", String.class, connection.getUnderlyingConnection());
Set<String> unmappedFrequencies = getUnMappedText(frequencies, connection);
if (!unmappedFrequencies.isEmpty()) {
throw new CustomPreconditionFailedException("Upgrade failed because of the following unmapped drug order frequencies that were found: [" + StringUtils.join(unmappedFrequencies, ", ") + "]. Please make sure you have mapped all free text dose units and " + "frequencies via the global property named orderEntry.unitsToConceptsMappings" + " or use 1.10 upgrade helper module to map them");
}
} catch (Exception e) {
throw new CustomPreconditionErrorException("An error occurred while checking for unmapped free text drug " + "order dose units and frequencies", e);
}
}
Aggregations