Package org.cyclos.impl.system
Interface CustomFieldValueHandler
-
- All Known Implementing Classes:
CustomFieldValueHandlerImpl
public interface CustomFieldValueHandlerHandler for custom field values, containing shared methods for validations, search filters and so on
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_FIELDScript attribute: the custom field being validatedstatic StringATTR_OBJECTScript attribute: the object being validatedstatic StringATTR_VALUEScript attribute: the current value being validatedstatic List<Property<?,?>>SEARCH_PROPERTIESThe possible properties that hold actual values onCustomFieldValueForSearchDTOstatic List<Property<?,?>>VALUE_PROPERTIESThe possible properties that hold actual values onCustomFieldValueDTO
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description <CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
voidaddDefaultValues(O entity, Collection<CF> fields, Collection<V> customValues)Adds a custom field value setting its default if it is not present in the given collection according to the fields list.voidaddLengthValidation(Property property, IntegerRange length)Adds a length range validation on the givenPropertyfor the givenIntegerRange.voidaddPatternValidation(Property property, String pattern)Adds an input with pattern validation on the givenPropertyfor the given pattern.voidaddValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings)Adds a validation on the givenValidatorfor the givenCustomFieldvoidaddValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings, String valuesProperty)Adds a validation on the givenValidatorfor the givenCustomField, using a custom values collectionvoidaddValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings, LoadValuesScriptFunction dynamicValueValidationFunction, String valuesProperty)Adds a validation on the givenValidatorfor the givenCustomField, using a custom values collectionvoidaddValueValidationIgnoringRequired(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings)Adds a validation on the givenValidatorfor the givenCustomField, ignoring required validationsvoidaddWordSizeValidation(Property property, CustomField<?,?,?> field)Adds a word size validation on the givenProperty.
A larger default size will be applied for TEXT and URL.<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
VbuildFieldValue(CF field, Class<V> valueType, QCustomFieldValue fv, com.querydsl.core.Tuple tuple)Builds a field value from a projected custom field.<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
List<V>cloneCustomValuesData(E owner, Collection<V> values)Clones a collection ofCustomFieldValuemanaging the special cases:CustomFieldType.FILEandCustomFieldType.IMAGE, i.e cloning the associatedCustomFieldValueFileandCustomFieldValueImageentities too.
This method offers the same support ascloneCustomValuesData(ModelWithCustomValues, Collection)but for entities.<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
voidcloneCustomValuesData(ModelWithCustomValues<CustomFieldValueDTO> model, Collection<V> values)Converts a collection ofCustomFieldValueto a collection ifCustomFieldValueDTOs and set it in the given model container but cloning the related custom field value's data.voidfillValuesFromScript(Class<? extends CustomField<?,?,?>> fieldType, LoadValuesScriptFunction function, Map<String,?> variables, Collection<? extends CustomFieldDetailedVO> vos)Fills in the givenCustomFieldDetailedVOs using values generated from script.voidfillValuesFromScript(Class<? extends CustomField<?,?,?>> fieldType, LoadValuesScriptFunction function, Map<String,?> variables, Collection<? extends CustomFieldDetailedVO> vos, boolean forBulkAction)Fills in the givenCustomFieldDetailedVOs using values generated from script.Stringformat(FormatterImpl formatter, CustomField<?,?,?> field, Object value)Formats the given value according to the custom field definitions, returning an empty string for null valueCustomField<?,?,?>getCustomField(CustomFieldVO vo)Converts the givenCustomFieldVOto the correspondingCustomFieldTheCustomFieldVOparameter must have set the corresponding field's nature.static Class<? extends CustomField<?,?,?>>getCustomFieldClass(CustomFieldNature nature)Returns theCustomField'class for the given nature.static CustomFieldNaturegetCustomFieldNature(Class<? extends CustomField<?,?,?>> clazz)Returns theCustomFieldNaturefor the given class.ObjectgetDefaultValue(CustomField<?,?,?> field)Returns the actual default value for this field.Set<com.querydsl.core.types.Path<?>>getProjectionPaths(CustomField<?,?,?> field, QCustomFieldValue fv)Returns the paths that should be projected for the given custom fieldObjectgetValue(CustomField<?,?,?> field, Object value, boolean sanitize)CallsgetValue(CustomField, Object, boolean, FormatterImpl)with no formatter, meaning dates / numbers as string will use the standard format, not a user-defined formatObjectgetValue(CustomField<?,?,?> field, Object value, boolean sanitize, FormatterImpl formatter)Returns the value (as entities when possible) for the given custom field value.ObjectgetValueForSearch(CustomField<?,?,?> field, Object value, boolean nativeValue)Returns the value used to filter when the given custom field is used as a search filter.
If the parameternativeValueis true then the result will be as close to the database as possible, depending on the custom field type.Class<?>getValueType(CustomField<?,?,?> field)Returns the type of actual values this field has, according to the field type:CustomFieldType.STRING,CustomFieldType.TEXT,CustomFieldType.RICH_TEXTorCustomFieldType.URL:String;CustomFieldType.BOOLEAN:Boolean;CustomFieldType.INTEGER:Integer;CustomFieldType.DECIMAL:BigDecimal;CustomFieldType.DATE:Date;CustomFieldType.SINGLE_SELECTION: the proper subclass ofCustomFieldPossibleValue;CustomFieldType.MULTI_SELECTION:Setof the proper subclass ofCustomFieldPossibleValue;;CustomFieldType.DYNAMIC_SELECTION:DynamicFieldValueVO;CustomFieldType.FILE:RawFile;CustomFieldType.IMAGE:Image;CustomFieldType.LINKED_ENTITY: Depends on the linked entity type:LinkedEntityType.USER:User;LinkedEntityType.RECORD:Record;LinkedEntityType.ADVERTISEMENT:BasicAd;LinkedEntityType.TRANSACTION:Transaction;LinkedEntityType.TRANSFER:Transfer;voidprocessAfterSave(EntityWithCustomValues<?,?,?,?> entity)Process actions over custom fields that require the entity to be saved first.com.querydsl.core.types.PredicatequeryFilter(com.querydsl.core.types.EntityPath<? extends CustomFieldValue<?,?,?,?>> valuePath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch)Returns a predicate which represents the condition for the given custom field and value path for the given custom field search value, or null if no query criteria specifiedvoidremove(CustomFieldValue<?,?,?,?> fieldValue)Removes the given field value, properly removing any stored files for binary fieldsvoidremoveAll(EntityWithCustomValues<?,?,?,?> owner)Removes all custom fields of the given owner, taking care to properly remove any stored files for binary fields.List<CustomFieldValueDTO>resolveValues(Class<? extends CustomField<?,?,?>> customFieldType, Collection<CustomFieldValueDTO> valueDTOs)Makes sure all values set in the given DTOs collection are correctly filled-in, so it can be sent back to clients with complete data.<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
voidsetCustomValues(E entity, Collection<CF> enabledFields, Collection<CF> editable, Collection<CustomFieldValueDTO> fieldValueDTOs)Saves the custom values from DTOs to the given entityvoidsetCustomValues(BasicUser user, Collection<UserCustomField> enabledFields, Collection<UserCustomField> editable, Collection<UserCustomField> managePrivacy, Collection<UserCustomFieldValueDTO> fieldValueDTOs)Saves the custom values from DTOs to the given uservoidsetDefaultValue(CustomFieldDetailedVO vo, Object defaultValue)Sets the default field value to the given value<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>>
voidsetDefaultValues(O entity, Collection<CF> fields)Adds a custom field value setting its default if it is not present in the given entity according to the fields list.voidsetModelValue(CustomField<?,?,?> customField, Object value, ICustomFieldValue<?,?> fieldValue)Sets the given value on the givenICustomFieldValue, according to the correct type, converting the value to the model-specific type.voidsortAndRemoveMissing(List<? extends CustomFieldValueDTO> customValues, List<? extends IEntity> allowedFields)Sorts the given list ofCustomFieldValueDTOand remove a value if it's for a field not present in the given list of allowed fields (i.e.voidsortAndRemoveMissingFromVO(List<? extends CustomFieldValueVO> customValues, List<? extends IEntity> allowedFields)Same assortAndRemoveMissing(List, List)but for a list of VOsList<? extends CustomFieldPossibleValue<?,?,?>>toCustomFieldPossibleValues(CustomField<?,?,?> customField, Collection<?> values)Converts each of the given input value to a custom field possible value of the given fieldList<SimpleEntity>toLinkedEntityValues(CustomField<?,?,?> customField, Collection<?> values)Convert each of the given input value to a linked entity suited for the given custom fieldStringtoReference(CustomField<?,?,?> field, Object value)Converts the given field value to a valid reference value<CF extends CustomField<CF,?,?>>
SortedMap<CF,Object>toSearchFiltersMap(Collection<CF> customFields, Collection<? extends CustomFieldValueForSearchDTO> fieldValues, boolean sanitize)Returns a map keyed by custom fields, whose values are the values for search of each field<CF extends CustomField<CF,?,?>>
SortedMap<CF,Object>toValuesMap(Collection<CF> customFields, Collection<? extends ICustomFieldValue<?,?>> fieldValues, boolean sanitize)Returns a map keyed by custom fields, whose values are the values of each field
-
-
-
Field Detail
-
ATTR_OBJECT
static final String ATTR_OBJECT
Script attribute: the object being validated- See Also:
- Constant Field Values
-
ATTR_FIELD
static final String ATTR_FIELD
Script attribute: the custom field being validated- See Also:
- Constant Field Values
-
ATTR_VALUE
static final String ATTR_VALUE
Script attribute: the current value being validated- See Also:
- Constant Field Values
-
VALUE_PROPERTIES
static final List<Property<?,?>> VALUE_PROPERTIES
The possible properties that hold actual values onCustomFieldValueDTO
-
SEARCH_PROPERTIES
static final List<Property<?,?>> SEARCH_PROPERTIES
The possible properties that hold actual values onCustomFieldValueForSearchDTO
-
-
Method Detail
-
getCustomFieldClass
static Class<? extends CustomField<?,?,?>> getCustomFieldClass(CustomFieldNature nature)
Returns theCustomField'class for the given nature.- Throws:
IllegalArgumentException- for unknown natures
-
getCustomFieldNature
static CustomFieldNature getCustomFieldNature(Class<? extends CustomField<?,?,?>> clazz)
Returns theCustomFieldNaturefor the given class.- Throws:
IllegalArgumentException- for unknown class
-
addDefaultValues
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> void addDefaultValues(O entity, Collection<CF> fields, Collection<V> customValues)
Adds a custom field value setting its default if it is not present in the given collection according to the fields list.
-
addLengthValidation
void addLengthValidation(Property property, IntegerRange length)
Adds a length range validation on the givenPropertyfor the givenIntegerRange. If the length parameter is null then it returns without changes.
-
addPatternValidation
void addPatternValidation(Property property, String pattern)
Adds an input with pattern validation on the givenPropertyfor the given pattern. If the pattern parameter is empty (or null) then it returns without changes.
-
addValueValidation
void addValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings)
Adds a validation on the givenValidatorfor the givenCustomField
-
addValueValidation
void addValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings, LoadValuesScriptFunction dynamicValueValidationFunction, String valuesProperty)
Adds a validation on the givenValidatorfor the givenCustomField, using a custom values collection
-
addValueValidation
void addValueValidation(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings, String valuesProperty)
Adds a validation on the givenValidatorfor the givenCustomField, using a custom values collection
-
addValueValidationIgnoringRequired
void addValueValidationIgnoringRequired(Validator validator, CustomField<?,?,?> field, com.querydsl.core.types.dsl.EntityPathBase<? extends CustomFieldValue<?,?,?,?>> fv, Map<String,?> dynamicValueBindings)
Adds a validation on the givenValidatorfor the givenCustomField, ignoring required validations
-
addWordSizeValidation
void addWordSizeValidation(Property property, CustomField<?,?,?> field)
Adds a word size validation on the givenProperty.
A larger default size will be applied for TEXT and URL. and a smaller for STRING types
-
buildFieldValue
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> V buildFieldValue(CF field, Class<V> valueType, QCustomFieldValue fv, com.querydsl.core.Tuple tuple)
Builds a field value from a projected custom field. Important: The returned value may be incomplete, and is only meant to be displayed. For example, the owner reference is not filled-in.
-
cloneCustomValuesData
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> List<V> cloneCustomValuesData(E owner, Collection<V> values)
Clones a collection ofCustomFieldValuemanaging the special cases:CustomFieldType.FILEandCustomFieldType.IMAGE, i.e cloning the associatedCustomFieldValueFileandCustomFieldValueImageentities too.
This method offers the same support ascloneCustomValuesData(ModelWithCustomValues, Collection)but for entities.- Returns:
- A list with the clones.
NOTE: This method can potentially create new entities that will be persisted then it must be used in aTransactionLevel.READ_WRITEtransaction.
-
cloneCustomValuesData
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> void cloneCustomValuesData(ModelWithCustomValues<CustomFieldValueDTO> model, Collection<V> values)
Converts a collection ofCustomFieldValueto a collection ifCustomFieldValueDTOs and set it in the given model container but cloning the related custom field value's data. More specifically it clones theCustomFieldValueFileandCustomFieldValueImage, if any, for the corresponding custom field of typeCustomFieldType.FILEorCustomFieldType.IMAGE.
NOTE: This method can potentially create new DTOs that will be persisted then it must be used in aTransactionLevel.READ_WRITEtransaction.
-
fillValuesFromScript
void fillValuesFromScript(Class<? extends CustomField<?,?,?>> fieldType, LoadValuesScriptFunction function, Map<String,?> variables, Collection<? extends CustomFieldDetailedVO> vos)
Fills in the givenCustomFieldDetailedVOs using values generated from script. For supported custom field types, call the script of typeScriptType.LOAD_CUSTOM_FIELD_VALUES. For other custom field types, do nothing.- Parameters:
fieldType- The actual custom field class, required to load the proper entitiesfunction- The function to call. May be called in the context of an entity or a searchvos- The list ofCustomFieldDetailedVOwhich will be processedvariables- Variables to be bound to the script context
-
fillValuesFromScript
void fillValuesFromScript(Class<? extends CustomField<?,?,?>> fieldType, LoadValuesScriptFunction function, Map<String,?> variables, Collection<? extends CustomFieldDetailedVO> vos, boolean forBulkAction)
Fills in the givenCustomFieldDetailedVOs using values generated from script. For supported custom field types, call the script of typeScriptType.LOAD_CUSTOM_FIELD_VALUES. For other custom field types, do nothing.- Parameters:
fieldType- The actual custom field class, required to load the proper entitiesfunction- The function to call. May be called in the context of an entity or a searchvos- The list ofCustomFieldDetailedVOwhich will be processedvariables- Variables to be bound to the script contextforBulkAction- True if the values are filled for a bulk action
-
format
String format(FormatterImpl formatter, CustomField<?,?,?> field, Object value)
Formats the given value according to the custom field definitions, returning an empty string for null value
-
getCustomField
CustomField<?,?,?> getCustomField(CustomFieldVO vo)
Converts the givenCustomFieldVOto the correspondingCustomFieldTheCustomFieldVOparameter must have set the corresponding field's nature.
-
getDefaultValue
Object getDefaultValue(CustomField<?,?,?> field)
Returns the actual default value for this field. The type of the resulting object will be the same asgetValueType(CustomField).
-
getProjectionPaths
Set<com.querydsl.core.types.Path<?>> getProjectionPaths(CustomField<?,?,?> field, QCustomFieldValue fv)
Returns the paths that should be projected for the given custom field
-
getValue
Object getValue(CustomField<?,?,?> field, Object value, boolean sanitize)
CallsgetValue(CustomField, Object, boolean, FormatterImpl)with no formatter, meaning dates / numbers as string will use the standard format, not a user-defined format
-
getValue
Object getValue(CustomField<?,?,?> field, Object value, boolean sanitize, FormatterImpl formatter)
Returns the value (as entities when possible) for the given custom field value. The type of the resulting object will be the same asgetValueType(CustomField). If the value is a string and a formatter is given, will use the formatter to parse the string, instead of assuming the standard formats- Parameters:
field- The custom fieldvalue- The value to resolve from. Can either be aICustomFieldValueor a scalar value, which will be converted to the corresponding typesanitize- Indicates if text should be sanitized. Should be set to true when reading text from clients, and false when reading data from the database.formatter- If null, dates / numbers parsed from string will be assumed in the standard format. If not null, is used to parse.
-
getValueForSearch
Object getValueForSearch(CustomField<?,?,?> field, Object value, boolean nativeValue)
Returns the value used to filter when the given custom field is used as a search filter.
If the parameternativeValueis true then the result will be as close to the database as possible, depending on the custom field type. No empty collections are returned. So, it is safe to assume that if the result is not null, it will be used on the query.
The possible returned types are:-
CustomFieldType.STRING,CustomFieldType.TEXT,CustomFieldType.RICH_TEXTorCustomFieldType.URL:String. IfnativeValueis true and the field uses a pattern (mask) then it is removed from the input value. Otherwise return the input value; CustomFieldType.BOOLEAN:Boolean;CustomFieldType.INTEGER:IntegerRange;CustomFieldType.DECIMAL:DecimalRange;CustomFieldType.DATE:DateRange;CustomFieldType.SINGLE_SELECTIONorCustomFieldType.MULTI_SELECTION: IfnativeValueis true thenSetofLongs (ids). OtherwiseSetofCustomFieldPossibleValues;CustomFieldType.DYNAMIC_SELECTION: IfnativeValueis true then either aStringwhen applying a fulltext search with the dynamic value's label or aSetofStrings when need to do exact matching against the internal value. Otherwise either the input value when applying a fulltext or aSetofStrings with the label of the values when need to do exact matching;CustomFieldType.LINKED_ENTITY: IfnativeValueis true thenSetofLongs (ids). OtherwiseSetofSimpleEntitys;CustomFieldType.FILEorCustomFieldType.IMAGE: null (those are not supported for filter);
- Parameters:
field- The custom fieldvalue- The value to resolve from. Can either be aBaseValueForSearchDTOor a scalar valuenativeValue- true when the result will be used as filter in the query send to the database.- Returns:
- The value for search converted to the specific type
-
-
getValueType
Class<?> getValueType(CustomField<?,?,?> field)
Returns the type of actual values this field has, according to the field type:-
CustomFieldType.STRING,CustomFieldType.TEXT,CustomFieldType.RICH_TEXTorCustomFieldType.URL:String; CustomFieldType.BOOLEAN:Boolean;CustomFieldType.INTEGER:Integer;CustomFieldType.DECIMAL:BigDecimal;CustomFieldType.DATE:Date;CustomFieldType.SINGLE_SELECTION: the proper subclass ofCustomFieldPossibleValue;CustomFieldType.MULTI_SELECTION:Setof the proper subclass ofCustomFieldPossibleValue; ;
CustomFieldType.DYNAMIC_SELECTION:DynamicFieldValueVO;CustomFieldType.FILE:RawFile;CustomFieldType.IMAGE:Image;CustomFieldType.LINKED_ENTITY: Depends on the linked entity type:
-
-
processAfterSave
void processAfterSave(EntityWithCustomValues<?,?,?,?> entity)
Process actions over custom fields that require the entity to be saved first. For example, temporary files / images are moved to the the final fileValues / imageValues fields.
-
queryFilter
com.querydsl.core.types.Predicate queryFilter(com.querydsl.core.types.EntityPath<? extends CustomFieldValue<?,?,?,?>> valuePath, CustomField<?,?,?> customField, CustomFieldValueForSearchDTO valueForSearch)
Returns a predicate which represents the condition for the given custom field and value path for the given custom field search value, or null if no query criteria specified
-
remove
void remove(CustomFieldValue<?,?,?,?> fieldValue)
Removes the given field value, properly removing any stored files for binary fields
-
removeAll
void removeAll(EntityWithCustomValues<?,?,?,?> owner)
Removes all custom fields of the given owner, taking care to properly remove any stored files for binary fields.
-
resolveValues
List<CustomFieldValueDTO> resolveValues(Class<? extends CustomField<?,?,?>> customFieldType, Collection<CustomFieldValueDTO> valueDTOs)
Makes sure all values set in the given DTOs collection are correctly filled-in, so it can be sent back to clients with complete data. For example, if a value has the id or reference to a linked entity, it will have the correctLinkedEntityVOset with display. The same applies to enumerated values or dynamic values. Important: The use case for this method is the case where a DTO with custom values is sent from client to server,then those values are sent back to the clients. Hence, no sanitization is performed on strings, because these strings will be sent back from the client to server later, and that would make the string be sanitized twice, which can make them invalid.- Returns:
- a new ordered list of custom values according to the fields order.
-
setCustomValues
void setCustomValues(BasicUser user, Collection<UserCustomField> enabledFields, Collection<UserCustomField> editable, Collection<UserCustomField> managePrivacy, Collection<UserCustomFieldValueDTO> fieldValueDTOs)
Saves the custom values from DTOs to the given user
-
setCustomValues
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,E>,E extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> void setCustomValues(E entity, Collection<CF> enabledFields, Collection<CF> editable, Collection<CustomFieldValueDTO> fieldValueDTOs)
Saves the custom values from DTOs to the given entity
-
setDefaultValue
void setDefaultValue(CustomFieldDetailedVO vo, Object defaultValue)
Sets the default field value to the given value
-
setDefaultValues
<CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>,V extends CustomFieldValue<CF,C,PV,O>,O extends SimpleEntity & EntityWithCustomValues<CF,C,PV,V>> void setDefaultValues(O entity, Collection<CF> fields)
Adds a custom field value setting its default if it is not present in the given entity according to the fields list. This method is a shortcut foraddDefaultValues(SimpleEntity, Collection, Collection)passing entity.getCustomValues() as the collection of custom values.
-
setModelValue
void setModelValue(CustomField<?,?,?> customField, Object value, ICustomFieldValue<?,?> fieldValue)
Sets the given value on the givenICustomFieldValue, according to the correct type, converting the value to the model-specific type. For example, enumerated values asCustomFieldPossibleValueVO, dates asDateTime, etc.
-
sortAndRemoveMissing
void sortAndRemoveMissing(List<? extends CustomFieldValueDTO> customValues, List<? extends IEntity> allowedFields)
Sorts the given list ofCustomFieldValueDTOand remove a value if it's for a field not present in the given list of allowed fields (i.e. the catalog).- Parameters:
customValues- the list of values to sort.allowedFields- the ordered list of allowed fields.
-
sortAndRemoveMissingFromVO
void sortAndRemoveMissingFromVO(List<? extends CustomFieldValueVO> customValues, List<? extends IEntity> allowedFields)
Same assortAndRemoveMissing(List, List)but for a list of VOs- See Also:
sortAndRemoveMissing(List, List)
-
toCustomFieldPossibleValues
List<? extends CustomFieldPossibleValue<?,?,?>> toCustomFieldPossibleValues(CustomField<?,?,?> customField, Collection<?> values)
Converts each of the given input value to a custom field possible value of the given field
-
toLinkedEntityValues
List<SimpleEntity> toLinkedEntityValues(CustomField<?,?,?> customField, Collection<?> values)
Convert each of the given input value to a linked entity suited for the given custom field
-
toReference
String toReference(CustomField<?,?,?> field, Object value)
Converts the given field value to a valid reference value
-
toSearchFiltersMap
<CF extends CustomField<CF,?,?>> SortedMap<CF,Object> toSearchFiltersMap(Collection<CF> customFields, Collection<? extends CustomFieldValueForSearchDTO> fieldValues, boolean sanitize)
Returns a map keyed by custom fields, whose values are the values for search of each field
-
toValuesMap
<CF extends CustomField<CF,?,?>> SortedMap<CF,Object> toValuesMap(Collection<CF> customFields, Collection<? extends ICustomFieldValue<?,?>> fieldValues, boolean sanitize)
Returns a map keyed by custom fields, whose values are the values of each field
-
-