Search in sources :

Example 11 with SchoolField

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));
}
Also used : SchoolField(fi.otavanopisto.pyramus.domainmodel.base.SchoolField) SchoolFieldDAO(fi.otavanopisto.pyramus.dao.base.SchoolFieldDAO)

Example 12 with SchoolField

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));
}
Also used : SchoolField(fi.otavanopisto.pyramus.domainmodel.base.SchoolField) SchoolFieldDAO(fi.otavanopisto.pyramus.dao.base.SchoolFieldDAO) JSONArrayExtractor(fi.otavanopisto.pyramus.util.JSONArrayExtractor)

Aggregations

SchoolField (fi.otavanopisto.pyramus.domainmodel.base.SchoolField)12 SchoolFieldDAO (fi.otavanopisto.pyramus.dao.base.SchoolFieldDAO)6 BillingDetails (fi.otavanopisto.pyramus.domainmodel.base.BillingDetails)6 School (fi.otavanopisto.pyramus.domainmodel.base.School)5 SchoolDAO (fi.otavanopisto.pyramus.dao.base.SchoolDAO)3 ContactType (fi.otavanopisto.pyramus.domainmodel.base.ContactType)3 Tag (fi.otavanopisto.pyramus.domainmodel.base.Tag)3 HashSet (java.util.HashSet)3 AddressDAO (fi.otavanopisto.pyramus.dao.base.AddressDAO)2 BillingDetailsDAO (fi.otavanopisto.pyramus.dao.base.BillingDetailsDAO)2 ContactTypeDAO (fi.otavanopisto.pyramus.dao.base.ContactTypeDAO)2 EmailDAO (fi.otavanopisto.pyramus.dao.base.EmailDAO)2 PhoneNumberDAO (fi.otavanopisto.pyramus.dao.base.PhoneNumberDAO)2 SchoolVariableDAO (fi.otavanopisto.pyramus.dao.base.SchoolVariableDAO)2 TagDAO (fi.otavanopisto.pyramus.dao.base.TagDAO)2 Address (fi.otavanopisto.pyramus.domainmodel.base.Address)2 Email (fi.otavanopisto.pyramus.domainmodel.base.Email)2 PhoneNumber (fi.otavanopisto.pyramus.domainmodel.base.PhoneNumber)2 SchoolVariableKey (fi.otavanopisto.pyramus.domainmodel.base.SchoolVariableKey)2 RESTPermit (fi.otavanopisto.pyramus.rest.annotation.RESTPermit)2