Beispiel #1
0
        public string GetEditionNote(EditionNoteResource editionNoteResource, TextFormatEnumContract format)
        {
            var projectExternalId     = editionNoteResource.Resource.Project.ExternalId;
            var bookVersionExternalId = editionNoteResource.BookVersion.ExternalId;
            var transformation        = GetTransformationOrDefault(format, BookTypeEnum.Edition);

            using (var ssc = m_communicationProvider.GetSearchServiceClient())
            {
                var result = ssc.GetBookEditionNote(projectExternalId, bookVersionExternalId, transformation.Name, transformation.OutputFormat, transformation.ResourceLevel);
                return(result);
            }
        }
Beispiel #2
0
        protected override long ExecuteWorkImplementation()
        {
            var now  = DateTime.UtcNow;
            var user = m_resourceRepository.Load <User>(m_userId);
            var latestEditionNote = m_resourceRepository.GetLatestEditionNote(m_projectId);

            if (latestEditionNote != null && latestEditionNote.Id != m_data.OriginalVersionId)
            {
                throw new MainServiceException(
                          MainServiceErrorCode.EditionNoteConflict,
                          $"Conflict. Current latest versionId is {latestEditionNote.Id}, but originalVersionId was specified {m_data.OriginalVersionId}",
                          HttpStatusCode.Conflict
                          );
            }

            if (latestEditionNote == null)
            {
                latestEditionNote = new EditionNoteResource
                {
                    Resource = new Resource
                    {
                        Project      = m_resourceRepository.Load <Project>(m_projectId),
                        ContentType  = ContentTypeEnum.None,
                        ResourceType = ResourceTypeEnum.EditionNote,
                        Name         = "Edition note"
                    },
                    VersionNumber = 0
                };
            }

            var newEditionNote = new EditionNoteResource
            {
                Resource      = latestEditionNote.Resource,
                CreateTime    = now,
                CreatedByUser = user,
                Comment       = m_data.Comment,
                VersionNumber = latestEditionNote.VersionNumber + 1,
                Text          = m_data.Text
            };

            newEditionNote.Resource.LatestVersion = newEditionNote;

            var resourceVersionId = (long)m_resourceRepository.Create(newEditionNote);

            return(resourceVersionId);
        }
        private long CreateEditionNoteResource(Resource resource, int version, User user, DateTime now, BookVersionResource bookVersion)
        {
            var newDbEditionNote = new EditionNoteResource
            {
                Resource      = resource,
                BookVersion   = bookVersion,
                VersionNumber = version,
                Comment       = string.Empty,
                CreateTime    = now,
                CreatedByUser = user,
            };

            resource.LatestVersion = newDbEditionNote;
            var resultId = m_resourceRepository.Create(newDbEditionNote);

            return((long)resultId);
        }
Beispiel #4
0
        private EditionNoteContract GetEditionNoteContract(EditionNoteResource editionNoteResource, TextFormatEnumContract format)
        {
            if (editionNoteResource == null)
            {
                return(null);
            }

            var contract = m_mapper.Map <EditionNoteContract>(editionNoteResource);

            if (editionNoteResource.Text != null)
            {
                contract.Text = ConvertTextFormat(format, editionNoteResource.Text);
            }
            else
            {
                var fulltextStorage = m_fulltextStorageProvider.GetFulltextStorage(editionNoteResource.Resource.Project.ProjectType);
                contract.Text = fulltextStorage.GetEditionNote(editionNoteResource, format);
            }

            return(contract);
        }
Beispiel #5
0
 public string GetEditionNote(EditionNoteResource editionNoteResource, TextFormatEnumContract format)
 {
     // ElasticSearch storage doesn't support edition notes
     return(null);
 }