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 Summary
Fields Modifier and Type Field Description static java.time.LocalDateTime
INITIAL_START_DATE
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
createLogbookOperationEvent(java.lang.Integer tenantId, java.lang.String eventType, StatusCode status, TraceabilityEvent event)
Update or finalize the traceability entry in the logbook collectionlong
getDataSize()
Warning: This method MUST be used after "saveDataInZip" witch initialize traceabilityIteratorboolean
getMaxEntriesReached()
java.lang.String
getPreviousMonthStartDate()
Get the first traceability (in logbook) one month before the given currentDate and return the startDate of the entrybyte[]
getPreviousMonthTimestampToken()
Get the first traceability (in logbook) one month before the given currentDate and return the timestampToken of the entryjava.lang.String
getPreviousStartDate()
Get the last traceability (in logbook) event and return the startDate of the entrybyte[]
getPreviousTimestampToken()
Get the last traceability (in logbook) event and return the timestampToken of the entryjava.lang.String
getPreviousYearStartDate()
Get the first traceability (in logbook) one year before the given currentDate and return the startDate of the entrybyte[]
getPreviousYearTimestampToken()
Get the first traceability (in logbook) one year before the given currentDate and return the timestampToken of the entryjava.lang.String
getStepName()
java.lang.String
getTimestampStepName()
java.lang.String
getTraceabilityEndDate()
java.lang.String
getTraceabilityStartDate()
TraceabilityStatistics
getTraceabilityStatistics()
TraceabilityType
getTraceabilityType()
java.lang.String
getZipName()
void
saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file)
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.void
saveEmpty(java.lang.Integer tenantId)
Save the close master event if neededvoid
startTraceability()
Prepare and start the traceability operationvoid
storeAndDeleteZip(java.lang.Integer tenant, java.lang.String strategyId, java.io.File zipFile, java.lang.String fileName, TraceabilityEvent event)
Store the temporary zip.
-
-
-
Method Detail
-
saveDataInZip
void saveDataInZip(MerkleTreeAlgo algo, TraceabilityFile file) throws java.io.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:
java.io.IOException
- if any error occurs while writing in traceabilityFileTraceabilityException
- 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(java.lang.Integer tenantId, java.lang.String eventType, StatusCode status, TraceabilityEvent event) throws TraceabilityException
Update or finalize the traceability entry in the logbook collection- Parameters:
tenantId
- tenant used for the operationeventType
- code of the eventType for the entrystatus
- status of the entryevent
- data of the entry- Throws:
TraceabilityException
- if any error occurs
-
storeAndDeleteZip
void storeAndDeleteZip(java.lang.Integer tenant, java.lang.String strategyId, java.io.File zipFile, java.lang.String fileName, TraceabilityEvent event) throws TraceabilityException
Store the temporary zip.- Parameters:
tenant
- tenant used for the operationstrategyId
- strategy used for the storagezipFile
- file containing multiple information about the traceability operation (data, merkle, computingData, ...)fileName
- name of the file on the destinationevent
- 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
java.lang.String getStepName()
- Returns:
- the main eventType code for the specific implementation class
-
getTimestampStepName
java.lang.String getTimestampStepName()
- Returns:
- the timestamp eventType code for the specific implementation class
-
getZipName
java.lang.String getZipName()
- Returns:
- the name of the tmp zip file
-
getTraceabilityStartDate
java.lang.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
java.lang.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
java.lang.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
java.lang.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
java.lang.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(java.lang.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()
-
-