use of se.inera.intyg.common.support.model.Status in project webcert by sklintyg.
the class IntygConverterUtil method buildStatusesFromUtkast.
/**
* Given an Utkast, a List of Statuses is built given:
*
* <li>If draft has a skickadTillMottagareDatum, a SENT status is added</li>
* <li>If draft has a aterkalledDatum, a CANCELLED status is added</li>
* <li>If there is a signature with a signature date, a RECEIVED status is added.</li>
*/
public static List<Status> buildStatusesFromUtkast(Utkast draft) {
List<Status> statuses = new ArrayList<>();
if (draft.getSkickadTillMottagareDatum() != null) {
Status status = new Status(CertificateState.SENT, draft.getSkickadTillMottagare(), draft.getSkickadTillMottagareDatum());
statuses.add(status);
}
if (draft.getAterkalladDatum() != null) {
Status status = new Status(CertificateState.CANCELLED, null, draft.getAterkalladDatum());
statuses.add(status);
}
if (draft.getStatus() == UtkastStatus.SIGNED && draft.getSignatur() != null && draft.getSignatur().getSigneringsDatum() != null) {
Status status = new Status(CertificateState.RECEIVED, null, draft.getSignatur().getSigneringsDatum());
statuses.add(status);
}
return statuses;
}
use of se.inera.intyg.common.support.model.Status in project webcert by sklintyg.
the class AbstractIntygServiceTest method buildCertificateMetaData.
protected CertificateMetaData buildCertificateMetaData() {
CertificateMetaData metaData = new CertificateMetaData();
metaData.setStatus(new ArrayList<>());
Status statusSigned = new Status(CertificateState.RECEIVED, "FKASSA", LocalDateTime.now());
metaData.getStatus().add(statusSigned);
metaData.setSignDate(LocalDateTime.now());
return metaData;
}
use of se.inera.intyg.common.support.model.Status in project webcert by sklintyg.
the class IntygModuleFacadeTest method testConvertFromInternalToPdfDocumentModuleNotFoundException.
@Test(expected = IntygModuleFacadeException.class)
public void testConvertFromInternalToPdfDocumentModuleNotFoundException() throws IntygModuleFacadeException, ModuleException, ModuleNotFoundException {
when(moduleRegistry.getModuleApi(CERTIFICATE_TYPE)).thenThrow(new ModuleNotFoundException());
moduleFacade.convertFromInternalToPdfDocument(CERTIFICATE_TYPE, INT_JSON, Arrays.asList(new Status(CertificateState.RECEIVED, "", LocalDateTime.now())), false);
}
use of se.inera.intyg.common.support.model.Status in project webcert by sklintyg.
the class UtkastIntygDecoratorTest method testSentIntygDoesNotAddAnySentStatus.
@Test
public void testSentIntygDoesNotAddAnySentStatus() {
CertificateResponse response = buildCertificateResponse();
response.getMetaData().getStatus().add(new Status(CertificateState.SENT, "FKASSA", LocalDateTime.now()));
testee.decorateWithUtkastStatus(response);
assertEquals(2, response.getMetaData().getStatus().size());
}
use of se.inera.intyg.common.support.model.Status in project webcert by sklintyg.
the class UtkastIntygDecoratorImpl method decorateWithUtkastStatus.
@Override
public void decorateWithUtkastStatus(CertificateResponse certificate) {
if (certificate.isRevoked()) {
return;
}
boolean isSent = isSent(certificate.getMetaData().getStatus());
boolean isRevoked = isRevoked(certificate.getMetaData().getStatus());
if (isSent && isRevoked) {
return;
}
Utkast utkast = utkastRepository.findOne(certificate.getMetaData().getCertificateId());
// Don't try to decorate if utkast not found. May be a non-webcert intyg.
if (utkast == null) {
return;
}
if (utkast.getSkickadTillMottagareDatum() != null && !isSent) {
// Add sent status flag
Status sentStatus = new Status(CertificateState.SENT, utkast.getSkickadTillMottagare(), utkast.getSkickadTillMottagareDatum());
certificate.getMetaData().getStatus().add(sentStatus);
}
if (utkast.getAterkalladDatum() != null && !isRevoked) {
// Add revoked status flag
Status revokedStatus = new Status(CertificateState.CANCELLED, "HSVARD", utkast.getAterkalladDatum());
certificate.getMetaData().getStatus().add(revokedStatus);
}
}
Aggregations