use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeEventOutgoingServiceBean method getSetUnsentMessageTypePropertiesForPoll.
private List<UnsentMessageTypeProperty> getSetUnsentMessageTypePropertiesForPoll(CommandType commandType) throws ExchangeLogException {
List<UnsentMessageTypeProperty> properties = new ArrayList<>();
if (commandType.getPoll() != null) {
String connectId = ExchangeLogMapper.getConnectId(commandType.getPoll());
Asset asset = getAsset(connectId);
properties = ExchangeLogMapper.getPropertiesForPoll(commandType.getPoll(), asset.getName());
} else if (commandType.getEmail() != null) {
properties = ExchangeLogMapper.getPropertiesForEmail(commandType.getEmail());
}
return properties;
}
use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-ActivityModule-APP by UnionVMS.
the class FishingTripServiceBean method getMdrCodesEnrichWithAssetsModuleDataIfNeeded.
// To process MDR code list and compare with database:vesselTransportMeansDao and then enrich with asset module
private void getMdrCodesEnrichWithAssetsModuleDataIfNeeded(VesselDetailsDTO vesselDetailsDTO) {
final String ACRONYM = "FLUX_VESSEL_ID_TYPE";
final String filter = "*";
final List<String> columnsList = new ArrayList<String>();
Integer nrOfResults = 9999999;
if (vesselDetailsDTO != null) {
List<String> codeList = null;
try {
codeList = mdrModuleService.getAcronymFromMdr(ACRONYM, filter, columnsList, nrOfResults, "code").get("code");
Set<AssetIdentifierDto> vesselIdentifiers = vesselDetailsDTO.getVesselIdentifiers();
List<AssetListCriteriaPair> assetListCriteriaPairs = BaseMapper.mapMdrCodeListToAssetListCriteriaPairList(vesselIdentifiers, codeList);
log.info("Asset Criteria Pair List size is :" + assetListCriteriaPairs.size());
log.info("Got code list of size from mdr:" + codeList.size());
if (null != assetListCriteriaPairs && !CollectionUtils.isEmpty(assetListCriteriaPairs)) {
AssetListCriteria criteria = new AssetListCriteria();
// need to set this
criteria.setIsDynamic(false);
criteria.getCriterias().addAll(assetListCriteriaPairs);
AssetListQuery query = new AssetListQuery();
AssetListPagination assetListPagination = new AssetListPagination();
// need to set this
assetListPagination.setPage(1);
// need to set this
assetListPagination.setListSize(1000);
query.setPagination(assetListPagination);
query.setAssetSearchCriteria(criteria);
List<Asset> assetList = assetModuleService.getAssetListResponse(query);
if (null != assetList && !CollectionUtils.isEmpty(assetList)) {
vesselDetailsDTO.enrichIdentifiers(assetList.get(0));
}
}
} catch (ServiceException e) {
log.error("Error while trying to send message to Assets module.", e);
}
}
}
use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-ActivityModule-APP by UnionVMS.
the class VesselDetailsDTOTest method testEnrichIdentifiers.
@Test
public void testEnrichIdentifiers() throws Exception {
Asset asset = new Asset();
asset.setCfr("cfrValueFromAsset");
AssetIdentifierDto cfr = new AssetIdentifierDto(CFR);
AssetIdentifierDto ext = new AssetIdentifierDto(EXT_MARK);
ext.setFaIdentifierId("extMarkingFromActivity");
AssetIdentifierDto ircs = new AssetIdentifierDto(IRCS);
ircs.setFaIdentifierId("ircsFromActivity");
AssetIdentifierDto iccat = new AssetIdentifierDto(ICCAT);
iccat.setFaIdentifierId("iccat");
AssetIdentifierDto uvi = new AssetIdentifierDto(UVI);
Set<AssetIdentifierDto> identifiers = newSet(ircs, cfr, iccat, uvi, ext);
VesselDetailsDTO dto = builder().vesselIdentifiers(identifiers).build();
dto.enrichIdentifiers(asset);
Set<AssetIdentifierDto> vesselIdentifiers = dto.getVesselIdentifiers();
ImmutableMap<VesselIdentifierSchemeIdEnum, AssetIdentifierDto> map = Maps.uniqueIndex(vesselIdentifiers, new Function<AssetIdentifierDto, VesselIdentifierSchemeIdEnum>() {
public VesselIdentifierSchemeIdEnum apply(AssetIdentifierDto from) {
return from.getIdentifierSchemeId();
}
});
AssetIdentifierDto cfr_ = map.get(CFR);
AssetIdentifierDto ext_ = map.get(EXT_MARK);
AssetIdentifierDto ircs_ = map.get(IRCS);
AssetIdentifierDto uvi_ = map.get(UVI);
AssetIdentifierDto iccat_ = map.get(ICCAT);
assertTrue(uvi.equals(uvi_));
assertTrue(ircs.equals(ircs_));
assertTrue(iccat.equals(iccat_));
}
use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.
the class FluxMessageReceiverBeanIT method postRequestTypeRequestSuccessTest.
/**
* Post request type request success test.
*
* @throws Exception the exception
*/
@Test
@Ignore
public void postRequestTypeRequestSuccessTest() throws Exception {
Asset testAsset = AssetTestHelper.createTestAsset();
MobileTerminalType mobileTerminalType = MobileTerminalTestHelper.createMobileTerminalType();
MobileTerminalTestHelper.assignMobileTerminal(testAsset, mobileTerminalType);
GregorianCalendar calendar = new GregorianCalendar();
calendar.setTime(new Date());
BridgeConnectorPortType bridgeConnectorPortType = createBridgeConnector();
RequestType requestType = new RequestType();
FLUXVesselPositionMessage fLUXVesselPositionMessage = new FLUXVesselPositionMessage();
VesselTransportMeansType vesselTransportMeansType = new VesselTransportMeansType();
IDType cfrId = new IDType();
cfrId.setSchemeID("CFR");
cfrId.setValue(testAsset.getCfr());
vesselTransportMeansType.getIDS().add(cfrId);
IDType ircsId = new IDType();
ircsId.setSchemeID("IRCS");
ircsId.setValue(testAsset.getIrcs());
vesselTransportMeansType.getIDS().add(ircsId);
// IDType extMarkingId = new IDType();
// extMarkingId.setSchemeID("EXT_MARKING");
// extMarkingId.setValue(testAsset.getExternalMarking());
// vesselTransportMeansType.getIDS().add(extMarkingId);
VesselCountryType vesselCountry = new VesselCountryType();
IDType countryId = new IDType();
countryId.setValue("SWE");
vesselCountry.setID(countryId);
vesselTransportMeansType.setRegistrationVesselCountry(vesselCountry);
VesselPositionEventType vesselPositionEventType = new VesselPositionEventType();
MeasureType measureType = new MeasureType();
measureType.setValue(new BigDecimal(282));
vesselPositionEventType.setCourseValueMeasure(measureType);
DateTimeType posDateTime = new DateTimeType();
posDateTime.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
vesselPositionEventType.setObtainedOccurrenceDateTime(posDateTime);
VesselGeographicalCoordinateType cordinates = new VesselGeographicalCoordinateType();
MeasureType longitude = new MeasureType();
longitude.setValue(new BigDecimal(21.5740000000));
cordinates.setLongitudeMeasure(longitude);
MeasureType latitude = new MeasureType();
latitude.setValue(new BigDecimal(59.6480000000));
cordinates.setLatitudeMeasure(latitude);
vesselPositionEventType.setSpecifiedVesselGeographicalCoordinate(cordinates);
MeasureType speedValue = new MeasureType();
speedValue.setValue(new BigDecimal(7.5));
vesselPositionEventType.setSpeedValueMeasure(speedValue);
CodeType typeCodeValue = new CodeType();
typeCodeValue.setValue("POS");
vesselPositionEventType.setTypeCode(typeCodeValue);
vesselTransportMeansType.getSpecifiedVesselPositionEvents().add(vesselPositionEventType);
fLUXVesselPositionMessage.setVesselTransportMeans(vesselTransportMeansType);
FLUXReportDocumentType fluxReportDocumentType = new FLUXReportDocumentType();
DateTimeType dateTimeType = new DateTimeType();
dateTimeType.setDateTime(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
fluxReportDocumentType.setCreationDateTime(dateTimeType);
FLUXPartyType fLUXPartyType = new FLUXPartyType();
fLUXPartyType.getIDS().add(countryId);
fluxReportDocumentType.setOwnerFLUXParty(fLUXPartyType);
TextType textType = new TextType();
fluxReportDocumentType.setPurpose(textType);
CodeType purposeCode = new CodeType();
purposeCode.setValue("9");
fluxReportDocumentType.setPurposeCode(purposeCode);
IDType idType = new IDType();
fluxReportDocumentType.setReferencedID(idType);
CodeType typeCode = new CodeType();
fluxReportDocumentType.setTypeCode(typeCode);
fLUXVesselPositionMessage.setFLUXReportDocument(fluxReportDocumentType);
requestType.setAny(createAnyElement(fLUXVesselPositionMessage));
requestType.setAD("SWE");
requestType.setAR(true);
requestType.setDF("df");
requestType.setON("on");
requestType.setTO(1234);
requestType.setTODT(DatatypeFactory.newInstance().newXMLGregorianCalendar(calendar));
ResponseType responseType = bridgeConnectorPortType.post(requestType);
assertNotNull(responseType);
assertEquals("OK", responseType.getStatus());
Thread.sleep(7500);
List<String> connectIds = new ArrayList<>();
connectIds.add(testAsset.getEventHistory().getEventId());
final HttpResponse response = Request.Post(getBaseUrl() + "movement/rest/movement/latest").setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).bodyByteArray(writeValueAsString(connectIds).getBytes()).execute().returnResponse();
List dataList = checkSuccessResponseReturnType(response, List.class);
assertEquals("Expect one position in movement db", 1, dataList.size());
}
use of eu.europa.ec.fisheries.wsdl.asset.types.Asset in project UVMS-Docker by UnionVMS.
the class PollRestIT method inactivateProgramPollTest.
/**
* Inactivate program poll test.
*
* @throws Exception
* the exception
*/
@Test
public void inactivateProgramPollTest() throws Exception {
Asset testAsset = AssetTestHelper.createTestAsset();
Map<String, Object> programPollDataMap = MobileTerminalTestHelper.createPoll_Helper(testAsset);
ArrayList sendPolls = (ArrayList) programPollDataMap.get("sentPolls");
String uid = (String) sendPolls.get(0);
// start it
{
final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/start/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
}
// inactivate it
final HttpResponse response = Request.Put(getBaseUrl() + "mobileterminal/rest/poll/inactivate/" + uid).setHeader("Content-Type", "application/json").setHeader("Authorization", getValidJwtToken()).execute().returnResponse();
Map<String, Object> dataMap = checkSuccessResponseReturnMap(response);
ArrayList values = (ArrayList) dataMap.get("value");
assertNotNull(values);
assertTrue(values.size() == 10);
}
Aggregations