Example #1
0
        /// <summary>
        /// Gets all property mappings for the configured index and the supplied type
        /// </summary>
        internal IndexMapping GetIndexMapping(Type type, string language, string index)
        {
            if (String.IsNullOrEmpty(index))
            {
                index = _settings.GetDefaultIndexName(language);
            }

            string       typeName   = type.GetTypeName();
            string       mappingUri = GetMappingUri(index, typeName);
            IndexMapping mappings;

            _logger.Debug($"GetIndexMapping for: {typeName}. Uri: {mappingUri}");

            try
            {
                mappings = BuildIndexMapping(_httpClientHelper.GetString(new Uri(mappingUri)), index, typeName);
            }
            catch (Exception ex)
            {
                _logger.Debug("Failed to get existing mapping from uri '" + mappingUri + "'", ex);
                mappings = new IndexMapping();
            }

            if (mappings.Properties == null)
            {
                mappings.Properties = new Dictionary <string, IndexMappingProperty>();
            }

            return(mappings);
        }
Example #2
0
        async static Task CreateIndex()
        {
            #region Create Index

            if (await client.IndexExistsAsync())
            {
                await client.RemoveIndexAsync();
            }
            await client.CreateIndexAsync();

            #endregion

            #region Mapping

            var mapping = new IndexMapping()
            {
                PrimaryFields = new string[] { "title", "content" },
                Fields        = new FieldMapping[]
                {
                    new DocumentGuidField(),
                    new IndexField("title"),
                    new IndexField("content"),
                    new IndexField("feed_id", FieldTypes.StringType),
                    new IndexField("publish_date", FieldTypes.DateTimeType),
                    new StoredField("url"),
                    new StoredField("image"),
                }
            };

            await client.MapAsync(mapping);

            #endregion
        }
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region private functions
        /// <summary>
        /// Refresh the list of vists data
        /// </summary>
        private void OnRefreshList()
        {
            try
            {
                Lstvw_Main.BeginRefresh();
                var iMap = AppData.PropertyModel.SelectedRecord.IndexMap;
                iMap = new IndexMapping(iMap.Property, iMap.RequestGroup, iMap.Record, 0);
                var inspectionList = AppData.PropertyModel.EntityFromMapping(iMap) as SRiInspection;
                var visitsList     = new List <CreateVisitsList>();
                if (inspectionList != null)
                {
                    var visitcount = inspectionList.Visits.Count;
                    for (int j = 0; j < visitcount; j++)
                    {
                        var data       = inspectionList.Visits[j];
                        var visitsData = new CreateVisitsList()
                        {
                            VisitTypeDescription = data.VisitTypeDescription,
                            ScheduleDate         = data.Visit.DateScheduled.ToString("dd MMM yyyy", "Scheduled for ", "Not scheduled"),
                            CompletedDate        = data.Visit.DateVisit.ToString("dd MMM yyyy", "Completed on ", "Outstanding"),
                            VisitListIndex       = j
                        };
                        visitsList.Add(visitsData);
                    }
                }
                Lstvw_Main.ItemsSource   = visitsList;
                Lstvw_Main.HeightRequest = visitsList.Count * 100;
                Lstvw_Main.EndRefresh();
                GC.Collect();
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
        async public Task <LuceneMappingResult> MappingAsync()
        {
            if (_mapping == null)
            {
                using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"{ _serverUrl }/lucene/mapping/{ _indexName }"))
                {
                    ModifyHttpRequest(requestMessage);

                    using (var httpResponse = await _httpClient.SendAsync(requestMessage))
                    {
                        var apiResult = await httpResponse.DeserializeFromSuccessResponse <LuceneMappingResult>();

                        if (apiResult != null)
                        {
                            _mapping = apiResult.Mapping;
                        }

                        return(apiResult);
                    }
                }
            }
            else
            {
                return(new LuceneMappingResult()
                {
                    Mapping = _mapping
                });
            }
        }
        public bool Map(string indexName, IndexMapping mapping)
        {
            try
            {
                if (ArchiveExists(indexName))
                {
                    var filePath = Path.Combine(ArchiveMetaPath(indexName), "mapping.json");

                    var fileInfo = new FileInfo(filePath);
                    if (fileInfo.Exists)
                    {
                        fileInfo.Delete();
                    }

                    if (fileInfo.Directory.Exists == false)
                    {
                        fileInfo.Directory.Create();
                    }

                    File.WriteAllText(
                        filePath,
                        JsonSerializer.Serialize(mapping));
                }

                return(true);
            }
            catch
            {
                return(false);
            }
        }
        /// ------------------------------------------------------------------------------------------------
        #region public functions

        /// <summary>
        /// Refresh the list of vists data
        /// </summary>
        public void OnRefreshList()
        {
            List <CreateVisitsList> VisitsList;
            CreateVisitsList        VisitsData;

            Lstvw_Main.BeginRefresh();
            IndexMapping iMap;

            iMap = AppData.PropertyModel.SelectedRecord.IndexMap;
            iMap = new IndexMapping(iMap.Property, iMap.RequestGroup, iMap.Record, 0);
            var InspectionList = AppData.PropertyModel.EntityFromMapping(iMap) as SRiInspection;

            VisitsList = new List <CreateVisitsList>();
            var visitcount = InspectionList.Visits.Count;

            for (int j = 0; j < visitcount; j++)
            {
                var data = InspectionList.Visits[j];
                VisitsData = new CreateVisitsList()
                {
                    VisitTypeDescription = data.VisitTypeDescription,
                    ScheduleDate         = data.Visit.DateScheduled.ToString("dd MMM yyyy", "Scheduled for ", "Not scheduled"),
                    CompletedDate        = data.Visit.DateVisit.ToString("dd MMM yyyy", "Completed on ", "Outstanding"),
                    VisitListIndex       = j
                };
                VisitsList.Add(VisitsData);
            }
            Lstvw_Main.ItemsSource   = VisitsList;
            Lstvw_Main.HeightRequest = (VisitsList.Count * 110) + 40;
            Lstvw_Main.EndRefresh();
            GC.Collect();
        }
Example #7
0
 /**
  * Rationalizes the sheets xf index mapping
  * @param xfmapping the index mapping
  */
 public void rationalize(IndexMapping xfmapping)
 {
     if (defaultFormat)
     {
         xfIndex = xfmapping.getNewIndex(xfIndex);
     }
 }
Example #8
0
        /// <summary>
        /// Gets all property mappings for the configured index and the supplied type
        /// </summary>
        internal static async Task <IndexMapping> GetIndexMappingAsync(Type type, string language, string index)
        {
            if (String.IsNullOrEmpty(index))
            {
                index = ElasticSearchSettings.GetDefaultIndexName(language);
            }

            index = index.ToLower();

            string       typeName   = type.GetTypeName();
            string       mappingUri = GetMappingUri(index, typeName);
            IndexMapping mappings;

            Logger.Debug($"GetIndexMapping for: {typeName}. Uri: {mappingUri}");

            try
            {
                string mappingJson = await HttpClientHelper.GetStringAsync(new Uri(mappingUri));

                mappings = BuildIndexMapping(mappingJson, index, typeName);
            }
            catch (Exception ex)
            {
                Logger.Debug("Failed to get existing mapping from uri '" + mappingUri + "'", ex);
                mappings = new IndexMapping();
            }

            if (mappings.Properties == null)
            {
                mappings.Properties = new Dictionary <string, IndexMappingProperty>();
            }

            return(mappings);
        }
        public void ShouldWriteElement()
        {
            var mapping = new IndexMapping();

            writer.VerifyXml(mapping)
            .RootElement.HasName("index");
        }
Example #10
0
        public override void ProcessIndex(IndexMapping indexMapping)
        {
            var conventions = finder.Find <IIndexConvention>();

            Apply <IIndexInspector, IIndexInstance>(conventions,
                                                    new IndexInstance(indexMapping));
        }
        public List <MappingValidatorType> Validate(IndexInformation index)
        {
            var errors = new List <MappingValidatorType>();

            IndexMapping currentMappings = GetCurrentIndexMappings(index);

            List <(Type, List <IndexableProperty>)> correctMappings = GetCorrectMappings(index);

            foreach ((Type, List <IndexableProperty>)correctMapping in correctMappings)
            {
                var properties = new List <MappingValidatorProperty>();

                foreach (IndexableProperty indexableProperty in correctMapping.Item2)
                {
                    CoreIndexer.GetPropertyMapping(indexableProperty, "no", currentMappings, out MappingConflict mappingConflict);
                    if (mappingConflict != MappingConflict.Found)
                    {
                        IEnumerable <string> errorDescriptions = mappingConflict.AsEnumDescriptions();
                        properties.Add(new MappingValidatorProperty(indexableProperty.Name, errors: errorDescriptions));
                    }
                }

                if (properties.Any())
                {
                    errors.Add(new MappingValidatorType(correctMapping.Item1.Name, properties));
                }
            }

            return(errors);
        }
Example #12
0
        /// <see>Dijkstra, Edsger W.,  A Discipline of Programming. Prentice-Hall, 1997.</see>
        /// <summary>
        ///     * Find the largest i for which a[i] < a[i+i]
        ///     * Replace a[i] with the next largest value in ( a[i+1] ... a[n] }.
        ///     * Reverse (a[i+1] ... [a[n]).  (I.e., set to lex. increasing order).
        /// </summary>
        public static IEnumerable <IEnumerable <int> > GetPermutations(int[] items)
        {
            int length = items.Length;

            IndexMapping[] indexPermutation = new IndexMapping[length];
            for (int i = 0; i < length; i++)
            {
                indexPermutation[i] = new IndexMapping(i, i);
            }
            while (true)
            {
                int i = length - 2;
                // Find largest non-decreasing final subsequence.
                for (; i >= 0 && indexPermutation[i].Index >= indexPermutation[i + 1].Index; i--)
                {
                }
                if (i < 0)
                {
                    yield break;
                }                            // Seq indices are in decreasing order
                int j = length - 1;
                // Find number to the right of a[i] that is next-largest.
                for (; j > i && indexPermutation[i].Index >= indexPermutation[j].Index; j--)
                {
                }
                Swap(ref indexPermutation[i], ref indexPermutation[j]);
                Array.Reverse(indexPermutation, i + 1, length - i - 1);
                yield return(applyIndexPermutation(items, indexPermutation));
            }
        }
Example #13
0
        public bool Map(string indexName, IndexMapping mapping)
        {
            if (!IndexExists(indexName))
            {
                throw new Exception("Index not exists");
            }

            if (mapping == null)
            {
                throw new ArgumentException("Parameter mapping == null");
            }

            var filePath = Path.Combine(_rootPath, MetaIndexName(indexName), "mapping.json");

            var fileInfo = new FileInfo(filePath);

            if (fileInfo.Exists)
            {
                fileInfo.Delete();
            }

            File.WriteAllText(
                filePath,
                JsonSerializer.Serialize(mapping));

            _archive.Map(indexName, mapping);

            _resources.RefreshMapping(indexName);

            return(true);
        }
        /// <summary>
        /// On tapped in visits data
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private async void Visits_Tapped(object s, ItemTappedEventArgs e)
        {
            try
            {
                if (_isExecute)
                {
                    _isExecute = false;
                    var data = e.Item as CreateVisitsList;
                    AppData.PropertyModel.SelectedVisit = null;
                    var iMap = AppData.PropertyModel.SelectedRecord.IndexMap;
                    if (data != null)
                    {
                        iMap = new IndexMapping(iMap.Property, iMap.RequestGroup, iMap.Record, 0, data.VisitListIndex);

                        var details = AppData.PropertyModel.SelectedRecord.Record.Record.Inspections[0].Visits[data.VisitListIndex];
                        //Details.Status = SyncStatus.New;
                        AppData.PropertyModel.SelectedVisit = new SelectedVisit(details, iMap, false);
                    }
                    //await SplitView.Instace().Navigation.PushModalAsync(new VisitActionPage(),true);
                    PageNavigation.PushMainPage(new VisitActionPage());
                    _isExecute = true;
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Example #15
0
        /**
         * Rationalizes the sheet's xf index mapping
         * @param xfMapping the index mapping for XFRecords
         * @param fontMapping the index mapping for fonts
         * @param formatMapping the index mapping for formats
         */
        public void rationalize(IndexMapping xfMapping,
                                IndexMapping fontMapping,
                                IndexMapping formatMapping)
        {
            if (!initialized)
            {
                initialize();
            }

            // Read through the array, looking for the data types
            // This is a total hack bodge for now - it will eventually need to be
            // integrated properly
            int  pos    = 0;
            int  code   = 0;
            int  length = 0;
            Type type   = null;

            while (pos < data.Length)
            {
                code   = IntegerHelper.getInt(data[pos], data[pos + 1]);
                length = IntegerHelper.getInt(data[pos + 2], data[pos + 3]);

                type = Type.getType(code);

                if (type == Type.FONTX)
                {
                    int fontind = IntegerHelper.getInt(data[pos + 4], data[pos + 5]);
                    IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                              data, pos + 4);
                }
                else if (type == Type.FBI)
                {
                    int fontind = IntegerHelper.getInt(data[pos + 12], data[pos + 13]);
                    IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                              data, pos + 12);
                }
                else if (type == Type.IFMT)
                {
                    int formind = IntegerHelper.getInt(data[pos + 4], data[pos + 5]);
                    IntegerHelper.getTwoBytes(formatMapping.getNewIndex(formind),
                                              data, pos + 4);
                }
                else if (type == Type.ALRUNS)
                {
                    int numRuns = IntegerHelper.getInt(data[pos + 4], data[pos + 5]);
                    int fontPos = pos + 6;
                    for (int i = 0; i < numRuns; i++)
                    {
                        int fontind = IntegerHelper.getInt(data[fontPos + 2],
                                                           data[fontPos + 3]);
                        IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                                  data, fontPos + 2);
                        fontPos += 4;
                    }
                }

                pos += length + 4;
            }
        }
 async public Task <IApiResult> Map(string id, [FromBody] IndexMapping mapping)
 {
     return(await SecureMethodHandler(id, (id) =>
     {
         return Task.FromResult <IApiResult>(new ApiResult(
                                                 _lucene.Map(id, mapping)
                                                 ));
     }));
 }
Example #17
0
        public void ShouldWriteColumns()
        {
            var mapping = new IndexMapping();

            mapping.AddColumn(new ColumnMapping());

            writer.VerifyXml(mapping)
            .Element("column").Exists();
        }
        public void ShouldWriteManyToManyElement()
        {
            var mapping = new IndexMapping {
                IsManyToMany = true
            };

            writer.VerifyXml(mapping)
            .RootElement.HasName("index-many-to-many");
        }
Example #19
0
        private void CreateListIndexMapping(Action <ListIndexPart> customIndex)
        {
            indexMapping = new IndexMapping();
            var builder = new ListIndexPart(indexMapping);

            if (customIndex != null)
            {
                customIndex(builder);
            }
        }
Example #20
0
        private void CreateIndexMapping(Action <IndexBuilder> customIndex)
        {
            indexMapping = new IndexMapping();
            var builder = new IndexBuilder(indexMapping);

            if (customIndex != null)
            {
                customIndex(builder);
            }
        }
        public void ShouldWriteForeignKey()
        {
            var mapping = new IndexMapping {
                IsManyToMany = true
            };

            mapping.ForeignKey = "FKTest";

            writer.VerifyXml(mapping)
            .HasAttribute("foreign-key", "FKTest");
        }
Example #22
0
        void InitialiseDefaults(Member member)
        {
            mapping.Member = member;
            mapping.SetDefaultValue(x => x.Name, member.Name);
            mapping.SetDefaultValue(x => x.TableName, mapping.ContainingEntityType.Name + member.Name);

            mapping.Key = key = new KeyMapping();
            key.AddDefaultColumn(new ColumnMapping {
                Name = mapping.ContainingEntityType.Name + "_id"
            });

            mapping.Index = index = new IndexMapping();
            mapping.Index.As <IndexMapping>(ix =>
                                            ix.SetDefaultValue(x => x.Type, new TypeReference(KeyType)));

            if (ValueType.IsSimpleType())
            {
                // value type value (element)
                mapping.Element = element = new ElementMapping();
                element.AddDefaultColumn(new ColumnMapping {
                    Name = "Value"
                });
                element.SetDefaultValue(x => x.Type, new TypeReference(typeof(TValue)));
            }
            else
            {
                // entity value
                mapping.Relationship = manyToMany = new ManyToManyMapping();
                manyToMany.Class     = new TypeReference(ValueType);
                manyToMany.AddDefaultColumn(new ColumnMapping {
                    Name = ValueType.Name + "_id"
                });
                manyToMany.ParentType = mapping.ContainingEntityType;
                manyToMany.ChildType  = ValueType;
            }

            if (KeyType.IsSimpleType())
            {
                mapping.Index.As <IndexMapping>(ix =>
                                                ix.AddDefaultColumn(new ColumnMapping {
                    Name = "Key"
                }));
            }
            else
            {
                mapping.Index.As <IndexMapping>(ix =>
                {
                    ix.IsManyToMany = true;
                    ix.AddDefaultColumn(new ColumnMapping {
                        Name = KeyType.Name + "_id"
                    });
                });
            }
        }
Example #23
0
        private void CreateIndexMapping(Action <IndexPart> customIndex)
        {
            var indexPart = new IndexPart(typeof(T));

            if (customIndex != null)
            {
                customIndex(indexPart);
            }

            indexMapping = indexPart.GetIndexMapping();
        }
Example #24
0
        public IndexMapping GetIndexMapping()
        {
            var mapping = new IndexMapping(attributes.CloneInner());

            mapping.ContainingEntityType = entity;

            columns.Each(x => mapping.AddColumn(new ColumnMapping {
                Name = x
            }));

            return(mapping);
        }
Example #25
0
        private void CreateIndexMapping(Action <IndexPart> customIndex)
        {
            var indexPart = new IndexPart(typeof(T));

            if (customIndex != null)
            {
                customIndex(indexPart);
            }

#pragma warning disable 612,618
            indexMapping = indexPart.GetIndexMapping();
#pragma warning restore 612,618
        }
 void ICollectionInstance.AsList()
 {
     mapping.Collection = Collection.List;
     if (mapping.Index == null)
     {
         var indexMapping  = new IndexMapping();
         var columnMapping = new ColumnMapping();
         columnMapping.Set(x => x.Name, Layer.Defaults, "Index");
         indexMapping.AddColumn(Layer.Defaults, columnMapping);
         mapping.Set(x => x.Index, Layer.Defaults, indexMapping);
     }
     ;
 }
Example #27
0
        public IndexMapping GetIndexMapping()
        {
            var mapping = new IndexMapping(attributes.Clone());

            mapping.ContainingEntityType = entity;

            columns.Each(name =>
            {
                var columnMapping = new ColumnMapping();
                columnMapping.Set(x => x.Name, Layer.Defaults, name);
                mapping.AddColumn(Layer.UserSupplied, columnMapping);
            });

            return(mapping);
        }
        /// <summary>
        /// On tapped in visits data
        /// </summary>
        /// <param name="s"></param>
        /// <param name="e"></param>
        private async void Visits_Tapped(object s, ItemTappedEventArgs e)
        {
            var data = e.Item as CreateVisitsList;

            AppData.PropertyModel.SelectedVisit = null;
            IndexMapping iMap;

            iMap = AppData.PropertyModel.SelectedRecord.IndexMap;
            iMap = new IndexMapping(iMap.Property, iMap.RequestGroup, iMap.Record, 0, data.VisitListIndex);

            var Details = AppData.PropertyModel.SelectedRecord.Record.Record.Inspections[0].Visits[data.VisitListIndex];

            AppData.PropertyModel.SelectedVisit = new SelectedVisit(Details, iMap, false);
            await SplitView.Instace().Navigation.PushModalAsync(new VisitActionPage());
        }
            public void RefreshMapping()
            {
                IndexMapping mapping = null;

                try
                {
                    var indexMetaPath = Path.Combine(_rootPath, $".{ _indexName }", "mapping.json");

                    var metaFileInfo = new FileInfo(indexMetaPath);
                    if (metaFileInfo.Exists)
                    {
                        mapping = File.ReadAllText(metaFileInfo.FullName).DeserializeJson <IndexMapping>();
                    }
                }
                catch { }

                _mapping = mapping ?? new IndexMapping();  // default (empty) mapping
            }
        async public Task <bool> MapAsync(IndexMapping mapping)
        {
            HttpContent postContent = new StringContent(
                JsonSerializer.Serialize(mapping),
                Encoding.UTF8,
                "application/json");

            using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, $"{ _serverUrl }/lucene/map/{ _indexName }"))
            {
                ModifyHttpRequest(requestMessage);
                requestMessage.Content = postContent;

                using (var httpResponse = await _httpClient.SendAsync(requestMessage))
                {
                    var apiResult = await httpResponse.DeserializeFromSuccessResponse <ApiResult>();

                    return(apiResult.Success);
                }
            }
        }
Example #31
0
        /**
         * Rationalizes the sheet's xf index mapping
         * @param xfMapping the index mapping for XFRecords
         * @param fontMapping the index mapping for fonts
         * @param formatMapping the index mapping for formats
         */
        public void rationalize(IndexMapping xfMapping,
            IndexMapping fontMapping,
            IndexMapping formatMapping)
        {
            if (!initialized)
                {
                initialize();
                }

            // Read through the array, looking for the data types
            // This is a total hack bodge for now - it will eventually need to be
            // integrated properly
            int pos = 0;
            int code = 0;
            int length = 0;
            Type type = null;
            while (pos < data.Length)
                {
                code = IntegerHelper.getInt(data[pos],data[pos + 1]);
                length = IntegerHelper.getInt(data[pos + 2],data[pos + 3]);

                type = Type.getType(code);

                if (type == Type.FONTX)
                    {
                    int fontind = IntegerHelper.getInt(data[pos + 4],data[pos + 5]);
                    IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                              data,pos + 4);
                    }
                else if (type == Type.FBI)
                    {
                    int fontind = IntegerHelper.getInt(data[pos + 12],data[pos + 13]);
                    IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                              data,pos + 12);
                    }
                else if (type == Type.IFMT)
                    {
                    int formind = IntegerHelper.getInt(data[pos + 4],data[pos + 5]);
                    IntegerHelper.getTwoBytes(formatMapping.getNewIndex(formind),
                                              data,pos + 4);
                    }
                else if (type == Type.ALRUNS)
                    {
                    int numRuns = IntegerHelper.getInt(data[pos + 4],data[pos + 5]);
                    int fontPos = pos + 6;
                    for (int i = 0; i < numRuns; i++)
                        {
                        int fontind = IntegerHelper.getInt(data[fontPos + 2],
                                                           data[fontPos + 3]);
                        IntegerHelper.getTwoBytes(fontMapping.getNewIndex(fontind),
                                                  data,fontPos + 2);
                        fontPos += 4;
                        }
                    }

                pos += length + 4;
                }
        }
        private void ImportAllStringRefs()
        {
            // TPT
            var m12PrimaryTptRefs = ImportStringRefs("m12-tpt-primary.json");
            var ebPrimaryTptRefs = ImportStringRefs("eb-tpt-primary.json");

            var m12SecondaryTptRefs = ImportStringRefs("m12-tpt-secondary.json");
            var ebSecondaryTptRefs = ImportStringRefs("eb-tpt-secondary.json");

            tptGroups.Groups.AddRange(MatchRefs(ebPrimaryTptRefs, m12PrimaryTptRefs));
            tptGroups.Groups.AddRange(MatchRefs(ebSecondaryTptRefs, m12SecondaryTptRefs));
            tptGroups.SortGroups();

            // Battle actions
            var m12BattleActionRefs = ImportStringRefs("m12-battle-actions.json");
            var ebBattleActionRefs = ImportStringRefs("eb-battle-actions.json");

            battleActionGroups.Groups.AddRange(MatchRefs(ebBattleActionRefs, m12BattleActionRefs));
            battleActionGroups.SortGroups();

            // Item help
            itemMapping = JsonConvert.DeserializeObject<IndexMapping>(File.ReadAllText("item-map.json"));
            var m12ItemHelpRefs = ImportStringRefs("m12-item-help.json");
            var ebItemHelpRefs = ImportStringRefs("eb-item-help.json");

            var itemHelpMappingGroups = itemMapping.Select(p => new MatchedGroup(
                ebItemHelpRefs.First(e => e.Index == p.First),
                m12ItemHelpRefs.First(m => m.Index == p.Second)))
                .OrderBy(g => g.Refs[Game.Eb].Index)
                .ToArray();

            itemHelpGroups.Groups.AddRange(itemHelpMappingGroups);

            // PSI help
            var m12PsiHelpRefs = ImportStringRefs("m12-psi-help.json");
            var ebPsiHelpRefs = ImportStringRefs("eb-psi-help.json");

            var psiHelpMappingGroups = ebPsiHelpRefs.Select(e =>
                new MatchedGroup(e,
                    m12PsiHelpRefs.First(m => m.Index == e.Index - 1)))
                .ToArray();

            psiHelpGroups.Groups.AddRange(psiHelpMappingGroups);
            psiHelpGroups.SortGroups();

            // Raw M12
            var labels = Enumerable.Range(0, 5864);
            foreach (int i in labels)
            {
                rawM12Groups.Groups.Add(new MatchedGroup(i, "L" + i.ToString()));
            }

            // Raw EB
            labels = Enumerable.Range(0, 5357);
            foreach (int i in labels)
            {
                rawEbGroups.Groups.Add(new MatchedGroup(Game.Eb, i, "L" + i.ToString()));
            }

            matchedCollections.Add(tptGroups);
            matchedCollections.Add(battleActionGroups);
            matchedCollections.Add(itemHelpGroups);
            matchedCollections.Add(psiHelpGroups);
            matchedCollections.Add(rawM12Groups);
            matchedCollections.Add(rawEbGroups);
        }