/// <summary> /// Special check for invalid paths /// </summary> /// <param name="values"></param> /// <param name="onComplete"></param> protected override void PerformIndexItems(IEnumerable <ValueSet> values, Action <IndexOperationEventArgs> onComplete) { // We don't want to re-enumerate this list, but we need to split it into 2x enumerables: invalid and valid items. // The Invalid items will be deleted, these are items that have invalid paths (i.e. moved to the recycle bin, etc...) // Then we'll index the Value group all together. var invalidOrValid = values.GroupBy(v => { if (!v.Values.TryGetValue("path", out IReadOnlyList <object>?paths) || paths.Count <= 0 || paths[0] == null) { return(ValueSetValidationStatus.Failed); } ValueSetValidationResult validationResult = ValueSetValidator.Validate(v); return(validationResult.Status); }).ToList(); var hasDeletes = false; var hasUpdates = false; // ordering by descending so that Filtered/Failed processes first foreach (IGrouping <ValueSetValidationStatus, ValueSet> group in invalidOrValid.OrderByDescending(x => x.Key)) { switch (group.Key) { case ValueSetValidationStatus.Valid: hasUpdates = true; //these are the valid ones, so just index them all at once base.PerformIndexItems(group.ToList(), onComplete); break; case ValueSetValidationStatus.Failed: // don't index anything that is invalid break; case ValueSetValidationStatus.Filtered: hasDeletes = true; // these are the invalid/filtered items so we'll delete them // since the path is not valid we need to delete this item in // case it exists in the index already and has now // been moved to an invalid parent. base.PerformDeleteFromIndex(group.Select(x => x.Id), null); break; } } if ((hasDeletes && !hasUpdates) || (!hasDeletes && !hasUpdates)) { //we need to manually call the completed method onComplete(new IndexOperationEventArgs(this, 0)); } }
public ClientTermValueSetModule( IValueSetService valueSetService, IAppConfiguration config, ILogger logger, ValueSetValidator valueSetValidator) : base($"/{TerminologyVersion.Route}/valuesets", config, logger) { this.valueSetService = valueSetService; this.valueSetValidator = valueSetValidator; this.Post("/", _ => this.AddValueSet(), null, PostActionName); this.Delete("/{valueSetGuid}", parameters => this.DeleteValueSet(parameters), null, DeleteActionName); }
public void Inclusion_Exclusion_Field_List() { var validator = new ValueSetValidator(null, null, new[] { "hello", "world" }, new[] { "world" }); var valueSet = ValueSet.FromObject("555", IndexTypes.Content, "test-content", new { hello = "world", path = "-1,555", world = "your oyster" }); var result = validator.Validate(valueSet); Assert.AreEqual(ValueSetValidationResult.Filtered, result); Assert.IsFalse(valueSet.Values.ContainsKey("path")); Assert.IsTrue(valueSet.Values.ContainsKey("hello")); Assert.IsFalse(valueSet.Values.ContainsKey("world")); }
public ValueSetModule( IValueSetService valueSetService, IValueSetSummaryService valueSetSummaryService, IClientTermValueSetService clientTermValueSetService, IClientTermCustomizationService clientTermCustomizationService, IValueSetComparisonService valueSetComparisonService, IAppConfiguration config, ILogger logger, ValueSetValidator valueSetValidator) : base($"/{TerminologyVersion.Route}/valuesets", config, logger) { this.valueSetService = valueSetService; this.valueSetSummaryService = valueSetSummaryService; this.clientTermValueSetService = clientTermValueSetService; this.clientTermCustomizationService = clientTermCustomizationService; this.valueSetComparisonService = valueSetComparisonService; this.valueSetValidator = valueSetValidator; this.Get("/", async _ => await this.GetValueSetPage(), null, "GetPaged"); this.Get("/{valueSetGuid}", parameters => this.GetValueSet(parameters.valueSetGuid), null, "GetValueSet"); this.Get( "/versions/{referenceId}", parameters => this.GetValueSetVersions(parameters.referenceId), null, "GetValueSetVersions"); this.Post("/multiple/", _ => this.GetMultipleValueSets(), null, "GetMultipleValueSets"); this.Post("/search/", async _ => await this.Search(), null, "Search"); this.Post("/copy/", _ => this.CopyValueSet(), null, "CopyValueSet"); this.Post("/compare/", async _ => await this.CompareValueSets(), null, "CompareValueSets"); this.Post("/", _ => this.AddValueSet(), null, "AddValueSet"); this.Patch("/{valueSetGuid}", parameters => this.PatchValueSet(parameters.valueSetGuid), null, "PatchValueSet"); this.Put( "/{valueSetGuid}/statuscode/{statusCode}", parameters => this.ChangeStatus(parameters.valueSetGuid, parameters.statusCode), null, "ChangeValueSetStatus"); this.Delete("/{valueSetGuid}", parameters => this.DeleteValueSet(parameters.valueSetGuid), null, "DeleteValueSet"); }
public ValueSetModule(IValueSetService valueSetService, IAppConfiguration config, ILogger logger, ValueSetValidator valueSetValidator) : base($"/{TerminologyVersion.Route}/valuesets", logger) { this.valueSetService = valueSetService; this.config = config; this.valueSetValidator = valueSetValidator; this.Get("/", _ => this.GetValueSetPage(), null, "GetPaged"); this.Get("/{valueSetUniqueId}", parameters => this.GetValueSets(parameters.valueSetUniqueId), null, "GetValueSet"); this.Post("/find/", _ => this.Find(), null, "Find"); this.Post("/", _ => this.AddValueSet(), null, "AddValueSet"); this.Delete("/{valueSetUniqueId}", parameters => this.DeleteValueSet(parameters), null, "DeleteValueSet"); }