use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.
the class ArendeServiceImpl method openArendeAsUnhandled.
@Override
public ArendeConversationView openArendeAsUnhandled(String meddelandeId) {
Arende arende = lookupArende(meddelandeId);
boolean arendeIsAnswered = !arendeRepository.findBySvarPaId(meddelandeId).isEmpty();
// Enforce business rule FS-011, from FK + answer should remain closed
if (!FrageStallare.WEBCERT.isKodEqual(arende.getSkickatAv()) && arendeIsAnswered) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + meddelandeId);
}
NotificationEvent notificationEvent = determineNotificationEvent(arende, arendeIsAnswered);
if (arendeIsAnswered) {
arende.setStatus(Status.ANSWERED);
} else {
if (FrageStallare.WEBCERT.isKodEqual(arende.getSkickatAv())) {
arende.setStatus(Status.PENDING_EXTERNAL_ACTION);
} else {
arende.setStatus(Status.PENDING_INTERNAL_ACTION);
}
}
Arende openedArende = arendeRepository.save(arende);
sendNotification(openedArende, notificationEvent);
return arendeViewConverter.convertToArendeConversationView(openedArende, arendeRepository.findBySvarPaId(meddelandeId).stream().findFirst().orElse(null), null, arendeRepository.findByPaminnelseMeddelandeId(meddelandeId), null);
}
use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.
the class ArendeServiceImpl method closeArendeAsHandled.
private Arende closeArendeAsHandled(Arende arendeToClose) {
NotificationEvent notificationEvent = determineNotificationEvent(arendeToClose, false);
arendeToClose.setStatus(Status.CLOSED);
arendeToClose.setSenasteHandelse(LocalDateTime.now(systemClock));
Arende closedArende = arendeRepository.save(arendeToClose);
sendNotification(closedArende, notificationEvent);
arendeDraftService.delete(closedArende.getIntygsId(), closedArende.getMeddelandeId());
return closedArende;
}
use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.
the class FragaSvarServiceImpl method openQuestionAsUnhandled.
@Override
public FragaSvar openQuestionAsUnhandled(Long frageSvarId) {
FragaSvar fragaSvar = lookupFragaSvar(frageSvarId);
// Enforce business rule FS-011, from FK + answer should remain closed
if (!FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare()) && !Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "FS-011: Cant revert status for question " + frageSvarId);
}
NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
if (!Strings.isNullOrEmpty(fragaSvar.getSvarsText())) {
fragaSvar.setStatus(Status.ANSWERED);
} else {
if (FrageStallare.WEBCERT.isKodEqual(fragaSvar.getFrageStallare())) {
fragaSvar.setStatus(Status.PENDING_EXTERNAL_ACTION);
} else {
fragaSvar.setStatus(Status.PENDING_INTERNAL_ACTION);
}
}
FragaSvar openedFragaSvar = fragaSvarRepository.save(fragaSvar);
sendNotification(openedFragaSvar, notificationEvent);
return openedFragaSvar;
}
use of se.inera.intyg.webcert.web.service.notification.NotificationEvent in project webcert by sklintyg.
the class FragaSvarServiceImpl method closeQuestionAsHandled.
private FragaSvar closeQuestionAsHandled(FragaSvar fragaSvar) {
NotificationEvent notificationEvent = determineNotificationEvent(fragaSvar);
fragaSvar.setStatus(Status.CLOSED);
FragaSvar closedFragaSvar = fragaSvarRepository.save(fragaSvar);
sendNotification(closedFragaSvar, notificationEvent);
if (!fragaSvar.getFrageStallare().equals(FrageStallare.WEBCERT.getKod())) {
arendeDraftService.delete(fragaSvar.getIntygsReferens().getIntygsId(), Long.toString(fragaSvar.getInternReferens()));
}
return closedFragaSvar;
}
Aggregations