<%@ page extends="oneit.servlets.process.AJAXProcessJSP" %>

<%@ page import="oneit.servlets.jsp.*,oneit.servlets.orm.*,oneit.servlets.objstore.*,oneit.servlets.jsp.tabs.*,oneit.logging.*,oneit.sql.*,oneit.objstore.services.*" %>
<%@ page import="performa.orm.*,performa.orm.types.*,performa.utils.*, java.util.*, oneit.objstore.*, oneit.servlets.process.*, oneit.utils.*" %>
<%@ page import="oneit.utils.filter.Filter, oneit.objstore.rdbms.filters.EqualsFilter" %>

<%@ include file="../../../setuprequest.jsp" %>

<%! protected String getName (ServletConfig config) { return "save_assessment_criteria_answers_jsp"; } %>
<oneit:form method="POST">
<%
    ORMProcessState     process         =   (ORMProcessState)ProcessDecorator.getDefaultProcess(request);
    ObjectTransaction   objTran         =   ObjectTransaction.getTransaction();
    Long                criteriaID      =   Long.valueOf(request.getParameter ("criteriaID"));
    boolean             answerOption    =   Boolean.valueOf(request.getParameter ("answerOption"));
    String              note            =   request.getParameter ("note");
    JobApplication      jobApplication  =   (JobApplication) process.getAttribute("JobApplication");
 
    jobApplication  =   (JobApplication) jobApplication.getInTransaction (objTran);

    Debug.assertion (jobApplication.getObjectWriteability() == FieldWriteability.TRUE, "Must be able to edit");

    AssessmentCriteria          criteria    =   AssessmentCriteria.getAssessmentCriteriaByID(objTran, criteriaID);
    AssessmentCriteriaAnswer    answer      =   jobApplication.getAssessmentCriteriaAnswer(criteria);

    if(answer == null)
    {
        answer  =   AssessmentCriteriaAnswer.createAssessmentCriteriaAnswer(objTran).getInTransaction (objTran);

        jobApplication.addToAssessmentCriteriaAnswers(answer);
        answer.setAssessmentCriteria(criteria);
    }

    answer.setAnswer(answerOption);
    answer.setNotes(note);
%>
</oneit:form>