Skip to content

Commit

Permalink
PATCHES FOR MOVEMENT RULES
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikos Paraskevopoulos authored and Nikos Paraskevopoulos committed Nov 26, 2020
1 parent fcf562e commit 3e24466
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
34 changes: 17 additions & 17 deletions LIQUIBASE/changelog/v3.4/db-changelog-UNIONVMS-4660.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,40 @@
<databaseChangeLog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd">
<changeSet id="UNIONVMS-4660-template-for-MovementRules" author="nomikosi">
<insert tableName="template">
<column name="template_id" value="36" />
<column name="template_id" value="2000" />
<column name="template_name" value="Movement report document" />
<column name="fact_template" value="MOVEMENT_REPORT_DOCUMENT" />
</insert>

<rollback>
<delete tableName="template">
<where>template_id = 36</where>
<where>template_id = 2000</where>
</delete>
</rollback>
</changeSet>

<changeSet id="UNIONVMS-4660-update-MO-R01-00-0001" author="nomikosi">
<insert tableName="rule">
<column name="template_id" value="36" />
<column name="template_id" value="2000" />
<column name="property_names" value="creationDateTime" />
<column name="note" value="Check presence. Must be present." />
<column name="level" value="L00" />
<column name="error_type" value="ERROR" />
<column name="disabled" value="false" />
<column name="br_id" value="MO-R01-00-0001" />
<column name="rule_id" value="700"/>
<column name="rule_id" value="20001"/>
</insert>
<insert tableName="context_expression">
<column name="expression" value="creationDateTime == null "/>
<column name="failure_message" value="Message creation date/time missing."/>
<column name="context" value="EU"/>
<column name="rule_id" value="700"/>
<column name="id" value="700"/>
<column name="rule_id" value="20001"/>
<column name="id" value="20001"/>
</insert>

<rollback>
<delete tableName="context_expression">
<where>rule_id = 700</where>
<where>rule_id = 20001</where>
</delete>
<delete tableName="rule">
<where>br_id = 'MO-R01-00-0001'</where>
Expand All @@ -45,26 +45,26 @@

<changeSet id="UNIONVMS-4660-update-MO-R01-00-0002" author="nomikosi">
<insert tableName="rule">
<column name="template_id" value="36" />
<column name="template_id" value="2000" />
<column name="property_names" value="creationDateTime" />
<column name="note" value="Format must be date in UTC according to ISO8601" />
<column name="level" value="L01" />
<column name="error_type" value="ERROR" />
<column name="disabled" value="false" />
<column name="br_id" value="MO-R01-00-0002" />
<column name="rule_id" value="701"/>
<column name="rule_id" value="20002"/>
</insert>
<insert tableName="context_expression">
<column name="expression" value="!isEmpty(creationDateTimeString) &amp;&amp; !isIsoDateStringValidFormat(creationDateTimeString)"/>
<column name="failure_message" value="Invalid message creation date/time."/>
<column name="context" value="EU"/>
<column name="rule_id" value="701"/>
<column name="id" value="701"/>
<column name="rule_id" value="20002"/>
<column name="id" value="20002"/>
</insert>

<rollback>
<delete tableName="context_expression">
<where>rule_id = 701</where>
<where>rule_id = 20002</where>
</delete>
<delete tableName="rule">
<where>br_id = 'MO-R01-00-0002'</where>
Expand All @@ -74,26 +74,26 @@

<changeSet id="UNIONVMS-4660-update-MO-R01-00-0003" author="nomikosi">
<insert tableName="rule">
<column name="template_id" value="36" />
<column name="template_id" value="2000" />
<column name="property_names" value="creationDateTime" />
<column name="note" value="A threshold to compensate for incorrect clock synchronization of the exchanging systems must be taken into account." />
<column name="level" value="L03" />
<column name="error_type" value="WARNING" />
<column name="disabled" value="false" />
<column name="br_id" value="MO-R01-00-0003" />
<column name="rule_id" value="702"/>
<column name="rule_id" value="20003"/>
</insert >
<insert tableName="context_expression">
<column name="expression" value="creationDateTime != null &amp;&amp; dateNotInPast(creationDateTime, 10)"/>
<column name="failure_message" value="Message creation date/time not in the past."/>
<column name="context" value="EU"/>
<column name="rule_id" value="702"/>
<column name="id" value="702"/>
<column name="rule_id" value="20003"/>
<column name="id" value="20003"/>
</insert >

<rollback>
<delete tableName="context_expression">
<where>rule_id = 702</where>
<where>rule_id = 20003</where>
</delete>
<delete tableName="rule">
<where>br_id = 'MO-R01-00-0003'</where>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -288,7 +289,12 @@ public void setMovementReportReceived(SetFLUXMovementReportRequest request, Stri
extraValues.put(DATA_FLOW, request.getFluxDataFlow());
Collection<AbstractFact> 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));
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3e24466

Please sign in to comment.