Search in sources :

Example 1 with ProtocolLinkedAttributeImport

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);
}
Also used : ProtocolLinkedAttributeImport(org.openremote.agent.protocol.ProtocolLinkedAttributeImport) AssetAttribute(org.openremote.model.asset.AssetAttribute) Protocol(org.openremote.agent.protocol.Protocol) Pair(org.openremote.model.util.Pair)

Aggregations

Protocol (org.openremote.agent.protocol.Protocol)1 ProtocolLinkedAttributeImport (org.openremote.agent.protocol.ProtocolLinkedAttributeImport)1 AssetAttribute (org.openremote.model.asset.AssetAttribute)1 Pair (org.openremote.model.util.Pair)1