Exemple #1
0
        private void UpdateDependencies(IndexItemModel item, string destinationId)
        {
            if (_indexerModel.EntityType == EntityType.Entity)
            {
                // Update Attribute Mapping (DestinationId) if _indexerModel is Entity
                var attrs = attributeRepository.GetByEntityId(_indexerModel.Id.ToString());
                foreach (var attr in attrs)
                {
                    Report($"Updating destination ID for attribute {attr.Name}.");
                    if (!attributeRepository.Initialized(attr))
                    {
                        Report($"Attribute {attr.Name} is not initialized.");
                        continue;
                    }

                    if (attr.HasState(EntityState.Disabled))
                    {
                        Report($"Attribute {attr.Name} is Disabled.");
                        continue;
                    }

                    attributeRepository.UpdateItemDestinationId(attr, item.GetSourceId(), destinationId);
                    Report($"Done updating destination ID for attribute {attr.Name}.");
                }
            }

            var dependencies = entityRepository.GetDependenciesOn(_indexerModel.Id, _indexerModel.EntityType);

            foreach (var dependency in dependencies)
            {
                if (dependency.HasDependOnStep(IntegrationStep.Pushing | IntegrationStep.Pushing))
                {
                    if (dependency.HasExecutionStep(IntegrationStep.Indexing | IntegrationStep.Indexed))
                    {
                        // Only add the signal to tell that the dependant entity should be pull (via PullNext) based on this item
                        entityRepository.AddPullDependency(
                            dependency.EntityId,
                            dependency.EntityType,
                            _indexerModel.Id,
                            _indexerModel.EntityType,
                            item.GetId());
                    }
                }
            }
        }