コード例 #1
0
 protected void copyQuestionnaireLists(Questionnaire src, Questionnaire dest) {
   dest.setQuestionnaireQuestions(src.getQuestionnaireQuestions());
   dest.setQuestionnaireUsages(src.getQuestionnaireUsages());
   dest.setQuestionnaireSeqId(null);
   for (QuestionnaireQuestion question : dest.getQuestionnaireQuestions()) {
     question.setQuestionnaireId(null);
     question.setId(null);
     question.setVersionNumber(new Long(1));
   }
   for (QuestionnaireUsage usage : dest.getQuestionnaireUsages()) {
     usage.setQuestionnaireId(null);
     usage.setId(null);
     usage.setVersionNumber(new Long(1));
   }
 }
コード例 #2
0
 @Override
 public boolean isUniqueUsage(Questionnaire questionnaire, QuestionnaireUsage usage) {
   Map<String, Object> fieldValues = new HashMap<String, Object>();
   fieldValues.put(MODULE_ITEM_CODE, usage.getCoeusModule().getModuleCode());
   fieldValues.put(MODULE_SUB_ITEM_CODE, usage.getCoeusSubModule().getSubModuleCode());
   List<QuestionnaireUsage> usages =
       (List<QuestionnaireUsage>)
           businessObjectService.findMatching(QuestionnaireUsage.class, fieldValues);
   for (QuestionnaireUsage curUsage : usages) {
     if (!StringUtils.equals(
             questionnaire.getQuestionnaireSeqId(),
             curUsage.getQuestionnaire().getQuestionnaireSeqId())
         && curUsage.getQuestionnaire().isActive()
         && isCurrentQuestionnaire(curUsage.getQuestionnaire())) {
       return false;
     }
   }
   return true;
 }
  private String getQuestionnaireLabel(AnswerHeader answerHeader) {
    String label = null;
    List<QuestionnaireUsage> usages = answerHeader.getQuestionnaire().getQuestionnaireUsages();
    if (CollectionUtils.isNotEmpty(usages) && usages.size() > 1) {
      Collections.sort((List<QuestionnaireUsage>) usages);
    }
    for (QuestionnaireUsage usage : usages) {
      if (getCoeusModuleCode().equals(usage.getModuleItemCode())
          && answerHeader.getModuleSubItemCode().equals(usage.getModuleSubItemCode())) {
        if ("0".equals(answerHeader.getModuleSubItemCode())) {
          label = usage.getQuestionnaireLabel();
        } else if (CoeusSubModule.PROTOCOL_SUBMISSION.equals(answerHeader.getModuleSubItemCode())) {
          Map keyValues = new HashMap();
          keyValues.put("protocolNumber", answerHeader.getModuleItemKey());
          keyValues.put("submissionNumber", answerHeader.getModuleSubItemKey());

          List<ProtocolSubmissionBase> submissions =
              ((List<ProtocolSubmissionBase>)
                  getBusinessObjectService()
                      .findMatchingOrderBy(
                          getProtocolSubmissionBOClassHook(), keyValues, "submissionId", false));
          if (submissions.isEmpty()) {
            // this may happen if it is undo last action
            label = usage.getQuestionnaireLabel();
          } else {
            keyValues.clear();
            keyValues.put("protocolId", submissions.get(0).getProtocolId());
            keyValues.put("submissionNumber", answerHeader.getModuleSubItemKey());

            ProtocolActionBase protocolAction =
                ((List<ProtocolActionBase>)
                        getBusinessObjectService()
                            .findMatching(getProtocolActionBOClassHook(), keyValues))
                    .get(0);
            label =
                usage.getQuestionnaireLabel()
                    + " - "
                    + protocolAction.getProtocolActionType().getDescription()
                    + " - "
                    + protocolAction.getActionDateString();
          }
        } else if (CoeusSubModule.AMENDMENT_RENEWAL.equals(answerHeader.getModuleSubItemCode())) {
          if (answerHeader.getModuleItemKey().contains("A")) {
            label =
                usage.getQuestionnaireLabel()
                    + " - Amendment "
                    + answerHeader.getModuleItemKey().substring(10);
          } else {
            label =
                usage.getQuestionnaireLabel()
                    + " - Renewal "
                    + answerHeader.getModuleItemKey().substring(10);
          }
        } else if (CoeusSubModule.AMENDMENT.equals(answerHeader.getModuleSubItemCode())) {
          if (answerHeader.getModuleItemKey().contains("A")) {
            label =
                usage.getQuestionnaireLabel()
                    + " - Amendment "
                    + answerHeader.getModuleItemKey().substring(10);
          }
        } else if (CoeusSubModule.RENEWAL.equals(answerHeader.getModuleSubItemCode())) {
          if (answerHeader.getModuleItemKey().contains("R")) {
            label =
                usage.getQuestionnaireLabel()
                    + " - Renewal "
                    + answerHeader.getModuleItemKey().substring(10);
          }
        }
      }
    }
    return label;
  }