use of org.apache.commons.collections.set.ListOrderedSet in project symmetric-ds by JumpMind.
the class ForeignKey method clone.
/**
* {@inheritDoc}
*/
public Object clone() throws CloneNotSupportedException {
ForeignKey result = (ForeignKey) super.clone();
result.name = name;
result.foreignTableName = foreignTableName;
result.references = new ListOrderedSet();
for (Iterator<?> it = references.iterator(); it.hasNext(); ) {
result.references.add(((Reference) it.next()).clone());
}
return result;
}
use of org.apache.commons.collections.set.ListOrderedSet in project openmrs-core by openmrs.
the class ConceptValidatorChangeSet method getAllowedLocalesList.
/**
* Retrieves the list of allowed locales from the database, sets the default locale, english and
* the default locale will be added to the list allowed locales if not yet included
*
* @param connection The database connection
* @return A list of allowed locales
*/
@SuppressWarnings("unchecked")
private List<Locale> getAllowedLocalesList(JdbcConnection connection) {
Statement stmt = null;
ListOrderedSet allowedLocales = new ListOrderedSet();
try {
// get the default locale
stmt = connection.createStatement();
ResultSet rsDefaultLocale = stmt.executeQuery("SELECT property_value FROM global_property WHERE property = '" + OpenmrsConstants.GLOBAL_PROPERTY_DEFAULT_LOCALE + "'");
if (rsDefaultLocale.next()) {
String defaultLocaleStr = rsDefaultLocale.getString("property_value");
if (!StringUtils.isBlank(defaultLocaleStr) && defaultLocaleStr.length() > 1) {
Locale defaultLocaleGP = LocaleUtility.fromSpecification(defaultLocaleStr);
if (defaultLocaleGP != null) {
defaultLocale = defaultLocaleGP;
}
} else {
updateWarnings.add("'" + defaultLocaleStr + "' is an invalid value for the global property default locale");
}
}
allowedLocales.add(defaultLocale);
// get the locale.allowed.list
ResultSet rsAllowedLocales = stmt.executeQuery("SELECT property_value FROM global_property WHERE property = '" + OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST + "'");
if (rsAllowedLocales.next()) {
String allowedLocaleStr = rsAllowedLocales.getString("property_value");
if (!StringUtils.isBlank(allowedLocaleStr)) {
String[] localesArray = allowedLocaleStr.split(",");
for (String localeStr : localesArray) {
if (localeStr.trim().length() > 1) {
allowedLocales.add(LocaleUtility.fromSpecification(localeStr.trim()));
} else {
updateWarnings.add("'" + localeStr + "' is an invalid value for the global property locale.allowed.list");
}
}
}
} else {
log.warn("The global property '" + OpenmrsConstants.GLOBAL_PROPERTY_LOCALE_ALLOWED_LIST + "' isn't set");
}
} catch (DatabaseException | SQLException e) {
log.warn("Error generated", e);
} finally {
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
log.warn("Failed to close the statement object");
}
}
}
// if it isn't among
allowedLocales.add(new Locale("en"));
return allowedLocales.asList();
}
Aggregations