/// <summary> /// retrieves contributors of resource and adds them to the associated metadata element /// </summary> /// <param name="metadata">the associated metadata</param> /// <param name="scholarlyWorks">scholarlyWorks object whose contributors to be retrieved</param> private static void AddResourceContributors(XElement metadata, ScholarlyWorks.ScholarlyWork scholarlyWorks) { if (null == metadata || null == scholarlyWorks) { return; } scholarlyWorks.Contributors.ToList().ForEach(delegate(ScholarlyWorks.Contact contact) { ScholarlyWorks.Person person = contact as ScholarlyWorks.Person; string personDetails = string.Empty; if (null != person) { personDetails = CoreHelper.GetCompleteName(person.FirstName, person.MiddleName, person.LastName); //In case if any other details are to be added then they can be added here } if (!string.IsNullOrEmpty(personDetails)) { metadata.Add(MetadataProviderHelper.GetElement(MetadataProviderHelper.Metadata_Contributor, personDetails)); } }); }
/// <summary> /// Creates the syndication item. /// </summary> /// <typeparam name="T">Type of resource.</typeparam> /// <param name="resource">The associated resource.</param> /// <returns>The SyndicationItem Object.</returns> private SyndicationItem CreateSyndicationItem <T>(T resource) where T : Core.Resource { if (null == resource) { return(null); } SyndicationItem item = new SyndicationItem(); //TODO: Would Title be Non Empty always.. If no then what would be the heading for the feed? item.Title = new TextSyndicationContent( string.IsNullOrEmpty(resource.Title) ? string.Empty : resource.Title); //item.Summary = new TextSyndicationContent( // string.IsNullOrEmpty(resource.Description) ? string.Empty : resource.Description); //TODO: How do we set the attributes for fields which are there only in Scholarly Works. ScholarlyWorks.ScholarlyWork scholarlyWork = resource as ScholarlyWorks.ScholarlyWork; if (null != scholarlyWork) { item.Copyright = new TextSyndicationContent( string.IsNullOrEmpty(scholarlyWork.Copyright) ? PlatformSettings.Copyrights : scholarlyWork.Copyright); // add authors scholarlyWork.Authors.ToList().ForEach(delegate(ScholarlyWorks.Contact contact) { ScholarlyWorks.Person person = contact as ScholarlyWorks.Person; if (null != person) { string name = CoreHelper.GetCompleteName(person.FirstName, person.MiddleName, person.LastName); item.Authors.Add(new SyndicationPerson( string.IsNullOrEmpty(person.Email) ? PlatformSettings.AuthorEmail : person.Email, name, string.IsNullOrEmpty(person.Uri) ? null : person.Uri)); } }); // add Contributors scholarlyWork.Contributors.ToList().ForEach(delegate(ScholarlyWorks.Contact contact) { ScholarlyWorks.Person person = contact as ScholarlyWorks.Person; if (null != person) { string name = CoreHelper.GetCompleteName(person.FirstName, person.MiddleName, person.LastName); item.Contributors.Add(new SyndicationPerson( string.IsNullOrEmpty(person.Email) ? PlatformSettings.AuthorEmail : person.Email, name, string.IsNullOrEmpty(person.Uri) ? null : person.Uri)); } }); // add tags as categories scholarlyWork.Tags.ToList().ForEach(delegate(ScholarlyWorks.Tag tag) { item.Categories.Add(new SyndicationCategory(tag.Title)); }); scholarlyWork.CategoryNodes.ToList().ForEach(delegate(ScholarlyWorks.CategoryNode category) { item.Categories.Add(new SyndicationCategory(category.Title)); }); } item.Id = resource.Id.ToString(); if (null != resource.DateAdded && DateTime.MinValue != resource.DateAdded.Value) { item.PublishDate = new DateTimeOffset(resource.DateAdded.Value); } if (null != resource.DateModified && DateTime.MinValue != resource.DateModified.Value) { item.LastUpdatedTime = new DateTimeOffset(resource.DateModified.Value); } //TODO: Syndication Links to be implemented here. return(item); }