Class PasteurCleanUpPolicy
java.lang.Object
org.odpi.openmetadata.adapters.connectors.pasteur.PasteurCleanUpPolicy
PasteurCleanUpPolicy decides which finished actions are old enough to be cleaned up. It is built from the
daysToCleanUp and completionStatuses configuration properties and holds no connection to the open metadata
ecosystem, so the rules can be tested on their own.
An action is eligible for clean-up when all of these are true:
- its type, or the nearest of its supertypes, has an entry in daysToCleanUp;
- its activity status is one of the completion statuses;
- at least that many days have passed since it completed. The completion time is the action's completionTime property, or the time it was last updated (or created) if that is not set.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DeleteMethodThe delete method used unless the deleteMethod configuration property names another. -
Constructor Summary
ConstructorsConstructorDescriptionPasteurCleanUpPolicy(Map<String, Long> daysToCleanUp, Collection<String> completionStatuses) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturn the type names that have an entry in daysToCleanUp, in the order they are cleaned up.static DategetCompletionDate(Date completionTime, Date updateTime, Date createTime) Return when the action completed.Return the completion statuses.Return the configured days to clean up.getDaysToCleanUp(String typeName, List<String> superTypeNames) Return the minimum days after completion for an action's type.booleanisActive()Return whether there is anything to clean up.booleanisCompletionStatus(String activityStatus) Return whether the activity status shows the action has finished.booleanisEligible(String typeName, List<String> superTypeNames, String activityStatus, Date completionTime, Date updateTime, Date createTime, Date now) Return whether an action is eligible for clean-up.static booleanisOldEnough(Date completionDate, long days, Date now) Return whether enough time has passed since an action completed.parseCompletionStatuses(List<String> configuredStatuses, List<String> defaultStatuses, List<String> invalidStatuses) Check the configured completion statuses against the ActivityStatus enum.parseDaysToCleanUp(Object configurationValue, List<String> invalidEntries) Turn the value of the daysToCleanUp configuration property into a map of type name to days.static DeleteMethodparseDeleteMethod(String configuredDeleteMethod) Return the delete method named in the deleteMethod configuration property.
-
Field Details
-
DEFAULT_DELETE_METHOD
The delete method used unless the deleteMethod configuration property names another. An action with lineage relationships is archived, so lineage queries can still find it, and the others are soft-deleted.
-
-
Constructor Details
-
PasteurCleanUpPolicy
Constructor.- Parameters:
daysToCleanUp- type name to the minimum days after completion - entries with a null key or value, or a negative value, are skippedcompletionStatuses- symbolic names of the activity statuses that show an action has finished
-
-
Method Details
-
getDaysToCleanUp
Return the configured days to clean up.- Returns:
- sorted map of type name to days
-
getCleanUpTypeNames
Return the type names that have an entry in daysToCleanUp, in the order they are cleaned up.- Returns:
- list of type names
-
getCompletionStatuses
Return the completion statuses.- Returns:
- set of symbolic names
-
isActive
public boolean isActive()Return whether there is anything to clean up.- Returns:
- false if there are no days to clean up or no completion statuses
-
getDaysToCleanUp
Return the minimum days after completion for an action's type. The entry for the type itself is used if there is one, otherwise the entry for the nearest supertype.- Parameters:
typeName- name of the action's typesuperTypeNames- names of its supertypes, nearest first - may be null- Returns:
- days, or null if neither the type nor any of its supertypes has an entry
-
isCompletionStatus
Return whether the activity status shows the action has finished.- Parameters:
activityStatus- symbolic name of the action's activity status - may be null- Returns:
- boolean
-
getCompletionDate
Return when the action completed. This is its completionTime property if it is set. Otherwise, it is the time the action was last updated, since setting the final status is normally the last update. An action that has never been updated uses its creation time.- Parameters:
completionTime- the action's completionTime property - may be nullupdateTime- when the action was last updated - may be nullcreateTime- when the action was created - may be null- Returns:
- date, or null if none of them is known
-
isOldEnough
Return whether enough time has passed since an action completed.- Parameters:
completionDate- when the action completed - null means it is not known, so the action is keptdays- minimum days after completionnow- the time to measure from- Returns:
- boolean
-
isEligible
public boolean isEligible(String typeName, List<String> superTypeNames, String activityStatus, Date completionTime, Date updateTime, Date createTime, Date now) Return whether an action is eligible for clean-up.- Parameters:
typeName- name of the action's typesuperTypeNames- names of its supertypes, nearest first - may be nullactivityStatus- symbolic name of the action's activity status - may be nullcompletionTime- the action's completionTime property - may be nullupdateTime- when the action was last updated - may be nullcreateTime- when the action was created - may be nullnow- the time to measure from- Returns:
- boolean
-
parseDaysToCleanUp
public static Map<String,Long> parseDaysToCleanUp(Object configurationValue, List<String> invalidEntries) Turn the value of the daysToCleanUp configuration property into a map of type name to days. The values arrive as numbers (Integer or Long, depending on their size, when the connection is read from JSON) or as strings. The entries that can not be turned into a number of days that is zero or more are skipped and described in invalidEntries.- Parameters:
configurationValue- value of the configuration property - may be nullinvalidEntries- list to add descriptions of the skipped entries to- Returns:
- map of type name to days - empty if the value is null or not a map
-
parseCompletionStatuses
public static List<String> parseCompletionStatuses(List<String> configuredStatuses, List<String> defaultStatuses, List<String> invalidStatuses) Check the configured completion statuses against the ActivityStatus enum. The comparison ignores case and surrounding spaces. The statuses that are not recognized are skipped and added to invalidStatuses.- Parameters:
configuredStatuses- value of the completionStatuses configuration property - null means use the defaultdefaultStatuses- statuses to use if none are configuredinvalidStatuses- list to add the unrecognized statuses to- Returns:
- list of the symbolic names of the recognized statuses
-
parseDeleteMethod
Return the delete method named in the deleteMethod configuration property.- Parameters:
configuredDeleteMethod- symbolic name of a DeleteMethod value (case is ignored), or null- Returns:
- the named delete method, the default if none is named, or null if the name is not a delete method
-