001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.transactionlog; 011 012import ca.cdr.api.annotations.CdrPublicAPI; 013import ca.cdr.api.model.enm.TransactionLogEventSubTypeEnum; 014import ca.cdr.api.model.enm.TransactionLogEventTypeEnum; 015import ca.cdr.api.model.json.TransactionLogEventsJson; 016import ca.cdr.api.model.json.TransactionLogStepJson; 017 018import java.util.Collections; 019import java.util.List; 020 021/** 022 * This class is the ingestion point for all Transaction Logs generated in Smile CDR. This class is capable of routing all incoming 023 * Transaction Logs to every Module which implements a transaction log writer. If you are looking to create and store a Transaction Log, this is the class to use. 024 */ 025@CdrPublicAPI 026public interface ITransactionLogStoringSvc { 027 028 /** 029 * Creates a new Transaction Log. This method will persist the transaction log to all modules which implement a transaction log writer. 030 * 031 * @param theIncomingTransactionLog parameter object encapsulating the properties required to persist a {@link TransactionLogEventsJson.TransactionLogEventJson} 032 * @return Returns a {@link TransactionLogIdentifiers} indicating the underlying PID of the transaction log, for each module that was able to persist the log and its initial steps. 033 */ 034 TransactionLogIdentifiers persistNewLog(IncomingTransactionLog theIncomingTransactionLog); 035 036 @Deprecated 037 default TransactionLogIdentifiers persistNewLog( 038 TransactionLogEventTypeEnum theType, 039 TransactionLogEventSubTypeEnum theSubType, 040 List<TransactionLogStepJson> theInitialSteps, 041 String theTransactionId, 042 String theTransactionGuid, 043 String theModuleId) { 044 045 IncomingTransactionLog incomingTransactionLog = IncomingTransactionLog.builder() 046 .withType(theType) 047 .withSubType(theSubType) 048 .withInitialSteps(theInitialSteps) 049 .withTransactionId(theTransactionId) 050 .withTransactionGuid(theTransactionGuid) 051 .withModuleId(theModuleId) 052 .build(); 053 054 return persistNewLog(incomingTransactionLog); 055 } 056 057 @Deprecated 058 default TransactionLogIdentifiers persistNewLog( 059 TransactionLogEventTypeEnum theType, 060 TransactionLogEventSubTypeEnum theSubType, 061 TransactionLogStepJson theInitialStep, 062 String theTransactionId, 063 String theTransactionGuid, 064 String theModuleId) { 065 return persistNewLog( 066 theType, 067 theSubType, 068 Collections.singletonList(theInitialStep), 069 theTransactionId, 070 theTransactionGuid, 071 theModuleId); 072 } 073 074 @Deprecated 075 default TransactionLogIdentifiers persistNewLog( 076 TransactionLogEventTypeEnum theType, 077 TransactionLogEventSubTypeEnum theSubType, 078 List<TransactionLogStepJson> theInitialSteps, 079 String theTransactionId, 080 String theModuleId) { 081 return persistNewLog(theType, theSubType, theInitialSteps, theTransactionId, null, theModuleId); 082 } 083 084 @Deprecated 085 default TransactionLogIdentifiers persistNewLog( 086 TransactionLogEventTypeEnum theType, 087 TransactionLogEventSubTypeEnum theSubType, 088 TransactionLogStepJson theInitialStep, 089 String theTransactionId, 090 String theModuleId) { 091 return persistNewLog( 092 theType, theSubType, Collections.singletonList(theInitialStep), theTransactionId, null, theModuleId); 093 } 094 095 /** 096 * This method adds new steps to existing parent Transaction Logs. 097 * 098 * @param theTransactionPidMap the {@link TransactionLogIdentifiers} entity containing the mappings of writer to pid. 099 * @param theStep the {@link TransactionLogStepJson} to add to this parent transaction log. 100 */ 101 void persistNewStep(TransactionLogIdentifiers theTransactionPidMap, TransactionLogStepJson theStep); 102 103 /** 104 * This is an alternative to {@link #persistNewStep(TransactionLogIdentifiers, TransactionLogStepJson)}. 105 * 106 * Since the GUID is manually set on create, it is guaranteed to be identical across all the possible TX Log writers, and as such we need no map for lookup. 107 * This will add a new step to the existing parent transcation log, identified by GUID. 108 * 109 * @param theTransactionGuid the GUID of the parent transaction log. 110 * @param theStep the {@link TransactionLogStepJson} to add to this parent transaction log. 111 */ 112 void persistNewStep(String theTransactionGuid, TransactionLogStepJson theStep); 113 114 /** 115 * Given an event, delete it by ID. 116 * 117 * @param theId the ID of the event to delete. 118 */ 119 void deleteEvent(Long theId); 120 121 /** 122 * Indicates whether Transaction Logging is enabled anywhere on the system, either in the cluster manager, or any modules which implement a transaction log writer. 123 * 124 * @return true if transaction logging is enabled anywhere on the system. 125 */ 126 boolean isEnabled(); 127}