package fi.otavanopisto.pyramus.json.settings;
import org.apache.commons.lang.math.NumberUtils;
import fi.internetix.smvc.controllers.JSONRequestContext;
import fi.otavanopisto.pyramus.dao.DAOFactory;
import fi.otavanopisto.pyramus.dao.grading.GradingScaleDAO;
import fi.otavanopisto.pyramus.framework.JSONRequestController;
import fi.otavanopisto.pyramus.framework.UserRole;
/**
* The controller responsible of archiving a grading scale.
*/
public class ArchiveGradingScaleJSONRequestController extends JSONRequestController {
/**
* Processes the request to create a new grading scale.
*
* @param jsonRequestContext The JSON request context
*/
public void process(JSONRequestContext jsonRequestContext) {
GradingScaleDAO gradingScaleDAO = DAOFactory.getInstance().getGradingScaleDAO();
Long gradingScaleId = NumberUtils.createLong(jsonRequestContext.getRequest().getParameter("gradingScaleId"));
gradingScaleDAO.archive(gradingScaleDAO.findById(gradingScaleId));
}
public UserRole[] getAllowedRoles() {
return new UserRole[] { UserRole.MANAGER, UserRole.STUDY_PROGRAMME_LEADER, UserRole.ADMINISTRATOR };
}
}