From 3e244666a7ee01ec4ef67c77ba426003446b3474 Mon Sep 17 00:00:00 2001 From: Nikos Paraskevopoulos Date: Wed, 16 Sep 2020 22:27:36 +0300 Subject: [PATCH] PATCHES FOR MOVEMENT RULES --- .../v3.4/db-changelog-UNIONVMS-4660.xml | 34 +++++++++---------- .../movement/RulesMovementProcessorBean.java | 10 ++++-- .../helper/RuleApplicabilityChecker.java | 3 ++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/LIQUIBASE/changelog/v3.4/db-changelog-UNIONVMS-4660.xml b/LIQUIBASE/changelog/v3.4/db-changelog-UNIONVMS-4660.xml index f1ec73fcc..7a8724037 100644 --- a/LIQUIBASE/changelog/v3.4/db-changelog-UNIONVMS-4660.xml +++ b/LIQUIBASE/changelog/v3.4/db-changelog-UNIONVMS-4660.xml @@ -2,40 +2,40 @@ - + - template_id = 36 + template_id = 2000 - + - + - - + + - rule_id = 700 + rule_id = 20001 br_id = 'MO-R01-00-0001' @@ -45,26 +45,26 @@ - + - + - - + + - rule_id = 701 + rule_id = 20002 br_id = 'MO-R01-00-0002' @@ -74,26 +74,26 @@ - + - + - - + + - rule_id = 702 + rule_id = 20003 br_id = 'MO-R01-00-0003' diff --git a/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/bean/movement/RulesMovementProcessorBean.java b/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/bean/movement/RulesMovementProcessorBean.java index be0601792..7277d41b8 100644 --- a/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/bean/movement/RulesMovementProcessorBean.java +++ b/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/bean/movement/RulesMovementProcessorBean.java @@ -125,6 +125,7 @@ import org.apache.commons.lang3.StringUtils; import un.unece.uncefact.data.standard.fluxvesselpositionmessage._4.FLUXVesselPositionMessage; import un.unece.uncefact.data.standard.mdr.communication.ObjectRepresentation; +import un.unece.uncefact.data.standard.unqualifieddatatype._18.IDType; import javax.annotation.PostConstruct; import javax.ejb.EJB; @@ -288,7 +289,12 @@ public void setMovementReportReceived(SetFLUXMovementReportRequest request, Stri extraValues.put(DATA_FLOW, request.getFluxDataFlow()); Collection factsResults = rulesEngine.evaluate(RECEIVING_MOVEMENT_MSG,fluxVesselPositionMessage,extraValues,null); - ValidationResult validationResult = rulePostProcessBean.checkAndUpdateValidationResult(factsResults, request.getRequest(), String.valueOf(fluxVesselPositionMessage.getFLUXReportDocument().getIDS()), RawMsgType.MOVEMENT); + final String reportId = fluxVesselPositionMessage.getFLUXReportDocument().getIDS().stream() + .filter(id -> "UUID".equals(id.getSchemeID())) + .map(IDType::getValue) + .findFirst() + .get(); + ValidationResult validationResult = rulePostProcessBean.checkAndUpdateValidationResult(factsResults, request.getRequest(), reportId, RawMsgType.MOVEMENT); if(validationResult.isError()){ exchangeServiceBean.updateExchangeMessage(request.getLogGuid(), fluxMessageHelper.calculateMessageValidationStatus(validationResult)); @@ -331,8 +337,8 @@ private void enrichAndSendMovementsAsBatch(ValidationResult validationResult,Lis sendBatchBackToExchange(exchangeLogGuid, rawMovements, MovementRefTypeType.MOVEMENT, username); } else { status = ExchangeLogStatusTypeType.FAILED; + sendBatchBackToExchange(exchangeLogGuid, rawMovements, MovementRefTypeType.MOVEMENT, username); } - sendBatchBackToExchange(exchangeLogGuid, rawMovements, MovementRefTypeType.MOVEMENT, username); updateRequestMessageStatusInExchange(exchangeLogGuid, status); } catch (MessageException | MobileTerminalModelMapperException | MobileTerminalUnmarshallException | JMSException | AssetModelMapperException e) { throw new RulesServiceException(e.getMessage(), e); diff --git a/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/business/helper/RuleApplicabilityChecker.java b/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/business/helper/RuleApplicabilityChecker.java index 000afefe1..35afec083 100644 --- a/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/business/helper/RuleApplicabilityChecker.java +++ b/service/src/main/java/eu/europa/ec/fisheries/uvms/rules/service/business/helper/RuleApplicabilityChecker.java @@ -76,6 +76,9 @@ && isDateInRange(messageCreationDate, faBrForBrIdAndContext.getStartDate(), faBr * @return */ public boolean isApplicable(String thisRulesBrId, String ruleContext, String messageDataFlow, DateTime messageCreationDate, MDRCacheRuleService mdrService) { + if (thisRulesBrId != null && thisRulesBrId.startsWith("MO-")) { + return true; + } String msgContext = mdrService.findContextForDf(messageDataFlow); if (StringUtils.isEmpty(msgContext)) { return false;