use of org.openremote.agent.protocol.ProtocolLinkedAttributeImport in project openremote by openremote.
the class LocalAgentConnector method getDiscoveredLinkedAttributes.
@Override
public Asset[] getDiscoveredLinkedAttributes(AttributeRef protocolConfigurationRef, FileInfo fileInfo) throws IllegalArgumentException, UnsupportedOperationException, IllegalStateException {
Optional<Pair<Protocol, AssetAttribute>> protocolAndConfigOptional = getProtocolAndConfig(protocolConfigurationRef);
if (!protocolAndConfigOptional.isPresent()) {
throw new IllegalArgumentException("Protocol not found for: " + protocolConfigurationRef);
}
Pair<Protocol, AssetAttribute> protocolAndConfig = protocolAndConfigOptional.get();
// Check protocol is of correct type
if (!(protocolAndConfigOptional.get().key instanceof ProtocolLinkedAttributeImport)) {
LOG.info("Protocol not of type '" + ProtocolLinkedAttributeImport.class.getSimpleName() + "'");
throw new UnsupportedOperationException("Protocol doesn't support linked attribute import:" + protocolAndConfigOptional.get().key.getProtocolDisplayName());
}
ProtocolLinkedAttributeImport discoveryProtocol = (ProtocolLinkedAttributeImport) protocolAndConfig.key;
return discoveryProtocol.discoverLinkedAssetAttributes(protocolAndConfig.value, fileInfo);
}
Aggregations