示例#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);
        }