/// <summary>
 /// Existing match service
 /// </summary>
 public MdmRecordMatchingService(IDataPersistenceService <AssigningAuthority> authorityService, IDataPersistenceService <Bundle> bundleService, IDataPersistenceService <EntityRelationship> erService, IDataPersistenceService <ActRelationship> arService, IRecordMatchingService existingMatchService = null)
 {
     this.m_matchService      = existingMatchService;
     this.m_erService         = erService;
     this.m_arService         = arService;
     this.m_uniqueAuthorities = authorityService.Query(o => o.IsUnique, AuthenticationContext.SystemPrincipal).Select(o => o.Key.Value).ToList();
     bundleService.Inserted  += (o, e) =>
     {
         foreach (var i in e.Data.Item.OfType <AssigningAuthority>())
         {
             if (i.BatchOperation == BatchOperationType.Delete || i.ObsoletionTime.HasValue)
             {
                 this.m_uniqueAuthorities.Remove(i.Key.Value);
             }
             else if (i.IsUnique)
             {
                 this.m_uniqueAuthorities.Add(i.Key.Value);
             }
         }
     };
     authorityService.Inserted += (o, e) =>
     {
         if (e.Data.IsUnique)
         {
             this.m_uniqueAuthorities.Add(e.Data.Key.Value);
         }
     };
     authorityService.Obsoleted += (o, e) =>
     {
         this.m_uniqueAuthorities.Remove(e.Data.Key.Value);
     };
 }
Beispiel #2
0
        /// <summary>
        /// Perform a query
        /// </summary>
        public IEnumerable <TModel> DoTestQuery(Expression <Func <TModel, bool> > predicate, Guid?knownResultKey)
        {
            IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >();

            Assert.IsNotNull(persistenceService);

            // Perform query
            var results = persistenceService.Query(predicate);

            // Look for the known key
            Assert.IsTrue(results.Any(p => p.Key == knownResultKey), "Result doesn't contain known key");

            return(results);
        }
Beispiel #3
0
        /// <summary>
        /// Perform a query
        /// </summary>
        public IEnumerable <TModel> DoTestQuery(Expression <Func <TModel, bool> > predicate, Guid?knownResultKey, IPrincipal authContext)
        {
            // Auth context
            if (authContext == null)
            {
                authContext = AuthenticationContext.AnonymousPrincipal;
            }

            IDataPersistenceService <TModel> persistenceService = ApplicationContext.Current.GetService <IDataPersistenceService <TModel> >();

            Assert.IsNotNull(persistenceService);

            // Perform query
            var results = persistenceService.Query(predicate, authContext);

            // Look for the known key
            Assert.IsTrue(results.Any(p => p.Key == knownResultKey), "Result doesn't contain known key");

            return(results);
        }