Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 1.77 KB | None | 0 0
  1.   @CommandHandler
  2.   def on( command: AddCATPayablesCommand): ResultOfAddingPayablesDto = {
  3.     command.filesForLanguageCombinations.flatMap { case (languageCombination, fileId) =>
  4.       fileContentRepository.fileContentDTOById(fileId) match {
  5.         case Some(fileDto) => fileViewModelDao.findById(fileId).map(_.name) match {
  6.           case Some(fileName) => command.financeType match {
  7.             case FullCATAnalysisFinanceTypeDto =>
  8.               command.jobAssignmentIds
  9.                 .filter(jobAssignmentQueryService.jobAssignmentLanguages(_) contains languageCombination)
  10.                 .map { jobAssignmentId =>
  11.                   payablesService.addCATPayable(
  12.                     languageCombination,
  13.                     jobAssignmentId,
  14.                     fileName,
  15.                     fileDto,
  16.                     command.calculationUnitId,
  17.                     command.selectedPriceProfileOriginForPayables)
  18.                 }
  19.             case TotalQuantityFinanceTypeDto => command.jobAssignmentIds.map { jobAssignmentId =>
  20.               payablesService.addPayable(
  21.                 languageCombination,
  22.                 jobAssignmentId,
  23.                 fileName,
  24.                 fileDto,
  25.                 command.calculationUnitId,
  26.                 command.selectedPriceProfileOriginForPayables)
  27.             }
  28.           }
  29.           case None => {
  30.             log.error(s"Skipping file with fileId = $fileId because file view model was not found")
  31.             Seq.empty
  32.           }
  33.         }
  34.         case None => {
  35.           log.error(s"Skipping file with fileId = $fileId because content was not found")
  36.           Seq.empty
  37.         }
  38.       }
  39.     }.foldLeft(ResultOfAddingPayablesDto.empty) { (result, item) =>
  40.       result.withAnotherResult(item)
  41.     }
  42.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement