/// <summary> /// Constructs the doc query entity. /// </summary> /// <param name="jobParameters">The job parameters.</param> /// <param name="datasetEntity">The dataset entity.</param> /// <returns></returns> private static DocumentQueryEntity ConstructDocQueryEntity(CreateReviewSetJobBEO jobParameters, DatasetBEO datasetEntity) { DocumentQueryEntity documentQueryEntity = new DocumentQueryEntity { QueryObject = new SearchQueryEntity { ReviewsetId = jobParameters.ReviewSetId, MatterId = datasetEntity.Matter.FolderID, IsConceptSearchEnabled = false, DatasetId = datasetEntity.FolderID } }; documentQueryEntity.IgnoreDocumentSnippet = true; documentQueryEntity.SortFields.Add(new Sort { SortBy = Constants.Relevance }); documentQueryEntity.OutputFields.AddRange(new List <Field> { new Field { FieldName = EVSystemFields.FamilyId }, new Field { FieldName = EVSystemFields.ReviewSetId }, new Field { FieldName = datasetEntity.DocumentControlNumberName }, new Field { FieldName = EVSystemFields.DuplicateId }, }); return(documentQueryEntity); }
/// <summary> /// This method converts the CreateReviewSetJobBEO to ReviewsetRecord /// </summary> /// <param name="reviewSetJobBEO">CreateReviewSetJobBEO/param> /// <returns>ReviewsetRecord</returns> private ReviewsetRecord ConvertToReviewSetRecord(CreateReviewSetJobBEO reviewSetJobBEO) { ReviewsetRecord rSetRecord = new ReviewsetRecord { Activity = reviewSetJobBEO.Activity, DatasetId = reviewSetJobBEO.DatasetId, DueDate = reviewSetJobBEO.DueDate, KeepDuplicatesTogether = reviewSetJobBEO.KeepDuplicates, KeepFamilyTogether = reviewSetJobBEO.KeepFamily, NumberOfDocuments = reviewSetJobBEO.NumberOfDocuments, NumberOfDocumentsPerSet = reviewSetJobBEO.NumberOfDocumentsPerSet, NumberOfReviewedDocs = reviewSetJobBEO.NumberOfReviewedDocs, NumberOfReviewSets = reviewSetJobBEO.NumberOfReviewSets, ReviewSetDescription = reviewSetJobBEO.ReviewSetDescription, ReviewSetGroup = reviewSetJobBEO.ReviewSetGroup, ReviewSetId = reviewSetJobBEO.ReviewSetId, BinderFolderId = reviewSetJobBEO.BinderFolderId, BinderId = _binderEntity.BinderId, BinderName = _binderEntity.BinderName, ReviewSetLogic = reviewSetJobBEO.ReviewSetLogic, ReviewSetName = reviewSetJobBEO.ReviewSetName, SplittingOption = reviewSetJobBEO.SplittingOption, StartDate = reviewSetJobBEO.StartDate, StatusId = reviewSetJobBEO.StatusId, CreatedBy = reviewSetJobBEO.JobScheduleCreatedBy, CollectionId = reviewSetJobBEO.CollectionId }; rSetRecord.DsTags.AddRange(reviewSetJobBEO.DsTags); return(rSetRecord); }
protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (CreateReviewSetJobBEO)XmlUtility.DeserializeObject(BootParameters, typeof(CreateReviewSetJobBEO)); }
/// <summary> /// Begins the work. /// </summary> protected override void BeginWork() { BootParameters.ShouldNotBe(null); base.BeginWork(); _jobParameter = (CreateReviewSetJobBEO)XmlUtility.DeserializeObject(BootParameters, typeof(CreateReviewSetJobBEO)); _jobParameter.ShouldNotBe(null); SetCommiyIndexStatusToInitialized(_jobParameter.MatterId); }
/// <summary> /// This method deserializes and determine the Xml CreateReviewSetJobBEO object /// </summary> /// <param name="bootParameter"></param> private CreateReviewSetJobBEO GetBootObject(string bootParameter) { CreateReviewSetJobBEO bootObject = null; if (!string.IsNullOrEmpty(bootParameter)) { //Creating a stringReader stream for the bootparameter StringReader stream = new StringReader(bootParameter); //Ceating xmlStream for xmlserialization XmlSerializer xmlStream = new XmlSerializer(typeof(CreateReviewSetJobBEO)); //Deserialization of bootparameter to get ProductionDetailsBEO bootObject = (CreateReviewSetJobBEO)xmlStream.Deserialize(stream); } return(bootObject); }
/// <summary> /// This method converts the CreateReviewSetJobBEO to ReviewsetRecord /// </summary> /// <param name="reviewSetJobBEO">CreateReviewSetJobBEO/param> /// <returns>ReviewsetRecord</returns> private ReviewsetRecord ConvertToReviewSetRecord(CreateReviewSetJobBEO reviewSetJobBEO) { ReviewsetRecord rSetRecord = new ReviewsetRecord { Activity = reviewSetJobBEO.Activity, DatasetId = reviewSetJobBEO.DatasetId, DueDate = reviewSetJobBEO.DueDate, KeepDuplicatesTogether = reviewSetJobBEO.KeepDuplicates, KeepFamilyTogether = reviewSetJobBEO.KeepFamily, NumberOfDocuments = reviewSetJobBEO.NumberOfDocuments, NumberOfDocumentsPerSet = reviewSetJobBEO.NumberOfDocumentsPerSet, NumberOfReviewedDocs = reviewSetJobBEO.NumberOfReviewedDocs, NumberOfReviewSets = reviewSetJobBEO.NumberOfReviewSets, ReviewSetDescription = reviewSetJobBEO.ReviewSetDescription, ReviewSetGroup = reviewSetJobBEO.ReviewSetGroup, ReviewSetId = reviewSetJobBEO.ReviewSetId, BinderFolderId = reviewSetJobBEO.BinderFolderId, BinderId = _binderEntity.BinderId, BinderName = _binderEntity.BinderName, ReviewSetLogic = reviewSetJobBEO.ReviewSetLogic, ReviewSetName = reviewSetJobBEO.ReviewSetName, SplittingOption = reviewSetJobBEO.SplittingOption, StartDate = reviewSetJobBEO.StartDate, StatusId = reviewSetJobBEO.StatusId, CreatedBy = reviewSetJobBEO.JobScheduleCreatedBy, CollectionId = reviewSetJobBEO.CollectionId }; rSetRecord.DsTags.AddRange(reviewSetJobBEO.DsTags); return rSetRecord; }
/// <summary> /// Constructs and returns the document search query entity /// </summary> /// <param name="jobParameters">The job parameters.</param> /// <param name="datasetEntity">The dataset entity.</param> /// <returns></returns> private DocumentQueryEntity GetQueryEntity(CreateReviewSetJobBEO jobParameters, DatasetBEO datasetEntity, int startIndex, int documentCount, List<Field> outputFields) { DocumentQueryEntity documentQueryEntity = new DocumentQueryEntity { QueryObject = new SearchQueryEntity { MatterId = datasetEntity.Matter.FolderID, IsConceptSearchEnabled = jobParameters.DocumentSelectionContext.SearchContext.IsConceptSearchEnabled, DatasetId = datasetEntity.FolderID } }; documentQueryEntity.IgnoreDocumentSnippet = true; documentQueryEntity.DocumentStartIndex = startIndex; documentQueryEntity.DocumentCount = documentCount; documentQueryEntity.SortFields.Add(new Sort { SortBy = Constants.Relevance }); if (outputFields != null && outputFields.Any()) { documentQueryEntity.OutputFields.AddRange(outputFields); } var tmpQuery = string.Empty; var selectionQuery = string.Empty; if (!string.IsNullOrEmpty(jobParameters.DocumentSelectionContext.SearchContext.Query)) { tmpQuery = string.Format("({0} )", jobParameters.DocumentSelectionContext.SearchContext.Query); } else { tmpQuery = string.Format("(NOT ({0}:\"{1}\"))", EVSystemFields.BinderId.ToLowerInvariant(), _binderEntity.BinderId); } switch (jobParameters.DocumentSelectionContext.GenerateDocumentMode) { case DocumentSelectMode.UseSelectedDocuments: { jobParameters.DocumentSelectionContext.SelectedDocuments.ForEach(d => selectionQuery += string.Format("{0}:\"{1}\" OR ", EVSystemFields.DocumentKey, d)); if (!string.IsNullOrEmpty(selectionQuery)) { selectionQuery = selectionQuery.Substring(0, selectionQuery.LastIndexOf(" OR ")); tmpQuery = string.Format("({0} AND ({1}))", tmpQuery, selectionQuery); } break; } case DocumentSelectMode.QueryAndExclude: { jobParameters.DocumentSelectionContext.DocumentsToExclude.ForEach(d => selectionQuery += string.Format("(NOT {0}:\"{1}\") AND ", EVSystemFields.DocumentKey, d)); if (!string.IsNullOrEmpty(selectionQuery)) { selectionQuery = selectionQuery.Substring(0, selectionQuery.LastIndexOf(" AND ")); tmpQuery = string.Format("({0} AND ({1}))", tmpQuery, selectionQuery); } break; } } documentQueryEntity.QueryObject.QueryList.Clear(); documentQueryEntity.QueryObject.QueryList.Add(new Query { SearchQuery = tmpQuery }); return documentQueryEntity; }
/// <summary> /// Absorb the boot parameters, deserialize and pass on the messages to the Search Worker /// </summary> public void DoBeginWork(string bootParameter) { bootParameter.ShouldNotBeEmpty(); // Deserialize and determine the boot object _bootObject = GetBootObject(bootParameter); // Assert condition to check for jobscheduled by _bootObject.JobScheduleCreatedBy.ShouldNotBeEmpty(); _bootObject.BinderFolderId.ShouldNotBe(0); // Get Dataset Details to know about the Collection id and the Matter ID details _datasetEntity = DataSetBO.GetDataSetDetailForDataSetId(_bootObject.datasetId); //Assert condition to check for dataset details _datasetEntity.ShouldNotBe(null); _binderEntity = BinderBO.GetBinderDetails(_bootObject.BinderFolderId.ToString()); _binderEntity.ShouldNotBe(null); _reviewSetRecord = ConvertToReviewSetRecord(_bootObject); // Construct the document query entity to determine the total documents _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, 1, null); // Mock the user session MockSession(); _docQueryEntity.TransactionName = _docQueryEntity.QueryObject.TransactionName = "ReviewsetStartupWorker - DoBeginWork (GetCount)"; var reviewsetLogic = _reviewSetRecord.ReviewSetLogic.ToLower(); if (reviewsetLogic == "all" || reviewsetLogic == "tag") { var searchQuery = !string.IsNullOrEmpty(_bootObject.SearchQuery)? _bootObject.SearchQuery.Replace("\"", ""): string.Empty; _totalDocumentCount = DocumentBO.GetDocumentCountForCreateReviewsetJob(_datasetEntity.Matter.FolderID, _datasetEntity.CollectionId, reviewsetLogic, searchQuery); } else { // Retrieve the total documents qualified _totalDocumentCount = ReviewerSearchInstance.GetDocumentCount(_docQueryEntity.QueryObject); } Tracer.Info("Reviewset Startup Worker : {0} matching documents determined for the requested query", _totalDocumentCount); if (_totalDocumentCount < 1) { var message = String.Format("Search server does not return any documents for the reviewset '{0}'", _reviewSetRecord.ReviewSetName); throw new ApplicationException(message); } LogMessage(true, string.Format("{0} documents are qualified", _totalDocumentCount)); // Construct the document query entity to write the resultant documents in xml file var outputFields = new List<Field>(); outputFields.AddRange(new List<Field>() { new Field { FieldName = EVSystemFields.DcnField}, new Field { FieldName = EVSystemFields.FamilyId}, new Field { FieldName = EVSystemFields.DuplicateId} }); _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, Convert.ToInt32(_totalDocumentCount), outputFields); }
/// <summary> /// Constructs and returns the document search query entity /// </summary> /// <param name="jobParameters">The job parameters.</param> /// <param name="datasetEntity">The dataset entity.</param> /// <returns></returns> private DocumentQueryEntity GetQueryEntity(CreateReviewSetJobBEO jobParameters, DatasetBEO datasetEntity, int startIndex, int documentCount, List <Field> outputFields) { DocumentQueryEntity documentQueryEntity = new DocumentQueryEntity { QueryObject = new SearchQueryEntity { MatterId = datasetEntity.Matter.FolderID, IsConceptSearchEnabled = jobParameters.DocumentSelectionContext.SearchContext.IsConceptSearchEnabled, DatasetId = datasetEntity.FolderID } }; documentQueryEntity.IgnoreDocumentSnippet = true; documentQueryEntity.DocumentStartIndex = startIndex; documentQueryEntity.DocumentCount = documentCount; documentQueryEntity.SortFields.Add(new Sort { SortBy = Constants.Relevance }); if (outputFields != null && outputFields.Any()) { documentQueryEntity.OutputFields.AddRange(outputFields); } var tmpQuery = string.Empty; var selectionQuery = string.Empty; if (!string.IsNullOrEmpty(jobParameters.DocumentSelectionContext.SearchContext.Query)) { tmpQuery = string.Format("({0} )", jobParameters.DocumentSelectionContext.SearchContext.Query); } else { tmpQuery = string.Format("(NOT ({0}:\"{1}\"))", EVSystemFields.BinderId.ToLowerInvariant(), _binderEntity.BinderId); } switch (jobParameters.DocumentSelectionContext.GenerateDocumentMode) { case DocumentSelectMode.UseSelectedDocuments: { jobParameters.DocumentSelectionContext.SelectedDocuments.ForEach(d => selectionQuery += string.Format("{0}:\"{1}\" OR ", EVSystemFields.DocumentKey, d)); if (!string.IsNullOrEmpty(selectionQuery)) { selectionQuery = selectionQuery.Substring(0, selectionQuery.LastIndexOf(" OR ")); tmpQuery = string.Format("({0} AND ({1}))", tmpQuery, selectionQuery); } break; } case DocumentSelectMode.QueryAndExclude: { jobParameters.DocumentSelectionContext.DocumentsToExclude.ForEach(d => selectionQuery += string.Format("(NOT {0}:\"{1}\") AND ", EVSystemFields.DocumentKey, d)); if (!string.IsNullOrEmpty(selectionQuery)) { selectionQuery = selectionQuery.Substring(0, selectionQuery.LastIndexOf(" AND ")); tmpQuery = string.Format("({0} AND ({1}))", tmpQuery, selectionQuery); } break; } } documentQueryEntity.QueryObject.QueryList.Clear(); documentQueryEntity.QueryObject.QueryList.Add(new Query { SearchQuery = tmpQuery }); return(documentQueryEntity); }
/// <summary> /// Absorb the boot parameters, deserialize and pass on the messages to the Search Worker /// </summary> public void DoBeginWork(string bootParameter) { bootParameter.ShouldNotBeEmpty(); // Deserialize and determine the boot object _bootObject = GetBootObject(bootParameter); // Assert condition to check for jobscheduled by _bootObject.JobScheduleCreatedBy.ShouldNotBeEmpty(); _bootObject.BinderFolderId.ShouldNotBe(0); // Get Dataset Details to know about the Collection id and the Matter ID details _datasetEntity = DataSetBO.GetDataSetDetailForDataSetId(_bootObject.datasetId); //Assert condition to check for dataset details _datasetEntity.ShouldNotBe(null); _binderEntity = BinderBO.GetBinderDetails(_bootObject.BinderFolderId.ToString()); _binderEntity.ShouldNotBe(null); _reviewSetRecord = ConvertToReviewSetRecord(_bootObject); // Construct the document query entity to determine the total documents _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, 1, null); // Mock the user session MockSession(); _docQueryEntity.TransactionName = _docQueryEntity.QueryObject.TransactionName = "ReviewsetStartupWorker - DoBeginWork (GetCount)"; var reviewsetLogic = _reviewSetRecord.ReviewSetLogic.ToLower(); if (reviewsetLogic == "all" || reviewsetLogic == "tag") { var searchQuery = !string.IsNullOrEmpty(_bootObject.SearchQuery)? _bootObject.SearchQuery.Replace("\"", ""): string.Empty; _totalDocumentCount = DocumentBO.GetDocumentCountForCreateReviewsetJob(_datasetEntity.Matter.FolderID, _datasetEntity.CollectionId, reviewsetLogic, searchQuery); } else { // Retrieve the total documents qualified _totalDocumentCount = ReviewerSearchInstance.GetDocumentCount(_docQueryEntity.QueryObject); } Tracer.Info("Reviewset Startup Worker : {0} matching documents determined for the requested query", _totalDocumentCount); if (_totalDocumentCount < 1) { var message = String.Format("Search server does not return any documents for the reviewset '{0}'", _reviewSetRecord.ReviewSetName); throw new ApplicationException(message); } LogMessage(true, string.Format("{0} documents are qualified", _totalDocumentCount)); // Construct the document query entity to write the resultant documents in xml file var outputFields = new List <Field>(); outputFields.AddRange(new List <Field>() { new Field { FieldName = EVSystemFields.DcnField }, new Field { FieldName = EVSystemFields.FamilyId }, new Field { FieldName = EVSystemFields.DuplicateId } }); _docQueryEntity = GetQueryEntity(_bootObject, _datasetEntity, 0, Convert.ToInt32(_totalDocumentCount), outputFields); }