Beispiel #1
0
        public void NameHelper_Tests_Case_CreateRuleOrFactName()
        {
            var name = NameHelper.CreateRuleOrFactName();

            Assert.AreEqual(name.IsEmpty, false);
            Assert.AreNotEqual(name.NameValue, string.Empty);
            Assert.AreNotEqual(name.NormalizedNameValue, string.Empty);
            Assert.AreEqual(name.KindOfName, KindOfName.Entity);
        }
        /// <inheritdoc/>
        protected override void OnEnter()
        {
            Result = CreateCodeEntityAndSetAsCurrent(KindOfCodeEntity.InlineTrigger);

            Result.Name               = NameHelper.CreateRuleOrFactName();
            _inlineTrigger            = CreateInlineTrigger();
            _inlineTrigger.CodeEntity = Result;
            Result.InlineTrigger      = _inlineTrigger;

            if (Result.ParentCodeEntity != null)
            {
                _inlineTrigger.Holder = Result.ParentCodeEntity.Name;
            }
        }
Beispiel #3
0
        private void PrepareDirty()
        {
            if (Name == null || Name.IsEmpty)
            {
                Name = NameHelper.CreateRuleOrFactName();
            }

            if (Kind == KindOfRuleInstance.Undefined)
            {
                if (SecondaryParts.IsNullOrEmpty())
                {
                    Kind = KindOfRuleInstance.Fact;
                }
                else
                {
                    Kind = KindOfRuleInstance.Rule;
                }
            }

            if (IsSource)
            {
                Normalized = ConvertorToNormalized.Convert(this);
                Normalized.PrepareDirty();

#if DEBUG
                //_gbcLogger.Info($"Normalized = {DebugHelperForRuleInstance.ToString(Normalized)}");
#endif
            }
            else
            {
                CalculateUsedKeys();
                PrimaryPart?.PrepareDirty(this);

                if (!SecondaryParts.IsNullOrEmpty())
                {
                    foreach (var item in SecondaryParts)
                    {
                        item.PrepareDirty(this);
                    }
                }

                Normalized = this;
            }

            _commonPersistIndexedLogicalData.NSetIndexedRuleInstanceToIndexData(Normalized);
        }
        private RuleInstance CreateInheritanceFact(InheritanceItem inheritanceItem)
        {
            var factName = NameHelper.CreateRuleOrFactName();

#if DEBUG
            //Log($"factName = {factName}");
#endif

            var fact = new RuleInstance();
            fact.Kind = KindOfRuleInstance.Fact;
            fact.AppendAnnotations(inheritanceItem);
            fact.Name = factName;
            //fact.KeysOfPrimaryRecords.Add(inheritanceItem.Id);

            var primaryPart = new PrimaryRulePart();
            fact.PrimaryPart   = primaryPart;
            primaryPart.Parent = fact;

            var isRelation = new LogicalQueryNode();
            isRelation.Name       = NameHelper.CreateName("is");
            isRelation.Kind       = KindOfLogicalQueryNode.Relation;
            isRelation.ParamsList = new List <LogicalQueryNode>();

            primaryPart.Expression = isRelation;

            var subItemNode = new LogicalQueryNode();
            isRelation.ParamsList.Add(subItemNode);
            subItemNode.Kind = KindOfLogicalQueryNode.Concept;
            subItemNode.Name = inheritanceItem.SubName;

            var superItemNode = new LogicalQueryNode();
            isRelation.ParamsList.Add(superItemNode);
            superItemNode.Kind = KindOfLogicalQueryNode.Concept;
            superItemNode.Name = inheritanceItem.SuperName;

            var rankNode = new LogicalQueryNode();
            isRelation.ParamsList.Add(rankNode);
            rankNode.Kind  = KindOfLogicalQueryNode.Value;
            rankNode.Value = inheritanceItem.Rank;

            return(fact);
        }
Beispiel #5
0
        /// <inheritdoc/>
        protected override void OnFinish()
        {
            if (Result.Name == null || Result.Name.IsEmpty)
            {
                Result.Name = NameHelper.CreateRuleOrFactName();
            }

            var secondaryPartsList = Result.SecondaryParts;

            if (secondaryPartsList.IsNullOrEmpty())
            {
                var primaryPart = Result.PrimaryPart;

                if (primaryPart.HasQuestionVars)
                {
                    Result.Kind = KindOfRuleInstance.Question;
                }
                else
                {
                    Result.Kind = KindOfRuleInstance.Fact;
                }
            }
            else
            {
                Result.Kind = KindOfRuleInstance.Rule;

                var primaryPart = Result.PrimaryPart;

                primaryPart.SecondaryParts = secondaryPartsList.ToList();

                foreach (var secondaryPart in secondaryPartsList)
                {
                    secondaryPart.PrimaryPart = primaryPart;
                }
            }

            Result.CheckDirty();
        }