Exemplo n.º 1
0
        /// <summary>
        /// public method that retrevies list of keyworditems to be modified from
        ///     in the given test package that are in the items csv
        /// </summary>
        /// <param name="testPackageFilePath"></param>
        /// <param name="itemsFilePath"></param>
        /// <returns></returns>
        public IEnumerable <KeywordListItem> GetKeywordListItems(string testPackageFilePath, string itemsFilePath)
        {
            IEnumerable <AssessmentItem> assessmentItems = GetAssessmentItems(testPackageFilePath, itemsFilePath);

            AddNonexistantWordlistResource(assessmentItems, testPackageFilePath);
            IEnumerable <string>       keywordListItemIds   = assessmentItems.Select(i => i.KeywordListItemId);
            IEnumerable <ItemDocument> keywordListDocuments = GetItemsXml(testPackageFilePath, keywordListItemIds);
            IList <KeywordListItem>    keywordListItems     = new List <KeywordListItem>();

            foreach (AssessmentItem assessmentItem in assessmentItems.ToList())
            {
                string       keywordListId = assessmentItem.KeywordListItemId;
                ItemDocument itDoc         = SelectByID(keywordListDocuments, keywordListId);
                if (!keywordListItems.Any(x => x.ItemId.Equals(keywordListId)))
                {
                    keywordListItems.Add(new KeywordListItem(keywordListId, itDoc));
                }
                assessmentItem.Illustrations.ToList().ForEach(x =>
                                                              x.CopiedToPath = GetCopyToLocation(x, itDoc.FullPath));
                keywordListItems.First(x => x.ItemId.Equals(keywordListId))
                .AssessmentItems.Add(assessmentItem);
            }

            return(keywordListItems);
        }
 public KeywordListItem(string ItemId, ItemDocument itDoc)
 {
     this.ItemId          = ItemId;
     this.AssessmentItems = new List <AssessmentItem>();
     this.Document        = itDoc.Document;
     this.FullPath        = itDoc.FullPath;
     this.Identifier      = Path.GetFileNameWithoutExtension(itDoc.FullPath);
 }
Exemplo n.º 3
0
            public void DeleteRelationshipsThatOnlyExistInOther(ItemDocument other)
            {
                var relatedIds = RelatedIds();
                var nonexistingItemsInThisDocument = other.RelatedItems
                                                     .Select(x => new Tuple <string, string>(x.GetAttribute("type"), x.GetAttribute("id")))
                                                     .Where(t => !relatedIds.ContainsKey(t.Item1) || !relatedIds[t.Item1].Contains(t.Item2));

                foreach (var item in nonexistingItemsInThisDocument)
                {
                    RelationshipItem.Add(new XElement("Item",
                                                      new XAttribute("type", item.Item1),
                                                      new XAttribute("id", item.Item2),
                                                      new XAttribute("action", "delete")
                                                      ));
                }
            }
Exemplo n.º 4
0
 public override int Run(string[] remainingArguments)
 {
     Innovator = Common.GetNewInnovator(Database);
     foreach (var filepath in AmlFilepaths())
     {
         var itemDocument       = ItemDocument.FromFilepath(filepath);
         var serverItemDocument = itemDocument.GetServerVersion(Innovator);
         if (serverItemDocument == null)
         {
             continue;
         }
         itemDocument.DeleteRelationshipsThatOnlyExistInOther(serverItemDocument);
         Console.WriteLine($"Updating {filepath}");
         itemDocument.Save(filepath);
     }
     return(0);
 }
Exemplo n.º 5
0
        private AssessmentItem CreateAssessmentItem(IEnumerable <ItemDocument> contentItems, string key, IEnumerable <Illustration> illustrations)
        {
            ItemDocument document = SelectByID(contentItems, key);

            if (document != null)
            {
                string   keywordlistItemId = GetKeywordListItemId(document.Document);
                XElement item = document.Document.OptionalElement("itemrelease")
                                .OptionalElement("item");
                string bankKey     = item.GetAttribute("bankkey");
                string itemVersion = item.GetAttribute("version");
                return(new AssessmentItem(key, keywordlistItemId, bankKey, itemVersion, illustrations, document));
            }
            else
            {
                return(new AssessmentItem(key, illustrations));
            }
        }
Exemplo n.º 6
0
 public async Task Put(ItemDocument value)
 {
     await _repository.AddOneAsync(value);
 }
 public AssessmentItem(string ItemId, string KeywordListItemId, string bankKey, string itemVersion, IEnumerable <Illustration> illustrations, ItemDocument document)
 {
     if (document != null)
     {
         this.ItemId            = ItemId;
         this.KeywordListItemId = KeywordListItemId;
         this.Illustrations     = illustrations;
         this.Document          = document.Document;
         this.FullPath          = document.FullPath;
         this.Name        = document.Name;
         this.Bankkey     = bankKey;
         this.ItemVersion = itemVersion;
         this.Identifier  = Path.GetFileNameWithoutExtension(document.FullPath);
     }
 }