public void AddPopulationDataReferences(Statement statement, PopulationData data, Entity entity) { Reference reference = null; Snak snak; switch ( data.source ) { case PopulationDataSourceType.Census: var statedInItem = String.Empty; if ( WikiBase.ItemCensus.Keys.Contains(data.Year) ) { statedInItem = WikiBase.ItemCensus[data.Year]; } snak = new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdStatedIn), new EntityIdValue(new EntityId(statedInItem))); reference = statement.CreateReferenceForSnak(snak); foreach ( var refItem in data.reference ) { var urlReference = refItem as MyUri; if ( urlReference != null ) { reference.AddSnak(new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdReferenceUrl), new StringValue(urlReference.Value))); } } break; case PopulationDataSourceType.DOPA: Uri source = PopulationDataDownloader.GetDisplayUrl(data.Year, entity.geocode); snak = new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdReferenceUrl), new StringValue(source.AbsoluteUri)); reference = statement.CreateReferenceForSnak(snak); reference.AddSnak(new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdPublisher), new EntityIdValue(new EntityId(WikiBase.ItemDopa)))); break; } if ( reference != null ) { statement.AddReference(reference); } }
private Boolean CreateDateQualifierAndReference(Statement statement, String propertyId, HistoryEntryBase entityHistory) { var result = false; var startDateQualifier = statement.Qualifiers.FirstOrDefault(x => x.PropertyId.PrefixedId == propertyId); if ( startDateQualifier == null ) { startDateQualifier = new Qualifier(statement, SnakType.Value, new EntityId(propertyId), TimeValue.DateValue(entityHistory.effective)); result = true; } var gazetteReference = entityHistory.Items.FirstOrDefault(x => x is GazetteRelated) as GazetteRelated; if ( gazetteReference != null ) { GazetteEntry gazetteAnnouncement = GlobalData.AllGazetteAnnouncements.FindAnnouncement(gazetteReference); if ( gazetteAnnouncement != null ) { var snak = new Snak(SnakType.Value, new EntityId(WikiBase.PropertyIdReferenceUrl), new StringValue(gazetteAnnouncement.DownloadUrl.AbsoluteUri)); var startDateReference = statement.CreateReferenceForSnak(snak); result = true; } } return result; }