예제 #1
0
        /// <summary>
        /// Creates string of tags related to resource
        /// </summary>
        /// <param name="metadata">the associated metadata</param>
        /// <param name="resource"> core.resource  </param>
        private static void AddResourceTags(XElement metadata, ScholarlyWorks.ScholarlyWorkItem resource)
        {
            if (null == metadata || null == resource)
            {
                return;
            }

            resource.Tags.ToList().ForEach(delegate(ScholarlyWorks.Tag tag)
            {
                if (!String.IsNullOrEmpty(tag.Name))
                {
                    metadata.Add(MetadataProviderHelper.GetElement(MetadataProviderHelper.Metadata_Subject, tag.Name));
                }
            });
        }
예제 #2
0
        /// <summary>
        /// Creates metadata element
        /// </summary>
        /// <param name="resource"> resource object </param>
        /// <returns> an instance of XElement </returns>
        internal static XElement GetMetadataElement(Core.Resource resource)
        {
            XElement metadata = null;

            metadata = new XElement(Metadata);

            if (!String.IsNullOrEmpty(resource.Title))
            {
                metadata.Add(MetadataProviderHelper.GetElement(Metadata_Title, resource.Title));
            }

            ScholarlyWorks.ScholarlyWork scholarlyWorks = resource as ScholarlyWorks.ScholarlyWork;
            if (null != scholarlyWorks)
            {
                if (scholarlyWorks.Authors != null)
                {
                    MetadataProviderHelper.AddResourceAuthors(metadata, scholarlyWorks);
                }
                if (scholarlyWorks.Contributors != null)
                {
                    MetadataProviderHelper.AddResourceContributors(metadata, scholarlyWorks);
                }
            }

            // TODO : 2.Currently Tags for a given resource are retrieved without
            //          checking any relationships, but the implementation needs to be changed if required
            ScholarlyWorks.ScholarlyWorkItem scholarlyWorkItem = resource as ScholarlyWorks.ScholarlyWorkItem;
            if (scholarlyWorkItem != null && scholarlyWorkItem.Tags != null)
            {
                MetadataProviderHelper.AddResourceTags(metadata, scholarlyWorkItem);
            }

            metadata.Add(MetadataProviderHelper.GetElement(Metadata_Description, resource.Description));

            if (!String.IsNullOrEmpty(resource.DateModified.Value.ToString()))
            {
                metadata.Add(MetadataProviderHelper.GetElement(Metadata_Date, resource.DateModified.Value.ToString(DateTimeGranularity, CultureInfo.InvariantCulture)));
            }
            return(metadata);
        }