Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

package org.sensorhub.api.processing;

import org.sensorhub.api.config.DisplayInfo;
import org.sensorhub.api.module.ModuleConfig;
import org.sensorhub.api.sensor.IdentificationInfo;


/**
Expand All @@ -27,5 +29,8 @@
*/
public class ProcessConfig extends ModuleConfig
{


@DisplayInfo(label = "Identification Info", desc="Information used to uniquely identify this system and its responsible parties")
public IdentificationInfo identificationInfo;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2026 GeoRobotix Innovative Research, LLC. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/

package org.sensorhub.api.sensor;

import org.sensorhub.api.config.DisplayInfo;
import org.vast.util.ResponsibleParty;

import java.util.Collection;

public class IdentificationInfo {

@DisplayInfo.Required
@DisplayInfo(label = "System UID", desc = "Overrides this resource's system UID")
public String systemUID;

@DisplayInfo(label = "System Kind UID", desc = "Optional field overrides this resource's system kind/type UID")
public String systemKindUID;

@DisplayInfo(label = "Responsible Parties", desc = "Contact/business information of system/device operators and technical support")
public Collection<ResponsibleParty> responsibleParties;

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class SensorConfig extends ModuleConfig

@DisplayInfo(desc="Time at which the SensorML description was last updated")
public Date lastUpdated = new Date();


@DisplayInfo(label = "Identification Info", desc="Information used to uniquely identify this system and its responsible parties")
public IdentificationInfo identificationInfo;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;

import net.opengis.sensorml.v20.AbstractProcess;
import net.opengis.swe.v20.DataComponent;
import org.sensorhub.api.command.IStreamingControlInterface;
Expand All @@ -30,6 +31,7 @@
import org.sensorhub.api.system.ISystemGroupDriver;
import org.sensorhub.api.utils.OshAsserts;
import org.sensorhub.impl.module.AbstractModule;
import org.sensorhub.utils.IdentificationInfoUtils;
import org.vast.ogc.gml.IFeature;


Expand Down Expand Up @@ -104,6 +106,9 @@ protected void afterInit() throws SensorHubException
{
if (processDescription == null)
throw new IllegalStateException("No process description created during init");

IdentificationInfoUtils.apply(config.identificationInfo, processDescription);

OshAsserts.checkValidUID(processDescription.getUniqueIdentifier());

if (inputs.isEmpty() && outputs.isEmpty())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.sensorhub.api.sensor.SensorException;
import org.sensorhub.api.utils.OshAsserts;
import org.sensorhub.impl.module.AbstractModule;
import org.sensorhub.utils.IdentificationInfoUtils;
import org.sensorhub.utils.MsgUtils;
import org.vast.ogc.gml.IFeature;
import org.vast.ogc.om.SamplingPoint;
Expand Down Expand Up @@ -151,10 +152,17 @@ protected void beforeInit() throws SensorHubException
@Override
protected void afterInit() throws SensorHubException
{
// override unique ID using identification info if not
if (config.identificationInfo != null)
{
OshAsserts.checkValidUID(config.identificationInfo.systemUID);
this.uniqueID = config.identificationInfo.systemUID;
this.randomUniqueID = false;
}
// generate random unique ID in case sensor driver hasn't generate one
// if a random UUID has already been generated, it will be restored by
// loadState() method that is called after init()
if (this.uniqueID == null)
else if (this.uniqueID == null)
{
String uuid = UUID.randomUUID().toString();
this.uniqueID = UUID_URI_PREFIX + uuid;
Expand All @@ -164,7 +172,7 @@ protected void afterInit() throws SensorHubException

this.randomUniqueID = true;
}

Comment thread
earocorn marked this conversation as resolved.
Resolved
// set last description update time if provided in config
if (config.lastUpdated != null)
this.lastUpdatedSensorDescription = config.lastUpdated.getTime();
Expand Down Expand Up @@ -202,7 +210,7 @@ protected void afterInit() throws SensorHubException
if (orientationOutput == null)
addOrientationOutput(Double.NaN);
}

Comment thread
earocorn marked this conversation as resolved.
Resolved
super.afterInit();
}

Expand Down Expand Up @@ -543,6 +551,8 @@ protected void updateSensorDescription()
if (!sensorDescription.isSetIdentifier())
sensorDescription.setUniqueIdentifier(uniqueID);

IdentificationInfoUtils.apply(config.identificationInfo, sensorDescription);

// name & description
sensorDescription.setDefinition(SWEConstants.DEF_SENSOR);
if (sensorDescription.getName() == null && config.name != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2026 GeoRobotix Innovative Research, LLC. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/

package org.sensorhub.utils;

import net.opengis.gml.v32.impl.ReferenceImpl;
import net.opengis.sensorml.v20.AbstractProcess;
import net.opengis.sensorml.v20.impl.ContactListImpl;
import org.isotc211.v2005.gco.impl.CodeListValueImpl;
import org.isotc211.v2005.gmd.impl.CIAddressImpl;
import org.isotc211.v2005.gmd.impl.CIContactImpl;
import org.isotc211.v2005.gmd.impl.CIOnlineResourceImpl;
import org.isotc211.v2005.gmd.impl.CIResponsiblePartyImpl;
import org.isotc211.v2005.gmd.impl.CITelephoneImpl;
import org.sensorhub.api.sensor.IdentificationInfo;
import org.sensorhub.api.utils.OshAsserts;


/** Applies configured identification overrides to SensorML descriptions. */
public final class IdentificationInfoUtils
{
private IdentificationInfoUtils()
{
}


public static void apply(IdentificationInfo info, AbstractProcess description)
{
if (info == null)
return;

OshAsserts.checkValidUID(info.systemUID);
description.setUniqueIdentifier(info.systemUID);
if (info.systemKindUID != null && !info.systemKindUID.isBlank())
{
OshAsserts.checkValidUID(info.systemKindUID);
description.setTypeOf(new ReferenceImpl(info.systemKindUID));
}

if (info.responsibleParties == null || info.responsibleParties.isEmpty())
return;

var contacts = new ContactListImpl();
for (var party : info.responsibleParties)
{
var contact = new CIResponsiblePartyImpl();
contact.setIndividualName(party.getIndividualName());
contact.setOrganisationName(party.getOrganizationName());
contact.setPositionName(party.getPositionName());
if (party.getRole() != null && !party.getRole().isBlank())
{
var role = new CodeListValueImpl(party.getRole());
var codeList = party.getRoleCodeList();
role.setCodeList(codeList == null || codeList.isBlank()
? "http://www.isotc211.org/2005/resources/codeList.xml#CI_RoleCode"
: codeList);
role.setCodeListValue(party.getRole());
contact.setRole(role);
}

if (party.hasContactInfo())
{
var details = new CIContactImpl();
contact.setContactInfo(details);
details.setHoursOfService(party.getHoursOfService());
details.setContactInstructions(party.getContactInstructions());
if (party.hasAddress())
{
var address = new CIAddressImpl();
address.getDeliveryPointList().addAll(party.getDeliveryPoints());
address.setCity(party.getCity());
address.setAdministrativeArea(party.getAdministrativeArea());
address.setPostalCode(party.getPostalCode());
address.setCountry(party.getCountry());
address.getElectronicMailAddressList().addAll(party.getEmails());
details.setAddress(address);
}
if (!party.getVoiceNumbers().isEmpty() || !party.getFaxNumbers().isEmpty())
{
var phone = new CITelephoneImpl();
phone.getVoiceList().addAll(party.getVoiceNumbers());
phone.getFacsimileList().addAll(party.getFaxNumbers());
details.setPhone(phone);
}
if (party.getWebsite() != null)
{
var website = new CIOnlineResourceImpl();
website.setLinkage(party.getWebsite());
details.setOnlineResource(website);
}
}
contacts.addContact(contact);
}
description.getContactsList().clear();
description.addContacts(contacts);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/***************************** BEGIN LICENSE BLOCK ***************************

The contents of this file are subject to the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one
at http://mozilla.org/MPL/2.0/.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.

Copyright (C) 2026 GeoRobotix Innovative Research, LLC. All Rights Reserved.

******************************* END LICENSE BLOCK ***************************/

package org.sensorhub.impl.sensor;

import static org.junit.Assert.*;
import java.util.List;
import org.junit.Test;
import org.sensorhub.api.sensor.IdentificationInfo;
import org.sensorhub.api.sensor.SensorConfig;
import org.vast.util.ResponsibleParty;

public class TestIdentificationInfo
{
@Test
public void overridesSurviveDescriptionRegeneration() throws Exception
{
var config = new SensorConfig();
config.identificationInfo = new IdentificationInfo();
config.identificationInfo.systemUID = "urn:test:configured";
config.identificationInfo.systemKindUID = "urn:test:kind";
var party = new ResponsibleParty();
party.setOrganizationName("Operator");
party.getEmails().addAll(List.of("first@example.org", "second@example.org"));
party.getVoiceNumbers().addAll(List.of("123", "456"));
party.setWebsite("https://example.org");
config.identificationInfo.responsibleParties = List.of(party);

var sensor = new FakeSensor();
sensor.init(config);
assertEquals(config.identificationInfo.systemUID, sensor.getUniqueIdentifier());
assertFalse(sensor.randomUniqueID);
for (int i = 0; i < 2; i++)
{
var description = sensor.getCurrentDescription();
assertEquals(sensor.getUniqueIdentifier(), description.getUniqueIdentifier());
assertEquals(config.identificationInfo.systemKindUID, description.getTypeOf().getHref());
assertEquals(1, description.getContactsList().size());
var contact = description.getContactsList().get(0).getContactList().get(0);
assertEquals("Operator", contact.getOrganisationName());
assertEquals(party.getEmails(), contact.getContactInfo().getAddress().getElectronicMailAddressList());
assertEquals(party.getVoiceNumbers(), contact.getContactInfo().getPhone().getVoiceList());
assertEquals(party.getWebsite(), contact.getContactInfo().getOnlineResource().getLinkage());
sensor.updateSensorDescription();
}
}
@Test
public void rolesSerializeWithOptionalCodeList() throws Exception
{
for (String codeList : new String[] {null, "", "urn:test:roles"})
{
var info = new IdentificationInfo();
info.systemUID = "urn:test:configured";
var party = new ResponsibleParty();
party.setRole("operator");
party.setRoleCodeList(codeList);
info.responsibleParties = List.of(party);
var description = new org.vast.sensorML.PhysicalSystemImpl();
org.sensorhub.utils.IdentificationInfoUtils.apply(info, description);

var output = new java.io.StringWriter();
var writer = new com.ctc.wstx.stax.WstxOutputFactory().createXMLStreamWriter(output);
var bindings = new org.vast.sensorML.SMLStaxBindings();
bindings.setNamespacePrefixes(writer);
bindings.declareNamespacesOnRootElement();
bindings.writeDescribedObject(writer, description);
writer.close();
assertTrue(output.toString().contains("codeListValue=\"operator\""));
assertTrue(output.toString().contains(codeList == null || codeList.isBlank()
? "codeList.xml#CI_RoleCode" : codeList));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,31 @@ protected void addMethodProperties(String prefix, Object bean)

String fullName = prefix + prop.getName();

// Getter-backed collections need the same list editor as public fields.
// In particular, live collections often have no setter.
Field field = fieldMap.get(prop.getName());
if (Collection.class.isAssignableFrom(prop.getPropertyType()) && prop.getReadMethod() != null
&& field.getGenericType() instanceof ParameterizedType)
{
var listType = (ParameterizedType)field.getGenericType();
if (listType.getActualTypeArguments()[0] instanceof Class<?>)
{
try
{
field.setAccessible(true);
var list = (Collection<?>)prop.getReadMethod().invoke(bean);
var elementType = (Class<?>)listType.getActualTypeArguments()[0];
var container = new MyBeanItemContainer<Object>(list, elementType, fullName + PROP_SEPARATOR);
addItemProperty(fullName, new ContainerProperty(bean, field, container));
continue;
}
catch (ReflectiveOperationException e)
{
throw new IllegalStateException("Cannot access property " + fullName, e);
}
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid this by making it an ArrayList in the config rather than a Collection?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that the collection/list (these are already List<String>) fields in ResponsibleParty are protected, so those fields do not show up in the UI. This seems to be an existing bug as the list fields don't show up in the UI from OGCServiceConfig. For example, go to SOS Service -> Capabilities Info, and you will see that the list fields (voiceNumbers, faxNumbers, deliveryPoints, and emails) do not show up.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The unit test in TestResponsiblePartyProperties is for confirming this.

//System.out.println(prop.getName() + ", get=" + prop.getReadMethod() + ", set=" + prop.getWriteMethod() + ", hidden=" + prop.isHidden());
addItemProperty(fullName, new MethodProperty(prop.getPropertyType(), bean, prop.getReadMethod(), prop.getWriteMethod()));
}
Expand Down
Loading
Loading