package hirondelle.fish.translate.locale;
import java.util.*;
import hirondelle.web4j.model.Id;
import hirondelle.web4j.database.DAOException;
import hirondelle.web4j.database.Db;
import hirondelle.web4j.database.DuplicateException;
import hirondelle.web4j.util.Util;
final class SupportedLocaleDAO {
List<SupportedLocale> list() throws DAOException {
return Db.list(SupportedLocale.class, SupportedLocaleAction.LOCALE_LIST);
}
Id add(SupportedLocale aLocale) throws DAOException, DuplicateException {
return Db.add(SupportedLocaleAction.LOCALE_ADD, baseParamsFrom(aLocale));
}
SupportedLocale fetch(Id aId) throws DAOException {
return Db.fetch(SupportedLocale.class, SupportedLocaleAction.LOCALE_FETCH, aId);
}
boolean change(SupportedLocale aLocale) throws DAOException, DuplicateException {
Object[] params = Db.addIdTo(baseParamsFrom(aLocale), aLocale.getId());
return Util.isSuccess(Db.edit(SupportedLocaleAction.LOCALE_CHANGE, params));
}
void delete(Id aId) throws DAOException {
Db.delete(SupportedLocaleAction.LOCALE_DELETE, aId);
}
private Object[] baseParamsFrom(SupportedLocale aLocale){
return new Object[]{aLocale.getShortForm(), aLocale.getDescription()};
}
}