Exemplo n.º 1
0
        /// <summary>
        /// Adds the multi parameter to the configured builders checked list box.
        /// </summary>
        /// <param name="multi">The <see cref="IMultiBuilder"/> parameter lookup object.</param>
        private void AddMultiParameterToBox(MultiLookup multi)
        {
            // var chkItemIndex = this.chklbParameters.Items.Add(para);
            var chkItemIndex = this.chklbParameters.Items.Add(multi);

            this.chklbParameters.SetItemChecked(chkItemIndex, multi.Parameters.Enabled);
        }
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs, LookupInOptions options)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key        = id,
                Builder    = builder,
                Cid        = Cid,
                CName      = Name,
                Transcoder = _transcoder
            };

            await _bucket.RetryAsync(lookup, options.TokenValue, options.TimeoutValue).ConfigureAwait(false);

            return(lookup);
        }
Exemplo n.º 3
0
        public async Task When_Index_Invalid_IndexNotFoundException_Thrown(int index)
        {
            var bytes = new byte[]
            {
                0x18, 0xd0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40,
                0x15, 0xfb, 0x22, 0x64, 0x3e, 0x29, 0x00, 0x00, 0x02, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x05, 0x22, 0x62, 0x61, 0x72, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };

            var specs = new LookupInSpecBuilder().Get("foo").Exists("bar").Specs;

            var op = new MultiLookup <byte[]>("thekey", specs);

            op.OperationBuilderPool = new DefaultObjectPool <OperationBuilder>(new OperationBuilderPoolPolicy());
            await op.SendAsync(new Mock <IConnection>().Object).ConfigureAwait(false);

            op.Read(new FakeMemoryOwner <byte>(bytes));

            var result = new LookupInResult(op.GetCommandValues(), 0, TimeSpan.FromHours(1), new DefaultSerializer());

            Assert.Throws <InvalidIndexException>(() => result.ContentAs <string>(index));
            var value = result.ContentAs <string>(0);

            Assert.Equal("bar", value);
        }
Exemplo n.º 4
0
        public async Task ContentAs_WhenPathNotFound_ThrowsPathNotFoundException()
        {
            var bytes = new byte[]
            {
                0x18, 0xd0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x40,
                0x15, 0xfb, 0x22, 0x64, 0x3e, 0x29, 0x00, 0x00, 0x02, 0x00, 0x0a,

                // Index 0 = Success
                0x00, 0x00,
                // Spec Body Length = 5
                0x00, 0x00, 0x00, 0x05,
                // "bar"
                0x22, 0x62, 0x61, 0x72, 0x22,

                // Index 1 = SubDocPathNotFound
                0x00, 0xc0,
                // Spec Body Length = 0
                0x00, 0x00, 0x00, 0x00
            };

            var specs = new LookupInSpecBuilder().Get("foo").Get("bar").Specs;

            var op = new MultiLookup <byte[]>("thekey", specs);

            op.OperationBuilderPool = new DefaultObjectPool <OperationBuilder>(new OperationBuilderPoolPolicy());
            await op.SendAsync(new Mock <IConnection>().Object).ConfigureAwait(false);

            op.Read(new FakeMemoryOwner <byte>(bytes));

            var result = new LookupInResult(op.GetCommandValues(), 0, TimeSpan.FromHours(1), new DefaultSerializer());

            Assert.Throws <PathNotFoundException>(() => result.ContentAs <string>(1));
        }
Exemplo n.º 5
0
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs,
                                                                   LookupInOptions options, IInternalSpan span)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key      = id,
                Builder  = builder,
                Cid      = Cid,
                CName    = Name,
                DocFlags = options.AccessDeletedValue ? SubdocDocFlags.AccessDeleted : SubdocDocFlags.None,
                Span     = span
            };

            _operationConfigurator.Configure(lookup, options);

            await RetryUntilTimeoutOrSuccessAsync(options.TokenValue, options.TimeoutValue, lookup).ConfigureAwait(false);

            return(lookup);
        }
Exemplo n.º 6
0
        /// <summary>
        /// dropdown popup
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="o"></param>
        /// <param name="setCfg"></param>
        /// <returns></returns>
        public static MultiLookup <T> Mod <T>(this MultiLookup <T> o, Action <PopupCfg> setCfg = null)
        {
            var cfg = new PopupCfg();

            if (setCfg != null)
            {
                setCfg(cfg);
            }

            o.Tag(cfg.ToTag());
            return(o);
        }
        public void Test()
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new LookupInBuilder <MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey");

            var op = new MultiLookup <MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"),
                                             new DefaultTranscoder(new DefaultConverter()), 10);

            builder.Get("foo.bar");

            var bytes = op.Write();
        }
        public void Test()
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new LookupInBuilder<MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey");

            var op = new MultiLookup<MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"),
                new DefaultTranscoder(new DefaultConverter()), 10);

            builder.Get("foo.bar");

            var bytes = op.Write();
        }
        public void MultiLookup_WillRetry_IfCasIsZero()
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.Get("pathone");
            builder.Get("pathtwo");
            var op = new MultiLookup <dynamic>("thekey", builder, new Mock <IVBucket>().Object,
                                               new Mock <ITypeTranscoder>().Object, 10)
            {
                Cas = 0
            };

            Assert.IsTrue(op.CanRetry());
        }
Exemplo n.º 10
0
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <LookupInSpec> specs,
                                                                   LookupInOptions options, IRequestSpan span)
        {
            //sanity check for deferred bootstrapping errors
            _bucket.ThrowIfBootStrapFailed();

            //Get the collection ID
            await PopulateCidAsync().ConfigureAwait(false);

            //add the virtual xattr attribute to get the doc expiration time
            if (options.ExpiryValue)
            {
                specs = specs.Concat(new [] {
                    new LookupInSpec
                    {
                        Path      = VirtualXttrs.DocExpiryTime,
                        OpCode    = OpCode.SubGet,
                        PathFlags = SubdocPathFlags.Xattr,
                        DocFlags  = SubdocDocFlags.None
                    }
                });
            }

            var lookup = new MultiLookup <byte[]>(id, specs)
            {
                Cid      = Cid,
                CName    = Name,
                SName    = ScopeName,
                DocFlags = options.AccessDeletedValue ? SubdocDocFlags.AccessDeleted : SubdocDocFlags.None,
                Span     = span
            };

            try
            {
                _operationConfigurator.Configure(lookup, options);

                using var ctp = CreateRetryTimeoutCancellationTokenSource(options, lookup);
                await _bucket.RetryAsync(lookup, ctp.TokenPair).ConfigureAwait(false);

                return(lookup);
            }
            catch
            {
                // Make sure we cleanup the operation in the error case where it isn't returned
                lookup.Dispose();
                throw;
            }
        }
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <OperationSpec> specs, LookupInOptions options)
        {
            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            var lookup = new MultiLookup <byte[]>
            {
                Key     = id,
                Builder = builder,
                Cid     = Cid
            };

            await ExecuteOp(lookup, options.Token, options.Timeout);

            return(lookup);
        }
Exemplo n.º 12
0
        public void Initialize()
        {
            var folder = Settings.Current.Builder.Folder;

            lookups        = new Dictionary <string, MultiLookup>();
            sourceLookups  = new Dictionary <string, SourceLookup>();
            rfLookups      = new Dictionary <string, ReferenceFileLookup>();
            genderConcepts = new GenderLookup();
            genderConcepts.Load();

            ingredientLevel = string.IsNullOrEmpty(folder)
            ? new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
                              @"Common\Lookups\IngredientLevel.sql")
            : new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
                              Path.Combine(folder, @"Common\Lookups\IngredientLevel.sql"));
            ingredientLevel.Load();

            foreach (var qd in Settings.Current.Building.SourceQueryDefinitions)
            {
                if (qd.Persons != null)
                {
                    foreach (var d in qd.Persons)
                    {
                        d.Vocabulary = this;
                    }
                }
                Load(folder, qd.ConditionOccurrence);
                Load(folder, qd.DrugExposure);
                Load(folder, qd.ProcedureOccurrence);
                Load(folder, qd.Observation);
                Load(folder, qd.VisitOccurrence);
                Load(folder, qd.CareSites);
                Load(folder, qd.Providers);
                Load(folder, qd.ProcedureCost);
                Load(folder, qd.Death);
            }

            locationConcepts = new EntityLookup <Location>(Settings.Current.Building.DestinationConnectionString);

            var location = Settings.Current.Building.CommonQueryDefinitions.FirstOrDefault(qd => qd.Locations != null);

            if (location != null)
            {
                locationConcepts.Load(location, location.Locations[0]);
            }
        }
        public void MultiLookup_Clone()
        {
            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new LookupInBuilder <dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.Get("pathone");
            builder.Get("pathtwo");
            var op = new MultiLookup <dynamic>("thekey", builder, new Mock <IVBucket>().Object,
                                               new Mock <ITypeTranscoder>().Object, 10)
            {
                Cas = 100
            };

            var cloned = (MultiLookup <dynamic>)op.Clone();

            Assert.AreEqual(op, cloned);
        }
Exemplo n.º 14
0
        private void doLookupButton_Click(object sender, EventArgs e)
        {
            DoLookupDialog dialog = new DoLookupDialog();

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string      ip        = dialog.IP;
                    MultiLookup statEntry = new MultiLookup(ip, mFibTreeOriginal, mFibTreeNormalized, mFibTreeCompressed);
                    mMultiLookupCollection.Add(statEntry);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Lookup error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 15
0
        public void Initialize()
        {
            var folder = Settings.Current.Builder.Folder;
             lookups = new Dictionary<string, MultiLookup>();
             sourceLookups = new Dictionary<string, SourceLookup>();
             rfLookups = new Dictionary<string, ReferenceFileLookup>();
             genderConcepts = new GenderLookup();
             genderConcepts.Load();

             ingredientLevel = string.IsNullOrEmpty(folder)
            ? new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
               @"Common\Lookups\IngredientLevel.sql")
            : new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
               Path.Combine(folder, @"Common\Lookups\IngredientLevel.sql"));
             ingredientLevel.Load();

             foreach (var qd in Settings.Current.Building.SourceQueryDefinitions)
             {
            if (qd.Persons != null)
            {
               foreach (var d in qd.Persons)
               {
                  d.Vocabulary = this;
               }
            }
            Load(folder, qd.ConditionOccurrence);
            Load(folder, qd.DrugExposure);
            Load(folder, qd.ProcedureOccurrence);
            Load(folder, qd.Observation);
            Load(folder, qd.VisitOccurrence);
            Load(folder, qd.CareSites);
            Load(folder, qd.Providers);
            Load(folder, qd.ProcedureCost);
            Load(folder, qd.Death);
             }

             locationConcepts = new EntityLookup<Location>(Settings.Current.Building.DestinationConnectionString);

             var location = Settings.Current.Building.CommonQueryDefinitions.FirstOrDefault(qd => qd.Locations != null);
             if (location != null)
             {
            locationConcepts.Load(location, location.Locations[0]);
             }
        }
Exemplo n.º 16
0
        public void Test_Projection_With_Poco()
        {
            var getRequest = new MultiLookup <byte[]>();

            getRequest.Read(new FakeMemoryOwner <byte>(_lookupInPacket));

            var readResult = new GetResult(getRequest.ExtractBody(),
                                           new LegacyTranscoder(), new Mock <ILogger <GetResult> >().Object,
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var result = readResult.ContentAs <Person>();

            Assert.Equal("Emmy-lou Dickerson", result.name);
        }
        public void Test_Projection()
        {
            var getRequest = new MultiLookup <byte[]>();

            getRequest.ReadAsync(_lookupInPacket);

            var readResult = new GetResult(_lookupInPacket,
                                           new DefaultTranscoder(new DefaultConverter()),
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var result = readResult.ContentAs <dynamic>();

            Assert.Equal("Emmy-lou Dickerson", result.name.Value);
        }
Exemplo n.º 18
0
        public void Test_Projection_With_Dictionary()
        {
            var getRequest = new MultiLookup <byte[]>();

            getRequest.ReadAsync(new FakeMemoryOwner <byte>(_lookupInPacket));

            var readResult = new GetResult(new FakeMemoryOwner <byte>(_lookupInPacket),
                                           new DefaultTranscoder(new DefaultConverter()),
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var result = readResult.ContentAs <Dictionary <string, dynamic> >();

            Assert.Equal(result["name"], "Emmy-lou Dickerson");
        }
Exemplo n.º 19
0
        public void Test_Projection_With_Dictionary()
        {
            var getRequest = new MultiLookup <byte[]>("thekey", Array.Empty <LookupInSpec>());

            getRequest.Read(new FakeMemoryOwner <byte>(_lookupInPacket));

            var readResult = new GetResult(getRequest.ExtractBody(),
                                           new LegacyTranscoder(), new Mock <ILogger <GetResult> >().Object,
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var result = readResult.ContentAs <Dictionary <string, dynamic> >();

            Assert.Equal(result["name"], "Emmy-lou Dickerson");
        }
Exemplo n.º 20
0
        public void Test_Projection_With_Poco()
        {
            var getRequest = new MultiLookup <byte[]>();

            getRequest.ReadAsync(new FakeMemoryOwner <byte>(_lookupInPacket));

            var readResult = new GetResult(new FakeMemoryOwner <byte>(_lookupInPacket),
                                           new DefaultTranscoder(),
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var result = readResult.ContentAs <Person>();

            Assert.Equal("Emmy-lou Dickerson", result.name);
        }
Exemplo n.º 21
0
        public void Test_ExpiryTime_Returns_Null_When_Expiry_Not_An_Option()
        {
            var getRequest = new MultiLookup <byte[]>("thekey", Array.Empty <LookupInSpec>());

            getRequest.Read(new FakeMemoryOwner <byte>(_lookupInPacket));

            var readResult = new GetResult(getRequest.ExtractBody(),
                                           new LegacyTranscoder(), new Mock <ILogger <GetResult> >().Object,
                                           _lookupInSpecs)
            {
                OpCode = OpCode.MultiLookup,
                Flags  = getRequest.Flags,
                Header = getRequest.Header
            };

            var expiryTime = readResult.ExpiryTime;

            Assert.Null(expiryTime);
        }
        public void When_Success_Return_Fragment()
        {
            var response = new byte[]
            {
                129, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 83, 67, 82, 65, 77, 45, 83,
                72, 65, 53, 49, 50, 32, 83, 67, 82, 65, 77, 45, 83, 72,
                65, 50, 53, 54, 32, 83, 67, 82, 65, 77, 45, 83, 72,
                65, 49, 32, 67, 82, 65, 77,  45, 77, 68, 53, 32,
                80, 76, 65, 73, 78
            };

            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new LookupInBuilder<MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey");

            var op = new MultiLookup<MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"),
                new DefaultTranscoder(new DefaultConverter()), 10);

            op.Data.Write(response, 0, response.Length);
            var result = op.GetResultWithValue();
        }
        public void When_Success_Return_Fragment()
        {
            var response = new byte[]
            {
                129, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 83, 67, 82, 65, 77, 45, 83,
                72, 65, 53, 49, 50, 32, 83, 67, 82, 65, 77, 45, 83, 72,
                65, 50, 53, 54, 32, 83, 67, 82, 65, 77, 45, 83, 72,
                65, 49, 32, 67, 82, 65, 77, 45, 77, 68, 53, 32,
                80, 76, 65, 73, 78
            };

            var mockedInvoker = new Mock <ISubdocInvoker>();
            var builder       = new LookupInBuilder <MyDoc>(mockedInvoker.Object, () => new DefaultSerializer(), "mykey");

            var op = new MultiLookup <MyDoc>(builder.Key, builder, new VBucket(null, 1, 1, null, 0, null, "default"),
                                             new DefaultTranscoder(new DefaultConverter()), 10);

            op.Data.Write(response, 0, response.Length);
            var result = op.GetResultWithValue();
        }
        private async Task <MultiLookup <byte[]> > ExecuteLookupIn(string id, IEnumerable <OperationSpec> specs, LookupInOptions options)
        {
            // convert new style specs into old style builder
            var builder = new LookupInBuilder <byte[]>(null, null, id, specs);

            //add the virtual xttar attribute to get the doc expiration time
            if (options.Expiry)
            {
                builder.Get(VirtualXttrs.DocExpiryTime, SubdocPathFlags.Xattr);
            }

            var lookup = new MultiLookup <byte[]>
            {
                Key        = id,
                Builder    = builder,
                Cid        = Cid,
                Transcoder = _transcoder
            };

            await _bucket.RetryAsync(lookup, options.Token, options.Timeout);

            return(lookup);
        }
        public void MultiLookup_Clone()
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new LookupInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.Get("pathone");
            builder.Get("pathtwo");
            var op = new MultiLookup<dynamic>("thekey", builder, new Mock<IVBucket>().Object,
                new Mock<ITypeTranscoder>().Object, 10)
            { Cas = 100 };

            var cloned = (MultiLookup<dynamic>)op.Clone();
            Assert.AreEqual(op, cloned);
        }
Exemplo n.º 26
0
        private void Load(string folder, IEnumerable <EntityDefinition> definitions)
        {
            if (definitions == null)
            {
                return;
            }

            foreach (var ed in definitions)
            {
                ed.Vocabulary = this;

                if (ed.Concepts == null)
                {
                    continue;
                }

                foreach (var c in ed.Concepts)
                {
                    if (!string.IsNullOrEmpty(c.SourceLookup))
                    {
                        if (!sourceLookups.ContainsKey(c.SourceLookup))
                        {
                            var lookupFolder = c.SourceLookup;

                            if (!string.IsNullOrEmpty(folder))
                            {
                                lookupFolder = Path.Combine(folder, c.SourceLookup);
                            }

                            var lookup = new SourceLookup(Settings.Current.Building.VocabularyConnectionString, lookupFolder, Settings.Current.Building.VocabularySchemaName);

                            lookup.Load();
                            sourceLookups.Add(c.SourceLookup, lookup);
                        }
                    }

                    if (c.ConceptIdMappers == null)
                    {
                        continue;
                    }

                    foreach (var conceptIdMapper in c.ConceptIdMappers)
                    {
                        if (!string.IsNullOrEmpty(conceptIdMapper.Lookup))
                        {
                            if (!lookups.ContainsKey(conceptIdMapper.Lookup))
                            {
                                var lookupFolder = conceptIdMapper.Lookup;

                                if (!string.IsNullOrEmpty(folder))
                                {
                                    lookupFolder = Path.Combine(folder, conceptIdMapper.Lookup);
                                }

                                var lookup = new MultiLookup(GetConnectionString(lookupFolder), lookupFolder, GetSchemaName(lookupFolder));

                                lookup.Load();
                                lookups.Add(conceptIdMapper.Lookup, lookup);
                            }
                        }

                        if (string.IsNullOrEmpty(conceptIdMapper.File))
                        {
                            continue;
                        }
                        if (lookups.ContainsKey(conceptIdMapper.File))
                        {
                            continue;
                        }

                        var lookupFileLocation = conceptIdMapper.File;
                        if (!string.IsNullOrEmpty(folder))
                        {
                            lookupFileLocation = Path.Combine(folder, conceptIdMapper.File);
                        }

                        if (!rfLookups.ContainsKey(conceptIdMapper.File))
                        {
                            var rfLookup = new ReferenceFileLookup(lookupFileLocation);
                            rfLookup.Load();
                            rfLookups.Add(conceptIdMapper.File, rfLookup);
                        }
                    }

                    if (c.SourceConceptIdMappers != null)
                    {
                        foreach (var conceptIdMapper in c.SourceConceptIdMappers)
                        {
                            if (!string.IsNullOrEmpty(conceptIdMapper.Lookup))
                            {
                                if (!lookups.ContainsKey(conceptIdMapper.Lookup))
                                {
                                    var lookupFolder = conceptIdMapper.Lookup;

                                    if (!string.IsNullOrEmpty(folder))
                                    {
                                        lookupFolder = Path.Combine(folder, conceptIdMapper.Lookup);
                                    }

                                    var lookup = new MultiLookup(GetConnectionString(lookupFolder), lookupFolder, GetSchemaName(lookupFolder));

                                    lookup.Load();
                                    lookups.Add(conceptIdMapper.Lookup, lookup);
                                }
                            }
                        }
                    }
                }
            }
        }
        public void MultiLookup_WillRetry_IfCasIsZero()
        {
            var mockedInvoker = new Mock<ISubdocInvoker>();
            var builder = new LookupInBuilder<dynamic>(mockedInvoker.Object, () => new DefaultSerializer(), "thekey");

            builder.Get("pathone");
            builder.Get("pathtwo");
            var op = new MultiLookup<dynamic>("thekey", builder, new Mock<IVBucket>().Object,
                new Mock<ITypeTranscoder>().Object, 10)
            { Cas = 0 };

            Assert.IsTrue(op.CanRetry());
        }
Exemplo n.º 28
0
 public void SetUp()
 {
     this.testObject = new MultiLookup();
 }
Exemplo n.º 29
0
 public void TearDown()
 {
     this.testObject = null;
 }
Exemplo n.º 30
0
 /// <summary>
 /// grid inside the multilookup popup
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="multilookup"></param>
 /// <param name="popupUrl"></param>
 /// <returns></returns>
 public static MultiLookup <T> MultiLookupGrid <T>(this MultiLookup <T> multilookup, string popupUrl)
 {
     multilookup.PopupUrl(popupUrl);
     multilookup.Mod("awem.multilookupGrid");
     return(multilookup);
 }
Exemplo n.º 31
0
 public void Construct()
 {
     this.testObject = new MultiLookup();
 }
Exemplo n.º 32
0
 private void visualizeLookups(MultiLookup multiLookup)
 {
     visualizedLookup = multiLookup;
     visualizeLookups();
 }
Exemplo n.º 33
0
        private void Load(string folder, IEnumerable<EntityDefinition> definitions)
        {
            if (definitions == null) return;

             foreach (var ed in definitions)
             {
            ed.Vocabulary = this;

            if (ed.Concepts == null) continue;

            foreach (var c in ed.Concepts)
            {
               if (!string.IsNullOrEmpty(c.SourceLookup))
               {
                  if (!sourceLookups.ContainsKey(c.SourceLookup))
                  {
                     var lookupFolder = c.SourceLookup;

                     if (!string.IsNullOrEmpty(folder))
                        lookupFolder = Path.Combine(folder, c.SourceLookup);

                     var lookup = new SourceLookup(Settings.Current.Building.VocabularyConnectionString, lookupFolder);

                     lookup.Load();
                     sourceLookups.Add(c.SourceLookup, lookup);
                  }
               }

               if (c.ConceptIdMappers == null) continue;

               foreach (var conceptIdMapper in c.ConceptIdMappers)
               {
                  if (!string.IsNullOrEmpty(conceptIdMapper.Lookup))
                  {
                     if (!lookups.ContainsKey(conceptIdMapper.Lookup))
                     {
                        var lookupFolder = conceptIdMapper.Lookup;

                        if (!string.IsNullOrEmpty(folder))
                           lookupFolder = Path.Combine(folder, conceptIdMapper.Lookup);

                        var lookup = new MultiLookup(Settings.Current.Building.VocabularyConnectionString, lookupFolder);

                        lookup.Load();
                        lookups.Add(conceptIdMapper.Lookup, lookup);
                     }
                  }

                  if (string.IsNullOrEmpty(conceptIdMapper.File)) continue;
                  if (lookups.ContainsKey(conceptIdMapper.File)) continue;

                  var lookupFileLocation = conceptIdMapper.File;
                  if (!string.IsNullOrEmpty(folder))
                  {
                     lookupFileLocation = Path.Combine(folder, conceptIdMapper.File);
                  }

                  var rfLookup = new ReferenceFileLookup(lookupFileLocation);
                  rfLookup.Load();
                  rfLookups.Add(conceptIdMapper.File, rfLookup);
               }
            }
             }
        }
Exemplo n.º 34
0
 public static MultiLookup <T> DropdownPopup <T>(this MultiLookup <T> multi)
 {
     multi.Tag(new { DropdownPopup = true });
     return(multi);
 }
Exemplo n.º 35
0
        public void Initialize()
        {
            var folder = Settings.Current.Builder.Folder;

            lookups        = new Dictionary <string, MultiLookup>();
            sourceLookups  = new Dictionary <string, SourceLookup>();
            rfLookups      = new Dictionary <string, ReferenceFileLookup>();
            genderConcepts = new GenderLookup();
            genderConcepts.Load();

            var ingredientLevelFile       = Settings.Current.Building.CDM.GetAttribute <IngredientLevelFileAttribute>().Value;
            var vendorIngredientLevelFile =
                Settings.Current.Building.Vendor.GetAttribute <IngredientLevelFileAttribute>();

            if (vendorIngredientLevelFile != null)
            {
                ingredientLevelFile = vendorIngredientLevelFile.Value;
            }

            ingredientLevel = string.IsNullOrEmpty(folder)
            ? new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
                              @"Common\Lookups\" + ingredientLevelFile, Settings.Current.Building.VocabularySchemaName)
            : new MultiLookup(Settings.Current.Building.VocabularyConnectionString,
                              Path.Combine(folder, @"Common\Lookups\" + ingredientLevelFile), Settings.Current.Building.VocabularySchemaName);
            ingredientLevel.Load();

            foreach (var qd in Settings.Current.Building.SourceQueryDefinitions)
            {
                if (qd.Persons != null)
                {
                    foreach (var d in qd.Persons)
                    {
                        d.Vocabulary = this;
                    }
                }
                Load(folder, qd.ConditionOccurrence);
                Load(folder, qd.DrugExposure);
                Load(folder, qd.ProcedureOccurrence);
                Load(folder, qd.Observation);
                Load(folder, qd.VisitOccurrence);
                Load(folder, qd.CareSites);
                Load(folder, qd.Providers);
                Load(folder, qd.Death);
                Load(folder, qd.Measurement);
                Load(folder, qd.DeviceExposure);
                Load(folder, qd.Note);

                Load(folder, qd.VisitCost);
                Load(folder, qd.ProcedureCost);
                Load(folder, qd.DeviceCost);
                Load(folder, qd.ObservationCost);
                Load(folder, qd.MeasurementCost);
                Load(folder, qd.DrugCost);
            }

            locationConcepts = new EntityLookup <Location>(Settings.Current.Building.DestinationConnectionString, Settings.Current.Building.DestinationSchemaName);
            var location = Settings.Current.Building.CommonQueryDefinitions.FirstOrDefault(qd => qd.Locations != null);

            if (location != null)
            {
                //if (Settings.Current.Building.DestinationEngine.Database == Database.Redshift)
                //{
                //   locationConcepts.LoadFromS3(location, location.Locations[0], "LOCATION.txt", new Dictionary<string, int>
                //   {
                //      {"LOCATION_ID", 0},
                //      {"STATE", 1},
                //      {"LOCATION_SOURCE_VALUE", 2}
                //   });
                //}
                //else
                {
                    locationConcepts.Load(location, location.Locations[0]);
                }
            }
        }