use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FKAnswerConverterTest method testConvertAnswer.
@Test
public void testConvertAnswer() throws Exception {
QuestionFromFkType questionFromFK = inflateQuestionFromFK();
AnswerToFkType referenceAnswerToFK = inflateAnswerToFK();
// convert QuestionFromFK to FragaSvar entity
FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
// add some data
fragaSvar.setInternReferens(321L);
fragaSvar.setSvarsText(fragaSvar.getFrageText());
fragaSvar.setSvarSigneringsDatum(fragaSvar.getFrageSigneringsDatum());
// convert FragaSvar entity to AnswerToFK
AnswerToFkType convertedAnswerToFK = FKAnswerConverter.convert(fragaSvar);
// compare convertedAnswerToFK to reference
String expected = jaxbToXml(referenceAnswerToFK);
String actual = jaxbToXml(convertedAnswerToFK);
assertEquals(expected, actual);
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FKQuestionConverterTest method testConvertQuestion.
@Test
public void testConvertQuestion() throws Exception {
QuestionFromFkType questionFromFK = inflateQuestionFromFK();
QuestionToFkType referenceQuestionToFK = inflateQuestionToFK();
// convert QuestionFromFK to FragaSvar entity
FragaSvar fragaSvar = fragaSvarConverter.convert(questionFromFK);
// add some data
fragaSvar.setAmne(Amne.KONTAKT);
fragaSvar.setInternReferens(321L);
// convert fragaSvar entity to QuestionToFK
QuestionToFkType convertedQuestionToFK = FKQuestionConverter.convert(fragaSvar);
// compare convertedQuestionToFK to reference
String expected = jaxbToXml(referenceQuestionToFK);
String actual = jaxbToXml(convertedQuestionToFK);
assertEquals(expected, actual);
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarResource method askQuestion.
@POST
@Path("/skickafraga/{vardgivare}/{enhet}/{intygId}/{typ}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public Response askQuestion(@PathParam("vardgivare") final String vardgivarId, @PathParam("enhet") final String enhetsId, @PathParam("intygId") final String intygId, @PathParam("typ") final String typ, CreateQuestionParameter parameter) {
SecurityContext originalContext = SecurityContextHolder.getContext();
SecurityContextHolder.setContext(getSecurityContext(vardgivarId, enhetsId));
try {
FragaSvar fragaSvarResponse = fragaSvarService.saveNewQuestion(intygId, typ, parameter.getAmne(), parameter.getFrageText());
return Response.ok(fragaSvarResponse).build();
} finally {
SecurityContextHolder.setContext(originalContext);
}
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarResource method deleteFragaSvarByEnhet.
@DELETE
@Path("/enhet/{enhetsId}")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteFragaSvarByEnhet(@PathParam("enhetsId") String enhetsId) {
List<String> enhetsIds = new ArrayList<>();
enhetsIds.add(enhetsId);
List<FragaSvar> fragorOchSvar = fragasvarRepository.findByEnhetsId(enhetsIds);
if (fragorOchSvar != null) {
for (FragaSvar fragaSvar : fragorOchSvar) {
fragasvarRepository.delete(fragaSvar);
}
}
return Response.ok().build();
}
use of se.inera.intyg.webcert.persistence.fragasvar.model.FragaSvar in project webcert by sklintyg.
the class FragaSvarModuleApiController method createQuestion.
@POST
@Path("/{intygsTyp}/{intygsId}")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createQuestion(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") final String intygsId, CreateQuestionParameter parameter) {
authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_HANTERA_FRAGOR, AuthoritiesConstants.FEATURE_SKAPA_NYFRAGA).orThrow();
LOG.debug("New question for cert {} with subject {}", intygsId, parameter.getAmne());
FragaSvar fragaSvarResponse = fragaSvarService.saveNewQuestion(intygsId, intygsTyp, parameter.getAmne(), parameter.getFrageText());
return Response.ok(fragaSvarResponse).build();
}
Aggregations