Commit 8610af15 by Nilu Committed by Harsh Shah

fixed issues in C008, C004

parent ebc0974d
package performa.form;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import oneit.logging.LogLevel;
import oneit.logging.LogMgr;
import oneit.objstore.StorageException;
import oneit.servlets.forms.SubmissionDetails;
import oneit.servlets.forms.SuccessfulResult;
import oneit.servlets.process.ORMProcessState;
import oneit.servlets.process.SaveFP;
import oneit.utils.BusinessException;
import performa.orm.Answer;
import performa.orm.JobApplication;
public class SaveAndExitWorkStypeFP extends SaveFP
{
@Override
public SuccessfulResult processForm(ORMProcessState process, SubmissionDetails submission, Map params) throws BusinessException, StorageException
{
HttpServletRequest request = submission.getRequest();
JobApplication jobApplication = process.getAttribute("JobApplication") != null ? (JobApplication) process.getAttribute("JobApplication") : (JobApplication) request.getAttribute("JobApplication");
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In SaveAndExitWorkStypeFP saving job application: ", jobApplication );
for (Answer answer : jobApplication.getProfileAssessmentAnswersSet())
{
if(answer.getAnswerNo() == null)
{
LogMgr.log(JobApplication.LOG, LogLevel.PROCESSING1,"In SaveAndExitWorkStypeFP deleting ProfileAssessmentAnswer : ", answer );
answer.delete();
}
}
return super.processForm(process, submission, params);
}
}
\ No newline at end of file
...@@ -62,7 +62,7 @@ public class Job extends BaseJob ...@@ -62,7 +62,7 @@ public class Job extends BaseJob
if (getIncludeAssessmentCriteria()) if (getIncludeAssessmentCriteria())
{ {
context.check(getAssessmentCriteriasCount() > 0 , this, MULTIPLEREFERENCE_AssessmentCriterias, "atleastOneRequirement"); context.check(getAssessmentCriteriasCount() > 0 , this, FIELD_IncludeAssessmentCriteria, "atleastOneRequirement");
} }
context.check(getSaveAssessmentTemplate() == null || !getSaveAssessmentTemplate() , this, FIELD_AssessmentTemplateName, "saveTemplateFirst"); context.check(getSaveAssessmentTemplate() == null || !getSaveAssessmentTemplate() , this, FIELD_AssessmentTemplateName, "saveTemplateFirst");
......
...@@ -116,32 +116,47 @@ public class JobApplication extends BaseJobApplication ...@@ -116,32 +116,47 @@ public class JobApplication extends BaseJobApplication
} }
public boolean initAssessmentAnswers(List<Question> allQuestions) throws StorageException, FieldException public boolean initAssessmentAnswers(List<Question> questions) throws StorageException, FieldException
{ {
boolean redirect = false; boolean redirect = false;
List<Question> allQuestions = new ArrayList<>();
if(getProfileAssessmentAnswersCount() == 0) for(Question question : questions)
{ {
for(Question question : allQuestions) allQuestions.add(question);
{
redirect = true;
Answer answer = Answer.createAnswer(getTransaction());
addToProfileAssessmentAnswers(answer); if(question.getRightQuestion() != null)
answer.setQuestion(question); {
allQuestions.add(question.getRightQuestion());
}
}
for(Question question : allQuestions)
{
boolean available = false;
if(question.getRightQuestion() != null) for(Answer answer : getProfileAssessmentAnswersSet())
{
if(question.equals(answer.getQuestion()))
{ {
Answer rightAnswer = Answer.createAnswer(getTransaction()); available = true;
break;
addToProfileAssessmentAnswers(rightAnswer);
rightAnswer.setQuestion(question.getRightQuestion());
} }
} }
}
if(!available)
{
Answer answer = Answer.createAnswer(getTransaction());
addToProfileAssessmentAnswers(answer);
answer.setQuestion(question);
redirect = true;
}
}
return redirect; return redirect;
} }
public Answer getAnswerForQuestion(Question question) throws FieldException public Answer getAnswerForQuestion(Question question) throws FieldException
{ {
Filter filter = Answer.SearchByAll().andQuestion(new EqualsFilter<>(question)); Filter filter = Answer.SearchByAll().andQuestion(new EqualsFilter<>(question));
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<FORM name="*.completeApplication" factory="Participant" class="performa.form.CompleteApplicationFP"/> <FORM name="*.completeApplication" factory="Participant" class="performa.form.CompleteApplicationFP"/>
<FORM name="*.saveAndExitExperienece" factory="Participant" class="performa.form.SaveAndExitExperienceFP"/> <FORM name="*.saveAndExitExperienece" factory="Participant" class="performa.form.SaveAndExitExperienceFP"/>
<FORM name="*.saveAndExitCulture" factory="Participant" class="performa.form.SaveAndExitCultureFP"/> <FORM name="*.saveAndExitCulture" factory="Participant" class="performa.form.SaveAndExitCultureFP"/>
<FORM name="*.saveAndExitWorkStyle" factory="Participant" class="performa.form.SaveAndExitWorkStypeFP"/>
</NODE> </NODE>
......
...@@ -10,10 +10,10 @@ ...@@ -10,10 +10,10 @@
String nextPage = WebUtils.getSamePageInRenderMode(request, "SubmitApplication"); String nextPage = WebUtils.getSamePageInRenderMode(request, "SubmitApplication");
JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication"); JobApplication jobApplication = (JobApplication) process.getAttribute("JobApplication");
Job job = jobApplication.getJob(); Job job = jobApplication.getJob();
int questionNumber = process.getAttribute("QuestionNumber")!= null ? (int) process.getAttribute("QuestionNumber") : 0; int questionNumber = process.getAttribute("QuestionNumber")!= null ? (int) process.getAttribute("QuestionNumber") : jobApplication.getProfileAssessmentAnswersCount();
String sectionNo = jobApplication.isIncludeAssessmentCriteria() ? "3" : "2";
List<Question> allQuestions = (List<Question>) process.getAttribute("AllQuestions"); List<Question> allQuestions = (List<Question>) process.getAttribute("AllQuestions");
String exitPage = WebUtils.getArticleLink(request, transaction, WebUtils.APPLY_JOB, "Page") + "&id=" + job.getID() + "&key=" + job.getRandomKey();
if(allQuestions == null) if(allQuestions == null)
{ {
allQuestions = job.getAllLeftQuestions(); allQuestions = job.getAllLeftQuestions();
...@@ -25,6 +25,8 @@ ...@@ -25,6 +25,8 @@
if(toRedirect) if(toRedirect)
{ {
process.setAttribute("QuestionNumber", questionNumber);
%><%@include file="/saferedirect.jsp" %><% %><%@include file="/saferedirect.jsp" %><%
} }
%> %>
...@@ -38,6 +40,11 @@ ...@@ -38,6 +40,11 @@
$(".ratting-number input[type='radio']:checked").closest('li').addClass("active" ); $(".ratting-number input[type='radio']:checked").closest('li').addClass("active" );
}); });
}); });
function gotoNextQuestion()
{
$("#nextButton").click();
}
</script> </script>
<div class="main-application-outline"> <div class="main-application-outline">
...@@ -138,7 +145,7 @@ ...@@ -138,7 +145,7 @@
%> %>
<li class="<%= activeStr %>"> <li class="<%= activeStr %>">
<a href="javascript:void(0);"> <a href="javascript:void(0);">
<input type="radio" name="<%= optionKey %>" id="<%= index %>" class="answer_radio" value="<%= index %>" <%= selectedStr %>> <input type="radio" name="<%= optionKey %>" id="<%= index %>" onchange="gotoNextQuestion();" class="answer_radio" value="<%= index %>" <%= selectedStr %>>
<label for="<%= index %>"><%= index %></label> <label for="<%= index %>"><%= index %></label>
</a> </a>
</li> </li>
...@@ -165,47 +172,38 @@ ...@@ -165,47 +172,38 @@
} }
%> %>
<div> <div>
<span style="float: left">
<% <%
if(questionNumber>0) if((questionNumber+1) < totNoOfQuestions)
{ {
%> %>
<oneit:button value="Previous" name="gotoPage" cssClass="box-btn-gray" <oneit:button value=" " name="gotoPage" id="nextButton" skin="link"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage)
.mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber - 1)).toMap()) .mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber + 1)).toMap())
.toMap() %>"/> .toMap() %>"/>
<% <%
} }
%> else
</span>
<span style="float: right">
<%
if((questionNumber+1)<totNoOfQuestions)
{ {
%> %>
<oneit:button value="Next" name="gotoPage" cssClass="box-btn"
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", currentPage) <oneit:button value="Complete" name="completeApplication" id="nextButton" skin="link"
.mapEntry("procParams", CollectionUtils.mapEntry("QuestionNumber", (questionNumber + 1)).toMap()) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage)
.toMap() %>"/> .mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
.mapEntry("attribNamesToRestore", Collections.singleton("JobApplication"))
.mapEntry("restartProcess", Boolean.TRUE)
.toMap() %>"/>
<% <%
} }
%> %>
</span>
</div> </div>
<div class="auto-save"> <div class="auto-save">
<% <span style="float: left">
if((questionNumber+1) == totNoOfQuestions) <oneit:button value="Save and exit" name="saveAndExitWorkStyle" cssClass="box-btn-gray"
{ requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage)
%> .mapEntry ("JobApplication", jobApplication)
<oneit:button value="Complete" name="completeApplication" cssClass="box-btn" .mapEntry(UpdateMappedObjFP.FAIL_VALIDATION_ERRORS, Boolean.FALSE)
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", nextPage) .toMap() %>"/>
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap()) </span>
.mapEntry("attribNamesToRestore", Collections.singleton("JobApplication"))
.mapEntry("restartProcess", Boolean.TRUE)
.toMap() %>"/>
<%
}
%>
<%-- <div>Autosaved 1 min ago.</div> --%> <%-- <div>Autosaved 1 min ago.</div> --%>
</div> </div>
</div> </div>
......
...@@ -30,12 +30,14 @@ ...@@ -30,12 +30,14 @@
<oneit:toString value="<%= job.getJobTitle() %>" mode="EscapeHTML"/> <oneit:toString value="<%= job.getJobTitle() %>" mode="EscapeHTML"/>
has been submitted for review. has been submitted for review.
</div> </div>
<div class="section-btn text-center"> <oneit:form name="applyJob" method="post" enctype="multipart/form-data">
<oneit:button value="Return to Job Details" name="gotoPage" cssClass="box-btn" <div class="section-btn text-center">
requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage) <oneit:button value="Return to Job Details" name="gotoPage" cssClass="box-btn"
.mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap()) requestAttribs="<%= CollectionUtils.mapEntry("nextPage", exitPage)
.toMap() %>"/> .mapEntry("procParams", CollectionUtils.mapEntry("JobApplication", jobApplication).toMap())
</div> .toMap() %>"/>
</div>
</oneit:form>
</div> </div>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment