Search in sources :

Example 1 with FluxReportIdentifierEntity

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;
}
Also used : FluxReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) FluxPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxPartyEntity) FluxPartyIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxPartyIdentifierEntity)

Example 2 with FluxReportIdentifierEntity

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;
}
Also used : FluxReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity) FluxReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity) FluxPartyEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxPartyEntity) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) HashSet(java.util.HashSet)

Example 3 with FluxReportIdentifierEntity

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;
}
Also used : FluxReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity) FluxReportIdentifierDTO(eu.europa.ec.fisheries.ers.service.dto.FluxReportIdentifierDTO) ArrayList(java.util.ArrayList)

Example 4 with FluxReportIdentifierEntity

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);
}
Also used : ActivityUniquinessList(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList) FluxReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity) Test(org.junit.Test)

Example 5 with FluxReportIdentifierEntity

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;
}
Also used : ActivityIDType(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityIDType) FluxReportIdentifierEntity(eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity) ArrayList(java.util.ArrayList)

Aggregations

FluxReportIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportIdentifierEntity)10 FluxReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxReportDocumentEntity)3 Test (org.junit.Test)3 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)2 FluxPartyEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxPartyEntity)2 FaReportCorrectionDTO (eu.europa.ec.fisheries.ers.service.dto.fareport.FaReportCorrectionDTO)2 ArrayList (java.util.ArrayList)2 FluxPartyIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FluxPartyIdentifierEntity)1 FluxReportIdentifierDTO (eu.europa.ec.fisheries.ers.service.dto.FluxReportIdentifierDTO)1 ActivityIDType (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityIDType)1 ActivityUniquinessList (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList)1 Date (java.util.Date)1 HashSet (java.util.HashSet)1 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)1