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.TransactionLogStepBodySerializationModeEnum;
014import ca.cdr.api.model.json.TransactionLogEventsJson;
015import org.springframework.data.domain.Page;
016import org.springframework.data.domain.Pageable;
017
018import java.util.Date;
019import java.util.List;
020
021/**
022 * This class is the entry point to retrieving Transaction Logs. In order to retrieve a transaction log, or search for transaction logs, it is critical to know the module which
023 * contains the log, since multiple modules can all be storing transaction logs. This interface allows you to select/search on a per-module basis.
024 */
025@CdrPublicAPI
026public interface ITransactionLogFetchingSvc {
027
028        /**
029         * Returns the serialization mode for the body of the transaction log.
030         *
031         * @return the serialization mode for the body of the transaction log.
032         */
033        TransactionLogStepBodySerializationModeEnum getTransactionLogStepSerializationBodyType();
034        /**
035         * Lists all the Module IDs which are capable of fetching Transaction Logs.
036         *
037         * @return a list of module IDs.
038         */
039        List<String> getModuleIdsOfTransactionLogReaders();
040
041        /**
042         * This is the primary search method for retrieving Transaction logs in paginated fashion. You can filter using top-level parameters here. For a more detailed search, populate
043         * the TranscationLogSearch object.
044         *
045         * @param theModuleId the ID of the module which contains the transcation logs.
046         * @param theFrom the start date for the search
047         * @param theTo the end date for the search
048         * @param thePageable the pageable object.
049         * @param theSearchParams the {@link TransactionLogSearch} to refine your query. You can pass `{@link TransactionLogSearch#all()} if you do not want to refine.
050         * @return a Page of {@link TransactionLogEventsJson.TransactionLogEventJson}, each representing a Transcation Log.
051         */
052        Page<TransactionLogEventsJson.TransactionLogEventJson> getPageableTransactionLog(
053                        String theModuleId, Date theFrom, Date theTo, Pageable thePageable, TransactionLogSearch theSearchParams);
054
055        /**
056         * Fetch one very specific Transcation Log by its known PID.
057         *
058         * @param theModuleId the ID of the module which contains the transaction logs.
059         * @param theId the PID of the Transaction Log.
060         * @param theIncludeBody Whether or not to include the body of the log.
061         * @return a {@link TransactionLogEventsJson.TransactionLogEventJson}.
062         */
063        TransactionLogEventsJson.TransactionLogEventJson getTransactionEvent(
064                        String theModuleId, Long theId, boolean theIncludeBody);
065
066        /**
067         * Fetches the next PID given a certain PID.
068         *
069         */
070        Long getNextId(String theModuleId, Long id);
071        /**
072         * Fetches the previous PID given a certain PID.
073         */
074        Long getPreviousId(String theModuleId, Long id);
075
076        /**
077         * This is the old method for retrieving Transaction Logs. It is not recommended to use this method, as it is not paginated. It is here for backwards compatibility. This method will be removed in a future release.
078         * @param theModuleId the ID of the module which contains the transaction logs.
079         * @param theFrom the start date for the search
080         * @param theTo the end date for the search
081         * @param thePageIndex the page index
082         * @param thePageSize the page size
083         * @param theSearchParams the {@link TransactionLogSearch} to refine your query. You can pass `{@link TransactionLogSearch#all()} if you do not want to refine.
084         * @return
085         */
086        @Deprecated
087        TransactionLogEventsJson getTransactionLog(
088                        String theModuleId,
089                        Date theFrom,
090                        Date theTo,
091                        int thePageIndex,
092                        int thePageSize,
093                        TransactionLogSearch theSearchParams);
094
095        /**
096         * whether the underlying system is configured to show the request body.
097         * @param theModuleId the ID of the module which contains the transaction logs.
098         * @return true if the request body will be shown.
099         */
100        boolean isShowRequestBody(String theModuleId);
101}