Search in sources :

Example 1 with FluxFaReportMessageEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapperTest method testMapToFLUXFAReportMessage.

@Test
@Parameters(method = "resources")
public void testMapToFLUXFAReportMessage(String resource) throws Exception {
    FLUXFAReportMessage fluxfaReportMessage = sourceToEntity(resource);
    FluxFaReportMessageEntity entity = incomingFAReportMapper.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.MANUAL, new FluxFaReportMessageEntity());
    FLUXFAReportMessage target = modelMapper.mapToFLUXFAReportMessage(new ArrayList<>(entity.getFaReportDocuments()));
    String controlSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(fluxfaReportMessage));
    String testSource = JAXBUtils.marshallJaxBObjectToString(getFirstElement(target));
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreComments(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    DetailedDiff diff = new DetailedDiff(new org.custommonkey.xmlunit.Diff(clearEmptyTags(controlSource), clearEmptyTags(testSource)));
    diff.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
    assertTrue("XML are similar " + diff, diff.similar());
}
Also used : DetailedDiff(org.custommonkey.xmlunit.DetailedDiff) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) RecursiveElementNameAndTextQualifier(org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 2 with FluxFaReportMessageEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FishingActivityViewMapperTest method initFishingActivityEntity.

@Before
@SneakyThrows
public void initFishingActivityEntity() {
    FLUXFAReportMessage fluxfaReportMessage = getActivityDataFromXML();
    FluxFaReportMessageEntity fluxRepMessageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.FLUX, new FluxFaReportMessageEntity());
    List<FaReportDocumentEntity> faReportDocuments = new ArrayList<>(fluxRepMessageEntity.getFaReportDocuments());
    fishingActivity = faReportDocuments.get(0).getFishingActivities().iterator().next();
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) ArrayList(java.util.ArrayList) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Before(org.junit.Before) SneakyThrows(lombok.SneakyThrows)

Example 3 with FluxFaReportMessageEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxFaReportMessageMapperTest method testFluxFaReportMessageMapper.

@Test
@SneakyThrows
public void testFluxFaReportMessageMapper() {
    InputStream is = this.getClass().getClassLoader().getResourceAsStream("fa_flux_message.xml");
    JAXBContext jaxbContext = JAXBContext.newInstance(FLUXFAReportMessage.class);
    Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
    FLUXFAReportMessage fluxfaReportMessage = (FLUXFAReportMessage) jaxbUnmarshaller.unmarshal(is);
    FluxFaReportMessageEntity fluxRepMessageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(fluxfaReportMessage, FaReportSourceEnum.FLUX, new FluxFaReportMessageEntity());
    List<FaReportDocumentEntity> faReportDocuments = new ArrayList(fluxRepMessageEntity.getFaReportDocuments());
    FluxReportDocumentEntity fluxReportDocument = fluxRepMessageEntity.getFluxReportDocument();
    assertNotNull(fluxRepMessageEntity);
    assertNotNull(fluxReportDocument);
    assertNotNull(fluxReportDocument.getFluxFaReportMessage());
    assertNotNull(faReportDocuments.get(0).getFluxReportDocument());
    assertEquals(1, faReportDocuments.size());
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) JAXBContext(javax.xml.bind.JAXBContext) Unmarshaller(javax.xml.bind.Unmarshaller) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Example 4 with FluxFaReportMessageEntity

use of eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBean method saveFishingActivityReportDocuments.

/**
 * {@inheritDoc}
 */
@Override
@Transactional(Transactional.TxType.REQUIRED)
public void saveFishingActivityReportDocuments(FLUXFAReportMessage faReportMessage, FaReportSourceEnum faReportSourceEnum) throws ServiceException {
    log.info("[INFO] Going to save [ " + faReportMessage.getFAReportDocuments().size() + " ] FaReportDocuments..");
    FluxFaReportMessageEntity messageEntity = FluxFaReportMessageMapper.INSTANCE.mapToFluxFaReportMessage(faReportMessage, faReportSourceEnum, new FluxFaReportMessageEntity());
    final Set<FaReportDocumentEntity> faReportDocuments = messageEntity.getFaReportDocuments();
    for (FaReportDocumentEntity faReportDocument : faReportDocuments) {
        try {
            updateGeometry(faReportDocument);
            enrichFishingActivityWithGuiID(faReportDocument);
        } catch (Exception e) {
            log.error("Could not update Geometry OR enrichActivities for faReportDocument:" + faReportDocument.getId());
        }
    }
    log.debug("fishing activity records to be saved : " + faReportDocuments.size());
    fluxReportMessageDao.saveFluxFaReportMessage(messageEntity);
    log.debug("Save partial FluxFaReportMessage before further processing");
    updateFaReportCorrections(faReportMessage.getFAReportDocuments());
    log.debug("Update FaReport Corrections is complete.");
    updateFishingTripStartAndEndDate(faReportDocuments);
    log.info("FluxFaReportMessage Saved successfully.");
}
Also used : FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) FluxFaReportMessageEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity) ParseException(com.vividsolutions.jts.io.ParseException) ServiceException(eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException) Transactional(javax.transaction.Transactional)

Aggregations

FluxFaReportMessageEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxFaReportMessageEntity)4 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)3 FLUXFAReportMessage (un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage)3 ArrayList (java.util.ArrayList)2 SneakyThrows (lombok.SneakyThrows)2 Test (org.junit.Test)2 ParseException (com.vividsolutions.jts.io.ParseException)1 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)1 ServiceException (eu.europa.ec.fisheries.uvms.commons.service.exception.ServiceException)1 InputStream (java.io.InputStream)1 Transactional (javax.transaction.Transactional)1 JAXBContext (javax.xml.bind.JAXBContext)1 Unmarshaller (javax.xml.bind.Unmarshaller)1 Parameters (junitparams.Parameters)1 DetailedDiff (org.custommonkey.xmlunit.DetailedDiff)1 RecursiveElementNameAndTextQualifier (org.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier)1 Before (org.junit.Before)1