Exemplo n.º 1
0
 /**
  * This method populates the <code>PtNotice</code> object along with notice input stream
  *
  * @param basicProperty the <code>BasicProperty</code> object for which the notice is generated
  * @param noticeNo - notice no
  * @param noticeType - type of notice
  * @param fileStream - input stream of generated notice.
  */
 public PtNotice saveNotice(
     String noticeNo, String noticeType, BasicProperty basicProperty, InputStream fileStream) {
   PtNotice ptNotice = new PtNotice();
   Module module = moduleDao.getModuleByName(PTMODULENAME);
   ptNotice.setModuleId(module.getId());
   ptNotice.setNoticeDate(new Date());
   ptNotice.setNoticeNo(noticeNo);
   ptNotice.setNoticeType(noticeType);
   ptNotice.setUserId(EgovThreadLocals.getUserId());
   ptNotice.setBasicProperty(basicProperty);
   String fileName = ptNotice.getNoticeNo() + ".pdf";
   FileStoreMapper fileStore =
       fileStoreService.store(fileStream, fileName, "application/pdf", PTMODULENAME);
   ptNotice.setFileStore(fileStore);
   basicProperty.addNotice(ptNotice);
   basicPropertyService.update(basicProperty);
   return ptNotice;
 }
 protected Set<FileStoreMapper> addToFileStore(final MultipartFile[] files) {
   if (ArrayUtils.isNotEmpty(files))
     return Arrays.asList(files)
         .stream()
         .filter(file -> !file.isEmpty())
         .map(
             file -> {
               try {
                 return fileStoreService.store(
                     file.getInputStream(),
                     file.getOriginalFilename(),
                     file.getContentType(),
                     PGRConstants.MODULE_NAME);
               } catch (final Exception e) {
                 throw new ApplicationRuntimeException("err.input.stream", e);
               }
             })
         .collect(Collectors.toSet());
   else return null;
 }