public ActionResult GetEditionNote(long projectId, TextFormatEnumContract format) { var client = GetBookClient(); var editionNote = client.GetEditionNoteText(projectId, TextFormatEnumContract.Html); return(Json(new { editionNote }, GetJsonSerializerSettings())); }
public string GetPageText(TextResource textResource, TextFormatEnumContract format) { var fulltextServiceClient = m_communicationProvider.GetFulltextServiceClient(); var result = fulltextServiceClient.GetTextResource(textResource.ExternalId, format); return(result.PageText); }
public string GetPageTextFromSearch(TextResource textResource, TextFormatEnumContract format, SearchPageRequestContract searchRequest) { var fulltextServiceClient = m_communicationProvider.GetFulltextServiceClient(); var result = fulltextServiceClient.GetTextResourceFromSearch(textResource.ExternalId, format, searchRequest); return(result.PageText); }
public EditionNoteContract GetLatestEditionNote(long projectId, TextFormatEnumContract format) { m_authorizationManager.AuthorizeBook(projectId, PermissionFlag.ReadProject); var editionNoteResource = m_resourceRepository.InvokeUnitOfWork(x => x.GetLatestEditionNote(projectId)); return(GetEditionNoteContract(editionNoteResource, format)); }
public TextResourceContract GetTextResource(string textResourceId, [FromQuery] TextFormatEnumContract formatValue) { var textResource = m_textResourceManager.GetTextResource(textResourceId); textResource.PageText = m_textConverter.Convert(textResource.PageText, formatValue); textResource.PageText = m_pageWithHtmlTagsCreator.CreatePage(textResource.PageText, formatValue); return(textResource); }
public string CreatePage(string textResourcePageText, TextFormatEnumContract formatValue) { if (formatValue != TextFormatEnumContract.Html) { return(textResourcePageText); } textResourcePageText = ReplaceLineBreaks(textResourcePageText); textResourcePageText = AddPageTags(textResourcePageText); return(textResourcePageText); }
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); } }
public string GetHeadwordText(HeadwordResource headwordResource, TextFormatEnumContract format) { var transformation = GetTransformationOrDefault(format, BookTypeEnum.Dictionary); using (var ssc = m_communicationProvider.GetSearchServiceClient()) { var project = headwordResource.Resource.Project; var bookVersion = headwordResource.BookVersion; var result = ssc.GetDictionaryEntryByXmlId(project.ExternalId, bookVersion.ExternalId, headwordResource.ExternalId, transformation.Name, transformation.OutputFormat, transformation.ResourceLevel); return(result); } }
public string GetPageTextFromSearch(TextResource textResource, TextFormatEnumContract format, SearchPageRequestContract searchRequest) { var transformation = GetTransformationOrDefault(format, BookTypeEnum.Edition); using (var ssc = m_communicationProvider.GetSearchServiceClient()) { var project = textResource.Resource.Project; var bookVersion = textResource.BookVersion; var result = ssc.GetEditionPageFromSearch(searchRequest.ConditionConjunction, project.ExternalId, bookVersion.ExternalId, textResource.ExternalId, transformation.Name, transformation.OutputFormat, transformation.ResourceLevel); return(result); } }
public string GetPageText(TextResource textResource, TextFormatEnumContract format) { var transformation = GetTransformationOrDefault(format, BookTypeEnum.Edition); using (var ssc = m_communicationProvider.GetSearchServiceClient()) { var project = textResource.Resource.Project; var bookVersion = textResource.BookVersion; //var result = ssc.GetBookPageByXmlId(project.ExternalId, bookVersion.ExternalId, textResource.ExternalId, "pageToHtml.xsl", outputFormat, ResourceLevelEnumContract.Shared); // TODO dynamically resolve transformation type var result = ssc.GetBookPageByXmlId(project.ExternalId, bookVersion.ExternalId, textResource.ExternalId, transformation.Name, transformation.OutputFormat, transformation.ResourceLevel); return(result); } }
public string GetPageText(long resourcePageId, TextFormatEnumContract format) { var textResource = m_resourceRepository.InvokeUnitOfWork(x => x.GetLatestPageText(resourcePageId)); if (textResource == null) { return(null); } var fulltextStorage = m_fulltextStorageProvider.GetFulltextStorage(textResource.Resource.Project.ProjectType); return(fulltextStorage.GetPageText(textResource, format)); }
private FullTextContract GetTextResource(TextResource dbResult, TextFormatEnumContract formatValue) { var result = m_mapper.Map <FullTextContract>(dbResult); if (result != null) { var fulltextStorage = m_fulltextStorageProvider.GetFulltextStorage(dbResult.Resource.Project.ProjectType); var text = fulltextStorage.GetPageText(dbResult, formatValue); result.Text = text; } return(result); }
private TransformationData GetTransformationOrDefault(TextFormatEnumContract format, BookTypeEnum bookType) { var outputFormat = ConvertOutputTextFormat(format); var dbTtransformation = m_bookRepository.InvokeUnitOfWork(x => x.GetDefaultTransformation(outputFormat, bookType)); var transformation = m_mapper.Map <TransformationData>(dbTtransformation); if (transformation == null) { transformation = new TransformationData { Name = "pageToHtml.xsl", OutputFormat = OutputFormatEnumContract.Html, ResourceLevel = ResourceLevelEnumContract.Shared, }; } return(transformation); }
private OutputFormatEnum ConvertOutputTextFormat(TextFormatEnumContract format) { switch (format) { case TextFormatEnumContract.Raw: return(OutputFormatEnum.Xml); case TextFormatEnumContract.Html: return(OutputFormatEnum.Html); case TextFormatEnumContract.Rtf: return(OutputFormatEnum.Rtf); default: throw new ArgumentOutOfRangeException(nameof(format), format, null); } }
public string Convert(string textResourceText, TextFormatEnumContract formatValue) { switch (formatValue) { case TextFormatEnumContract.Raw: return(textResourceText); case TextFormatEnumContract.Html: return(m_markdownToHtmlConverter.ConvertToHtml(textResourceText)); case TextFormatEnumContract.Rtf: throw new NotSupportedException(); default: throw new ArgumentOutOfRangeException(nameof(formatValue), formatValue, null); } }
public string GetHeadwordText(long headwordId, TextFormatEnumContract format) { try { var result = m_client.GetString($"book/headword/{headwordId}/text?format={format}"); return(result); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
private string ConvertTextFormat(TextFormatEnumContract targetFormat, string text) { switch (targetFormat) { case TextFormatEnumContract.Html: return(m_markdownConverter.ConvertToHtml(text)); case TextFormatEnumContract.Raw: return(text); case TextFormatEnumContract.Rtf: throw new MainServiceException(MainServiceErrorCode.UnsupportedFormatType, "Converting text to RTF format is not supported"); default: throw new MainServiceException(MainServiceErrorCode.UnsupportedFormatType, $"Converting text to unknown format {targetFormat} is not supported"); } }
public EditionNoteContract GetLatestEditionNote(long projectId, TextFormatEnumContract format) { try { var result = m_client.Get <EditionNoteContract>($"project/{projectId}/edition-note?format={format}"); return(result); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public string GetPageText(long pageId, TextFormatEnumContract format) { try { var result = m_client.GetString($"project/page/{pageId}/text-content?format={format}"); return(result); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public TextResourceContract GetTextResource(string resourceId, TextFormatEnumContract formatValue) { try { var textResource = m_client.Get <TextResourceContract>($"text/{resourceId}?formatValue={formatValue}"); return(textResource); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public TextResourceContract GetTextResourceFromSearch(string resourceId, TextFormatEnumContract format, SearchPageRequestContract searchRequest) { try { var result = m_client.Post <TextResourceContract>($"text/{resourceId}/search?formatValue={format}", searchRequest); return(result); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public string GetPageTextFromSearch(long pageId, TextFormatEnumContract format, SearchPageRequestContract request) { try { var result = m_client.PostReturnString($"book/page/{pageId}/text/search?format={format}", request); return(result); } catch (HttpRequestException e) { if (m_logger.IsErrorEnabled()) { m_logger.LogError("{0} failed with {1}", m_client.GetCurrentMethod(), e); } throw; } }
public string GetHeadwordText(long headwordId, TextFormatEnumContract format, SearchPageRequestContract request = null) { m_authorizationManager.AuthorizeResource(headwordId); var headwordResource = m_bookRepository.InvokeUnitOfWork(x => x.GetHeadwordResource(headwordId, false)); if (headwordResource == null) { return(null); } var fulltextStorage = m_fulltextStorageProvider.GetFulltextStorage(headwordResource.Resource.Project.ProjectType); var result = request == null ? fulltextStorage.GetHeadwordText(headwordResource, format) : fulltextStorage.GetHeadwordTextFromSearch(headwordResource, format, request); return(result); }
public IActionResult GetEditionNote(long projectId, TextFormatEnumContract format) { var client = GetProjectClient(); try { var result = client.GetLatestEditionNote(projectId, format); return(Json(result)); } catch (HttpErrorCodeException exception) { if (exception.StatusCode == HttpStatusCode.NotFound) { return(Json(null)); } throw; } }
public string GetPageText(long resourcePageId, TextFormatEnumContract format, SearchPageRequestContract searchRequest = null) { m_authorizationManager.AuthorizeResource(resourcePageId); var textResourceList = m_bookRepository.InvokeUnitOfWork(x => x.GetPageText(resourcePageId)); var textResource = textResourceList.FirstOrDefault(); if (textResource == null) { return(null); } var fulltextStorage = m_fulltextStorageProvider.GetFulltextStorage(textResource.Resource.Project.ProjectType); var result = searchRequest == null ? fulltextStorage.GetPageText(textResource, format) : fulltextStorage.GetPageTextFromSearch(textResource, format, searchRequest); return(result); }
public string GetHeadwordTextFromSearch(HeadwordResource headwordResource, TextFormatEnumContract format, SearchPageRequestContract searchRequest) { throw new NotSupportedException("Headwords/dictionaries are not supported in ElasticSearch storage."); }
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); }
public FullTextContract GetTextResourceVersion(long textVersionId, TextFormatEnumContract formatValue) { var dbResult = m_resourceRepository.InvokeUnitOfWork(x => x.GetResourceVersion <TextResource>(textVersionId, true, true)); return(GetTextResource(dbResult, formatValue)); }
public ActionResult <TextResourceContract> GetSearchTextResource(string textResourceId, [FromQuery] TextFormatEnumContract formatValue, [FromBody] SearchPageRequestContract searchPageRequestContract) { if (ContainsAnyUnsupportedCriteria(searchPageRequestContract)) { return(BadRequest("Request contains unsupported criteria")); } var textResource = m_searchManager.SearchOnPageByCriteria(textResourceId, searchPageRequestContract); textResource.PageText = m_textConverter.Convert(textResource.PageText, formatValue); textResource.PageText = m_pageWithHtmlTagsCreator.CreatePage(textResource.PageText, formatValue); return(textResource); }
public FullTextContract GetTextResourceByPageId(long pageId, TextFormatEnumContract formatValue) { var dbResult = m_resourceRepository.InvokeUnitOfWork(x => x.GetLatestPageText(pageId)); return(GetTextResource(dbResult, formatValue)); }