Exemple #1
0
        /// <summary>
        /// Match Attribute Values for the specified Link
        /// </summary>
        private bool?ValidateMatchedLinks(FilteredSkuLink link, string attributeName, out string leftValue, out string rightValue)
        {
            var leftValues  = link.LeftSku.GetValuesForAttribute(attributeName, true).Select(ed => ed.Value).ToList();
            var rightValues = link.RightSku.GetValuesForAttribute(attributeName, true).Select(ed => ed.Value).ToList();

            leftValue = leftValues.Aggregate(
                string.Empty, (current, value) => string.IsNullOrEmpty(current) ? value : current + ", " + value);
            rightValue = rightValues.Aggregate(
                string.Empty, (current, value) => string.IsNullOrEmpty(current) ? value : current + ", " + value);

            if (leftValues.Count == 0)
            {
                AddSkuGap(link.LeftSku, attributeName);
                return(null);
            }

            if (rightValues.Count == 0)
            {
                var leftSchemaAttributes =
                    link.LeftTaxonomy.SchemaInfos.Where(si => si.SchemaData != null).Select(si => si.Attribute).ToList();

                var leftDeriviedAttribute =
                    leftSchemaAttributes.Where(
                        a => (a.AttributeName == attributeName + " (Ratio)") && a.AttributeType.Contains(AttributeTypeEnum.Global.ToString())).SelectMany(
                        p => p.DerivedAttributes).FirstOrDefault(p => p.TaxonomyID == link.LeftTaxonomy.ID);

                if (leftDeriviedAttribute != null)
                {
                    var ta = new TaxAttValueCalculator(link.LeftSku);
                    ta.ProcessCalculatedAttribute(leftDeriviedAttribute.Expression, leftDeriviedAttribute.MaxResultLength);
                    var attributes = ta.GetAttributesInTokens();
                    foreach (var attribute in
                             attributes.Where(attribute => link.LeftSku.GetValuesForAttribute(attribute).Count == 0))
                    {
                        AddSkuGap(link.LeftSku, attribute);
                    }
                    return(null);
                }

                AddSkuGap(link.RightSku, attributeName);
                return(null);
            }

            if (leftValues.Any(lv => _notDiscernibles.Union(_dontCareValues).Contains(lv)) ||
                rightValues.Any(rv => _notDiscernibles.Union(_dontCareValues).Contains(rv)))
            {
                return(true);
            }

            return(leftValues.Any(lv => rightValues.Any(rv => rv.Equals(lv))));
        }
Exemple #2
0
 partial void OnCreated()
 {
     _derivedValueCalculator = new TaxAttValueCalculator(this);
 }