Search in sources :

Example 1 with AssetProperty

use of software.amazon.awssdk.services.iotsitewise.model.AssetProperty in project aws-iot-greengrass-edge-connector-for-kinesis-video-stream by awslabs.

the class SiteWiseManager method buildEdgeConnectorForKVSConfiguration.

private EdgeConnectorForKVSConfiguration buildEdgeConnectorForKVSConfiguration(String cameraSiteWiseAssetId) throws IllegalAccessException {
    DescribeAssetResponse assetResponse = siteWiseClient.describeAsset(cameraSiteWiseAssetId);
    EdgeConnectorForKVSConfiguration edgeConnectorForKVSConfiguration = new EdgeConnectorForKVSConfiguration();
    edgeConnectorForKVSConfiguration.setSiteWiseAssetId(cameraSiteWiseAssetId);
    for (AssetProperty assetProperty : assetResponse.assetProperties()) {
        GetAssetPropertyValueResponse result;
        Field[] fields = edgeConnectorForKVSConfiguration.getClass().getDeclaredFields();
        for (Field field : fields) {
            if (field.getName().equalsIgnoreCase(assetProperty.name())) {
                result = siteWiseClient.getAssetPropertyValue(cameraSiteWiseAssetId, assetProperty.id());
                if (result != null && result.propertyValue() != null) {
                    if (field.getType() == String.class) {
                        field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().stringValue());
                        break;
                    } else if (field.getType() == Integer.TYPE || field.getType() == Integer.class) {
                        field.set(edgeConnectorForKVSConfiguration, result.propertyValue().value().integerValue());
                        break;
                    }
                }
            }
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOADED_TIME_RANGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setVideoUploadedTimeRangePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_RECORDED_TIME_RANGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setVideoRecordedTimeRangePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_CACHED_VIDEO_AGE_OUT_ON_EDGE_MEASUREMENT_NAME)) {
            edgeConnectorForKVSConfiguration.setCachedVideoAgeOutOnEdgePropertyId(assetProperty.id());
        }
        if (assetProperty.name().equalsIgnoreCase(Constants.SITE_WISE_VIDEO_UPLOAD_REQUEST_MEASUREMENT_NAME)) {
            if (assetProperty.notification().state() == PropertyNotificationState.ENABLED) {
                edgeConnectorForKVSConfiguration.setVideoUploadRequestMqttTopic(assetProperty.notification().topic());
            } else {
                log.warn("Video Upload Request MQTT Notification Disabled for Asset Id " + cameraSiteWiseAssetId);
            }
        }
    }
    return edgeConnectorForKVSConfiguration;
}
Also used : Field(java.lang.reflect.Field) DescribeAssetResponse(software.amazon.awssdk.services.iotsitewise.model.DescribeAssetResponse) GetAssetPropertyValueResponse(software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse) AssetProperty(software.amazon.awssdk.services.iotsitewise.model.AssetProperty) EdgeConnectorForKVSConfiguration(com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)

Aggregations

EdgeConnectorForKVSConfiguration (com.aws.iot.edgeconnectorforkvs.model.EdgeConnectorForKVSConfiguration)1 Field (java.lang.reflect.Field)1 AssetProperty (software.amazon.awssdk.services.iotsitewise.model.AssetProperty)1 DescribeAssetResponse (software.amazon.awssdk.services.iotsitewise.model.DescribeAssetResponse)1 GetAssetPropertyValueResponse (software.amazon.awssdk.services.iotsitewise.model.GetAssetPropertyValueResponse)1