use of org.activityinfo.store.spi.FormNotFoundException in project activityinfo by bedatadriven.
the class ActivityFormProvider method openForm.
@Override
public FormStorage openForm(QueryExecutor executor, ResourceId formId) throws SQLException {
int activityId = CuidAdapter.getLegacyIdFromCuid(formId);
Map<Integer, Activity> map = activityLoader.load(singleton(activityId));
Activity activity = map.get(activityId);
if (activity == null) {
throw new FormNotFoundException(formId);
}
return new SiteFormStorage(activity, buildMapping(activity, formId), executor, activityLoader.getPermissionCache());
}
use of org.activityinfo.store.spi.FormNotFoundException in project activityinfo by bedatadriven.
the class AdminLevel method fetch.
public static AdminLevel fetch(QueryExecutor executor, int levelId) throws SQLException {
// set in the adminlevel table
try (ResultSet rs = executor.query("SELECT " + "L.Name, " + "L.parentId ParentId, " + "P.Name ParentLevelName, " + "L.CountryId, " + "L.Version " + "FROM adminlevel L " + "LEFT JOIN adminlevel P ON (L.parentId = P.AdminLevelId) " + "WHERE L.AdminLevelId = " + levelId)) {
if (!rs.next()) {
throw new FormNotFoundException(CuidAdapter.adminLevelFormClass(levelId));
}
AdminLevel level = new AdminLevel();
level.id = levelId;
level.name = rs.getString(1);
level.parentId = rs.getInt(2);
if (rs.wasNull()) {
level.parentId = 0;
}
level.parentName = rs.getString(3);
level.countryId = rs.getInt(4);
level.version = rs.getLong(5);
return level;
}
}
Aggregations