public class HMCHelper extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
HMCHelper.AttributePreset |
static class |
HMCHelper.DefaultHMCContext
Default
HMCContext implementation. |
static class |
HMCHelper.XSSFilter
Filtering utility for protecting against XSS (Cross Site Scripting).
|
| Modifier and Type | Field and Description |
|---|---|
static String |
DATE_PATTERN |
static String |
DEFAULT_DATE_PATTERN |
static String |
DEFAULT_TIME_PATTERN |
static String |
HMC_DEVELOPERMODE
Deprecated.
use
ConfigConstants.DEVELOPERMODE directly |
static String |
HMC_NAMESPACE |
static String |
LOG_DIVIDER |
static String |
MONTH_APR |
static String |
MONTH_AUG |
static String |
MONTH_DEC |
static String |
MONTH_FEB |
static String |
MONTH_JAN |
static String |
MONTH_JUL |
static String |
MONTH_JUN |
static String |
MONTH_MAR |
static String |
MONTH_MAY |
static String |
MONTH_NOV |
static String |
MONTH_OCT |
static String |
MONTH_SEP |
static String |
NONE |
static String |
SCHEMA_URL_PROPERTY |
static String |
SESSION_STRUCTURE_TIMESTAMP |
static String |
TIME_PATTERN |
static String |
USE_DB_STRUCTURE
Deprecated.
use
ConfigConstants.STRUCTURE_DB directly |
static String |
WEEKDAY_FR |
static String |
WEEKDAY_MO |
static String |
WEEKDAY_SA |
static String |
WEEKDAY_SU |
static String |
WEEKDAY_TH |
static String |
WEEKDAY_TU |
static String |
WEEKDAY_WE |
| Modifier | Constructor and Description |
|---|---|
protected |
HMCHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
clearThreadLocals() |
static boolean |
collectionsEqual(Collection col1,
Collection col2,
boolean ignoreSequence)
Returns true if the two given collections are equal.
|
static boolean |
containsIgnoreCase(Collection stringColl,
String qualifier) |
static String |
detab(String text,
int spaceCount)
Replace tabs within the given string with equivalent spaces.
|
static boolean |
extractBooleanAttribute(Map<String,String> attributes,
String attributeName,
boolean defaultValue) |
static int |
extractIntegerAttribute(Map<String,String> attributes,
String attributeName,
int defaultValue) |
static String |
extractStringAttribute(Map<String,String> attributes,
String attributeName,
String defaultValue) |
static SavedQuery |
findSavedQuery(ComposedType type,
String code)
Finds and returns a SavedQuery which result type is of the given type (or one of its supertypes) and which code is
equal to the given code.
|
static String |
getAttributeDescriptorName(AttributeDescriptor descriptor) |
static String |
getAttributeDescriptorName(DisplayState displayState,
AttributeDescriptor attributeDescriptor) |
static String |
getClassName(Class theClass) |
static Object |
getClipboard()
Returns the value currently contained in the clipboard.
|
static ComposedType |
getComposedTypeType() |
static ComposedType |
getComposedTypeType(JaloSession jaloSession)
Deprecated.
Use
getComposedTypeType() instead. |
static String |
getCoreExceptionMessage(DisplayState displayState,
Exception exception) |
static ComposedType |
getCountryType() |
static ComposedType |
getCountryType(JaloSession jaloSession)
Deprecated.
Use
getCountryType() instead. |
static ComposedType |
getCurrencyType() |
static ComposedType |
getCurrencyType(JaloSession jaloSession)
Deprecated.
Use
getCurrencyType() instead. |
static ComposedType |
getCustomerType() |
static ComposedType |
getCustomerType(JaloSession jaloSession)
Deprecated.
Use
getCustomerType() instead. |
static DateFormat |
getDateFormat(String pattern)
Gets a DateFormat instance for the given date pattern string.
|
static String |
getDefaultDatePattern()
Returns the default date pattern for the current locale (from the appropriate locales.properties file).
|
static String |
getDefaultTimePattern()
Returns the default time pattern for the current locale (from the appropriate locales.properties file).
|
static Map |
getDefaultValues(ComposedType composedType) |
static ComposedType |
getDeliveryModeType() |
static ComposedType |
getDeliveryModeType(JaloSession jaloSession)
Deprecated.
Use
getDeliveryModeType() instead. |
static ComposedType |
getDiscountType() |
static ComposedType |
getDiscountType(JaloSession jaloSession)
Deprecated.
Use
getDiscountType() instead. |
static ComposedType |
getEmployeeType() |
static ComposedType |
getEmployeeType(JaloSession jaloSession)
Deprecated.
Use
getEmployeeType() instead. |
static ComposedType |
getEnumerationValueType() |
static ComposedType |
getEnumerationValueType(JaloSession jaloSession)
Deprecated.
Use
getEnumerationValueType() instead. |
static HMCContext |
getHMCContextFor(AbstractChip chip) |
static ComposedType |
getItemType() |
static ComposedType |
getLanguageType() |
static ComposedType |
getLanguageType(JaloSession jaloSession)
Deprecated.
Use
getLanguageType() instead. |
static Locale |
getLocale(Language language) |
static String |
getLocalizedMonths()
Returns a javascript string array as a string which contains all twelve months as their localized abbreviations.
|
static String |
getLocalizedString(String strKey)
Returns a localized string for the given key or the key itself if no localized string were found.
|
static String |
getLocalizedWeekdays()
Returns a javascript string array as a string which contains all seven weekdays as their localized abbreviations.
|
static ComposedType |
getMediaType() |
static ComposedType |
getMediaType(JaloSession jaloSession)
Deprecated.
Use
getMediaType() instead. |
static NumberFormat |
getNumberFormat(String numberPattern,
Locale locale)
Returns the NumberFormat for the current locale and the given pattern string.
|
static ComposedType |
getOrderType() |
static ComposedType |
getOrderType(JaloSession jaloSession)
Deprecated.
Use
getOrderType() instead. |
static NumberFormat |
getPriceFormat(JaloSession jaloSession)
method returns a price format according to currently selected language
|
static ComposedType |
getPrincipalType() |
static ComposedType |
getPrincipalType(JaloSession jaloSession)
Deprecated.
Use
getPrincipalType() instead. |
static ComposedType |
getProductType() |
static ComposedType |
getProductType(JaloSession jaloSession)
Deprecated.
Use
getProductType() instead. |
static List<SavedQuery> |
getSavedQueries(ComposedType type)
For the given
ComposedType all available SavedQueries (with this type as return type)
are returned. |
static Item |
getSingleClipboardItem()
Returns an Item contained in the clipboard.
|
static Item |
getSingleClipboardItem(ComposedType type)
Returns an Item contained in the clipboard which is an instance of the specified ComposedType.
|
static ComposedType |
getTaxType() |
static ComposedType |
getTaxType(JaloSession jaloSession)
Deprecated.
Use
getTaxType() instead. |
static ComposedType |
getTitleType() |
static ComposedType |
getTitleType(JaloSession jaloSession)
Deprecated.
Use
getTitleType() instead. |
static ComposedType |
getType(Class jaloClass) |
static ComposedType |
getType(JaloSession jaloSession,
Class jaloClass)
Deprecated.
Use
getType(Class) instead. |
static String |
getTypeName(DisplayState displayState,
Type type)
Deprecated.
please use
getTypeName(Type) instead, the displaystate is not necessary |
static String |
getTypeName(Type type)
This helper functions returns the localized name of the given type.
|
static ComposedType |
getTypeType() |
static ComposedType |
getTypeType(JaloSession jaloSession)
Deprecated.
Use
getTypeType() instead. |
static ComposedType |
getUnitType() |
static ComposedType |
getUnitType(JaloSession jaloSession)
Deprecated.
Use
getUnitType() instead. |
static ComposedType |
getUserGroupType() |
static ComposedType |
getUserGroupType(JaloSession jaloSession)
Deprecated.
Use
getUserGroupType() instead. |
static Map<String,Object> |
getValueMap(GenericItemChip itemChip,
ComposedType type,
Collection<HMCHelper.AttributePreset> presets) |
static Collection |
getVariantAttributeDescriptors(ComposedType type)
For the given ComposedType all VariantAttributeDescriptors (if any) are returned.
|
static HMCHelper.XSSFilter |
getXSSFilter() |
static HMCHelper.XSSFilter |
getXSSFilter(String tag)
Returns an XSSFilter instance for which the submitted tag was removed from the internal the predefined
"alowwed entitties" list Note: In some cases (see PLA-8216) we want to exclude some html tags from the mentioned
list
|
static boolean |
isContainedInMainWindow(AbstractChip chip)
Returns true if the given chip is contained in the main window.
|
static boolean |
isImage(Media media)
Returns true if the given media object contains an url that points to an image file.
|
static boolean |
isInMainWindow(AbstractChip chip) |
static boolean |
isMainChip(Chip theChip) |
static boolean |
isUrlReachable(String urlString)
Returns true if the schema url (configuration property 'hmc.schema.url') is correct, reachable and does not have
an empty content.
|
static void |
LogHeader(Class source,
Priority prio,
String header) |
static void |
LogHeader(Class source,
String header) |
static String |
makeString(Language language) |
static void |
openItemCreator(Collection elementTypes,
Map initialValues,
AttributeChip openingAttributeChip,
GenericItemChip openingItemChip,
AbstractAttributeEditorChip openingEditorChip) |
static void |
openItemCreator(ComposedType itemType,
Map initialValues,
AttributeChip openingAttributeChip,
ItemChip openingItemChip,
AbstractAttributeEditorChip openingEditorChip,
boolean considerSubtypes)
Opens a new window to create a new item.
|
static void |
openItemCreator(ComposedType itemType,
Map initialValues,
AttributeChip openingAttributeChip,
ItemChip openingItemChip,
AbstractAttributeEditorChip openingEditorChip,
boolean considerSubtypes,
boolean isModal)
Opens a new window to create a new item.
|
static void |
openItemCreatorInOrganizer(ComposedType type)
For the given composedtype a creator will be opened within the organizer.
|
static void |
openItemSearch(ComposedType typeToSearch,
ItemAcceptor itemAcceptor,
ReferenceEditorNode referenceEditorNode,
boolean autoPerform,
Map presetValues)
Opens a new window containing an item search.
|
static void |
openItemSearch(ComposedType typeToSearch,
ItemAcceptor itemAcceptor,
ReferenceEditorNode referenceEditorNode,
boolean autoPerform,
Map presetValues,
ComposedType presetSearchType)
Opens a new window containing an item search.
|
static String |
removeSpaces(String value) |
static String |
replace(String str,
String pattern,
String replace)
Replaces a given pattern "pattern" in a String "str" with the pattern "replace".
|
static String |
reTranslate(String value) |
static double |
round(double number,
int digits)
Rounds a given double to the given fraction digits.
|
static float |
round(float number,
int digits)
Rounds a given float to the given fraction digits.
|
static int |
searchItems(String argument,
Collection<Item> results,
ComposedType searchType,
Collection<String> searchAttributes,
Map<String,Object> presetValues,
Operator condition,
int range,
boolean includeSubTypes)
Searches items based on the given search argument.
|
static int |
searchItems(String argument,
Collection<Item> results,
ComposedType searchType,
Collection<String> searchAttributes,
Operator condition,
int range,
boolean includeSubTypes)
Searches items based on the given search argument.
|
static void |
setPresetConditions(GenericSearchChip searchChip,
Map presetValues) |
static void |
swallowException(Exception exception) |
static String |
translate(String key) |
static String |
xssEncodeHTML(String s)
Thin wrapper method around
XSSEncoder#encodeHTML(String) to avoid catching exceptions all over the place! |
static String |
xssEncodeHTMLPreservingIndentation(String str) |
public static final String LOG_DIVIDER
public static final String NONE
@Deprecated public static final String USE_DB_STRUCTURE
ConfigConstants.STRUCTURE_DB directlypublic static final String SESSION_STRUCTURE_TIMESTAMP
@Deprecated public static final String HMC_DEVELOPERMODE
ConfigConstants.DEVELOPERMODE directlypublic static final String HMC_NAMESPACE
public static final String SCHEMA_URL_PROPERTY
public static final String DEFAULT_DATE_PATTERN
public static final String DATE_PATTERN
public static final String DEFAULT_TIME_PATTERN
public static final String TIME_PATTERN
public static final String MONTH_JAN
public static final String MONTH_FEB
public static final String MONTH_MAR
public static final String MONTH_APR
public static final String MONTH_MAY
public static final String MONTH_JUN
public static final String MONTH_JUL
public static final String MONTH_AUG
public static final String MONTH_SEP
public static final String MONTH_OCT
public static final String MONTH_NOV
public static final String MONTH_DEC
public static final String WEEKDAY_MO
public static final String WEEKDAY_TU
public static final String WEEKDAY_WE
public static final String WEEKDAY_TH
public static final String WEEKDAY_FR
public static final String WEEKDAY_SA
public static final String WEEKDAY_SU
public static void clearThreadLocals()
public static HMCContext getHMCContextFor(AbstractChip chip)
public static HMCHelper.XSSFilter getXSSFilter()
public static HMCHelper.XSSFilter getXSSFilter(String tag)
tag - html tag which will be excludedpublic static NumberFormat getPriceFormat(JaloSession jaloSession)
jaloSession - public static ComposedType getType(Class jaloClass)
@Deprecated public static ComposedType getType(JaloSession jaloSession, Class jaloClass)
getType(Class) instead.public static ComposedType getCustomerType()
@Deprecated public static ComposedType getCustomerType(JaloSession jaloSession)
getCustomerType() instead.public static ComposedType getUserGroupType()
@Deprecated public static ComposedType getUserGroupType(JaloSession jaloSession)
getUserGroupType() instead.public static ComposedType getProductType()
@Deprecated public static ComposedType getProductType(JaloSession jaloSession)
getProductType() instead.public static ComposedType getComposedTypeType()
@Deprecated public static ComposedType getComposedTypeType(JaloSession jaloSession)
getComposedTypeType() instead.public static ComposedType getEnumerationValueType()
@Deprecated public static ComposedType getEnumerationValueType(JaloSession jaloSession)
getEnumerationValueType() instead.public static ComposedType getEmployeeType()
@Deprecated public static ComposedType getEmployeeType(JaloSession jaloSession)
getEmployeeType() instead.public static ComposedType getPrincipalType()
@Deprecated public static ComposedType getPrincipalType(JaloSession jaloSession)
getPrincipalType() instead.public static ComposedType getTitleType()
@Deprecated public static ComposedType getTitleType(JaloSession jaloSession)
getTitleType() instead.public static ComposedType getCountryType()
@Deprecated public static ComposedType getCountryType(JaloSession jaloSession)
getCountryType() instead.public static ComposedType getCurrencyType()
@Deprecated public static ComposedType getCurrencyType(JaloSession jaloSession)
getCurrencyType() instead.public static ComposedType getLanguageType()
@Deprecated public static ComposedType getLanguageType(JaloSession jaloSession)
getLanguageType() instead.public static ComposedType getMediaType()
@Deprecated public static ComposedType getMediaType(JaloSession jaloSession)
getMediaType() instead.public static ComposedType getUnitType()
@Deprecated public static ComposedType getUnitType(JaloSession jaloSession)
getUnitType() instead.public static ComposedType getTaxType()
@Deprecated public static ComposedType getTaxType(JaloSession jaloSession)
getTaxType() instead.public static ComposedType getDiscountType()
@Deprecated public static ComposedType getDiscountType(JaloSession jaloSession)
getDiscountType() instead.public static ComposedType getDeliveryModeType()
@Deprecated public static ComposedType getDeliveryModeType(JaloSession jaloSession)
getDeliveryModeType() instead.public static ComposedType getOrderType()
@Deprecated public static ComposedType getOrderType(JaloSession jaloSession)
getOrderType() instead.public static ComposedType getTypeType()
@Deprecated public static ComposedType getTypeType(JaloSession jaloSession)
getTypeType() instead.public static ComposedType getItemType()
@Deprecated public static String getTypeName(DisplayState displayState, Type type)
getTypeName(Type) instead, the displaystate is not necessarydisplayState - the displaystatetype - the typepublic static String getTypeName(Type type)
type - the typepublic static String getAttributeDescriptorName(DisplayState displayState, AttributeDescriptor attributeDescriptor)
public static String getAttributeDescriptorName(AttributeDescriptor descriptor)
descriptor - the attribute descriptorpublic static void swallowException(Exception exception)
public static boolean isMainChip(Chip theChip)
public static String replace(String str, String pattern, String replace)
public static String getCoreExceptionMessage(DisplayState displayState, Exception exception)
public static boolean isUrlReachable(String urlString)
public static String detab(String text, int spaceCount)
text - the string which is to be detabbedspaceCount - the number of spaces which will replace tabspublic static String getLocalizedString(String strKey)
strKey - the key to get a localized representation for.public static boolean containsIgnoreCase(Collection stringColl, String qualifier)
public static String getClassName(Class theClass)
theClass - public static double round(double number,
int digits)
public static float round(float number,
int digits)
public static final boolean isImage(Media media)
media - the media object in questionpublic static boolean collectionsEqual(Collection col1, Collection col2, boolean ignoreSequence)
ignoreSequence
parameter).col1 - first collection, may be nullcol2 - second collection, may be nullignoreSequence - if true, the order in which the elements appear within the two collections will be ignoredpublic static final DateFormat getDateFormat(String pattern)
pattern - a date pattern, e.g. 'dd.MM.yyyy'public static final String getDefaultDatePattern()
public static final String getDefaultTimePattern()
public static final String getLocalizedMonths()
public static final String getLocalizedWeekdays()
public static final NumberFormat getNumberFormat(String numberPattern, Locale locale)
public static void openItemCreator(ComposedType itemType, Map initialValues, AttributeChip openingAttributeChip, ItemChip openingItemChip, AbstractAttributeEditorChip openingEditorChip, boolean considerSubtypes)
itemType - the ComposedType of the new iteminitialValues - a map containing initial values (may be empty) where attribute qualifiers must be mapped to valuesopeningAttributeChip - the AttributeChip from which the create window was opened (may be null), is used to update the opening
chipopeningItemChip - the ItemChip from which the create window was opened (may be null), is used to update the opening chipopeningEditorChip - the AbstractAttributeEditorChip from which the create window was opened (may be null), , is used to
update the opening chipconsiderSubtypes - if true a dialog to select a concrete subtype (if any) will appear before the actual create windowpublic static void openItemCreator(Collection elementTypes, Map initialValues, AttributeChip openingAttributeChip, GenericItemChip openingItemChip, AbstractAttributeEditorChip openingEditorChip)
elementTypes - initialValues - openingAttributeChip - openingItemChip - openingEditorChip - public static void openItemCreator(ComposedType itemType, Map initialValues, AttributeChip openingAttributeChip, ItemChip openingItemChip, AbstractAttributeEditorChip openingEditorChip, boolean considerSubtypes, boolean isModal)
itemType - the ComposedType of the new iteminitialValues - a map containing initial values (may be empty) where attribute qualifiers must be mapped to valuesopeningAttributeChip - the AttributeChip from which the create window was opened (may be null), is used to update the opening
chipopeningItemChip - the ItemChip from which the create window was opened (may be null), is used to update the opening chipopeningEditorChip - the AbstractAttributeEditorChip from which the create window was opened (may be null), , is used to
update the opening chipconsiderSubtypes - if true a dialog to select a concrete subtype (if any) will appear before the actual create windowisModal - if true the new window will be in modal modepublic static boolean isInMainWindow(AbstractChip chip)
public static void openItemCreatorInOrganizer(ComposedType type)
public static Map getDefaultValues(ComposedType composedType)
composedType - public static void openItemSearch(ComposedType typeToSearch, ItemAcceptor itemAcceptor, ReferenceEditorNode referenceEditorNode, boolean autoPerform, Map presetValues)
typeToSearch - the ComposedType for which to search (including subtypes)itemAcceptor - the Chip which implements ItemAcceptor to receive the item(s) of this search via
ItemAcceptor.setSelectedItems(List) (usually this is the chip that calls this method)referenceEditorNode - a ReferenceEditorNode which may modify the search conditions (may be null)autoPerform - if true the search will automatically startedpresetValues - a map containing preset values for the search. attribute qualifiers must be mapped to values and the
appropriate condition chips will be added and filledpublic static void openItemSearch(ComposedType typeToSearch, ItemAcceptor itemAcceptor, ReferenceEditorNode referenceEditorNode, boolean autoPerform, Map presetValues, ComposedType presetSearchType)
typeToSearch - the ComposedType for which to search (including subtypes)itemAcceptor - the Chip which implements ItemAcceptor to receive the item(s) of this search via
ItemAcceptor.setSelectedItems(List) (usually this is the chip that calls this method)referenceEditorNode - a ReferenceEditorNode which may modify the search conditions (may be null)autoPerform - if true the search will automatically startedpresetValues - a map containing preset values for the search. attribute qualifiers must be mapped to values and the
appropriate condition chips will be added and filledpresetSearchType - if you want to preset another composedtype than the actual 'type to search' you can do so by setting the
presetSearchTypepublic static void setPresetConditions(GenericSearchChip searchChip, Map presetValues)
public static boolean isContainedInMainWindow(AbstractChip chip)
public static Object getClipboard()
DisplayState.getClipboard() this method also checks for validity of contained Item objects (to prevent
'object no longer valid' errors, for example).public static Item getSingleClipboardItem()
public static Item getSingleClipboardItem(ComposedType type)
public static Map<String,Object> getValueMap(GenericItemChip itemChip, ComposedType type, Collection<HMCHelper.AttributePreset> presets)
itemChip - type - presets - public static Collection getVariantAttributeDescriptors(ComposedType type)
public static boolean extractBooleanAttribute(Map<String,String> attributes, String attributeName, boolean defaultValue)
public static int extractIntegerAttribute(Map<String,String> attributes, String attributeName, int defaultValue)
public static String extractStringAttribute(Map<String,String> attributes, String attributeName, String defaultValue)
public static SavedQuery findSavedQuery(ComposedType type, String code)
type - the result type for which to search a saved querycode - the code for which to searchpublic static List<SavedQuery> getSavedQueries(ComposedType type)
ComposedType all available SavedQueries (with this type as return type)
are returned.type - the ComposedType for which to search all savedqueriespublic static int searchItems(String argument, Collection<Item> results, ComposedType searchType, Collection<String> searchAttributes, Operator condition, int range, boolean includeSubTypes)
argument - the search string which will be used for a 'contains' conditionresults - a collection which will be filled with the resulting itemssearchType - the (super-)type of the items which should be foundsearchAttributes - a list of attribute qualifiers for which the search string (the 'argument') should be appliedcondition - a search Operator like Operator.OR (when using more than one search attribute this
operator is used to combine these)range - the maximum search countincludeSubTypes - if true all subtypes are included in the search, if false only items of the exact given searchType are
searchedpublic static int searchItems(String argument, Collection<Item> results, ComposedType searchType, Collection<String> searchAttributes, Map<String,Object> presetValues, Operator condition, int range, boolean includeSubTypes)
argument - the search string which will be used for a 'contains' conditionresults - a collection which will be filled with the resulting itemssearchType - the (super-)type of the items which should be foundsearchAttributes - a list of attribute qualifiers for which the search string (the 'argument') should be appliedpresetValues - map of attribute qualifiers to preset values for these attributes (for given searchType).
The search will be restricted to results where the attribute values equal their presets.condition - a search Operator like Operator.OR (when using more than one search attribute this
operator is used to combine these)range - the maximum search countincludeSubTypes - if true all subtypes are included in the search, if false only items of the exact given searchType are
searchedpublic static String xssEncodeHTML(String s)
XSSEncoder#encodeHTML(String) to avoid catching exceptions all over the place!Copyright © 2017 SAP SE. All Rights Reserved.