use of fi.otavanopisto.pyramus.domainmodel.base.SchoolField in project pyramus by otavanopisto.
the class SaveSchoolFieldsJSONRequestController method process.
public void process(JSONRequestContext jsonRequestContext) {
SchoolFieldDAO schoolFieldDAO = DAOFactory.getInstance().getSchoolFieldDAO();
int rowCount = NumberUtils.createInteger(jsonRequestContext.getRequest().getParameter("schoolFieldsTable.rowCount")).intValue();
for (int i = 0; i < rowCount; i++) {
String colPrefix = "schoolFieldsTable." + i;
Long schoolFieldId = jsonRequestContext.getLong(colPrefix + ".id");
String name = jsonRequestContext.getString(colPrefix + ".name");
boolean modified = new Long(1).equals(jsonRequestContext.getLong(colPrefix + ".modified"));
if (schoolFieldId == -1) {
schoolFieldDAO.create(name);
} else if (modified) {
SchoolField schoolField = schoolFieldDAO.findById(schoolFieldId);
schoolFieldDAO.update(schoolField, name);
}
}
jsonRequestContext.setRedirectURL(jsonRequestContext.getReferer(true));
}
use of fi.otavanopisto.pyramus.domainmodel.base.SchoolField in project pyramus by otavanopisto.
the class SchoolsSetupWizardViewController method setup.
@Override
public void setup(PageRequestContext requestContext) throws SetupWizardException {
SchoolFieldDAO schoolFieldDAO = DAOFactory.getInstance().getSchoolFieldDAO();
List<SchoolField> schoolFields = schoolFieldDAO.listUnarchived();
setJsDataVariable(requestContext, "schoolFields", new JSONArrayExtractor("name", "id").extractString(schoolFields));
}
Aggregations