use of org.geotoolkit.observation.xml.v100.MeasureType in project UVMS-ActivityModule-APP by UnionVMS.
the class ActivityEntityToModelMapper method mapFishingDurationMeasure.
private void mapFishingDurationMeasure(FishingActivity target, FishingActivityEntity source) {
if (ObjectUtils.allNotNull(target, source)) {
MeasureType measureType = new MeasureType();
Double fishingDurationMeasure = source.getFishingDurationMeasure();
if (fishingDurationMeasure != null) {
measureType.setValue(new BigDecimal(fishingDurationMeasure));
}
if (StringUtils.isNotEmpty(source.getFishingDurationMeasureCode())) {
measureType.setUnitCode(source.getFishingDurationMeasureCode());
}
if (StringUtils.isNotEmpty(source.getFishingDurationMeasureUnitCodeListVersionID())) {
measureType.setUnitCodeListVersionID(source.getFishingDurationMeasureUnitCodeListVersionID());
}
target.setFishingDurationMeasure(measureType);
}
}
use of org.geotoolkit.observation.xml.v100.MeasureType in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getFluxCharacteristics.
public static FLUXCharacteristic getFluxCharacteristics() {
CodeType typeCode = getCodeType("Code 1", "57t3yf-ght43yrf-ght56yru-ght7565h");
List<TextType> descriptions = Arrays.asList(getTextType("This is test description"));
MeasureType valueMeasure = getMeasureType(333, "C62", "57t3yf-ght43yrf-ght56yru-ght7565h");
DateTimeType valueDateTime = getDateTimeType("2016-07-01 11:15:00");
IndicatorType valueIndicator = getIndicatorType(true, "Test value", "Test format");
CodeType valueCode = getCodeType("Code Value 1", "57tr4t3yf-ght43yrf-ght56yr5u-ght75365h");
List<TextType> values = Arrays.asList(getTextType("This is sample value"));
QuantityType valueQuantity = getQuantityType(123);
List<FLUXLocation> specifiedFLUXLocations = null;
List<FLAPDocument> relatedFLAPDocuments = Arrays.asList(getFlapDocument());
FLUXCharacteristic fluxCharacteristic = new FLUXCharacteristic(typeCode, descriptions, valueMeasure, valueDateTime, valueIndicator, valueCode, values, valueQuantity, specifiedFLUXLocations, relatedFLAPDocuments);
return fluxCharacteristic;
}
use of org.geotoolkit.observation.xml.v100.MeasureType in project UVMS-ActivityModule-APP by UnionVMS.
the class MapperUtil method getStandardFishingActivity.
private static FishingActivity getStandardFishingActivity() {
List<IDType> ids = Arrays.asList(getIdType("Id_1", "fhr574fh-thrud754-kgitjf754-gjtufe89"));
CodeType typeCode = getCodeType("FISHING_OPERATION", "FLUX_FA_TYPE");
DateTimeType occurrenceDateTime = getDateTimeType("2016-07-01 11:15:00");
CodeType reasonCode = getCodeType("Reason_code_1", "FA_REASON_DEPARTURE");
CodeType vesselRelatedActivityCode = getCodeType("Vessel activity 1", "58thft-58fjd8-gt85eje-hjgute8");
CodeType fisheryTypeCode = getCodeType("Fishing_Type_code 1", "FA_FISHERY");
CodeType speciesTargetCode = getCodeType("Species code 1", "FAO_SPECIES");
QuantityType operationsQuantity = getQuantityType(100);
MeasureType fishingDurationMeasure = getMeasureType(500, "C62", "4hr2yf0-t583thf-6jgttue8-6jtie844");
List<FLAPDocument> specifiedFLAPDocument = Arrays.asList(getFlapDocument());
VesselStorageCharacteristic sourceVesselStorageCharacteristic = getVesselStorageCharacteristic();
VesselStorageCharacteristic destinationVesselStorageCharacteristic = getVesselStorageCharacteristic();
List<FACatch> specifiedFACatches = Arrays.asList(getFaCatch());
List<FLUXLocation> relatedFLUXLocations = Arrays.asList(getFluxLocation());
List<GearProblem> specifiedGearProblems = Arrays.asList(getGearProblem());
List<FLUXCharacteristic> specifiedFLUXCharacteristics = Arrays.asList(getFluxCharacteristics());
List<FishingGear> specifiedFishingGears = Arrays.asList(getFishingGear());
List<DelimitedPeriod> specifiedDelimitedPeriods = Arrays.asList(getDelimitedPeriod());
FishingTrip specifiedFishingTrip = getFishingTrip();
List<VesselTransportMeans> relatedVesselTransportMeans = Arrays.asList(getVesselTransportMeans());
// FishingActivity fishingActivity = new FishingActivity();
FishingActivity fishingActivity = new FishingActivity(ids, typeCode, occurrenceDateTime, reasonCode, vesselRelatedActivityCode, fisheryTypeCode, speciesTargetCode, operationsQuantity, fishingDurationMeasure, specifiedFACatches, relatedFLUXLocations, specifiedGearProblems, specifiedFLUXCharacteristics, specifiedFishingGears, sourceVesselStorageCharacteristic, destinationVesselStorageCharacteristic, null, specifiedFLAPDocument, specifiedDelimitedPeriods, specifiedFishingTrip, relatedVesselTransportMeans);
return fishingActivity;
}
use of org.geotoolkit.observation.xml.v100.MeasureType 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 org.geotoolkit.observation.xml.v100.MeasureType in project geotoolkit by Geomatys.
the class ObservationXMLBindingTest method marshallingTest.
/**
* Test simple Record Marshalling.
*
* @throws java.lang.Exception
*/
@Test
public void marshallingTest() throws Exception {
DirectPositionType pos = new DirectPositionType("urn:ogc:crs:espg:4326", 2, Arrays.asList(3.2, 6.5));
PointType location = new PointType("point-ID", pos);
SamplingPointType sp = new SamplingPointType("samplingID-007", "urn:sampling:test:007", "a sampling Test", new FeaturePropertyType(""), location);
PhenomenonType observedProperty = new PhenomenonType("phenomenon-007", "urn:OGC:phenomenon-007");
TimePeriodType samplingTime = new TimePeriodType("t1", "2007-01-01", "2008-09-09");
TextBlockType encoding = new TextBlockType("encoding-001", ",", "@@", ".");
List<AnyScalarPropertyType> fields = new ArrayList<>();
AnyScalarPropertyType field = new AnyScalarPropertyType("text-field-001", new Text("urn:something", "some value"));
fields.add(field);
SimpleDataRecordType record = new SimpleDataRecordType(fields);
DataArrayType array = new DataArrayType("array-001", 1, "array-001", record, encoding, "somevalue", null);
DataArrayPropertyType arrayProp = new DataArrayPropertyType(array);
ObservationType obs = new ObservationType("urn:Observation-007", "observation definition", sp, observedProperty, "urn:sensor:007", arrayProp, samplingTime);
StringWriter sw = new StringWriter();
marshaller.marshal(obs, sw);
String result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
String expResult = "<om:Observation xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:om=\"http://www.opengis.net/om/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\"" + " xmlns:swe=\"http://www.opengis.net/swe/1.0.1\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + '\n' + " <gml:name>urn:Observation-007</gml:name>" + '\n' + " <om:samplingTime>" + '\n' + " <gml:TimePeriod gml:id=\"t1\">" + '\n' + " <gml:beginPosition>2007-01-01</gml:beginPosition>" + '\n' + " <gml:endPosition>2008-09-09</gml:endPosition>" + '\n' + " </gml:TimePeriod>" + '\n' + " </om:samplingTime>" + '\n' + " <om:procedure xlink:href=\"urn:sensor:007\"/>" + '\n' + " <om:observedProperty>" + '\n' + " <swe:Phenomenon gml:id=\"phenomenon-007\">" + '\n' + " <gml:name>urn:OGC:phenomenon-007</gml:name>" + '\n' + " </swe:Phenomenon>" + '\n' + " </om:observedProperty>" + '\n' + " <om:featureOfInterest>" + '\n' + " <sampling:SamplingPoint gml:id=\"samplingID-007\">" + '\n' + " <gml:description>a sampling Test</gml:description>" + '\n' + " <gml:name>urn:sampling:test:007</gml:name>" + '\n' + " <gml:boundedBy>" + '\n' + " <gml:Null>not_bounded</gml:Null>" + '\n' + " </gml:boundedBy>" + '\n' + " <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + " <sampling:position>" + '\n' + " <gml:Point gml:id=\"point-ID\">" + '\n' + " <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </sampling:position>" + '\n' + " </sampling:SamplingPoint>" + '\n' + " </om:featureOfInterest>" + '\n' + " <om:result xsi:type=\"swe:DataArrayPropertyType\" >" + '\n' + " <swe:DataArray gml:id=\"array-001\">" + '\n' + " <swe:elementCount>" + '\n' + " <swe:Count>" + '\n' + " <swe:value>1</swe:value>" + '\n' + " </swe:Count>" + '\n' + " </swe:elementCount>" + '\n' + " <swe:elementType name=\"array-001\">" + '\n' + " <swe:SimpleDataRecord>" + '\n' + " <swe:field name=\"text-field-001\">" + '\n' + " <swe:Text definition=\"urn:something\">" + '\n' + " <swe:value>some value</swe:value>" + '\n' + " </swe:Text>" + '\n' + " </swe:field>" + '\n' + " </swe:SimpleDataRecord>" + '\n' + " </swe:elementType>" + '\n' + " <swe:encoding>" + '\n' + " <swe:TextBlock blockSeparator=\"@@\" decimalSeparator=\".\" tokenSeparator=\",\" id=\"encoding-001\"/>" + '\n' + " </swe:encoding>" + '\n' + " <swe:values>somevalue</swe:values>" + '\n' + " </swe:DataArray>" + '\n' + " </om:result>" + '\n' + "</om:Observation>\n";
assertXmlEquals(expResult, result, "xmlns:*");
UnitOfMeasureEntry uom = new UnitOfMeasureEntry("m", "meters", "distance", "meters");
MeasureType meas = new MeasureType(uom, 7);
MeasurementType measmt = new MeasurementType("urn:Observation-007", "observation definition", sp, observedProperty, "urn:sensor:007", meas, samplingTime);
sw = new StringWriter();
marshaller.marshal(measmt, sw);
result = sw.toString();
// we remove the first line
result = result.substring(result.indexOf("?>") + 2).trim();
expResult = "<om:Measurement xmlns:sampling=\"http://www.opengis.net/sampling/1.0\"" + " xmlns:om=\"http://www.opengis.net/om/1.0\"" + " xmlns:xlink=\"http://www.w3.org/1999/xlink\"" + " xmlns:gml=\"http://www.opengis.net/gml\"" + " xmlns:swe=\"http://www.opengis.net/swe/1.0.1\"" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + '\n' + " <gml:name>urn:Observation-007</gml:name>" + '\n' + " <om:samplingTime>" + '\n' + " <gml:TimePeriod gml:id=\"t1\">" + '\n' + " <gml:beginPosition>2007-01-01</gml:beginPosition>" + '\n' + " <gml:endPosition>2008-09-09</gml:endPosition>" + '\n' + " </gml:TimePeriod>" + '\n' + " </om:samplingTime>" + '\n' + " <om:procedure xlink:href=\"urn:sensor:007\"/>" + '\n' + " <om:observedProperty>" + '\n' + " <swe:Phenomenon gml:id=\"phenomenon-007\">" + '\n' + " <gml:name>urn:OGC:phenomenon-007</gml:name>" + '\n' + " </swe:Phenomenon>" + '\n' + " </om:observedProperty>" + '\n' + " <om:featureOfInterest>" + '\n' + " <sampling:SamplingPoint gml:id=\"samplingID-007\">" + '\n' + " <gml:description>a sampling Test</gml:description>" + '\n' + " <gml:name>urn:sampling:test:007</gml:name>" + '\n' + " <gml:boundedBy>" + '\n' + " <gml:Null>not_bounded</gml:Null>" + '\n' + " </gml:boundedBy>" + '\n' + " <sampling:sampledFeature xlink:href=\"\"/>" + '\n' + " <sampling:position>" + '\n' + " <gml:Point gml:id=\"point-ID\">" + '\n' + " <gml:pos srsName=\"urn:ogc:crs:espg:4326\" srsDimension=\"2\">3.2 6.5</gml:pos>" + '\n' + " </gml:Point>" + '\n' + " </sampling:position>" + '\n' + " </sampling:SamplingPoint>" + '\n' + " </om:featureOfInterest>" + '\n' + " <om:result xsi:type=\"om:MeasureType\" uom=\"meters\">7.0</om:result>" + '\n' + "</om:Measurement>\n";
assertXmlEquals(expResult, result, "xmlns:*");
ObservationCollectionType collection = new ObservationCollectionType();
collection.add(measmt);
sw = new StringWriter();
marshaller.marshal(collection, sw);
result = sw.toString();
// System.out.println(result);
collection = new ObservationCollectionType();
collection.add(obs.getTemporaryTemplate("temporaryName", samplingTime));
sw = new StringWriter();
marshaller.marshal(collection, sw);
result = sw.toString();
}
Aggregations