Beispiel #1
0
        private XElement GetKeywordlistItemDepency(KeywordListItem keywordlistItem)
        {
            XNamespace ns = ManifestModifier.Namespace;

            return(new XElement(ns + "dependency",
                                new XAttribute("identifierref", keywordlistItem.Identifier)));
        }
Beispiel #2
0
        /// <summary>
        /// Adds a keyword to a keywordlist item xml and saves and xml and
        ///     copies the illustration to the zip archive
        /// </summary>
        /// <param name="keywordListItem"></param>
        /// <param name="testPackageArchive"></param>
        /// <returns></returns>
        private void AddIllustrationInfoToKeywordListItemXml(KeywordListItem keywordListItem, ZipArchive testPackageArchive)
        {
            XDocument itemXml     = keywordListItem.Document;
            XElement  rootElement = itemXml
                                    .OptionalElement("itemrelease")
                                    .OptionalElement("item");
            XElement keywordListElt = rootElement.ElementOrCreate("keywordList");

            foreach (AssessmentItem assessmentItem in keywordListItem.AssessmentItems)
            {
                foreach (Illustration illustration in assessmentItem.Illustrations)
                {
                    AddIllustrationToKeywordListItem(illustration, keywordListElt, keywordListItem.ItemId);
                    itemsModifier.MoveMediaFileForIllustration(illustration, assessmentItem, testPackageArchive);
                }

                if (assessmentItem.Illustrations.Any(x => x.KeywordAdded))
                {
                    AddNewKeywordsToAssessmentItemContent(assessmentItem);
                    itemsModifier.SaveItem(assessmentItem, testPackageArchive);
                }
            }

            itemsModifier.SaveItem(keywordListItem, testPackageArchive);
        }
Beispiel #3
0
        private void AddNonexistingKeywordlistToAssessmentItem(KeywordListItem keywordListItem, AssessmentItem assessmentItem, XElement assessmentItemResource, IList <XElement> resources)
        {
            IEnumerable <XElement> dependencies = assessmentItemResource.Descendants("dependency");

            if (!dependencies.Any(x => x.GetAttribute("identifierref") == keywordListItem.Identifier))
            {
                assessmentItemResource.Add(GetKeywordlistItemDepency(keywordListItem));
            }
        }
Beispiel #4
0
        private XElement GetKeywordlistItemMetadataResource(KeywordListItem keywordlistItem, string metaPath)
        {
            XNamespace ns = ManifestModifier.Namespace;

            return(new XElement(ns + "resource",
                                new XAttribute("identifier", keywordlistItem.MetadataIdentifier),
                                new XAttribute("type", Properties.Resources.MetadataResourceTypeInManifest),
                                new XElement(ns + "file",
                                             new XAttribute("href", metaPath))));
        }
Beispiel #5
0
 private void AddNonexistingKeywordlist(KeywordListItem keywordListItem, AssessmentItem assessmentItem, XElement assessmentItemResource, IList <XElement> resources)
 {
     if (!resources.Any(x => x.GetAttribute("identifier") == keywordListItem.Identifier))
     {
         assessmentItemResource.Parent.Add(GetKeywordlistItemResource(keywordListItem));
     }
     if (!resources.Any(x => x.GetAttribute("identifier") == keywordListItem.MetadataIdentifier))
     {
         assessmentItemResource.Parent.Add(GetKeywordlistItemMetadataResource(keywordListItem, assessmentItem.KeywordListMetadataFullPath));
     }
 }
Beispiel #6
0
        private XElement GetKeywordlistItemResource(KeywordListItem keywordlistItem)
        {
            XNamespace ns = ManifestModifier.Namespace;

            return(new XElement(ns + "resource",
                                new XAttribute("identifier", keywordlistItem.Identifier),
                                new XAttribute("type", Properties.Resources.WordlistResourceTypeInManifest),
                                new XElement(ns + "file",
                                             new XAttribute("href", keywordlistItem.FullPath)),
                                new XElement(ns + "dependency",
                                             new XAttribute("identifierref", keywordlistItem.MetadataIdentifier))));
        }
Beispiel #7
0
        private void AddKeywordListItems(KeywordListItem keywordListItem, AssessmentItem assessmentItem, IList <XElement> resources)
        {
            XElement assessmentItemResource = resources.FirstOrDefault(x =>
                                                                       x.GetAttribute("identifier") == assessmentItem.Identifier);

            AddNonexistingKeywordlist(keywordListItem, assessmentItem, assessmentItemResource, resources);
            AddNonexistingKeywordlistToAssessmentItem(keywordListItem, assessmentItem, assessmentItemResource, resources);

            foreach (Illustration illustration in assessmentItem.Illustrations)
            {
                ClearElements(resources, illustration, assessmentItemResource);
                assessmentItemResource.AddAfterSelf(GetManifestResourceElement(illustration));
                assessmentItemResource.Add(GetManifestDependencyElement(illustration));
            }
        }