Class CustomLogRecordRepositoryImpl

java.lang.Object
org.qubership.atp.ram.repositories.impl.CustomLogRecordRepositoryImpl
All Implemented Interfaces:
CustomLogRecordRepository, FieldConstants

@Repository public class CustomLogRecordRepositoryImpl extends Object implements CustomLogRecordRepository, FieldConstants
  • Constructor Details

    • CustomLogRecordRepositoryImpl

      public CustomLogRecordRepositoryImpl()
  • Method Details

    • getTopLogRecordsByFilterLookup

      public List<LogRecord> getTopLogRecordsByFilterLookup(UUID testRunId, List<String> statuses, List<String> types, boolean showNotAnalyzedItemsOnly)
      Filter log records by lookup. See here for details: https://docs.mongodb.com/manual/reference/operator/aggregation/graphLookup/ Query example: { $match: { testRunId: JUUID("00a2361c-0e54-467c-ab95-094df7f1eaeb"), parentRecordId: { "$exists": false }, rootCause: { "$exists": true } } }, { $graphLookup: { from: "logrecord", startWith: "$_id", connectFromField: "_id", connectToField: "parentRecordId", as: "children", depthField: "depth", restrictSearchWithMatch: { testingStatus: { $in: ["PASSED"] }, type: { $in: ["UI", "COMPOUND"] } } } }, { $match: { "children.0": { $exists: true } } }, { $project: { children: 0 } }
      Specified by:
      getTopLogRecordsByFilterLookup in interface CustomLogRecordRepository
      Parameters:
      testRunId - test run id
      statuses - testing statuses
      types - steps types
      showNotAnalyzedItemsOnly - is root cause present
      Returns:
      search result
    • getAllHierarchicalChildrenLogRecords

      public List<LogRecord> getAllHierarchicalChildrenLogRecords(UUID parentLogRecord)
      Specified by:
      getAllHierarchicalChildrenLogRecords in interface CustomLogRecordRepository
    • getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup

      public List<LogRecordWithParentResponse> getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup(UUID testRunId, FileType fileType)
      Get parent LR (top level) and list of child with pot files. Query example: db.logrecord.aggregate( { $match: { testRunId: testRunIdVar, "fileMetadata.type": "POT", } }, { $graphLookup: { from: "logrecord", startWith: "$parentRecordId", connectFromField: "parentRecordId", connectToField: "_id", as: "parent", depthField: "depth", restrictSearchWithMatch: { testRunId: testRunIdVar } } } )
      Specified by:
      getTopLogRecordsIdAndChildLogRecordsByFileTypeFilterLookup in interface CustomLogRecordRepository
      Parameters:
      testRunId - id of TR
      fileType - type of file
      Returns:
      map with parent ID and child
    • getLogRecordParentAndChildrenByTestingStatusAndTestRunId

      public LogRecordWithChildrenResponse getLogRecordParentAndChildrenByTestingStatusAndTestRunId(UUID tesRunId, TestingStatuses testingStatus)
      Find first parent and children LR by TR is and status. Query example: var testRunIdVar = JUUID("12851ab0-5d4f-41b9-bfe2-e91a6c5c9783") db.logrecord.aggregate( { $match: { testRunId: testRunIdVar, parentRecordId: {$exists:false} } }, { $sort: { lastUpdated: 1 } }, { $graphLookup: { from: "logrecord", startWith: "$_id", connectFromField: "_id", connectToField: "parentRecordId", as: "children", depthField: "depth", restrictSearchWithMatch: { "testingStatus": "FAILED", } } }, { $match: { "children.0": {$exists: true} } }, { $unwind: "$children" }, { $sort: { "children.depth": -1 } }, { $limit: 1 } )
      Specified by:
      getLogRecordParentAndChildrenByTestingStatusAndTestRunId in interface CustomLogRecordRepository
      Parameters:
      tesRunId - TR id
      testingStatus - status
      Returns:
      first LR with children
    • findLogRecordsByTestRunIdsAndValidationWithHint

      public List<LogRecord> findLogRecordsByTestRunIdsAndValidationWithHint(Collection<UUID> testRunIds)
      Find all LR-s by test runs ID and exist validation.
      Specified by:
      findLogRecordsByTestRunIdsAndValidationWithHint in interface CustomLogRecordRepository
      Parameters:
      testRunIds - for found LR-s
      Returns:
      list of LR-s
    • findLogRecordsWithParentsByPreviewExists

      public List<LogRecordWithParentListResponse> findLogRecordsWithParentsByPreviewExists(UUID testRunId)
      Find all LR's with preview and list of parents (LR) by TR id. Query example: [ { "$match": { "testRunId": JUUID("26f1555b-85c6-489c-a2cf-691fa96e9f2f"), "preview": { "$exists": true, "$ne": "" } } }, { "$graphLookup": { "from": "logrecord", "startWith": "$parentRecordId", "connectFromField": "parentRecordId", "connectToField": "_id", "as": "parent", "depthField": "depth" } }, { "$project": { "name": 1, "testingStatus": 1, "startDate": 1, "parent": 1 } }, { "$sort": { "startDate": 1 } } ] Response example: [ { "_id":"4fc1dbbe-ab58-4090-9d4b-6363a068a315", "name":"Message", "startDate":2022-04-25T16:54:56.461Z, "testingStatus":"PASSED", "parent":[ { "_id": "32a63b59-18b2-40fa-9a35-dd137a7f5647", "name": "Login as \"user\" with password \"password\"", "type": "UI", "depth": 0 } ] } ]
      Specified by:
      findLogRecordsWithParentsByPreviewExists in interface CustomLogRecordRepository
      Parameters:
      testRunId - Test Run id.
      Returns:
      All LR's with preview and list of parents (LR).
    • findLastOrcLogRecordByTestRunAndExecutionStatus

      public LogRecord findLastOrcLogRecordByTestRunAndExecutionStatus(UUID testRunId, ExecutionStatuses status)
      Find orchestrator log records. Query example: var testRunIdVar = JUUID("20d9e670-81e9-48c9-b0e9-8d22f4b850fa") var status = "IN PROGRESS"; db.logrecord.aggregate( [ { $match: { testRunId: testRunIdVar, executionStatus: status } }, { $sort: { createdDateStamp: -1 } }, { $graphLookup: { from: "logrecord", startWith: "$parentRecordId", connectFromField: "parentRecordId", connectToField: "_id", as: "parent", restrictSearchWithMatch: { testRunId: testRunIdVar } } }, { $match: { $or: [ { $and: [ { "parentRecordId": { $exists: false } }, { "type": {$ne: "COMPOUND"} } ] }, { $and: [ { "parent" : { $not: { $elemMatch: { "type": { $nin: ["COMPOUND"] } } } } }, { "parentRecordId": { $exists: true } } ] } ] } }, { $limit: 1 } ] )
      Specified by:
      findLastOrcLogRecordByTestRunAndExecutionStatus in interface CustomLogRecordRepository
      Parameters:
      testRunId - TR id
      status - execution status
    • getProjectIdByLogRecordId

      public UUID getProjectIdByLogRecordId(UUID logRecordId)
      Get project id by logRecord id. db.logrecord.aggregate([ { $match: { _id: LUUID("ff4ebd21-947b-86c0-b765-0237ac4adca4") } }, { $lookup: { from: "testrun", localField: "testRunId", foreignField: "_id", as: "testrun" } }, { $unwind: "$testrun" }, { $lookup: { from: "executionRequests", localField: "testrun.executionRequestId", foreignField: "_id", as: "executionRequest" } }, { $unwind: "$executionRequest" }, { $project: { "projectId": "$executionRequest.projectId", "_id": 0 } } ] )
      Specified by:
      getProjectIdByLogRecordId in interface CustomLogRecordRepository