Beispiel #1
0
        public void TestUpdateFullBookAudio()
        {
            var unitOfWorkProvider = CreateMockUnitOfWorkProvider();
            var resourceRepository = new MockResourceRepository(unitOfWorkProvider);
            var bookData           = new BookData
            {
                FullBookRecordings = new List <FullBookRecordingData>
                {
                    new FullBookRecordingData // update
                    {
                        FileName = "file-2.mp3"
                    },
                    new FullBookRecordingData // new
                    {
                        FileName = "file-8.mp3"
                    }
                },
                FileNameMapping = new Dictionary <string, FileResource>
                {
                    { "file-2.mp3", new FileResource {
                          NewNameInStorage = "guid-2"
                      } },
                    { "file-8.mp3", new FileResource {
                          NewNameInStorage = "guid-8"
                      } },
                }
            };

            var subtask = new UpdateTracksSubtask(resourceRepository);

            subtask.UpdateFullBookTracks(40, 1, bookData);

            var createdRecordings = resourceRepository.CreatedObjects.OfType <AudioResource>().ToList();
            var updatedRecordings = resourceRepository.UpdatedObjects.OfType <AudioResource>().ToList();
            var updatedResources  = resourceRepository.UpdatedObjects.OfType <Resource>().ToList();

            Assert.AreEqual(0, updatedRecordings.Count);
            Assert.AreEqual(2, createdRecordings.Count);
            Assert.AreEqual(2, updatedResources.Count);

            Assert.IsTrue(updatedResources[0].IsRemoved);
            Assert.IsTrue(updatedResources[1].IsRemoved);

            var recording2 = createdRecordings.FirstOrDefault(x => x.FileName == "file-2.mp3");
            var recording8 = createdRecordings.FirstOrDefault(x => x.FileName == "file-8.mp3");

            Assert.AreEqual(2, recording2?.VersionNumber);
            Assert.AreEqual(1, recording8?.VersionNumber);

            if (recording2 == null || recording8 == null)
            {
                Assert.Fail();
            }
            Assert.IsNotNull(recording2.FileId);
            Assert.IsNotNull(recording8.FileId);
        }
Beispiel #2
0
        protected override void ExecuteWorkImplementation()
        {
            m_projectId = m_nullableProjectId ?? throw new InvalidOperationException("Required ProjectId wasn't set in ResourceSessionDirector");
            // Updating Project data is not required, because data has been already updated

            m_importedResourceVersionIds = new List <long>();

            m_bookVersionId = new UpdateBookVersionSubtask(m_resourceRepository).UpdateBookVersion(m_projectId, m_userId, m_bookData);

            var updateEditionNoteSubtask = new UpdateEditionNoteSubtask(m_resourceRepository);
            var editionNoteVersionId     = updateEditionNoteSubtask.UpdateEditionNote(m_projectId, m_bookVersionId, m_userId, m_bookData);

            if (editionNoteVersionId != null)
            {
                m_importedResourceVersionIds.Add(editionNoteVersionId.Value);
            }

            //TODO update: transformations

            new UpdateAuthorsSubtask(m_projectRepository, m_personRepository).UpdateAuthors(m_projectId, m_bookData);
            new UpdateResponsiblePersonSubtask(m_projectRepository, m_personRepository).UpdateResponsiblePersonList(m_projectId, m_bookData);

            var updateMetadataSubtask = new UpdateMetadataSubtask(m_metadataRepository);

            updateMetadataSubtask.UpdateMetadata(m_projectId, m_userId, m_bookData);

            // Categories are not updated from import (XMD doesn't contain detailed categorization)
            //new UpdateCategoriesSubtask(m_categoryRepository).UpdateCategoryList(m_projectId, m_bookData);

            new UpdateLiteraryKindsSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryKinds(m_projectId, m_bookData);
            new UpdateLiteraryGenresSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryGenres(m_projectId, m_bookData);
            new UpdateLiteraryOriginalsSubtask(m_catalogValueRepository, m_metadataRepository).UpdateLiteraryOriginals(m_projectId, m_bookData);
            new UpdateKeywordsSubtask(m_projectRepository, m_catalogValueRepository).UpdateKeywords(m_projectId, m_bookData);

            var updateTermsSubtask = new UpdateTermsSubtask(m_resourceRepository);

            updateTermsSubtask.UpdateTerms(m_projectId, m_bookData);

            var updatePagesSubtask = new UpdatePagesSubtask(m_resourceRepository);

            updatePagesSubtask.UpdatePages(m_projectId, m_bookVersionId, m_userId, m_bookData, updateTermsSubtask.ResultTermCache);
            m_importedResourceVersionIds.AddRange(updatePagesSubtask.ImportedResourceVersionIds);

            var updateChaptersSubtask = new UpdateChaptersSubtask(m_resourceRepository);

            updateChaptersSubtask.UpdateChapters(m_projectId, m_userId, m_bookData, updatePagesSubtask.ResultPageResourceList);
            m_importedResourceVersionIds.AddRange(updateChaptersSubtask.ImportedResourceVersionIds);

            var updateHeadwordsSubtask = new UpdateHeadwordsSubtask(m_resourceRepository);

            updateHeadwordsSubtask.UpdateHeadwords(m_projectId, m_bookVersionId, m_userId, m_bookData, updatePagesSubtask.ResultPageResourceList);
            m_importedResourceVersionIds.AddRange(updateHeadwordsSubtask.ImportedResourceVersionIds);

            var updateTracksSubtask = new UpdateTracksSubtask(m_resourceRepository);

            updateTracksSubtask.UpdateTracks(m_projectId, m_userId, m_bookData);
            updateTracksSubtask.UpdateFullBookTracks(m_projectId, m_userId, m_bookData);
            m_importedResourceVersionIds.AddRange(updateTracksSubtask.ImportedResourceVersionIds);

            new UpdateHistoryLogSubtask(m_projectRepository).UpdateHistoryLog(m_projectId, m_userId, m_message, m_bookData);
        }