Esempio n. 1
0
 /**
  * This method sorts all the forms in order as specified in S2sFormBinding.xml and returns the
  * list of namespaces in sorted order.
  *
  * @param s2sOppForms list of S2sOppForms.
  * @return List<String> list of sorted name spaces.
  */
 protected List<String> getSortedNameSpaces(List<S2sOppForms> s2sOppForms) {
   List<String> orderedNamespaces = new ArrayList<String>();
   List<String> namespaces;
   FormMappingLoader formMappingLoader = new FormMappingLoader();
   formMappingLoader.getBindings();
   Map<Integer, List<String>> sortedNamespaces = formMappingLoader.getSortedNameSpaces();
   List<Integer> sortedIndices = new ArrayList<Integer>(sortedNamespaces.keySet());
   int index = 0;
   for (Integer sortedIndex : sortedIndices) {
     for (S2sOppForms oppForm : s2sOppForms) {
       namespaces = sortedNamespaces.get(sortedIndex);
       for (String namespace : namespaces) {
         if (namespace.equals(oppForm.getOppNameSpace())) {
           if (Boolean.TRUE.equals(oppForm.getSelectToPrint())) {
             orderedNamespaces.add(index++, namespace);
           }
         }
       }
     }
   }
   return orderedNamespaces;
 }
  public boolean processRunAuditBusinessRules(Document document) {

    boolean valid = true;
    ProposalDevelopmentDocument proposalDevelopmentDocument =
        (ProposalDevelopmentDocument) document;
    DevelopmentProposal developmentProposal = proposalDevelopmentDocument.getDevelopmentProposal();
    S2sOpportunity opp = developmentProposal.getS2sOpportunity();

    if (opp != null && opp.getS2sOppForms() != null) {
      for (S2sOppForms oppforms : opp.getS2sOppForms()) {
        List<QuestionnaireUsage> usages =
            getProposalDevelopmentS2sQuestionnaireService()
                .getQuestionnaireUsages(
                    oppforms.getOppNameSpace(), oppforms.getFormName(), developmentProposal);
        // if the returned usages list is empty, there are no Questionnaires for that opp form.
        if (usages.size() > 0) {
          List<AnswerHeader> headers =
              proposalDevelopmentS2sQuestionnaireService.getProposalAnswerHeaderForForm(
                  developmentProposal, oppforms.getOppNameSpace(), oppforms.getFormName());
          for (int i = 0; i < headers.size(); i++) {
            AnswerHeader header = headers.get(i);
            if (!header.getCompleted()) {
              valid = false;
              getProposalS2sAuditErrorsByGroup(
                      "s2sQuestionnaireHelper", usages.get(0).getQuestionnaireLabel(), i)
                  .add(
                      new AuditError(
                          String.format(PROPOSAL_S2S_QUESTIONS_KEY, i),
                          KeyConstants.ERROR_S2S_QUESTIONNAIRE_NOT_COMPLETE,
                          Constants.QUESTIONS_PAGE + "." + usages.get(0).getQuestionnaireLabel(),
                          new String[] {usages.get(0).getQuestionnaireLabel()}));
            }
          }
        }
      }
    }
    return valid;
  }