예제 #1
0
 private void SetSlogan(IEnumerable <Entity> entities, StringBuilder collisionInfo, Boolean overrideData)
 {
     if (entities == null)
     {
         throw new ArgumentNullException("entities");
     }
     ClearRunInfo();
     foreach (var entity in entities)
     {
         var item = _helper.GetWikiDataItemForEntity(entity);
         if (item == null)
         {
             _runInfo[WikiDataState.ItemNotFound]++;
             collisionInfo.AppendFormat("{0}: {1} was deleted!", entity.wiki.wikidata, entity.english);
         }
         else
         {
             var state = _helper.SloganCorrect(item, entity);
             _runInfo[state]++;
             if (state == WikiDataState.WrongValue)
             {
                 collisionInfo.AppendFormat("{0}: {1} has wrong slogan", item.id, entity.english);
                 collisionInfo.AppendLine();
             }
             if (state != WikiDataState.Valid)
             {
                 var statement = _helper.SetSlogan(item, entity);
                 if (statement != null)
                 {
                     statement.save(_helper.GetClaimSaveEditSummary(statement));
                     if ((statement != null) && entity.type.IsCompatibleEntityType(EntityType.Amphoe))
                     {
                         var source = AmphoeComHelper.AmphoeWebsite(entity.geocode);
                         if (source != null)
                         {
                             var snak            = new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdReferenceUrl), new StringValue(source.AbsoluteUri));
                             var sloganReference = statement.CreateReferenceForSnak(snak);
                             statement.AddReference(sloganReference);
                             foreach (var reference in statement.References)
                             {
                                 reference.Save(_helper.GetReferenceSaveEditSummary(reference));
                             }
                         }
                     }
                 }
             }
         }
     }
 }