Пример #1
0
  public AbstractPollingTemplate findDefaultTemplateByCriteria(
      ConstantTableItem docType, ConstantTableItem gmdType, String language, boolean isDefault) {
    AbstractPollingTemplate template = null;

    if (template == null && docType != null && gmdType != null && language != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(
              docType, gmdType, language, isDefault);
    }

    if (template == null && docType != null && gmdType != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(docType, gmdType, null, isDefault);
    }

    if (template == null && docType != null && language != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(docType, null, language, isDefault);
    }

    if (template == null && docType != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(docType, null, null, isDefault);
    }

    if (template == null && gmdType != null && language != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(null, gmdType, language, isDefault);
    }

    if (template == null && gmdType != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(null, gmdType, null, isDefault);
    }

    if (template == null && language != null) {
      template =
          voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(null, null, language, isDefault);
    }

    if (template == null) {
      template = voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(null, null, null, isDefault);
    }

    return template;
  }
Пример #2
0
 public AbstractPollingTemplate savePollingTemplate(AbstractPollingTemplate pollingTemplate)
     throws UsedTemplateException {
   //        if (voteDao.isUsedTemplate(pollingTemplate)) {
   //            throw new UsedTemplateException("template_is_used");
   //
   //        }
   if (pollingTemplate instanceof BibliographicPollingTemplate) {
     ConstantTableItem docType = ((BibliographicPollingTemplate) pollingTemplate).getDocType();
     ConstantTableItem gmdType = ((BibliographicPollingTemplate) pollingTemplate).getGmdType();
     String language = pollingTemplate.getLanguage();
     if (pollingTemplate.isDefaultTemplate()) {
       AbstractPollingTemplate defaultTemplate =
           voteDao.findDefaultTemplateByDocTypeGmdTypeLanguage(docType, gmdType, language, true);
       if (defaultTemplate != null && !defaultTemplate.equals(pollingTemplate)) {
         defaultTemplate.setDefaultTemplate(false);
         voteDao.save(defaultTemplate);
       }
     }
   }
   if (pollingTemplate.getCreationDate() == null) {
     pollingTemplate.setCreationDate(new Date());
   }
   return (AbstractPollingTemplate) voteDao.saveByMerge(pollingTemplate);
 }