use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityToSubscriptionMapperTest method before.
@Before
@SneakyThrows
public void before() {
IDType idType = new IDType();
idType.setSchemeID("FLUX_GP_PARTY");
idType.setValue("BEL");
FLUXParty fluxParty = new FLUXParty();
fluxParty.setIDS(Collections.singletonList(idType));
DelimitedPeriod delimitedPeriod = new DelimitedPeriod();
DateTimeType startDateTime = new DateTimeType();
GregorianCalendar cal = new GregorianCalendar();
DateTime dateTime = DateUtils.XML_FORMATTER.parseDateTime("2016-07-01T11:14:00Z");
cal.setTime(dateTime.toDate());
XMLGregorianCalendar xmlDate = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal);
startDateTime.setDateTime(xmlDate);
delimitedPeriod.setStartDateTime(startDateTime);
DateTimeType endDateTime = new DateTimeType();
GregorianCalendar cal2 = new GregorianCalendar();
DateTime dateTime2 = DateUtils.XML_FORMATTER.parseDateTime("2017-07-01T02:00:00Z");
cal2.setTime(dateTime2.toDate());
XMLGregorianCalendar xmlDate2 = DatatypeFactory.newInstance().newXMLGregorianCalendar(cal2);
endDateTime.setDateTime(xmlDate2);
delimitedPeriod.setEndDateTime(endDateTime);
FAQueryParameter faQueryParameter = new FAQueryParameter();
CodeType codeType = new CodeType();
codeType.setValue(SubCriteriaType.VESSELID.value());
faQueryParameter.setTypeCode(codeType);
IDType idType0 = new IDType();
idType0.setValue("PD2438");
idType0.setSchemeID("IRCS");
faQueryParameter.setValueID(idType0);
FAQueryParameter faQueryParameter2 = new FAQueryParameter();
CodeType codeType2 = new CodeType();
codeType2.setValue(SubCriteriaType.VESSELID.value());
faQueryParameter2.setTypeCode(codeType2);
IDType idType2 = new IDType();
idType2.setValue("SVN123456789");
idType2.setSchemeID("CFR");
faQueryParameter2.setValueID(idType2);
FAQueryParameter faQueryParameter3 = new FAQueryParameter();
CodeType codeType3 = new CodeType();
codeType3.setValue(SubCriteriaType.TRIPID.value());
faQueryParameter3.setTypeCode(codeType3);
IDType idType3 = new IDType();
idType3.setValue("FRA-TRP-2016122102030");
idType3.setSchemeID("EU_TRIP_ID");
faQueryParameter3.setValueID(idType3);
FAQueryParameter faQueryParameter4 = new FAQueryParameter();
CodeType codeType4 = new CodeType();
codeType4.setValue("CONSOLIDATED");
CodeType valueCode = new CodeType();
valueCode.setListID("BOOLEAN_VALUE");
valueCode.setValue("Y");
faQueryParameter4.setTypeCode(codeType4);
faQueryParameter4.setValueCode(valueCode);
List<FAQueryParameter> faQueryParameters = new ArrayList<>();
faQueryParameters.add(faQueryParameter);
faQueryParameters.add(faQueryParameter2);
faQueryParameters.add(faQueryParameter3);
faQueryParameters.add(faQueryParameter4);
FAQuery faQuery = new FAQuery();
faQuery.setSpecifiedDelimitedPeriod(delimitedPeriod);
faQuery.setSimpleFAQueryParameters(faQueryParameters);
faQuery.setSubmitterFLUXParty(fluxParty);
fluxfaQueryMessage.setFAQuery(faQuery);
}
use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class FaQueryFactory method createFaQueryForTrip.
public static FAQuery createFaQueryForTrip(String tripId, String sendTo, boolean consolidated) {
FAQuery faq = new FAQuery();
faq.setID(new IDType(UUID.randomUUID().toString(), "UUID", null, null, null, null, null, null));
faq.setTypeCode(new CodeType("TRIP", "FA_QUERY_TYPE", null, null, null, null, null, null, null, null));
try {
final XMLGregorianCalendar currentDate = DateUtils.getCurrentDate();
faq.setSubmittedDateTime(new DateTimeType(currentDate, null));
} catch (DatatypeConfigurationException e) {
log.error("[ERROR] Error while trying to create XMLGregorianCalendar () DateUtils.getCurrentDate()! Going to retry", e);
return null;
}
faq.setSubmitterFLUXParty(new FLUXParty(Collections.singletonList(new IDType(sendTo, "FLUX_GP_PARTY", null, null, null, null, null, null)), null));
faq.setSimpleFAQueryParameters(Arrays.asList(new FAQueryParameter(new CodeType("TRIPID", "FA_QUERY_PARAMETER", null, null, null, null, null, null, null, null), null, null, new IDType(tripId, "EU_TRIP_ID", null, null, null, null, null, null)), new FAQueryParameter(new CodeType("CONSOLIDATED", "FA_QUERY_PARAMETER", null, null, null, null, null, null, null, null), new CodeType(consolidated ? "Y" : "N", "BOOLEAN_VALUE", null, null, null, null, null, null, null, null), null, null)));
return faq;
}
use of un.unece.uncefact.data.standard.reusableaggregatebusinessinformationentity._20.FAQuery in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityRulesModuleServiceBean method composeAndSendTripUpdateFaQueryToRules.
@Override
public void composeAndSendTripUpdateFaQueryToRules(String tripId) throws ActivityModuleException {
String sendTo = fishingTripService.getOwnerFluxPartyFromTripId(tripId);
if (StringUtils.isEmpty(sendTo)) {
throw new ActivityModuleException("Owner for the provided Trip Id [ " + tripId + " ] was not found, so the Update Trip Query cannot be executed!");
}
// TODO : Ask cedric where to get this parameter from! or ask Greg
boolean consolidated = false;
FAQuery faQueryForTrip = FaQueryFactory.createFaQueryForTrip(tripId, sendTo, consolidated);
if (faQueryForTrip == null) {
throw new ActivityModuleException("Fa Query is null!! Check the [tripId, sendTo] parameters!");
}
try {
SubscriptionPermissionResponse subscriptionPermissionResponse = permissionChecker.checkPermissionForFaQuery(faQueryForTrip);
if (SubscriptionPermissionAnswer.YES.equals(subscriptionPermissionResponse.getSubscriptionCheck())) {
final List<SubscriptionParameter> parameters = subscriptionPermissionResponse.getParameters();
String dataFlow = extractParameterByName(parameters, "DF");
// TODO : mocking up df value untill subscription is ready
if (StringUtils.isEmpty(dataFlow)) {
dataFlow = "urn:un:unece:uncefact:fisheries:FLUX:FA:EU:2";
}
// TODO : END Mocking
if (StringUtils.isEmpty(dataFlow)) {
log.error("[ERROR] Subscription is missing the dataFlow parameter! Cannot send FaQuery! ");
throw new ActivityModuleException("Subscription is missing the dataFlow parameter! Cannot send FaQuery!");
}
String logId = faQueryForTrip.getID().getValue();
FLUXFAQueryMessage fluxfaQueryMessage = new FLUXFAQueryMessage(faQueryForTrip);
final String faqReqStr = JAXBMarshaller.marshallJaxBObjectToString(fluxfaQueryMessage);
// TODO : change this values (username, senderOrReceiver (Node name?)) when got answer from CEDRIC
// senderOrReceiver : From subscription
// FR : system parameter
// username : Mock to FLUX
rulesProducerBean.sendModuleMessage(RulesModuleRequestMapper.createSendFaQueryMessageRequest(faqReqStr, "FLUX", logId, dataFlow, "BEL"), activityConsumerBean.getDestination());
} else {
throw new ActivityModuleException("The FaQuery that was build with the following parameters [" + tripId + "," + sendTo + ",consolidated : " + consolidated + "] doesn't match to any subscription!");
}
} catch (MessageException | RulesModelMapperException | ActivityModelMarshallException e) {
log.error("[ERROR] Error while trying to ActivityRulesModuleService.composeAndSendTripUpdateFaQueryToRules(...)!", e);
throw new ActivityModuleException("JAXBException or MessageException!", e);
}
}
Aggregations