use of eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityDataUtil method getFluxReportDocumentEntity.
public static FluxReportDocumentEntity getFluxReportDocumentEntity(String fluxDocumentID, String referenceID, Date creationDateTime, String purposeCode, String purposeCodeListId, String purpose, String ownerFluxPartyId, String ownerFluxPartyName) {
FluxReportDocumentEntity fluxReportDocumentEntity = new FluxReportDocumentEntity();
FluxReportIdentifierEntity entity = new FluxReportIdentifierEntity();
entity.setFluxReportIdentifierId(fluxDocumentID);
fluxReportDocumentEntity.setFluxReportIdentifiers(new HashSet<>(Arrays.asList(entity)));
fluxReportDocumentEntity.setCreationDatetime(creationDateTime);
FluxPartyEntity fluxPartyEntity = new FluxPartyEntity();
fluxPartyEntity.setFluxPartyName(ownerFluxPartyName);
FluxPartyIdentifierEntity fluxPartyIdentifierEntity = new FluxPartyIdentifierEntity();
fluxPartyIdentifierEntity.setFluxPartyIdentifierId(ownerFluxPartyId);
fluxReportDocumentEntity.setFluxParty(fluxPartyEntity);
fluxReportDocumentEntity.setPurpose(purpose);
fluxReportDocumentEntity.setPurposeCode(purposeCode);
fluxReportDocumentEntity.setPurposeCodeListId(purposeCodeListId);
fluxReportDocumentEntity.setReferenceId(referenceID);
return fluxReportDocumentEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FaReportDocumentMapper method getFluxReportDocument.
protected FluxReportDocumentEntity getFluxReportDocument(FLUXReportDocument fluxReportDocument, FaReportDocumentEntity faReportDocumentEntity) {
if (fluxReportDocument == null) {
return null;
}
FluxReportDocumentEntity fluxReportDocumentEntity = FluxReportDocumentMapper.INSTANCE.mapToFluxReportDocumentEntity(fluxReportDocument);
if (fluxReportDocument.getOwnerFLUXParty() != null) {
FluxPartyEntity fluxPartyEntity = FluxPartyMapper.INSTANCE.mapToFluxPartyEntity(fluxReportDocument.getOwnerFLUXParty());
fluxPartyEntity.setFluxReportDocument(fluxReportDocumentEntity);
fluxReportDocumentEntity.setFluxParty(fluxPartyEntity);
}
Set<FluxReportIdentifierEntity> reportIdentifierEntitySet = new HashSet<>();
if (CollectionUtils.isNotEmpty(fluxReportDocument.getIDS())) {
for (IDType idType : fluxReportDocument.getIDS()) {
FluxReportIdentifierEntity fluxReportIdentifierEntity = FluxReportIdentifierMapper.INSTANCE.mapToFluxReportIdentifierEntity(idType);
fluxReportIdentifierEntity.setFluxReportDocument(fluxReportDocumentEntity);
reportIdentifierEntitySet.add(fluxReportIdentifierEntity);
}
}
fluxReportDocumentEntity.setFluxReportIdentifiers(reportIdentifierEntitySet);
fluxReportDocumentEntity.setFaReportDocument(faReportDocumentEntity);
return fluxReportDocumentEntity;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingActivityMapper method getUniqueId.
protected List<FluxReportIdentifierDTO> getUniqueId(FishingActivityEntity entity) {
if (entity == null || entity.getFaReportDocument() == null || entity.getFaReportDocument().getFluxReportDocument() == null) {
return Collections.emptyList();
}
List<FluxReportIdentifierDTO> identifierDTOs = new ArrayList<>();
Set<FluxReportIdentifierEntity> identifiers = entity.getFaReportDocument().getFluxReportDocument().getFluxReportIdentifiers();
for (FluxReportIdentifierEntity fluxReportIdentifierEntity : identifiers) {
identifierDTOs.add(FluxReportIdentifierMapper.INSTANCE.mapToFluxReportIdentifierDTO(fluxReportIdentifierEntity));
}
return identifierDTOs;
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxReportIdentifierDaoTest method testGetMatchingIdentifiers.
@Test
public void testGetMatchingIdentifiers() {
when(dao.getEntityManager().createNamedQuery(anyString(), any(FluxReportIdentifierEntity.class.getClass()))).thenReturn(query);
ActivityUniquinessList reqElem = getMockedRequest().iterator().next();
final List<FluxReportIdentifierEntity> matchingIdentifiers = dao.getMatchingIdentifiers(reqElem.getIds(), reqElem.getActivityTableType());
assertNotNull(matchingIdentifiers);
assertTrue(matchingIdentifiers.size() == 0);
}
use of eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity in project UVMS-ActivityModule-APP by UnionVMS.
the class FluxReportIdentifierDao method getMatchingIdentifiers.
public List<FluxReportIdentifierEntity> getMatchingIdentifiers(List<ActivityIDType> ids, ActivityTableType tableType) {
String namedQueryToSelect = tableType == ActivityTableType.FLUX_REPORT_DOCUMENT_ENTITY ? FluxReportIdentifierEntity.FIND_MATCHING_IDENTIFIER : FluxReportIdentifierEntity.FIND_RELATED_MATCHING_IDENTIFIER;
List<FluxReportIdentifierEntity> resultList = new ArrayList<>();
// FIXME avoid looping ad querying
for (ActivityIDType idType : ids) {
TypedQuery<FluxReportIdentifierEntity> query = getEntityManager().createNamedQuery(namedQueryToSelect, FluxReportIdentifierEntity.class);
query.setParameter(ID, idType.getValue());
query.setParameter(SCHEME_ID, idType.getIdentifierSchemeId());
resultList.addAll(query.getResultList());
}
resultList.removeAll(Collections.singleton(null));
return resultList;
}
Aggregations