Example #1
0
        private DsiRelation AddOrUpdateRelation(int consumerId, int providerId, string type, int weight)
        {
            Dictionary <string, DsiRelation> relations = GetRelations(consumerId, providerId);

            IncrementRelationTypeCount(type);

            if (relations.ContainsKey(type))
            {
                _relationCount--; // Revert previous increment when relation exists and just weight increased
                relations[type].Weight += weight;
            }
            else
            {
                relations[type] = new DsiRelation(consumerId, providerId, type, weight);
            }

            return(relations[type]);
        }
Example #2
0
        public IDsiRelation ImportRelation(int consumerId, int providerId, string type, int weight)
        {
            Logger.LogDataModelMessage("Import relation consumerId={consumerId} providerId={providerId} type={type} weight={weight}");

            _relationCount++;

            DsiRelation relation = null;

            IDsiElement consumer = _elementsDataModel.FindElementById(consumerId);
            IDsiElement provider = _elementsDataModel.FindElementById(providerId);

            if ((consumer != null) && (provider != null))
            {
                relation = AddOrUpdateRelation(consumer.Id, provider.Id, type, weight);
            }
            else
            {
                AnalyzerLogger.LogDataModelRelationNotResolved(consumerId.ToString(), providerId.ToString());
            }
            return(relation);
        }
Example #3
0
        public IDsiRelation AddRelation(string consumerName, string providerName, string type, int weight, string context)
        {
            Logger.LogDataModelMessage("Add relation consumerName={consumerName} providerName={providerName} type={type} weight={weight}");

            DsiRelation relation = null;

            _relationCount++;

            IDsiElement consumer = _elementsDataModel.FindElementByName(consumerName);
            IDsiElement provider = _elementsDataModel.FindElementByName(providerName);

            if ((consumer != null) && (provider != null))
            {
                relation = AddOrUpdateRelation(consumer.Id, provider.Id, type, weight);
            }
            else
            {
                AnalyzerLogger.LogDataModelRelationNotResolved(consumerName, providerName);
            }

            return(relation);
        }