public OcsQASessionVo removeUnusedCategoryQuestions(OcsQASessionVo ocsQASession, CategoryCollection usedCategories) { if (ocsQASession == null || ocsQASession.getCategoryQuestionAnswers() == null) return ocsQASession; for (int i = ocsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo categoryQuestion = ocsQASession.getCategoryQuestionAnswers().get(i); if (!usedCategories.contains(categoryQuestion.getCategory())) ocsQASession.getCategoryQuestionAnswers().remove(categoryQuestion); } return ocsQASession; }
public OcsQASessionVo removeUnusedServiceQuestions(OcsQASessionVo ocsQASession, ArrayList<Integer> usedServices) { if (ocsQASession == null || ocsQASession.getCategoryQuestionAnswers() == null) return ocsQASession; for (int i = ocsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo categoryQuestion = ocsQASession.getCategoryQuestionAnswers().get(i); if (categoryQuestion.getServiceQuestionAnswers() != null) { for (int j = categoryQuestion.getServiceQuestionAnswers().size() - 1; j >= 0; j--) { ServiceQuestionAnswerVo serviceQuestion = categoryQuestion.getServiceQuestionAnswers().get(j); if (!usedServices.contains(serviceQuestion.getService().getID_Service())) categoryQuestion.getServiceQuestionAnswers().remove(serviceQuestion); } } } return ocsQASession; }
private InvestigationLiteVoCollection getExistingInvestigations(OcsQASessionVo voOcsQA) { if (voOcsQA == null) return null; InvestigationLiteVoCollection voColl = new InvestigationLiteVoCollection(); for (int i = 0; voOcsQA.getCategoryQuestionAnswersIsNotNull() && i < voOcsQA.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = voOcsQA.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); for (int k = 0; serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null && k < serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size(); k++) { voColl.add(serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k).getInvestigation()); } } } return voColl; }
private boolean isInvestigationAdded(InvestigationRefVo voRefInvestigation, OcsQASessionVo voOcsQA) { if(voRefInvestigation == null || voOcsQA == null) return false; for (int i = 0; voOcsQA.getCategoryQuestionAnswersIsNotNull() && i < voOcsQA.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = voOcsQA.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); for (int k = 0; serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null && k < serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size(); k++) { if(voRefInvestigation.equals(serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k).getInvestigation())) return true; } } } return false; }
private void removeUnusedCategoryQuestions(CategoryCollection categoryColl, OcsQASessionVo voOcsQASession) { if (voOcsQASession == null || voOcsQASession.getCategoryQuestionAnswers() == null) return; for (int i = voOcsQASession.getCategoryQuestionAnswers().size() - 1; i >= 0; i--) { CategoryQuestionAnswerVo question = voOcsQASession.getCategoryQuestionAnswers().get(i); if (categoryColl == null || !categoryColl.contains(question.getCategory())) { voOcsQASession.getCategoryQuestionAnswers().remove(question); } } }
private void removeUnusedInvestigations(InvestigationOcsQuestionsVoCollection investigationOcsQuestionsColl, OcsQASessionVo ocsQASession) { InvestigationLiteVoCollection voExistingInvColl = getExistingInvestigations(ocsQASession); for (int i = 0; voExistingInvColl != null && i < voExistingInvColl.size(); i++) { //Check if the investigation was removed if(isInvestigationRemoved(voExistingInvColl.get(i), investigationOcsQuestionsColl)) { removeInvestigationFromVo(voExistingInvColl.get(i).getID_Investigation(), ocsQASession); } } }
public OcsQASessionVo removeInvestigationFromVo(Integer investigationId, OcsQASessionVo ocsQASession) { if (investigationId == null) return ocsQASession; for (int i = 0; ocsQASession != null && ocsQASession.getCategoryQuestionAnswersIsNotNull() && i < ocsQASession.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo categoryQuestionAnswerVo = ocsQASession.getCategoryQuestionAnswers().get(i); for (int j = 0; categoryQuestionAnswerVo.getServiceQuestionAnswersIsNotNull() && j < categoryQuestionAnswerVo.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo serviceQuestionAnswerVo = categoryQuestionAnswerVo.getServiceQuestionAnswers().get(j); if (serviceQuestionAnswerVo.getInvestigationQuestionAnswers() != null) { //Remove the Investigation Question Answer for (int k = serviceQuestionAnswerVo.getInvestigationQuestionAnswers().size() - 1; k >= 0; k--) { InvestigationQuestionAnswerVo invQAVo = serviceQuestionAnswerVo.getInvestigationQuestionAnswers().get(k); if (invQAVo.getInvestigationIsNotNull() && invQAVo.getInvestigation().getID_InvestigationIsNotNull() && invQAVo.getInvestigation().getID_Investigation().equals(investigationId)) { serviceQuestionAnswerVo.getInvestigationQuestionAnswers().remove(invQAVo); } } } } } return ocsQASession; }
private CategoryQuestionAnswerVo getCategoryQuestionAnswer(Category category, OcsQASessionVo voOcsQASession) { for (int i = 0; voOcsQASession != null && i < voOcsQASession.getCategoryQuestionAnswers().size(); i++) { if(voOcsQASession.getCategoryQuestionAnswers().get(i).getCategory().equals(category)) return voOcsQASession.getCategoryQuestionAnswers().get(i); } CategoryQuestionAnswerVo voCategoryQuestionAnswer = new CategoryQuestionAnswerVo(); voCategoryQuestionAnswer.setCategory(category); voCategoryQuestionAnswer.setServiceQuestionAnswers(new ServiceQuestionAnswerVoCollection()); voCategoryQuestionAnswer.setCategoryQuestionAnswers(new GeneralQuestionAnswerVoCollection()); return voCategoryQuestionAnswer; }
private void checkDataIntegrity(OcsQASessionVo ocsQASessionVo) throws PresentationLogicException { for (int j = 0; ocsQASessionVo != null && ocsQASessionVo.getCategoryQuestionAnswersIsNotNull() && j < ocsQASessionVo.getCategoryQuestionAnswers().size(); j++) { if(ocsQASessionVo.getCategoryQuestionAnswers().get(j).getCategory() == null) throw new PresentationLogicException("Invalid Category for Category Questions and Answers"); } }
private static GeneralQuestionAnswerVoCollection getGeneralQuestionAnswerCollection(OcsQASessionVo voOcsQASession) { GeneralQuestionAnswerVoCollection voColl = new GeneralQuestionAnswerVoCollection(); for (int j = 0; voOcsQASession != null && voOcsQASession.getCategoryQuestionAnswersIsNotNull() && j < voOcsQASession.getCategoryQuestionAnswers().size(); j++) { CategoryQuestionAnswerVo voCatQAnswer = voOcsQASession.getCategoryQuestionAnswers().get(j); // Category for (int k = 0; k < voCatQAnswer.getCategoryQuestionAnswers().size(); k++) { voColl.add(voCatQAnswer.getCategoryQuestionAnswers().get(k)); } // Service for (int k = 0; k < voCatQAnswer.getServiceQuestionAnswers().size(); k++) { ServiceQuestionAnswerVo voServiceQAnswer = voCatQAnswer.getServiceQuestionAnswers().get(k); for (int index = 0; index < voServiceQAnswer.getServiceQuestionAnswers().size(); index++) { voColl.add(voServiceQAnswer.getServiceQuestionAnswers().get(index)); } for (int i = 0; i < voServiceQAnswer.getInvestigationQuestionAnswers().size(); i++) { InvestigationQuestionAnswerVo voSQAnswer = voServiceQAnswer.getInvestigationQuestionAnswers().get(i); for (int index = 0; voSQAnswer != null && index < voSQAnswer.getInvestigationQuestionAnswers().size(); index++) { voColl.add(voSQAnswer.getInvestigationQuestionAnswers().get(index)); } } } } return voColl; }
public String[] validateAnswers() { OcsQASessionVo voValidate = new OcsQASessionVo(); voValidate = this.getAnswers(voValidate); ArrayList<String> errors = new ArrayList<String>(); if (voValidate != null) { for (int i = 0; voValidate.getCategoryQuestionAnswersIsNotNull() && i < voValidate.getCategoryQuestionAnswers().size(); i++) { CategoryQuestionAnswerVo voCQA = voValidate.getCategoryQuestionAnswers().get(i); // Category Questions getMandatoryQuestionErrors(errors, voCQA.getCategoryQuestionAnswers(), voCQA.getCategory().toString()); for (int j = 0; j < voCQA.getServiceQuestionAnswers().size(); j++) { ServiceQuestionAnswerVo voSQA = voCQA.getServiceQuestionAnswers().get(j); //ServiceQuestions getMandatoryQuestionErrors(errors, voSQA.getServiceQuestionAnswers(), voSQA.getService().getServiceName()); for (int k = 0; k < voSQA.getInvestigationQuestionAnswers().size(); k++) { InvestigationQuestionAnswerVo voIQA = voSQA.getInvestigationQuestionAnswers().get(k); //Investigation Questions getMandatoryQuestionErrors(errors, voIQA.getInvestigationQuestionAnswers(), voIQA.getInvestigation().getInvestigationIndex().getName()); } } } } if (errors.size() > 0) { String[] errs = new String[errors.size()]; errors.toArray(errs); return errs; } return null; }