Example #1
0
        /// <summary>
        /// Get all the key=value pairs (pins) exposed by the implementor.
        /// </summary>
        /// <param name="item">The optional item. The item with its parts
        /// can optionally be passed to this method for those parts requiring
        /// to access further data.</param>
        /// <returns>The pins: multiple pins with key <c>area</c>,
        /// <c>owner</c> (both filtered, with digits).</returns>
        public override IEnumerable <DataPin> GetDataPins(IItem item)
        {
            DataPinBuilder builder = new DataPinBuilder(
                new StandardDataPinTextFilter());

            if (Provenances?.Count > 0)
            {
                builder.AddValues("area", Provenances.Select(p => p.Area),
                                  filter: true, filterOptions: true);
            }

            if (Owners?.Count > 0)
            {
                builder.AddValues("owner", Owners,
                                  filter: true, filterOptions: true);
            }

            return(builder.Build(this));
        }
Example #2
0
        /// <summary>
        /// Get all the key=value pairs (pins) exposed by the implementor.
        /// </summary>
        /// <param name="item">The optional item. The item with its parts
        /// can optionally be passed to this method for those parts requiring
        /// to access further data.</param>
        /// <returns>The pins: <c>area</c> (filtered, with digits),
        /// <c>pers-count</c>, <c>ann-count</c>, <c>rest-count</c>,
        /// <c>pers-name</c> (full name; filtered, with digits),
        /// <c>pers-date-value</c>, <c>ann-X-count</c>, <c>rest-X-count</c>,
        /// <c>rest-date-value</c>.</returns>
        public override IEnumerable <DataPin> GetDataPins(IItem item)
        {
            DataPinBuilder builder =
                new DataPinBuilder(DataPinHelper.DefaultFilter);

            if (Provenances?.Count > 0)
            {
                builder.AddValues("area", Provenances.Select(p => p.Area),
                                  filter: true, filterOptions: true);
            }

            builder.Set("pers", Persons?.Count ?? 0, false);
            builder.Set("ann", Annotations?.Count ?? 0, false);
            builder.Set("rest", Restorations?.Count ?? 0, false);

            if (Persons?.Count > 0)
            {
                builder.AddValues("pers-name", from p in Persons
                                  where p.Name != null
                                  select p.Name.GetFullName(),
                                  filter: true, filterOptions: true);

                foreach (var person in Persons.Where(p => p.Date != null))
                {
                    builder.AddValue("pers-date-value",
                                     person.Date.GetSortValue());
                }
            }

            if (Annotations?.Count > 0)
            {
                foreach (var annotation in Annotations)
                {
                    string id = SanitizeForPinId(annotation.Type);
                    if (id != null)
                    {
                        builder.Increase(id, false, "ann-");
                    }
                }
            }

            if (Restorations?.Count > 0)
            {
                foreach (var restoration in Restorations)
                {
                    string id = SanitizeForPinId(restoration.Type);
                    if (id != null)
                    {
                        builder.Increase(id, false, "rest-");
                    }

                    if (restoration.Date != null)
                    {
                        builder.AddValue("rest-date-value",
                                         restoration.Date.GetSortValue());
                    }
                }
            }

            return(builder.Build(this));
        }