protected List<ConversionStrategy<?>> createConversionStrategies(Properties configuration, String propertyName) { List<String> conversionStrategyClassNames = getStringList(propertyName, configuration); List<ConversionStrategy<?>> conversionStrategies = new ArrayList<ConversionStrategy<?>>(conversionStrategyClassNames.size()); for (String conversionStrategyClassName : conversionStrategyClassNames) { ConversionStrategy<?> conversionStrategy = createInstanceOfType(conversionStrategyClassName, false); conversionStrategies.add(conversionStrategy); } return conversionStrategies; } }
/** * @param script A database script, not null * @return True if the given script is a post processing script according to the script source configuration */ protected boolean isPostProcessingScript(Script script) { List<String> startsWiths = PropertyUtils.getStringList(PROPKEY_POSTPROCESSINGSCRIPT_DIRNAME, configuration); for (String startsWith : startsWiths) { if (script.getFileName().startsWith(startsWith)) { return true; } } return false; }
/** * Gets the configured extensions for the script files. * * @return The extensions, not null */ protected List<String> getScriptExtensions() { List<String> extensions = getStringList(PROPKEY_SCRIPT_EXTENSIONS, configuration); // check whether an extension is configured if (extensions.isEmpty()) { logger.warn("No extensions are specificied using the property " + PROPKEY_SCRIPT_EXTENSIONS + ". The Unitils database maintainer won't do anyting"); } // Verify the correctness of the script extensions for (String extension : extensions) { if (extension.startsWith(".")) { throw new UnitilsException("DefaultScriptSource file extension defined by " + PROPKEY_SCRIPT_EXTENSIONS + " should not start with a '.'"); } } return extensions; }
/** * @return A List containing all scripts in the given script locations, not null */ protected List<Script> loadAllScripts(String dialect, String databaseName, boolean defaultDatabase) { List<String> scriptLocations = PropertyUtils.getStringList(PROPKEY_SCRIPT_LOCATIONS, configuration); List<Script> scripts = new ArrayList<Script>(); for (String scriptLocation : scriptLocations) { if (!new File(scriptLocation).exists()) { throw new UnitilsException("File location " + scriptLocation + " defined in property " + PROPKEY_SCRIPT_LOCATIONS + " doesn't exist"); } getScriptsAt(scripts, scriptLocation, "", databaseName, defaultDatabase); } return scripts; }
/** * Checks if the name of the script contains one of the qualifiers. * @param fileName * @return {@link Boolean} */ public boolean containsOneOfQualifiers(String fileName){ List<String> excludes = PropertyUtils.getStringList(PROPKEY_EXCLUDE_QUALIFIERS, configuration, false); List<String> includes = PropertyUtils.getStringList(PROPKEY_INCLUDE_QUALIFIERS, configuration, false); List<String> qualifiers = PropertyUtils.getStringList(PROPKEY_QUALIFIERS, configuration, false); if (excludes.isEmpty() && includes.isEmpty() && qualifiers.isEmpty()) { return true; } if (includes.isEmpty()) { /* * 1. The filename can be without qualifiers. * 2. Or the qualifier must be in the list of qualifiers and not in the exclude list. */ return (containsQualifier(fileName, qualifiers) && !containsQualifier(fileName, excludes)) || checkIfThereAreNoQualifiers(fileName); } else { return containsQualifier(fileName, includes) && !containsQualifier(fileName, excludes); } }
List<String> scriptLocations = PropertyUtils.getStringList("dbMaintainer.script.locations", configuration); List<String> dbSpecificLocations = PropertyUtils.getStringList("dbMaintainer.script.locations." + dialect, configuration); scriptLocations.addAll(dbSpecificLocations); List<String> scriptIgnoredLocations = PropertyUtils.getStringList("dbMaintainer.script.locations.ignore", configuration);
/** * Gets the list of items to preserve. The case is correct if necesary. Quoting an identifier * makes it case sensitive. If requested, the identifiers will be quailified with the default schema name if no * schema name is used as prefix. * * @param propertyName The name of the property that defines the items, not null * @param prefixDefaultSchema True to prefix item with default schema when needed * @return The set of items, not null */ protected Set<String> getItemsToPreserve(String propertyName, boolean prefixDefaultSchema) { Set<String> result = new HashSet<String>(); List<String> itemsToPreserve = getStringList(propertyName, configuration); for (String itemToPreserve : itemsToPreserve) { // ignore case when stored in mixed casing (e.g MS-Sql), otherwise we can't compare the item names if (defaultDbSupport.getStoredIdentifierCase() == MIXED_CASE) { itemToPreserve = itemToPreserve.toUpperCase(); } String correctCaseitemToPreserve = defaultDbSupport.toCorrectCaseIdentifier(itemToPreserve); if (prefixDefaultSchema && correctCaseitemToPreserve.indexOf('.') == -1) { correctCaseitemToPreserve = defaultDbSupport.getSchemaName() + "." + correctCaseitemToPreserve; } result.add(correctCaseitemToPreserve); } return result; } }
List<String> scriptLocations = PropertyUtils.getStringList(PROPKEY_SCRIPT_LOCATIONS, configuration); List<Script> scripts = new ArrayList<Script>(); for (String scriptLocation : scriptLocations) {
Map<String, Set<String>> result = new HashMap<String, Set<String>>(); List<String> itemsToPreserve = getStringList(propertyName, configuration); for (String itemToPreserve : itemsToPreserve) {
Set<String> result = new HashSet<String>(); List<String> schemasToPreserve = getStringList(PROPKEY_PRESERVE_SCHEMAS, configuration); for (String schemaToPreserve : schemasToPreserve) {