Пример #1
0
 private void SubstituteMainForAltNames(
     MatchedName match,
     GazetteerNames gazetteerNames)
 {
     SubstituteAltGazetteerName(match.GazetteerLocation, gazetteerNames);
     SubstituteAltInputName(match.InputLocation, gazetteerNames);
 }
Пример #2
0
 private void SaveMatchLevel1(MatchedName match)
 {
     // Don't save if the values are the same
     if (match.Level1NotSame())
     {
         matchProvider.SaveMatchLevel1(
             match.InputLocation.Name1,
             match.GazetteerLocation.Name1);
     }
 }
Пример #3
0
 private static void ValidateLevel1Match(
     MatchedName match,
     GazetteerNames gazetteerNames,
     StringBuilder stringBuilder)
 {
     if (gazetteerNames.IsInLevel1Names(match.InputLocation.Name1))
     {
         if (match.Level1NotSame())
         {
             // The input value is in the gazetteer but is not the same as the selected match
             stringBuilder.Append(match.OriginalInput.Name1);
         }
     }
 }
Пример #4
0
 private static void ValidateLevel3Match(
     MatchedName match,
     GazetteerNames gazetteerNames,
     StringBuilder errorMessage)
 {
     if (gazetteerNames.IsInLevel3Names(
             match.InputLocation.Name3,
             match.InputLocation.Name1,
             match.InputLocation.Name2))
     {
         if (match.Level3NotSame())
         {
             // The input value is in the gazetteer but is not the same as the selected match
             errorMessage.Append(match.OriginalInput.Name3);
         }
     }
 }
Пример #5
0
        private static void ValidateMatch(MatchedName match, GazetteerNames gazetteerNames)
        {
            StringBuilder errorMessage = new StringBuilder();

            // We do not allow saved matches for input names that already exist in the gazetteer
            // as this would result in conflicting information so throw ex if the input
            // is in the gazetteer and is not the same as the selection.
            ValidateLevel1Match(match, gazetteerNames, errorMessage);
            ValidateLevel2Match(match, gazetteerNames, errorMessage);
            ValidateLevel3Match(match, gazetteerNames, errorMessage);

            if (errorMessage.Length > 0)
            {
                string message = string.Format(
                    "Input name is already in the gazetteer, cannot save match: {0} ",
                    errorMessage);
                throw new NameInGazetteerException(message);
            }
        }
Пример #6
0
        public void SaveMatch(
            Location inputLocation,
            Location gazetteerLocation,
            GazetteerNames gazetteerNames)
        {
            Validate(inputLocation);
            Validate(gazetteerLocation);
            MatchedName match = new MatchedName(inputLocation, gazetteerLocation);

            // Don't save alts to the db
            SubstituteMainForAltNames(match, gazetteerNames);

            // Throw ex if the input already exists in the gazetteer
            ValidateMatch(match, gazetteerNames);

            SaveMatchLevel1(match);
            SaveMatchLevel2(match);
            SaveMatchLevel3(match);
        }
Пример #7
0
 private void SubstituteMainForAltNames(
     MatchedName match,
     GazetteerNames gazetteerNames)
 {
     SubstituteAltGazetteerName(match.GazetteerLocation, gazetteerNames);
     SubstituteAltInputName(match.InputLocation, gazetteerNames);
 }
Пример #8
0
 private void SaveMatchLevel3(MatchedName match)
 {
     // Don't save if the values are the same
     if (match.Level3NotSame())
     {
         matchProvider.SaveMatchLevel3(
             match.InputLocation.Name3,
             match.GazetteerLocation.Name1,
             match.GazetteerLocation.Name2,
             match.GazetteerLocation.Name3);
     }
 }
Пример #9
0
        private static void ValidateMatch(MatchedName match, GazetteerNames gazetteerNames)
        {
            StringBuilder errorMessage = new StringBuilder();

            // We do not allow saved matches for input names that already exist in the gazetteer
            // as this would result in conflicting information so throw ex if the input
            // is in the gazetteer and is not the same as the selection.
            ValidateLevel1Match(match, gazetteerNames, errorMessage);
            ValidateLevel2Match(match, gazetteerNames, errorMessage);
            ValidateLevel3Match(match, gazetteerNames, errorMessage);

            if (errorMessage.Length > 0)
            {
                string message = string.Format(
                    "Input name is already in the gazetteer, cannot save match: {0} ",
                    errorMessage);
                throw new NameInGazetteerException(message);
            }
        }
Пример #10
0
 private static void ValidateLevel3Match(
     MatchedName match,
     GazetteerNames gazetteerNames,
     StringBuilder errorMessage)
 {
     if (gazetteerNames.IsInLevel3Names(
         match.InputLocation.Name3,
         match.InputLocation.Name1,
         match.InputLocation.Name2))
     {
         if (match.Level3NotSame())
         {
             // The input value is in the gazetteer but is not the same as the selected match
             errorMessage.Append(match.OriginalInput.Name3);
         }
     }
 }
Пример #11
0
 private static void ValidateLevel1Match(
     MatchedName match,
     GazetteerNames gazetteerNames,
     StringBuilder stringBuilder)
 {
     if (gazetteerNames.IsInLevel1Names(match.InputLocation.Name1))
     {
         if (match.Level1NotSame())
         {
             // The input value is in the gazetteer but is not the same as the selected match
             stringBuilder.Append(match.OriginalInput.Name1);
         }
     }
 }
Пример #12
0
        public void SaveMatch(
            Location inputLocation,
            Location gazetteerLocation,
            GazetteerNames gazetteerNames)
        {
            Validate(inputLocation);
            Validate(gazetteerLocation);
            MatchedName match = new MatchedName(inputLocation, gazetteerLocation);

            // Don't save alts to the db
            SubstituteMainForAltNames(match, gazetteerNames);

            // Throw ex if the input already exists in the gazetteer
            ValidateMatch(match, gazetteerNames);

            SaveMatchLevel1(match);
            SaveMatchLevel2(match);
            SaveMatchLevel3(match);
        }