Пример #1
0
 /// <summary>
 /// Add the claim.
 /// </summary>
 /// <param name="claim">The claim</param>
 internal void addClaim(Claim claim)
 {
     string property = claim.mainSnak.propertyId.getPrefixedId();
     if(!this.claims.ContainsKey(property))
     {
         this.claims[property] = new Dictionary<string,Claim>();
     }
     this.claims[property][claim.internalId] = claim;
 }
Пример #2
0
 /// <summary>
 /// Remove the claim.
 /// </summary>
 /// <param name="claim">The claim</param>
 /// <returns>If the claim was removed successfully</returns>
 internal bool removeClaim(Claim claim)
 {
     string property = claim.mainSnak.propertyId.getPrefixedId();
     if (!this.claims.ContainsKey(property))
     {
         return false;
     }
     if (this.claims[property].Remove(claim.internalId))
     {
         if (this.claims[property].Count == 0)
         {
             this.claims.Remove(property);
         }
         return true;
     }
     return false;
 }
Пример #3
0
        /// <summary>
        /// Get the default edit summary for a claim save.
        /// </summary>
        /// <param name="value">Claim to ber parsed.</param>
        /// <returns>Edit summary.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="value"/> is <c>null</c>.</exception>
        public String GetClaimSaveEditSummary(Claim value)
        {
            if ( value == null )
                throw new ArgumentNullException("value");

            var result = String.Empty;
            Snak snak = value.mainSnak;
            var entityIdValue = snak.DataValue as EntityIdValue;
            if ( entityIdValue != null )
            {
                result = String.Format("[[Property:P{0}]]: [[Q{1}]]", snak.PropertyId.NumericId, entityIdValue.NumericId);
            }
            var stringValue = snak.DataValue as StringValue;
            if ( stringValue != null )
            {
                result = String.Format("[[Property:P{0}]]: {1}", snak.PropertyId.NumericId, stringValue.Value);
            }
            var coordinateValue = snak.DataValue as GlobeCoordinateValue;
            if ( coordinateValue != null )
            {
                result = String.Format(CultureInfo.InvariantCulture, "[[Property:P{0}]]: {1:#.####}, {2:#.####}", snak.PropertyId.NumericId, coordinateValue.Latitude, coordinateValue.Longitude);
            }
            var quantityValue = snak.DataValue as QuantityValue;
            if ( quantityValue != null )
            {
                if ( (quantityValue.LowerBound == quantityValue.UpperBound) && (quantityValue.Amount == quantityValue.UpperBound) )
                {
                    result = String.Format("[[Property:P{0}]]: {1}", snak.PropertyId.NumericId, quantityValue.Amount);
                }
                // TODO: ± if upper and lower not same
            }
            var monoString = snak.DataValue as MonolingualTextValue;
            if ( monoString != null )
            {
                result = String.Format("[[Property:P{0}]]: {1}", snak.PropertyId.NumericId, monoString.Text);
            }
            return result;
        }