Пример #1
0
 /**
  * This method validates the lookupReturn field. The field must may not contain null.
  *
  * @param question - the question to be validated
  * @return true if all validation has passed, false otherwise
  */
 private boolean validateLookupReturn(Question question) {
   if (question.getLookupReturn() != null) {
     return validateLookupReturnBasedOnLookupClass(question);
   } else {
     GlobalVariables.getMessageMap()
         .putError(
             Constants.QUESTION_DOCUMENT_FIELD_LOOKUP_RETURN,
             KeyConstants.ERROR_QUESTION_LOOKUP_RETURN_NOT_SPECIFIED);
     return false;
   }
 }
Пример #2
0
 /**
  * This method validates the lookupReturn with the specified lookupClass of the question. (The
  * lookupReturn may be different if JavaScript is disabled and thus the automatic population of
  * the lookupReturn drop down list has not occurred after the lookupClass has changed.)
  *
  * @param question - the question to be validated
  * @return true if validation has passed, false otherwise
  */
 @SuppressWarnings("unchecked")
 private boolean validateLookupReturnBasedOnLookupClass(Question question) {
   if (question.getLookupClass() != null) {
     try {
       List<String> lookupReturnClasses =
           getCustomAttributeService().getLookupReturns(question.getLookupClass());
       for (String lookupReturnClass : lookupReturnClasses) {
         if (StringUtils.equals(lookupReturnClass, question.getLookupReturn())) {
           return true;
         }
       }
       GlobalVariables.getMessageMap()
           .putError(
               Constants.QUESTION_DOCUMENT_FIELD_LOOKUP_RETURN,
               KeyConstants.ERROR_QUESTION_LOOKUP_RETURN_INVALID);
       return false;
     } catch (Exception e) {
       LOG.info(e.getMessage());
       throw new RuntimeException("QuestionMaintenanceDocumentRule encountered exception", e);
     }
   }
   return true;
 }