public static IEnumerable <FiltersDefinition> ShuffleSimpleRandomFiltersCombination(IEnumerable <Mission> missions, Dictionary <string, CatalogueSetConfiguration> catConfig, int num, Func <ItemNumberRange, string> rangeReformatter = null) { List <FiltersDefinition> _randomCombinations = new List <FiltersDefinition>(); var baselines = catConfig.Select(cc => DataHelper.ResolveBaseline(cc.Key, cc.Value)); for (int i = 0; i < num; i++) { // Shuffle in missions present in the baselines... var matchingMissions = missions.Where(m => baselines.Any(b => // and in the collections... b.Collections.Any(c => // with the platform parameter equals to the mission name c.Value.Parameters.Any(p => p.FullName == "{http://a9.com/-/opensearch/extensions/eo/1.0/}platform" && p.Value == m.MissionName.Value)))); var _mission = matchingMissions.ToArray()[rnd.Next(0, matchingMissions.Count())]; var collections = baselines.SelectMany(b => b.Collections.Where(c => c.Value.Parameters.Any(p => p.FullName == "{http://a9.com/-/opensearch/extensions/eo/1.0/}platform" && p.Value == _mission.MissionName.Value))).ToDictionary(kvp => kvp.Key, kvp => kvp.Value); var fd = Mission.ShuffleSimpleRandomFiltersCombination(_mission, collections, string.Format("Simple-Random-{0}", i), rangeReformatter); // fd.AddFilter("archiveStatus", "{http://a9.com/-/opensearch/extensions/eo/1.0/}statusSubType", "online", "Online", null, null); _randomCombinations.Add(fd); } return(_randomCombinations); }
public static FiltersDefinition GenerateOfflineDataFiltersDefinition(int max, IEnumerable <Mission> missions, Dictionary <string, CatalogueSetConfiguration> catConfig) { FiltersDefinition _filtersDefinition = Mission.ShuffleSimpleRandomFiltersCombination(missions, catConfig, 1).First(); _filtersDefinition.Name = "Offline-Random"; _filtersDefinition.AddFilter("archiveStatus", "{http://a9.com/-/opensearch/extensions/eo/1.0/}statusSubType", "Offline", "Offline data", Mission.GetArchivingStatusValidator(Terradue.ServiceModel.Ogc.Eop21.StatusSubTypeValueEnumerationType.OFFLINE), null); _filtersDefinition.AddFilter("sensingEnd", "{http://a9.com/-/opensearch/extensions/time/1.0/}end", DateTime.UtcNow.Subtract(TimeSpan.FromDays(700)).ToString("s"), "more than 2 years ago", null, null); return(_filtersDefinition); }