private async Task <RawDataInformationDto[]> ListRawDataByUuidList(RawDataEntityDto entity, string[] uuids, IFilterCondition filter, CancellationToken cancellationToken = default)
        {
            StringUuidTools.CheckUuids(entity, uuids);

            var requestPath          = $"rawData/{entity}";
            var parameterDefinitions = new List <ParameterDefinition>();

            if (filter != null)
            {
                var filterTree      = ((FilterCondition)filter).BuildFilterTree();
                var filterString    = new FilterTreeFormatter().FormatString(filterTree);
                var filterParameter = ParameterDefinition.Create("filter", filterString);
                parameterDefinitions.Add(filterParameter);
            }

            //Split into multiple parameter sets to limit uuid parameter lenght
            var splitter            = new ParameterSplitter(this, requestPath);
            var collectionParameter = CollectionParameterFactory.Create("uuids", uuids);
            var parameterSets       = splitter.SplitAndMerge(collectionParameter, parameterDefinitions);

            //Execute requests in parallel
            var requests = parameterSets
                           .Select(set => RequestBuilder.CreateGet(requestPath, set.ToArray()))
                           .Select(request => _RestClient.Request <RawDataInformationDto[]>(request, cancellationToken));
            var result = await Task.WhenAll(requests).ConfigureAwait(false);

            return(result.SelectMany(r => r).ToArray());
        }
예제 #2
0
        /// <exception cref="ArgumentOutOfRangeException">The syntax of any uuid in <paramref name="uuids"/> is invalid.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="uuids"/> is <see langword="null" />.</exception>
        public static void CheckUuids(RawDataEntityDto entity, [NotNull] IEnumerable <string> uuids)
        {
            if (uuids == null)
            {
                throw new ArgumentNullException(nameof(uuids));
            }

            foreach (var uuid in uuids)
            {
                CheckUuid(entity, uuid);
            }
        }
예제 #3
0
        /// <exception cref="ArgumentOutOfRangeException">The syntax of <paramref name="uuid"/> is invalid.</exception>
        public static void CheckUuid(RawDataEntityDto entity, string uuid)
        {
            var uuidMustBeComposed = entity == RawDataEntityDto.Value;

            if (uuidMustBeComposed && !IsStringUuidPair(uuid))
            {
                throw new ArgumentOutOfRangeException(
                          nameof(uuid),
                          $"'{uuid}' is not a valid measurement value identifier. " +
                          "Measurement value identifiers are expected in this format: MeasurementUuid|CharacteristicUuid.");
            }

            if (!uuidMustBeComposed)
            {
                StringUuidToGuid(uuid);
            }
        }
        private Task <RawDataInformationDto[]> ListRawDataForAllEntities(RawDataEntityDto entity, [NotNull] IFilterCondition filter, CancellationToken cancellationToken = default)
        {
            if (filter == null)
            {
                throw new ArgumentNullException(nameof(filter));
            }

            var requestPath = $"rawData/{entity}";

            var parameterDefinitionList = new List <ParameterDefinition>();
            var filterTree      = ((FilterCondition)filter).BuildFilterTree();
            var filterString    = new FilterTreeFormatter().FormatString(filterTree);
            var filterParameter = ParameterDefinition.Create("filter", filterString);

            parameterDefinitionList.Add(filterParameter);

            return(_RestClient.Request <RawDataInformationDto[]>(RequestBuilder.CreateGet(requestPath, parameterDefinitionList.ToArray()), cancellationToken));
        }
        /// <summary>
        /// Fetches a list of raw data information for the <paramref name="entity"/> identified by <paramref name="uuids"/> and filtered by <paramref name="filter"/>.
        /// Either <paramref name="uuids" /> or <paramref name="filter"/> must have a value.
        /// </summary>
        /// <param name="entity">The <see cref="RawDataEntityDto"/> the raw data information should be fetched for.</param>
        /// <param name="uuids">The list of value uuids the data information should be fetched for.</param>
        /// <param name="filter">A condition used to filter the result.</param>
        /// <param name="cancellationToken">A token to cancel the asynchronous operation.</param>
        /// <exception cref="InvalidOperationException">No uuids and no filter was specified.</exception>
        /// <exception cref="OperationNotSupportedOnServerException">An attribute filter for raw data is not supported by this server.</exception>
        public async Task <RawDataInformationDto[]> ListRawData(RawDataEntityDto entity, string[] uuids, IFilterCondition filter = null, CancellationToken cancellationToken = default)
        {
            if (uuids == null && filter == null)
            {
                throw new InvalidOperationException("Either a filter or at least one uuid must be specified.");
            }

            if (filter != null)
            {
                var featureMatrix = await GetFeatureMatrixInternal(FetchBehavior.FetchIfNotCached, cancellationToken).ConfigureAwait(false);

                if (!featureMatrix.SupportsRawDataAttributeFilter)
                {
                    throw new OperationNotSupportedOnServerException(
                              "An attribute filter for raw data is not supported by this server.",
                              RawDataServiceFeatureMatrix.RawDataAttributeFilterMinVersion,
                              featureMatrix.CurrentInterfaceVersion);
                }
            }

            return(uuids != null
                                ? await ListRawDataByUuidList(entity, uuids, filter, cancellationToken).ConfigureAwait(false)
                                : await ListRawDataForAllEntities(entity, filter, cancellationToken).ConfigureAwait(false));
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RawDataTargetEntityDto"/> class based on the specified <code>uuid</code> and <code>entity</code>.
 /// </summary>
 /// <param name="entity">The entity to which this raw data object belongs to.</param>
 /// <param name="uuid">The uuid of the entity.</param>
 public RawDataTargetEntityDto(RawDataEntityDto entity, string uuid)
 {
     Entity = entity;
     Uuid   = uuid;
 }
예제 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="RawDataTargetEntityDto"/> class based on the specified <code>uuid</code> and <code>entity</code>.
 /// </summary>
 /// <param name="entity">The entity to which this raw data object belongs to.</param>
 /// <param name="uuid">The uuid of the entity.</param>
 private RawDataTargetEntityDto(RawDataEntityDto entity, Guid uuid) : this(entity, uuid.ToString())
 {
 }