Advertisement
Bobrovozka

Untitled

Nov 4th, 2020
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.25 KB | None | 0 0
  1. static CallTaskDtoLegacy callTaskDto(CallTask callTask, String zoneOffset) {
  2.         long createdSec = callTask.getCreated();
  3.         long createdMillis = createdSec * 1000;
  4.         String createdFormatted = TimeFormatService.formattedDateTimeFromMillis(createdMillis, zoneOffset);
  5.  
  6.         Optional<Long> taskFinishedTimestampMillis;
  7.         if (callTask.getState() == CallTask.State.PERFORMED || callTask.getState() == CallTask.State.FAILED) {
  8.             long performedTimestampSec = callTask.getPerformedTimestamp();
  9.             taskFinishedTimestampMillis = Optional.of(performedTimestampSec * 1000);
  10.         } else {
  11.             taskFinishedTimestampMillis = Optional.empty();
  12.         }
  13.         String taskFinishedFormatted = taskFinishedTimestampMillis
  14.                 .map(t -> TimeFormatService.formattedDateTimeFromMillis(t, zoneOffset))
  15.                 .orElse(null);
  16.  
  17.         Optional<Long> callAnsweredTimestampMillis = callAnsweredTimestampMillis(callTask);
  18.  
  19.         String callAnsweredFormatted = callAnsweredTimestampMillis
  20.                 .map(t -> TimeFormatService.formattedDateTimeFromMillis(t, zoneOffset))
  21.                 .orElse(null);
  22.  
  23.         return new CallTaskDtoLegacy(callTask.getId(),
  24.                 callTask.getPhone(),
  25.                 READABLE_STATES.get(callTask.getState()),
  26.                 callTask.getState(),
  27.                 createdMillis,
  28.                 createdFormatted,
  29.                 callAnsweredTimestampMillis.orElse(null),
  30.                 callAnsweredFormatted,
  31.                 taskFinishedTimestampMillis.orElse(null),
  32.                 taskFinishedFormatted,
  33.                 zoneOffset,
  34.                 combineParametersAndReportParameters(callTask),
  35.                 outgoingCalls(callTask.getOutgoingCalls(), zoneOffset),
  36.                 results(callTask.getScenarioResult()),
  37.                 logs(callTask),
  38.                 callTask.getFailComment(),
  39.                 combineParametersAndReportParameters(callTask),
  40.                 callTask.getTalkMillis()
  41.         );
  42.     }
  43.  
  44. private static List<CallTaskDtoLegacy.CallDto> outgoingCalls(List<OutgoingCall> calls, String zoneOffset) {
  45.         return calls.stream()
  46.                 .map(c -> from(c, zoneOffset))
  47.                 .collect(Collectors.toList());
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement