Package org.jbpm.casemgmt.api.generator
Interface CaseIdGenerator
-
- All Known Implementing Classes:
InMemoryCaseIdGenerator,NoneCaseIdGenerator,TableCaseIdGenerator
public interface CaseIdGeneratorResponsible for generating and keeping track of generated case identifiers. Identifiers are always prefixed (and by that registered) by constant - default is CASE.
In addition, it's up to generator to to return fixed size generated string to keep the IDs in similar format. Recommended is to have it set to at least 10 items as part of the generated value:
Generators should return following:0000000001,0000000010,0000000100instead of1,10,100
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Stringgenerate(String prefix, Map<String,Object> optionalParameters)Generates next value for given prefix.StringgetIdentifier()Identifier of the generator so it can be found and registered at runtimevoidregister(String prefix)Should be called only one time per given prefix.default StringresolveCaseIdPrefix(String prefix, Map<String,Object> optionalParameters)Evaluates the current prefix expression to generate the sequence name given the parameters passedvoidunregister(String prefix)Unregisters given prefix from the generator.
-
-
-
Method Detail
-
getIdentifier
String getIdentifier()
Identifier of the generator so it can be found and registered at runtime- Returns:
- unique identifier
-
register
void register(String prefix)
Should be called only one time per given prefix. Subsequent calls with same prefix do not affect the generator state.- Parameters:
prefix- unique prefix that should be used for generating case identifiers
-
unregister
void unregister(String prefix)
Unregisters given prefix from the generator. It's up to generator implementation to either remove the prefix and its latest value permanently or resume it in case of further registration of the same prefix.- Parameters:
prefix- unique prefix that should be used for generating case identifiers
-
generate
String generate(String prefix, Map<String,Object> optionalParameters)
Generates next value for given prefix. Returned value should include the prefix as part of the returned value.- Parameters:
prefix- unique prefix that should be used for generating case identifiersoptionalParameters- map of optionalParameters that might be helpful for implementation- Returns:
- complete case id in format (PREFIX-GENERATED_VALUE)
- Throws:
CasePrefixNotFoundException- in case given prefix was not registered
-
resolveCaseIdPrefix
default String resolveCaseIdPrefix(String prefix, Map<String,Object> optionalParameters)
Evaluates the current prefix expression to generate the sequence name given the parameters passed- Parameters:
identifierPrefix- expression to be evaluatedoptionalParameters- parameters needed to evaluate the expression- Returns:
- returns the sequence name
- Throws:
CasePrefixCannotBeGeneratedException- when it is not possible to generate the case prefix expression
-
-