public class NumberSeriesManager extends Manager
createNumberSeries(String, String, int, int) method. With that you create a new series identified by a unique key
where the series starts at the specified start value and contains of specified number of digits. The type of a series specified
whether it is numeric using NumberGenerator.NumberSeriesConstants.TYPES.ALPHANUMERIC (consisting only of digits)
or alpha numeric using NumberGenerator.NumberSeriesConstants.TYPES.NUMERIC (consisting of letters too). The digits
and start value will be stored persistent for a series.getUniqueNumber(String). For resetting a series to a
specific start value you can call resetNumberSeries(String, String, int). The setDigits(String, int) method
can be called any time for changing the length of the generated numbers. The setStartValue(String, String) should not
be called, the property is only used for storing the original start value of a series and will have no effect after series
creation. It only is useful if storing a new start value for a later resetting of the series using the stored start value.| Modifier and Type | Class and Description |
|---|---|
protected static class |
NumberSeriesManager.NumberSeriesManagerSerializableDTO |
Manager.GenericManagerSingletonCreator, Manager.ManagerSingletonCreator| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BEAN_NAME
Identifier of this manager used at core-spring.xml spring configuration.
|
static java.lang.String |
CONFIG_PARAM_NUMBER_CACHE
Allows to set number series cache size globally and per series:
|
static int |
DEFAULT_NUMBER_CACHE_SIZE
Default cache size for number series.
|
| Constructor and Description |
|---|
NumberSeriesManager() |
| Modifier and Type | Method and Description |
|---|---|
void |
assureCustomerIDSeriesCreated()
Deprecated.
since ages - number series is created during init - there is no need to check each time a new number is fetched!
|
void |
assureOrderCodeSeriesCreated()
Deprecated.
since ages - number series are created during init - there is no need to check each time we need a new number !
|
protected void |
checkBeforeItemRemoval(SessionContext ctx,
Item item)
Superclass method overridden to avoid calls to ejb layer.
|
protected int |
checkDigits(java.lang.String key,
int digits)
Checks digits and if
digits < 0 fetches default digits for given series key. |
void |
createEssentialData(java.util.Map params,
JspContext jspc) |
NumberSeries |
createNumberSeries(java.lang.String key,
java.lang.String startValue,
int type)
Deprecated.
since 5.0 - please use
createNumberSeries(String, String, int, int, String) instead. |
NumberSeries |
createNumberSeries(java.lang.String key,
java.lang.String startValue,
int type,
int digits)
Deprecated.
since 5.0 - please use
createNumberSeries(String, String, int, int, String). |
NumberSeries |
createNumberSeries(java.lang.String key,
java.lang.String startValue,
int type,
int digits,
java.lang.String template)
Creates a new number series, sets the given start value via
setStartValue(String, String) and the given digits via
setDigits(String, int) persistent. |
java.util.Collection |
getAllNumberSeries()
Makes a snapshot of all number series currently existing in the database.
|
java.util.Collection<java.lang.String> |
getAllNumberSeriesKeys()
Returns all keys where number series exists.
|
int |
getDigits(java.lang.String key)
Returns the configured digits for the given number series.
|
static NumberSeriesManager |
getInstance()
Gets the instance of this manager.
|
NumberSeries |
getNumberSeries(java.lang.String key)
Makes a snapshot of the number series linked to the given key.
|
NumberSeries |
getOrCreateCustomerIDSeries()
Returns standard number series for customer IDs.
|
NumberSeries |
getOrCreateOrderCodeSeries()
Returns standard number series for order codes.
|
java.lang.String |
getStartValue(java.lang.String key)
Returns the original start value of the given series.
|
java.lang.String |
getUniqueNumber(java.lang.String key)
Returns a unique number for a given number series key.
|
java.lang.String |
getUniqueNumber(java.lang.String key,
int digits)
Returns a unique number for a given series key and a digit length.
|
NumberSeries |
getUniqueNumberUnformatted(java.lang.String key)
Returns the unique number object rather than its formatted representation (see
getUniqueNumber(String, int). |
boolean |
isCreatorDisabled()
Part of
DataCreator interface. |
protected void |
notifyItemRemoval(SessionContext ctx,
Item item)
Superclass method overridden to avoid calls to ejb layer.
|
void |
removeDigits(java.lang.String key)
Removes the digits setting from NumberSeriesManager for the given series.
|
void |
removeNumberSeries(java.lang.String key)
Removes a number series and removes the digits and start value setting for this series.
|
void |
removeStartValue(java.lang.String key)
Removes the original start value property and value.
|
void |
resetNumberSeries(java.lang.String key,
java.lang.String startValue,
int type)
Deprecated.
since 5.0 - please use
resetNumberSeries(String, String, int, String). |
void |
resetNumberSeries(java.lang.String key,
java.lang.String startValue,
int type,
java.lang.String template)
Resets the number series with the given key to the given start value and type.
|
void |
setDigits(java.lang.String key,
int digits)
Saves the digits for the given number series.
|
void |
setStartValue(java.lang.String key,
java.lang.String startvalue)
Changes the original start value of the given series.
|
java.lang.Object |
writeReplace() |
afterItemCreation, beforeItemCreation, destroy, extractNonRequiredRemoteFromItem, extractRequiredRemoteFromItem, getAllValuesSessionContext, getAttribute, getAttributeMap, getFirstItemByAttribute, getFirstItemByAttribute, getRemote, getRemoteManagerClass, getSession, getSingletonManagerInstance, getTenant, getTransientObject, getTransientObjectMap, init, setAttribute, setTenant, setTransientObject, wrappublic static final java.lang.String BEAN_NAME
public static final java.lang.String CONFIG_PARAM_NUMBER_CACHE
# set global cache size numberseries.cache.size=100 # set custom cache size for a single series numberseries.cache.size.mySeries=1
public static final int DEFAULT_NUMBER_CACHE_SIZE
public static NumberSeriesManager getInstance()
protected void checkBeforeItemRemoval(SessionContext ctx, Item item) throws ConsistencyCheckException
checkBeforeItemRemoval in class Managerctx - the current session contextitem - the item which should be removedConsistencyCheckException - thrown to abort removal due to consistency errorsprotected void notifyItemRemoval(SessionContext ctx, Item item)
notifyItemRemoval in class Managerctx - the currency session contextitem - the item which is going to be removedpublic java.lang.String getUniqueNumber(java.lang.String key,
int digits)
throws JaloInvalidParameterException
key - the key of the number series, e.g. "Order"digits - the length of the result number string; if the actual number is smaller it will be filled with leading '0's -
but if it is larger it wont be truncated !JaloInvalidParameterException - if a number series with given key is unknownprotected int checkDigits(java.lang.String key,
int digits)
digits < 0 fetches default digits for given series key.key - the series keydigits - the given digitspublic java.lang.String getUniqueNumber(java.lang.String key)
throws JaloInvalidParameterException
key - the key of the number series, e.g. "Order"JaloInvalidParameterException - if a number series with given key is unknownpublic NumberSeries getUniqueNumberUnformatted(java.lang.String key) throws JaloInvalidParameterException
getUniqueNumber(String, int). Use as
follows:
NumberSeries ns = NumberSeriesManager.getInstance().getUniqueNumberUnformatted("fooSeries");
// get 10 digits text
String number10 = ns.getFormatted(10);
// get real number
long number = ns.getCurrentNumber();
key - the number series keyJaloInvalidParameterException - if no series exists for keypublic void removeNumberSeries(java.lang.String key)
throws JaloInvalidParameterException
key - the key of the number series, e.g. "Order"JaloInvalidParameterException@Deprecated public NumberSeries createNumberSeries(java.lang.String key, java.lang.String startValue, int type) throws JaloInvalidParameterException
createNumberSeries(String, String, int, int, String) instead.setStartValue(String, String). Call
setDigits(String, int) to assure that the right digits are set or use
createNumberSeries(String, String, int, int). Otherwise you may get an exception on other moduls like hybris
platform hmc.key - the key of the number series, e.g. "Order"startValue - the star value of this serie: numeric series must have a Long parseable value, alphanumeric must match
['0'..'9''A'..'Z']*type - one of NumberGenerator.NumberSeriesConstants.TYPES.ALPHANUMERIC and
NumberGenerator.NumberSeriesConstants.TYPES.NUMERICJaloInvalidParameterExceptionpublic NumberSeries createNumberSeries(java.lang.String key, java.lang.String startValue, int type, int digits, java.lang.String template) throws JaloInvalidParameterException
setStartValue(String, String) and the given digits via
setDigits(String, int) persistent.key - the number series key.startValue - the number series start value.type - the number series type
NumberGenerator.NumberSeriesConstants.TYPES.ALPHANUMERIC or
NumberGenerator.NumberSeriesConstants.TYPES.NUMERICdigits - the number of digitstemplate - the template to be applied on generated valueNumberSeries object.JaloInvalidParameterException - if there is no series registered for given key@Deprecated public NumberSeries createNumberSeries(java.lang.String key, java.lang.String startValue, int type, int digits) throws JaloInvalidParameterException
createNumberSeries(String, String, int, int, String).setStartValue(String, String) and the given digits via
setDigits(String, int) persistent.key - the number series key.startValue - the number series start value.type - the number series type
NumberGenerator.NumberSeriesConstants.TYPES.ALPHANUMERIC or
NumberGenerator.NumberSeriesConstants.TYPES.NUMERICdigits - the number of digitsNumberSeries object.JaloInvalidParameterException - if there is no series registered for given keypublic java.util.Collection<java.lang.String> getAllNumberSeriesKeys()
public java.util.Collection getAllNumberSeries()
NumberSeries objects or an empty list.public NumberSeries getNumberSeries(java.lang.String key) throws JaloInvalidParameterException
JaloInvalidParameterException will be thrown.key - the series keyNumberSeries object for the key.JaloInvalidParameterException@Deprecated
public void resetNumberSeries(java.lang.String key,
java.lang.String startValue,
int type)
throws JaloInvalidParameterException
resetNumberSeries(String, String, int, String).key - the number series key, must not be null.startValue - the series new startvalue.type - the series typeJaloInvalidParameterException - if no series was found for given keypublic void resetNumberSeries(java.lang.String key,
java.lang.String startValue,
int type,
java.lang.String template)
throws JaloInvalidParameterException
key - the number series key, must not be null.startValue - the series new startvalue.type - the series typetemplate - the template to be applied on generated valueJaloInvalidParameterException - if no series was found for given keypublic void setDigits(java.lang.String key,
int digits)
key - the number series key. key must not be null.digits - the digitspublic int getDigits(java.lang.String key)
key - the number series key. must not be null.public void removeDigits(java.lang.String key)
key - the number series key. Must not be null.public void setStartValue(java.lang.String key,
java.lang.String startvalue)
resetNumberSeries(String, String, int). Therefore you can use the getStartValue(String) method.key - the series key, must not be nullstartvalue - the series start valuepublic java.lang.String getStartValue(java.lang.String key)
resetNumberSeries(String, String, int) method.key - the series key, must not be nullpublic void removeStartValue(java.lang.String key)
key - the series key, must not be nullpublic boolean isCreatorDisabled()
DataCreator interface. Returns true.truepublic void createEssentialData(java.util.Map params,
JspContext jspc)
@Deprecated public void assureCustomerIDSeriesCreated()
NumberSeriesConstants.Series.CUSTOMER_ID is created. If not existent it
will be created. The series can be used at unique customer id generation.public NumberSeries getOrCreateCustomerIDSeries()
@Deprecated public void assureOrderCodeSeriesCreated()
NumberSeriesConstants.Series.ORDER_CODE is created. If not existent it
will be created. The series can be used at unique customer id generation.public NumberSeries getOrCreateOrderCodeSeries()
public java.lang.Object writeReplace()
throws java.io.ObjectStreamException
writeReplace in class Managerjava.io.ObjectStreamExceptionCopyright © 2018 SAP SE. All Rights Reserved.