* @return Map of default properties for a schema taking into consideration supplied defaults.
*/
public PropertyMap getDefaultDatabaseProperties(RelationalSchema schema, PropertyMap config)
{
String sScriptName = getSetupEtcScriptName();
PropertyMap propertyMap = new TransferObject();
PropertyMap referenceMap = setDefaultDatabaseProperties(new TransferObject());
for (PropertyIterator itr = referenceMap.getIterator(); itr.hasNext();)
{
itr.next();
itr.setValue(null); // unset only default values so that they do not override custom later
}
setCustomDatabaseProperties(referenceMap, config);
setMetadataDatabaseProperties(referenceMap, schema);
if (sScriptName != null)
{
InputStream istream = null;
try
{
istream = URLUtil.openResource(getClass(), "etc/" + sScriptName);
setTemplateDefaults(propertyMap,
referenceMap,
new InputStreamReader(istream, XMLUtil.ENCODING),
schema.getMetadata().isTestEnvironment());
}
catch (Throwable t)
{
ObjUtil.rethrow(t);
}
finally
{
IOUtil.close(istream);
}
}
PropertyMap defaultsMap = setDefaultDatabaseProperties(new TransferObject());
// look for unset keys needing to be overridden with custom values or defaults
for (PropertyIterator itr = propertyMap.getIterator(); itr.hasNext();)
{
String sKey = (String)itr.next();
Object value = referenceMap.findValue(sKey);
if (value != null ||
(itr.getValue() == null && (value = defaultsMap.findValue(sKey)) != null))
{
itr.setValue(value); // override default in template with custom value in schema
}
}