Example #1
0
        private void tvwCondition_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            NoBoldNode node = (NoBoldNode)tvwCondition.SelectedNode;

            if (node is FunctionExecution)
            {
                FunctionExecution funcNode = ((FunctionExecution)node);
                funcNode.ApplyBaseDefinition.FunctionId = cmbInternalFunctions.Text;
                tvwCondition.SelectedNode      = funcNode;
                tvwCondition.SelectedNode.Text = "[" + "dataType" + "] " + funcNode.ApplyBaseDefinition.FunctionId;
            }
            else if (node is FunctionParameter)
            {
                FunctionParameter funcNode = ((FunctionParameter)node);
                funcNode.FunctionDefinition.FunctionId = cmbInternalFunctions.Text;
                tvwCondition.SelectedNode      = funcNode;
                tvwCondition.SelectedNode.Text = "Function: " + funcNode.FunctionDefinition.FunctionId;;
            }
            else if (node is AttributeValue)
            {
                AttributeValue attNode = ((AttributeValue)node);
                attNode.AttributeValueDefinition.Value    = txtValue.Text;
                attNode.AttributeValueDefinition.DataType = cmbDataType.Text;
                tvwCondition.SelectedNode      = attNode;
                tvwCondition.SelectedNode.Text = "[" + attNode.AttributeValueDefinition.DataType + "] " + attNode.AttributeValueDefinition.Contents;
            }
            else if (node is AttributeDesignator)
            {
                AttributeDesignator attNode = ((AttributeDesignator)node);
                attNode.AttributeDesignatorDefinition.AttributeId = txtValue.Text;
                attNode.AttributeDesignatorDefinition.DataType    = cmbDataType.Text;
                tvwCondition.SelectedNode      = attNode;
                tvwCondition.SelectedNode.Text = "[" + attNode.AttributeDesignatorDefinition.DataType + "]:" + attNode.AttributeDesignatorDefinition.AttributeId;
            }
            else if (node is AttributeSelector)
            {
                AttributeSelector attNode = ((AttributeSelector)node);
                attNode.AttributeSelectorDefinition.RequestContextPath = txtValue.Text;
                tvwCondition.SelectedNode      = attNode;
                tvwCondition.SelectedNode.Text = "XPath: " + attNode.AttributeSelectorDefinition.RequestContextPath;
            }
        }
        public void AttributeSelector_Invalid()
        {
            string[] tests = new string[]
            {
                ".a",
                "#123",
                "a",
                "*",
                "+",
                ">",
                "|foo",
                "foo]"
            };

            foreach (string test in tests)
            {
                ITextProvider     tp = new StringTextProvider(test);
                TokenStream       ts = Helpers.MakeTokenStream(tp);
                AttributeSelector attributeSelector = new AttributeSelector();
                Assert.IsFalse(attributeSelector.Parse(new ItemFactory(tp, null), tp, ts));
            }
        }
Example #3
0
        /// <summary>
        /// Parses inspection plan filter criterias to a <see cref="ParameterDefinition"/> list.
        /// </summary>
        /// <param name="partPath">Path of the part the query should be restricted by.</param>
        /// <param name="partUuids">Uuids of the parts the query should be restricted by.</param>
        /// <param name="charUuids">Uuids of the parts the query should be restricted by.</param>
        /// <param name="depth">The depth determines how deep the response should be.</param>
        /// <param name="requestedPartAttributes">Restricts the part attributes that are returned.</param>
        /// <param name="requestedCharacteristicAttributes">Restricts the characteristic attributes that are returned.</param>
        /// <param name="withHistory">Determines if the history should be returned.</param>
        /// <returns></returns>
        public static List <ParameterDefinition> ParseToParameter(PathInformation partPath = null, Guid[] partUuids = null, Guid[] charUuids = null, ushort?depth = null, AttributeSelector requestedPartAttributes = null, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false)
        {
            var parameter = new List <ParameterDefinition>();

            if (partPath != null)
            {
                parameter.Add(ParameterDefinition.Create("partPath", PathHelper.PathInformation2DatabaseString(partPath)));
            }

            if (depth.HasValue)
            {
                parameter.Add(ParameterDefinition.Create("depth", depth.ToString()));
            }

            if (withHistory)
            {
                parameter.Add(ParameterDefinition.Create("withHistory", true.ToString()));
            }

            if (partUuids != null && partUuids.Length > 0)
            {
                parameter.Add(ParameterDefinition.Create("partUuids", ConvertGuidListToString(partUuids)));
            }

            if (charUuids != null && charUuids.Length > 0)
            {
                parameter.Add(ParameterDefinition.Create("charUuids", ConvertGuidListToString(charUuids)));
            }

            if (requestedPartAttributes != null)
            {
                if (requestedPartAttributes.AllAttributes != AllAttributeSelection.True && requestedPartAttributes.Attributes != null)
                {
                    parameter.Add(ParameterDefinition.Create("requestedPartAttributes", ConvertUshortArrayToString(requestedPartAttributes.Attributes)));
                }
                else if (requestedPartAttributes.AllAttributes == AllAttributeSelection.False)
                {
                    parameter.Add(ParameterDefinition.Create("requestedPartAttributes", "None"));
                }
            }
            if (requestedCharacteristicAttributes != null)
            {
                if (requestedCharacteristicAttributes.AllAttributes != AllAttributeSelection.True && requestedCharacteristicAttributes.Attributes != null)
                {
                    parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", ConvertUshortArrayToString(requestedCharacteristicAttributes.Attributes)));
                }
                else if (requestedCharacteristicAttributes.AllAttributes == AllAttributeSelection.False)
                {
                    parameter.Add(ParameterDefinition.Create("requestedCharacteristicAttributes", "None"));
                }
            }
            return(parameter);
        }
Example #4
0
        /// <inheritdoc />
        public async Task <InspectionPlanCharacteristicDto> GetCharacteristicByUuid(Guid charUuid, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false, CancellationToken cancellationToken = default)
        {
            var parameter = RestClientHelper.ParseToParameter(requestedCharacteristicAttributes: requestedCharacteristicAttributes, withHistory: withHistory);

            return(await _RestClient.Request <InspectionPlanCharacteristicDto>(RequestBuilder.CreateGet($"characteristics/{charUuid}", parameter.ToArray()), cancellationToken).ConfigureAwait(false));
        }
Example #5
0
        /// <inheritdoc />
        public async Task <IEnumerable <InspectionPlanCharacteristicDto> > GetCharacteristicsByUuids(Guid[] charUuids, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false, CancellationToken cancellationToken = default)
        {
            if (charUuids == null || charUuids.Length == 0)
            {
                return(new InspectionPlanCharacteristicDto[0]);
            }

            var result = new List <InspectionPlanCharacteristicDto>(charUuids.Length);

            var featureMatrix = await GetFeatureMatrixInternal(FetchBehavior.FetchIfNotCached, cancellationToken).ConfigureAwait(false);

            if (!featureMatrix.SupportsCharacteristicUuidRestrictionForCharacteristicFetch)
            {
                foreach (var uuid in charUuids)
                {
                    var inspectionPlanCharacteristic = await GetCharacteristicByUuid(uuid, requestedCharacteristicAttributes, withHistory, cancellationToken).ConfigureAwait(false);

                    if (inspectionPlanCharacteristic != null)
                    {
                        result.Add(inspectionPlanCharacteristic);
                    }
                }
            }
            else
            {
                const string requestPath = "characteristics";
                var          targetSize  = RestClientHelper.GetUriTargetSize(ServiceLocation, requestPath, MaxUriLength, ParameterDefinition.Create("charUuids", "{}"));

                foreach (var uuidList in ArrayHelper.Split(charUuids, targetSize, RestClientHelper.LengthOfListElementInUri))
                {
                    var parameter       = RestClientHelper.ParseToParameter(null, null, uuidList, null, null, requestedCharacteristicAttributes, withHistory);
                    var characteristics = await _RestClient.Request <InspectionPlanCharacteristicDto[]>(RequestBuilder.CreateGet("characteristics", parameter.ToArray()), cancellationToken).ConfigureAwait(false);

                    result.AddRange(characteristics);
                }
            }

            return(result);
        }
Example #6
0
        /// <inheritdoc />
        public async Task <IEnumerable <InspectionPlanCharacteristicDto> > GetCharacteristics(PathInformationDto partPath = null, ushort?depth = null, AttributeSelector requestedCharacteristicAttributes = null, bool withHistory = false, CancellationToken cancellationToken = default)
        {
            var parameter = RestClientHelper.ParseToParameter(partPath, null, null, depth, null, requestedCharacteristicAttributes, withHistory);

            return(await _RestClient.Request <InspectionPlanCharacteristicDto[]>(RequestBuilder.CreateGet("characteristics", parameter.ToArray()), cancellationToken).ConfigureAwait(false));
        }
Example #7
0
        /// <inheritdoc />
        public async Task <IEnumerable <InspectionPlanPartDto> > GetParts(PathInformationDto partPath = null, Guid[] partUuids = null, ushort?depth = null, AttributeSelector requestedPartAttributes = null, bool withHistory = false, CancellationToken cancellationToken = default)
        {
            if (partUuids != null && partUuids.Length > 0)
            {
                var result = new List <InspectionPlanPartDto>(partUuids.Length);
                foreach (var uuid in partUuids)
                {
                    var inspectionPlanPart = await GetPartByUuid(uuid, requestedPartAttributes, withHistory, cancellationToken).ConfigureAwait(false);

                    if (inspectionPlanPart != null)
                    {
                        result.Add(inspectionPlanPart);
                    }
                }

                return(result);
            }

            var parameter = RestClientHelper.ParseToParameter(partPath, partUuids, null, depth, requestedPartAttributes, withHistory: withHistory);

            return(await _RestClient.Request <InspectionPlanPartDto[]>(RequestBuilder.CreateGet("parts", parameter.ToArray()), cancellationToken).ConfigureAwait(false));
        }
Example #8
0
 public IElement GetInstance(Node node)
 {
     return(AttributeSelector.GetInstance(node));
 }
Example #9
0
 public IElement GetInstance(string value)
 {
     return(AttributeSelector.GetInstance(value));
 }