Interface LogbookTraceabilityHelper

All Known Implementing Classes:
LogbookLifeCycleTraceabilityHelper, LogbookObjectGroupLifeCycleTraceabilityHelper, LogbookOperationTraceabilityHelper, LogbookStorageTraceabilityHelper, LogbookUnitLifeCycleTraceabilityHelper

public interface LogbookTraceabilityHelper
Interface used to handle specific steps of the traceability process
  • Field Details

    • INITIAL_START_DATE

      static final LocalDateTime INITIAL_START_DATE
  • Method Details

    • saveDataInZip

      void saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file) throws IOException, TraceabilityException
      Search for entries to secure with the traceability process and store data in the given Traceability zip file.
      Also, Merkle Algorithm should be updated by adding each wanted entry as a leaf of the tree.
      Parameters:
      algo - algorithm used to generate MerkleTree with data.
      file - output zip to store data (in some TYPE_COLLECTION.json)
      Throws:
      IOException - if any error occurs while writing in traceabilityFile
      TraceabilityException - for any other errors specifically in the search / data transformation
    • startTraceability

      void startTraceability() throws TraceabilityException
      Prepare and start the traceability operation
      Throws:
      TraceabilityException - if any error occurs
    • createLogbookOperationEvent

      void createLogbookOperationEvent(Integer tenantId, String eventType, StatusCode status, TraceabilityEvent event) throws TraceabilityException
      Update or finalize the traceability entry in the logbook collection
      Parameters:
      tenantId - tenant used for the operation
      eventType - code of the eventType for the entry
      status - status of the entry
      event - data of the entry
      Throws:
      TraceabilityException - if any error occurs
    • storeAndDeleteZip

      void storeAndDeleteZip(Integer tenant, String strategyId, File zipFile, String fileName, TraceabilityEvent event) throws TraceabilityException
      Store the temporary zip.
      Parameters:
      tenant - tenant used for the operation
      strategyId - strategy used for the storage
      zipFile - file containing multiple information about the traceability operation (data, merkle, computingData, ...)
      fileName - name of the file on the destination
      event - traceability event that should be updated by this operation
      Throws:
      TraceabilityException - if any error occurs
    • getTraceabilityType

      TraceabilityType getTraceabilityType()
      Returns:
      the traceabilityType of the implementation class
    • getStepName

      String getStepName()
      Returns:
      the main eventType code for the specific implementation class
    • getTimestampStepName

      String getTimestampStepName()
      Returns:
      the timestamp eventType code for the specific implementation class
    • getZipName

      String getZipName()
      Returns:
      the name of the tmp zip file
    • getTraceabilityStartDate

      String getTraceabilityStartDate() throws TraceabilityException
      Returns:
      the start date of the traceability (computed from the end date of the last traceability)
      Throws:
      TraceabilityException - on error
    • getTraceabilityEndDate

      String getTraceabilityEndDate() throws TraceabilityException
      Returns:
      the end date of the traceability (now)
      Throws:
      TraceabilityException - on error
    • getDataSize

      long getDataSize() throws TraceabilityException
      Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIterator
      Returns:
      the number of items secured in traceabilityIterator
      Throws:
      TraceabilityException - if the traceabilityIterator isn't yet initialized
    • getPreviousTimestampToken

      byte[] getPreviousTimestampToken() throws InvalidParseOperationException
      Get the last traceability (in logbook) event and return the timestampToken of the entry
      Returns:
      the timestamp token of the last traceability entry or null if no previous traceability OK for that type
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
    • getPreviousMonthTimestampToken

      byte[] getPreviousMonthTimestampToken() throws InvalidParseOperationException, TraceabilityException
      Get the first traceability (in logbook) one month before the given currentDate and return the timestampToken of the entry
      Returns:
      the timestamp token of the matching entry or null if no matching entry
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
      TraceabilityException - if any other error occurs
    • getPreviousYearTimestampToken

      byte[] getPreviousYearTimestampToken() throws InvalidParseOperationException, TraceabilityException
      Get the first traceability (in logbook) one year before the given currentDate and return the timestampToken of the entry
      Returns:
      the timestamp token of the matching entry or null if no matching entry
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
      TraceabilityException - if any other error occurs
    • getPreviousStartDate

      String getPreviousStartDate() throws InvalidParseOperationException
      Get the last traceability (in logbook) event and return the startDate of the entry
      Returns:
      the start date of the last traceability entry
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
    • getPreviousMonthStartDate

      String getPreviousMonthStartDate() throws InvalidParseOperationException, TraceabilityException
      Get the first traceability (in logbook) one month before the given currentDate and return the startDate of the entry
      Returns:
      the start date of the matching entry or null if no matching entry
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
      TraceabilityException - if any other error occurs
    • getPreviousYearStartDate

      String getPreviousYearStartDate() throws InvalidParseOperationException, TraceabilityException
      Get the first traceability (in logbook) one year before the given currentDate and return the startDate of the entry
      Returns:
      the start date of the matching entry or null if no matching entry
      Throws:
      InvalidParseOperationException - if any errors occurs while deserializing entry's data.
      TraceabilityException - if any other error occurs
    • saveEmpty

      void saveEmpty(Integer tenantId) throws TraceabilityException
      Save the close master event if needed
      Parameters:
      tenantId - the tenant used for log
      Throws:
      TraceabilityException
    • getMaxEntriesReached

      boolean getMaxEntriesReached()
      Returns:
      true if max entries reached (unit & object group lifecycle traceability operation are limited in size)
    • getTraceabilityStatistics

      TraceabilityStatistics getTraceabilityStatistics()