Search in sources :

Example 1 with FAReportDocument

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBeanTest method setUp.

@Before
public void setUp() {
    FAReportDocument faReportDocument2 = MapperUtil.getFaReportDocument();
    faReportDocument2.getRelatedFLUXReportDocument().setPurposeCode(MapperUtil.getCodeType("9", "4fyrh-58fj4-5jtu-58tjr"));
    IDType id = faReportDocument2.getRelatedFLUXReportDocument().getReferencedID();
    FAReportDocument faReportDocument1 = MapperUtil.getFaReportDocument();
    faReportDocument1.getRelatedFLUXReportDocument().setIDS(Arrays.asList(id));
    faReportDocument1.getRelatedFLUXReportDocument().setPurposeCode(MapperUtil.getCodeType("3", "4f5yrh-58f7j4-5j5tu-58tj7r"));
    fluxFaReportMessage = new FLUXFAReportMessage();
    faReportDocuments = Arrays.asList(faReportDocument1, faReportDocument2);
    fluxFaReportMessage.setFAReportDocuments(faReportDocuments);
    fluxFaReportMessage.setFLUXReportDocument(MapperUtil.getFluxReportDocument());
}
Also used : FLUXFAReportMessage(un.unece.uncefact.data.standard.fluxfareportmessage._3.FLUXFAReportMessage) IDType(un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument) Before(org.junit.Before)

Example 2 with FAReportDocument

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument in project UVMS-ActivityModule-APP by UnionVMS.

the class FluxMessageServiceBean method updateFaReportCorrections.

/**
 * If there is a reference Id exist for any of the FaReport Document, than it means this is an update to an existing report.
 */
private void updateFaReportCorrections(List<FAReportDocument> faReportDocuments) throws ServiceException {
    List<FaReportDocumentEntity> faReportDocumentEntities = new ArrayList<>();
    for (FAReportDocument faReportDocument : faReportDocuments) {
        if (faReportDocument.getRelatedFLUXReportDocument().getReferencedID() != null && faReportDocument.getRelatedFLUXReportDocument().getPurposeCode() != null) {
            FaReportDocumentEntity faReportDocumentEntity = faReportDocumentDao.findFaReportByIdAndScheme(faReportDocument.getRelatedFLUXReportDocument().getReferencedID().getValue(), faReportDocument.getRelatedFLUXReportDocument().getReferencedID().getSchemeID());
            if (faReportDocumentEntity != null) {
                FaReportStatusType faReportStatusEnum = FaReportStatusType.getFaReportStatusEnum(Integer.parseInt(faReportDocument.getRelatedFLUXReportDocument().getPurposeCode().getValue()));
                faReportDocumentEntity.setStatus(faReportStatusEnum.getStatus());
                faReportDocumentEntities.add(faReportDocumentEntity);
            }
        }
    }
    faReportDocumentDao.updateAllFaData(faReportDocumentEntities);
}
Also used : FaReportStatusType(eu.europa.ec.fisheries.ers.fa.utils.FaReportStatusType) FaReportDocumentEntity(eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity) ArrayList(java.util.ArrayList) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)

Example 3 with FAReportDocument

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method deleteBranchesThatMatchWithTheIdsList.

private void deleteBranchesThatMatchWithTheIdsList(List<ActivityIDType> ids, List<FAReportDocument> faReportDocuments) {
    final Iterator<FAReportDocument> iterator = faReportDocuments.iterator();
    while (iterator.hasNext()) {
        FAReportDocument faRep = iterator.next();
        FLUXReportDocument relatedFLUXReportDocument = faRep.getRelatedFLUXReportDocument();
        if (relatedFLUXReportDocument != null && reportDocumentIdsMatch(relatedFLUXReportDocument.getIDS(), ids)) {
            log.warn("[WARN] Deleted FaReportDocument (from XML MSG Node) since it already exist in the Activity DB..\n" + "Following is the ID : { " + preetyPrintIds(relatedFLUXReportDocument.getIDS()) + " }");
            iterator.remove();
            log.info("[INFO] Remaining [ " + faReportDocuments.size() + " ] FaReportDocuments to be saved.");
        }
    }
}
Also used : FLUXReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXReportDocument) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)

Example 4 with FAReportDocument

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEventServiceBean method deleteDuplicatedReportsFromXMLDocument.

private void deleteDuplicatedReportsFromXMLDocument(FLUXFAReportMessage repMsg) {
    GetNonUniqueIdsRequest getNonUniqueIdsRequest = null;
    try {
        getNonUniqueIdsRequest = ActivityModuleRequestMapper.mapToGetNonUniqueIdRequestObject(collectAllIdsFromMessage(repMsg));
    } catch (ActivityModelMarshallException e) {
        log.error("[ERROR] Error while trying to get the unique ids from FaReportDocumentIdentifiers table...");
    }
    GetNonUniqueIdsResponse matchingIdsResponse = matchingIdsService.getMatchingIdsResponse(getNonUniqueIdsRequest.getActivityUniquinessLists());
    List<ActivityUniquinessList> activityUniquinessLists = matchingIdsResponse.getActivityUniquinessLists();
    final List<FAReportDocument> faReportDocuments = repMsg.getFAReportDocuments();
    if (CollectionUtils.isNotEmpty(activityUniquinessLists)) {
        for (ActivityUniquinessList unique : activityUniquinessLists) {
            deleteBranchesThatMatchWithTheIdsList(unique.getIds(), faReportDocuments);
        }
    }
}
Also used : ActivityUniquinessList(eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList) ActivityModelMarshallException(eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException) GetNonUniqueIdsRequest(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest) GetNonUniqueIdsResponse(eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse) FAReportDocument(un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)

Example 5 with FAReportDocument

use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityEntityToModelMapper method mapPurposeCode.

private void mapPurposeCode(FAReportDocument target, String typeCode, String listId) {
    if (ObjectUtils.allNotNull(target)) {
        CodeType codeType = new CodeType();
        codeType.setValue(typeCode);
        codeType.setListID(listId);
        target.setTypeCode(codeType);
    }
}
Also used : CodeType(un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType)

Aggregations

FAReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAReportDocument)9 ArrayList (java.util.ArrayList)5 FaReportDocumentEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportDocumentEntity)4 IDType (un.unece.uncefact.data.standard.unqualifieddatatype._20.IDType)4 FLUXReportDocument (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FLUXReportDocument)3 CodeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.CodeType)3 FaReportIdentifierEntity (eu.europa.ec.fisheries.ers.fa.entities.FaReportIdentifierEntity)2 FishingActivityEntity (eu.europa.ec.fisheries.ers.fa.entities.FishingActivityEntity)2 ActivityUniquinessList (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityUniquinessList)2 FishingActivity (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FishingActivity)2 VesselTransportMeans (un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.VesselTransportMeans)2 DateTimeType (un.unece.uncefact.data.standard.unqualifieddatatype._20.DateTimeType)2 VesselTransportMeansEntity (eu.europa.ec.fisheries.ers.fa.entities.VesselTransportMeansEntity)1 FaReportStatusType (eu.europa.ec.fisheries.ers.fa.utils.FaReportStatusType)1 ActivityModelMarshallException (eu.europa.ec.fisheries.uvms.activity.model.exception.ActivityModelMarshallException)1 ActivityIDType (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityIDType)1 ActivityTableType (eu.europa.ec.fisheries.uvms.activity.model.schemas.ActivityTableType)1 GetNonUniqueIdsRequest (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsRequest)1 GetNonUniqueIdsResponse (eu.europa.ec.fisheries.uvms.activity.model.schemas.GetNonUniqueIdsResponse)1 EnumMap (java.util.EnumMap)1