Skip to content

Commit

Permalink
Merge branch 'release/2024-6' into release/2024-7
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrilleSigerhed authored Sep 2, 2024
2 parents 6c92ceb + 685bf3e commit c61f8ee
Show file tree
Hide file tree
Showing 82 changed files with 4,925 additions and 822 deletions.
2 changes: 1 addition & 1 deletion Jenkins.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies.infra.version=3.21.0.+
dependencies.common.version=3.21.0.+

dependencies.infra.version.resolved=3.21.0.40
dependencies.common.version.resolved=3.21.0.33
dependencies.common.version.resolved=3.21.0.35

build.args=build testAggregateTestReport camelTest -PcodeQuality
sonarqube.args=-x jsTests
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2024 Inera AB (http://www.inera.se)
*
* This file is part of sklintyg (https://github.com/sklintyg).
*
* sklintyg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sklintyg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package se.inera.intyg.webcert.web.csintegration.aggregate;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.common.support.facade.model.question.QuestionType;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.CreateQuestionFacadeService;

@Service
@RequiredArgsConstructor
public class CreateQuestionAggregator implements CreateQuestionFacadeService {

private final CreateQuestionFacadeService createQuestionFromWC;
private final CreateQuestionFacadeService createMessageFromCS;
private final CertificateServiceProfile certificateServiceProfile;

@Override
public Question create(String certificateId, QuestionType type, String message) {
if (!certificateServiceProfile.active()) {
return createQuestionFromWC.create(certificateId, type, message);
}

final var responseFromCS = createMessageFromCS.create(certificateId, type, message);

return responseFromCS != null ? responseFromCS : createQuestionFromWC.create(certificateId, type, message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (C) 2024 Inera AB (http://www.inera.se)
*
* This file is part of sklintyg (https://github.com/sklintyg).
*
* sklintyg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sklintyg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package se.inera.intyg.webcert.web.csintegration.aggregate;

import org.springframework.stereotype.Service;
import se.inera.intyg.webcert.web.csintegration.integration.CSIntegrationService;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.DeleteQuestionFacadeService;

@Service("deleteQuestionAggregator")
public class DeleteQuestionAggregator implements DeleteQuestionFacadeService {

private final DeleteQuestionFacadeService deleteQuestionFromWC;
private final DeleteQuestionFacadeService deleteQuestionFromCS;
private final CertificateServiceProfile certificateServiceProfile;
private final CSIntegrationService csIntegrationService;

public DeleteQuestionAggregator(
DeleteQuestionFacadeService deleteQuestionFromWC, DeleteQuestionFacadeService deleteQuestionFromCS,
CertificateServiceProfile certificateServiceProfile, CSIntegrationService csIntegrationService) {
this.deleteQuestionFromWC = deleteQuestionFromWC;
this.deleteQuestionFromCS = deleteQuestionFromCS;
this.certificateServiceProfile = certificateServiceProfile;
this.csIntegrationService = csIntegrationService;
}

@Override
public void delete(String questionId) {
if (!certificateServiceProfile.active()) {
deleteQuestionFromWC.delete(questionId);
return;
}

if (Boolean.TRUE.equals(csIntegrationService.messageExists(questionId))) {
deleteQuestionFromCS.delete(questionId);
return;
}

deleteQuestionFromWC.delete(questionId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,47 @@

package se.inera.intyg.webcert.web.csintegration.aggregate;

import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.common.support.facade.model.question.QuestionType;
import se.inera.intyg.webcert.web.csintegration.message.GetQuestionsFromCertificateService;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.GetQuestionsFacadeService;
import se.inera.intyg.webcert.web.service.facade.question.GetQuestionsResourceLinkService;
import se.inera.intyg.webcert.web.web.controller.facade.dto.QuestionsResponseDTO;

@Service
public class GetQuestionsAggregator {
public class GetQuestionsAggregator implements GetQuestionsFacadeService {

private final CertificateServiceProfile certificateServiceProfile;
private final GetQuestionsFacadeService getQuestionsFromWebcert;
private final GetQuestionsResourceLinkService getQuestionsResourceLinkService;
private final GetQuestionsFromCertificateService getQuestionsFromCertificateService;

public GetQuestionsAggregator(
CertificateServiceProfile certificateServiceProfile,
@Qualifier(value = "GetQuestionsFacadeServiceImpl") GetQuestionsFacadeService getQuestionsFromWebcert,
GetQuestionsResourceLinkService getQuestionsResourceLinkService,
@Qualifier("getQuestionsFromCertificateService") GetQuestionsFromCertificateService getQuestionsFromCertificateService) {
this.certificateServiceProfile = certificateServiceProfile;
this.getQuestionsFromWebcert = getQuestionsFromWebcert;
this.getQuestionsResourceLinkService = getQuestionsResourceLinkService;
this.getQuestionsFromCertificateService = getQuestionsFromCertificateService;
}

public QuestionsResponseDTO getComplements(String certificateId) {
return QuestionsResponseDTO.builder()
.questions(
get(certificateId).getQuestions().stream()
.filter(question -> question.getType().equals(QuestionType.COMPLEMENT))
.collect(Collectors.toList())
)
.build();
@Override
public List<Question> getComplementQuestions(String certificateId) {
return getQuestions(certificateId).stream()
.filter(question -> question.getType().equals(QuestionType.COMPLEMENT))
.collect(Collectors.toList());
}

public QuestionsResponseDTO get(String certificateId) {
@Override
public List<Question> getQuestions(String certificateId) {
if (!certificateServiceProfile.active()) {
return getQuestionsFromWebcert(certificateId);
return getQuestionsFromWebcert.getQuestions(certificateId);
}

final var responseFromCS = getQuestionsFromCertificateService.get(certificateId);

return responseFromCS != null ? responseFromCS : getQuestionsFromWebcert(certificateId);
}

private QuestionsResponseDTO getQuestionsFromWebcert(String certificateId) {
final var questions = getQuestionsFromWebcert.getQuestions(certificateId);
final var links = getQuestionsResourceLinkService.get(questions);
return QuestionsResponseDTO.create(questions, links);
return responseFromCS != null ? responseFromCS : getQuestionsFromWebcert.getQuestions(certificateId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,34 @@
package se.inera.intyg.webcert.web.csintegration.aggregate;

import org.springframework.stereotype.Service;
import se.inera.intyg.webcert.web.csintegration.certificate.HandleQuestionFromCertificateService;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.GetQuestionsResourceLinkService;
import se.inera.intyg.webcert.web.service.facade.question.HandleQuestionFacadeService;
import se.inera.intyg.webcert.web.web.controller.facade.dto.QuestionResponseDTO;

@Service
public class HandleQuestionAggregator {
public class HandleQuestionAggregator implements HandleQuestionFacadeService {

private final HandleQuestionFacadeService handleQuestionFromWC;
private final HandleQuestionFromCertificateService handleQuestionFromCS;
private final HandleQuestionFacadeService handleQuestionFromCS;
private final CertificateServiceProfile certificateServiceProfile;
private final GetQuestionsResourceLinkService getQuestionsResourceLinkService;

public HandleQuestionAggregator(
HandleQuestionFacadeService handleQuestionFromWebcert, HandleQuestionFromCertificateService handleQuestionFromCS,
CertificateServiceProfile certificateServiceProfile, GetQuestionsResourceLinkService getQuestionsResourceLinkService) {
this.handleQuestionFromWC = handleQuestionFromWebcert;
HandleQuestionFacadeService handleQuestionFromWC,
HandleQuestionFacadeService handleQuestionFromCS,
CertificateServiceProfile certificateServiceProfile) {
this.handleQuestionFromWC = handleQuestionFromWC;
this.handleQuestionFromCS = handleQuestionFromCS;
this.certificateServiceProfile = certificateServiceProfile;
this.getQuestionsResourceLinkService = getQuestionsResourceLinkService;
}

public QuestionResponseDTO handle(String questionId, boolean isHandled) {
@Override
public Question handle(String questionId, boolean isHandled) {
if (!certificateServiceProfile.active()) {
return handleQuestionsFromWC(questionId, isHandled);
return handleQuestionFromWC.handle(questionId, isHandled);
}

final var responseFromCS = handleQuestionFromCS.handle(questionId, isHandled);

return responseFromCS != null ? responseFromCS : handleQuestionsFromWC(questionId, isHandled);
}

private QuestionResponseDTO handleQuestionsFromWC(String questionId, boolean isHandled) {
final var question = handleQuestionFromWC.handle(questionId, isHandled);
final var links = getQuestionsResourceLinkService.get(question);
return QuestionResponseDTO.create(question, links);
return responseFromCS != null ? responseFromCS : handleQuestionFromWC.handle(questionId, isHandled);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Inera AB (http://www.inera.se)
*
* This file is part of sklintyg (https://github.com/sklintyg).
*
* sklintyg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sklintyg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package se.inera.intyg.webcert.web.csintegration.aggregate;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.SaveQuestionFacadeService;

@Service
@RequiredArgsConstructor
public class SaveQuestionAggregator implements SaveQuestionFacadeService {

private final SaveQuestionFacadeService saveQuestionFromWC;
private final SaveQuestionFacadeService saveMessageFromCS;
private final CertificateServiceProfile certificateServiceProfile;

@Override
public Question save(Question question) {
if (!certificateServiceProfile.active()) {
return saveQuestionFromWC.save(question);
}

final var responseFromCS = saveMessageFromCS.save(question);

return responseFromCS != null ? responseFromCS : saveQuestionFromWC.save(question);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (C) 2024 Inera AB (http://www.inera.se)
*
* This file is part of sklintyg (https://github.com/sklintyg).
*
* sklintyg is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* sklintyg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package se.inera.intyg.webcert.web.csintegration.aggregate;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.webcert.web.csintegration.util.CertificateServiceProfile;
import se.inera.intyg.webcert.web.service.facade.question.SendQuestionFacadeService;

@Service
@RequiredArgsConstructor
public class SendQuestionAggregator implements SendQuestionFacadeService {

private final SendQuestionFacadeService sendQuestionFromWC;
private final SendQuestionFacadeService sendMessageFromCS;
private final CertificateServiceProfile certificateServiceProfile;

@Override
public Question send(Question question) {
if (!certificateServiceProfile.active()) {
return sendQuestionFromWC.send(question);
}

final var responseFromCS = sendMessageFromCS.send(question);

return responseFromCS != null ? responseFromCS : sendQuestionFromWC.send(question);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,24 @@
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import se.inera.intyg.common.support.common.enumerations.HandelsekodEnum;
import se.inera.intyg.common.support.facade.model.question.Question;
import se.inera.intyg.webcert.web.csintegration.integration.CSIntegrationRequestFactory;
import se.inera.intyg.webcert.web.csintegration.integration.CSIntegrationService;
import se.inera.intyg.webcert.web.csintegration.util.PDLLogService;
import se.inera.intyg.webcert.web.service.facade.question.HandleQuestionFacadeService;
import se.inera.intyg.webcert.web.service.fragasvar.dto.FrageStallare;
import se.inera.intyg.webcert.web.web.controller.facade.dto.QuestionResponseDTO;

@Service
@Service("handleQuestionFromCS")
@RequiredArgsConstructor
public class HandleQuestionFromCertificateService {
public class HandleQuestionFromCertificateService implements HandleQuestionFacadeService {

private final CSIntegrationService csIntegrationService;
private final CSIntegrationRequestFactory csIntegrationRequestFactory;
private final PDLLogService pdlLogService;
private final PublishCertificateStatusUpdateService publishCertificateStatusUpdateService;

public QuestionResponseDTO handle(String questionId, boolean isHandled) {
@Override
public Question handle(String questionId, boolean isHandled) {
if (Boolean.FALSE.equals(csIntegrationService.messageExists(questionId))) {
return null;
}
Expand All @@ -59,9 +61,7 @@ public QuestionResponseDTO handle(String questionId, boolean isHandled) {

publishCertificateStatusUpdateService.publish(certificate, eventType(question.getAuthor()));

return QuestionResponseDTO.builder()
.question(question)
.build();
return question;
}

private HandelsekodEnum eventType(String author) {
Expand Down
Loading

0 comments on commit c61f8ee

Please sign in to comment.