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());
}
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();
}
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());
}
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.");
}
Aggregations