Class DataHolderHelper
java.lang.Object
org.ametys.plugins.repository.data.holder.impl.DataHolderHelper
- All Implemented Interfaces:
Disposable,Component,Serviceable
Helper for implementations of data holder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordStores informations needed to choose status of createdSynchronizableValue -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic DataContextaddObjectInfoToContext(ModelAwareDataHolder dataHolder, DataContext context) Enriches the givenDataContextwith object-level information from the root data holder (e.g.static <T> TaggregateMultipleValues(List<? extends ModelAwareDataHolder> dataHolders, String dataPath, Class managedClass) Aggregates multiple values of the data holders at the given pathstatic ObjectappendValuesInArray(Object originalValues, Object valuesToAppend, ElementType elementType) Append some values to the given original onesstatic ObjectconvertValue(ElementDefinition definition, Object value) Converts the given value according to the given definition If the value is multiple, an array is retrieved with each value converted to the right typestatic ObjectconvertValueIgnoringIncompatibleOnes(ElementDefinition definition, Object value) Converts the given value according to the given definition If the value is multiple, an array is retrieved with each value converted to the right type If the value is not compatible whit the data type, no exception is thrown and the value is converted to anUntouchedValuein order to be ignoredconvertValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values) Converts the given values according to the definitions in the givenViewItemAccessorconvertValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values, BiFunction<ElementDefinition, Object, Object> convertValueFunction) Converts the given values according to the definitions in the givenViewItemAccessorconvertValuesWithSynchronizableValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values, BiFunction<ElementDefinition, Object, Object> convertValueFunction, Optional<DataHolderHelper.SynchronizableValuesStatusInfos> synchronizableValuesStatusInfos) Converts the given values according to the definitions in the givenViewItemAccessorstatic voidcopyTo(DataHolder source, ModifiableDataHolder destination, String name, DataContext context) Copy the data name of the sourceDataHolderto the givenModifiableDataHolderdestination.static voidcopyTo(DataHolder source, ModifiableDataHolder destination, DataContext context) Copies the sourceDataHolderto the givenModifiableDataHolderdestination.static ValueContextcreateValueContextFromSynchronizationContext(ModelAwareDataHolder dataHolder, String dataPath, SynchronizationContext synchronizationContext) Creates a value context from the givenSynchronizationContextstatic ViewItemAccessorcreateViewItemAccessorFromValues(Collection<? extends ModelItemAccessor> modelItemAccessors, Map<String, Object> values) Create aViewItemAccessorfor the items corresponding to the given valuesstatic ObjectdataToJSON(DataHolder dataHolder, String relativeDataPath, DataContext context) Convert the data at the given relative path into a JSON objectdataToJSON(DataHolder dataHolder, DataContext context) Convert the data contained in the givenDataHolderdataToJSON(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Convert the data in the given view of the givenDataHolderdataToMap(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context) Returns all data of the given DataHolder as a typed-values Map.static voiddataToSAX(DataHolder dataHolder, ContentHandler contentHandler, String relativeDataPath, DataContext context) Generates SAX events for data at the given relative path in thisDataHolderstatic voiddataToSAX(DataHolder dataHolder, ContentHandler contentHandler, DataContext context) Generates SAX events for data contained in thisDataHolderstatic voiddataToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) Generates SAX events for the data in the given view in the givenDataHoldervoiddispose()static voidexternalDisableConditionsToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext dataContext) Generates SAX events for external disable conditions of the items in the given viewfindEditableItemsByType(ModelAwareDataHolder dataHolder, String type) Find all modifiable data of the given type on aModelAwareDataHolder, including in composite or repeater entries.findItemsByType(ModelAwareDataHolder dataHolder, String type) Find all data of the given type on aModelAwareDataHolder, including in composite or repeater entries.findItemsByType(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, String type) Find all data of the given type on aModelAwareDataHolder, including in composite or repeater entries.static ObjectgetArrayValuesFromSynchronizableValue(SynchronizableValue synchronizableValue, ValueContext valueContext) Retrieves an array of values from the givenSynchronizableValue.static I18nizableTextgetDataFullLabel(String dataPath, Collection<? extends ModelItemAccessor> itemAccessors) Get the label for the path in the item accessors.getExternalDisableConditionsValues(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext dataContext) Retrieves the values of the disable conditions of the items in the given view for the given data holderRetrieve theExternalizableDataProviderExtensionPointstatic RepeaterEntrygetRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) Retrieves the repeater entry at the given positiongetRepeaterNameAndEntryPosition(String pathSegment) Retrieves the pair of repeater name and entry position of the given path segment Returnnullif the given path does not represent a repeater entrystatic <T> TRetrieves the value at the given path for the data aware ametys object with given idstatic <T> TgetValue(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) Retrieves the value of the data at the given pathstatic ObjectgetValueFromSynchronizableValue(Object value, ModelAwareDataHolder dataHolder, ModelItem modelItem, Optional<String> dataPath, SynchronizationContext context) Returns the value of the synchronized value corresponding of the future status If the value is not aSynchronizableValue, the value itself is returned The future status is determined from the synchronizable value itself or from the context if needed.static booleanhasNonEmptyRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) Checks if there is a non empty repeater entry at the given positionstatic booleanhasRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) Checks if there is a repeater entry at the given positionstatic booleanhasValue(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) Checks if there is a non empty value, for the data at the given pathstatic booleanhasValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context) Check if there is a value to render at the given pathstatic booleanhasValueOrEmpty(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) Checks if there is value, even empty, for the data at the given pathstatic booleanisExternalDisableConditionsAware(ViewItemAccessor viewItemAccessor, boolean isEdition) Determines if the givenViewItemAccessorcan have external disabled conditions itselfstatic booleanisMultiple(ModelItemAccessor parent, String attributePath) Check if at least one element in the attribute path is multiple from the given parent accessor.static booleanisRepeaterEntryPath(String path) Test if the path is a repeater entry path (for example entries[1])static voidremoveValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, ValueContext context) Removes the stored value of the data at the given pathstatic ObjectremoveValuesInArray(Object originalValues, Object valuesToRemove, ElementType elementType) Removes some values from the given original onesstatic booleanrenderValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context, boolean isEdition) Check if the value at the given path should be renderedvoidservice(ServiceManager manager) static voidsetValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, Object value, ValueContext context) Sets the value of the data at the given pathstatic voidsetValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, Object value, ValueContext context, boolean forceStatus) Sets the value of the data at the given path
-
Field Details
-
REPEATER_ENTRY_PATTERN
Pattern for repeater entry : entryName[i] -
EXTERNAL_DISABLE_CONDITIONS_VALUES
The constant to use to send values of external disable conditions- See Also:
-
-
Constructor Details
-
DataHolderHelper
public DataHolderHelper()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
dispose
- Specified by:
disposein interfaceDisposable
-
hasRepeaterEntry
public static boolean hasRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) throws BadItemTypeException Checks if there is a repeater entry at the given position- Parameters:
dataHolder- data holder that contains the repeater entry. The data holder must be the direct parent of the repeaterrepeaterName- the name of the repeaterentryPosition- the position of the entry- Returns:
trueif there is an entry at the given position,falseotherwise- Throws:
BadItemTypeException- if the value stored in the repository for the given repeater name is not a repeater
-
hasNonEmptyRepeaterEntry
public static boolean hasNonEmptyRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) throws BadItemTypeException Checks if there is a non empty repeater entry at the given position- Parameters:
dataHolder- data holder that contains the repeater entry. The data holder must be the direct parent of the repeaterrepeaterName- the name of the repeaterentryPosition- the position of the entry- Returns:
trueif there is a non empty entry at the given position,falseotherwise- Throws:
BadItemTypeException- if the value stored in the repository for the given repeater name is not a repeater
-
getRepeaterEntry
public static RepeaterEntry getRepeaterEntry(ModelAwareDataHolder dataHolder, String repeaterName, int entryPosition) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException Retrieves the repeater entry at the given position- Parameters:
dataHolder- data holder that contains the repeater entry. The data holder must be the direct parent of the repeaterrepeaterName- the name of the repeaterentryPosition- the position of the entry- Returns:
- the repeater entry
- Throws:
IllegalArgumentException- if the given repeater name is null or emptyUndefinedItemPathException- if the given repeater name is not defined by the data holder's modelBadItemTypeException- if the value stored in the repository for the given repeater name is not a repeater
-
isRepeaterEntryPath
Test if the path is a repeater entry path (for example entries[1])- Parameters:
path- the path representing the repeater entry- Returns:
- true if the pathSegment is a repeater entry path
-
getRepeaterNameAndEntryPosition
Retrieves the pair of repeater name and entry position of the given path segment Returnnullif the given path does not represent a repeater entry- Parameters:
pathSegment- the path segment representing the repeater entry- Returns:
- the pair of repeater name and entry position
-
getDataFullLabel
public static I18nizableText getDataFullLabel(String dataPath, Collection<? extends ModelItemAccessor> itemAccessors) throws UndefinedItemPathException Get the label for the path in the item accessors. If the provided path is an item path, a label will also be generated but without any indexes for repeater entries- Parameters:
dataPath- the data pathitemAccessors- the list of item accessors where the item should be retrieved- Returns:
- the label of the path
- Throws:
IllegalArgumentException- if the given path is null or emptyUndefinedItemPathException- if no item exists for the given pathBadItemTypeException- if the given path is not coherent with the accessors
-
hasValue
public static boolean hasValue(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) throws IllegalArgumentException, BadDataPathCardinalityException Checks if there is a non empty value, for the data at the given path- Parameters:
dataHolder- the data holderdataPath- path of the datacontext- the context of the value to check- Returns:
trueif the data at the given path is defined by the model, if there is a non empty value for the data, and if the type of this value matches the type of the definition.falseotherwise- Throws:
IllegalArgumentException- if the given data path is null or emptyBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
hasValueOrEmpty
public static boolean hasValueOrEmpty(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) throws IllegalArgumentException, BadDataPathCardinalityException Checks if there is value, even empty, for the data at the given path- Parameters:
dataHolder- the data holderdataPath- path of the datacontext- the context of the value to check- Returns:
trueif the data at the given path is defined by the model, if there is a value, even empty, for the data, and if the type of this value matches the type of the definition.falseotherwise- Throws:
IllegalArgumentException- if the given data path is null or emptyBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
hasValue
public static boolean hasValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context) Check if there is a value to render at the given path- Parameters:
dataHolder- the data holder containing the data to checkdataPath- the path of the data to checkcontext- the data context- Returns:
trueif there is a value to render,falseotherwise
-
renderValue
public static boolean renderValue(ModelAwareDataHolder dataHolder, String dataPath, DataContext context, boolean isEdition) Check if the value at the given path should be rendered- Parameters:
dataHolder- the data holder containing the data to checkdataPath- the path of the data to checkcontext- the data contextisEdition-trueif values are rendered in edition mode,falseotherwise- Returns:
trueif the value has to be rendered,falseotherwise
-
getValue
public static <T> T getValue(String ametysObjectId, String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Retrieves the value at the given path for the data aware ametys object with given id- Type Parameters:
T- type of the value to retrieve- Parameters:
ametysObjectId- identifier of the data aware ametys objectdataPath- path of the data- Returns:
- the value of the data or
nullif not exists or is empty. - Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueUndefinedItemPathException- if the given data path is not defined by the modelBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
getValue
public static <T> T getValue(ModelAwareDataHolder dataHolder, String dataPath, ValueContext context) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Retrieves the value of the data at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataHolder- the data holderdataPath- path of the datacontext- the context of the value to retrieve- Returns:
- the value of the data or
nullif not exists or is empty. - Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueUndefinedItemPathException- if the given data path is not defined by the modelBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
setValue
public static void setValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, Object value, ValueContext context) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Sets the value of the data at the given path- Parameters:
dataHolder- the data holderdataPath- path of the datavalue- the value to set. Givenullto empty the value.context- context of the data to set- Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the type defined by the model doesn't match the given value to setUndefinedItemPathException- if the given data path is not defined by the modelBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
setValue
public static void setValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, Object value, ValueContext context, boolean forceStatus) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Sets the value of the data at the given path- Parameters:
dataHolder- the data holderdataPath- path of the datavalue- the value to set. Givenullto empty the value.context- context of the data to setforceStatus-trueto force the status to the given status context if defined- Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the type defined by the model doesn't match the given value to setUndefinedItemPathException- if the given data path is not defined by the modelBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
removeValue
public static void removeValue(ModifiableModelAwareDataHolder dataHolder, String dataPath, ValueContext context) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Removes the stored value of the data at the given path- Parameters:
dataHolder- the data holderdataPath- path of the datacontext- context of the data to remove- Throws:
IllegalArgumentException- if the given data path is null or emptyUnknownDataException- if the value at the given data path does not existBadItemTypeException- if the value of the parent of the given path is not an item containerUndefinedItemPathException- if the given data path is not defined by the modelBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
copyTo
public static void copyTo(DataHolder source, ModifiableDataHolder destination, DataContext context) throws UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathException Copies the sourceDataHolderto the givenModifiableDataHolderdestination.- Parameters:
source- the sourceDataHolderdestination- theModifiableDataHolderdestinationcontext- The context of the data to copy- Throws:
UnknownTypeException- for data holder without model, if there is no available type compatible with the copied valueNotUniqueTypeException- for data holder without model, if there is more than one available types compatibles with the copied valueBadItemTypeException- if there is an error of data teype while copying the value in the destinationUndefinedItemPathException- for model aware data holders, if a data to copy doesn't match the model in the destination
-
copyTo
public static void copyTo(DataHolder source, ModifiableDataHolder destination, String name, DataContext context) throws IllegalArgumentException, UnknownDataException, UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathException Copy the data name of the sourceDataHolderto the givenModifiableDataHolderdestination.- Parameters:
source- the sourceDataHolderdestination- theModifiableDataHolderdestinationname- the name of the datacontext- The context of the data to copy- Throws:
IllegalArgumentException- if the given data name is null or emptyUnknownDataException- if there is no data with the given name in the source data holderUnknownTypeException- for data holder without model, if there is no available type compatible with the copied valueNotUniqueTypeException- for data holder without model, if there is more than one available types compatibles with the copied valueBadItemTypeException- if there is an error of data teype while copying the value in the destinationUndefinedItemPathException- for model aware data holders, if a data to copy doesn't match the model in the destination
-
dataToSAX
public static void dataToSAX(DataHolder dataHolder, ContentHandler contentHandler, DataContext context) throws SAXException, UnknownTypeException, NotUniqueTypeException, BadItemTypeException Generates SAX events for data contained in thisDataHolder- Parameters:
dataHolder- theDataHolderto SAXcontentHandler- theContentHandlerthat will receive the SAX eventscontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationUnknownTypeException- if there is no compatible type with the saxed valueNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the saxed valueBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
public static void dataToSAX(DataHolder dataHolder, ContentHandler contentHandler, String relativeDataPath, DataContext context) throws SAXException, UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathException Generates SAX events for data at the given relative path in thisDataHolder- Parameters:
dataHolder- theDataHolderto SAXcontentHandler- theContentHandlerthat will receive the SAX eventsrelativeDataPath- the path of the data to SAX, relative to the given data holdercontext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationUnknownTypeException- if there is no compatible type with the saxed valueNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the saxed valueBadItemTypeException- if the saxed value's type does not matches the stored dataUndefinedItemPathException- if the given data holder has a model and the given relative path is not defined in this model
-
dataToSAX
public static void dataToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) throws SAXException, BadItemTypeException Generates SAX events for the data in the given view in the givenDataHolder- Parameters:
dataHolder- theModelAwareDataHolderto SAXcontentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- The context of the data to SAXisEdition-trueif SAX events are generated in edition mode,falseotherwise- Throws:
SAXException- if an error occurs during the SAX events generationBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToJSON
public static Map<String,Object> dataToJSON(DataHolder dataHolder, DataContext context) throws UnknownTypeException, NotUniqueTypeException, BadItemTypeException Convert the data contained in the givenDataHolder- Parameters:
dataHolder- theDataHoldercontext- The context of the data to convert- Returns:
- The data of the given
DataHolderas JSON - Throws:
UnknownTypeException- if there is no compatible type with the value to convertNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the value to convertBadItemTypeException- if the value's type does not matches the stored data
-
dataToJSON
public static Object dataToJSON(DataHolder dataHolder, String relativeDataPath, DataContext context) throws UnknownTypeException, NotUniqueTypeException, BadItemTypeException, UndefinedItemPathException Convert the data at the given relative path into a JSON object- Parameters:
dataHolder- theDataHolderrelativeDataPath- the path of the data to convert, relative to the given data holdercontext- The context of the data to convert- Returns:
- The value as JSON
- Throws:
UnknownTypeException- if there is no compatible type with the value to convertNotUniqueTypeException- if there are many compatible types (there is no way to determine which type is the good one) with the value to convertBadItemTypeException- if the value's type does not matches the stored dataUndefinedItemPathException- if the given data holder has a model and the given relative path is not defined in this model
-
dataToJSON
public static Map<String,Object> dataToJSON(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context, boolean isEdition) throws BadItemTypeException Convert the data in the given view of the givenDataHolder- Parameters:
dataHolder- theModelAwareDataHoldercontaining the data to convertviewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convertisEdition-trueto convert in edition mode,falseotherwise- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToMap
public static Map<String,Object> dataToMap(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Returns all data of the given DataHolder as a typed-values Map.- Parameters:
dataHolder- the DataHolder to exportviewItemAccessor- theViewItemAccessorreferencing the items to include in the resulting Mapcontext- The context of the data- Returns:
- a Map containing all data.
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
addObjectInfoToContext
public static DataContext addObjectInfoToContext(ModelAwareDataHolder dataHolder, DataContext context) Enriches the givenDataContextwith object-level information from the root data holder (e.g. theAmetysObject) of the given data holder- Parameters:
dataHolder- the data holdercontext- the original context- Returns:
- a new context enriched with object information
-
findEditableItemsByType
public static <T> Map<String,T> findEditableItemsByType(ModelAwareDataHolder dataHolder, String type) Find all modifiable data of the given type on aModelAwareDataHolder, including in composite or repeater entries. Properties are not modifiables, so they are excluded from the result- Type Parameters:
T- the actual type of the requested data.- Parameters:
dataHolder- the data holder.type- the type identifier.- Returns:
- a Map with all data paths as keys and corresponding data as values.
-
findItemsByType
Find all data of the given type on aModelAwareDataHolder, including in composite or repeater entries.- Type Parameters:
T- the actual type of the requested data.- Parameters:
dataHolder- the data holder.type- the type identifier.- Returns:
- a Map with all data paths as keys and corresponding data as values.
-
findItemsByType
public static <T> Map<String,T> findItemsByType(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, String type) Find all data of the given type on aModelAwareDataHolder, including in composite or repeater entries.- Type Parameters:
T- the actual type of the requested data.- Parameters:
dataHolder- the data holder.viewItemAccessor- the view items to restrict totype- the type identifier.- Returns:
- a Map with all data paths as keys and corresponding data as values.
-
getExternalizableDataProviderExtensionPoint
public static ExternalizableDataProviderExtensionPoint getExternalizableDataProviderExtensionPoint()Retrieve theExternalizableDataProviderExtensionPoint- Returns:
- the
ExternalizableDataProviderExtensionPoint
-
createValueContextFromSynchronizationContext
public static ValueContext createValueContextFromSynchronizationContext(ModelAwareDataHolder dataHolder, String dataPath, SynchronizationContext synchronizationContext) Creates a value context from the givenSynchronizationContext- Parameters:
dataHolder- the data holderdataPath- the path of the value needing contextsynchronizationContext- theSynchronizationContext- Returns:
- the created
ValueContext
-
getValueFromSynchronizableValue
public static Object getValueFromSynchronizableValue(Object value, ModelAwareDataHolder dataHolder, ModelItem modelItem, Optional<String> dataPath, SynchronizationContext context) Returns the value of the synchronized value corresponding of the future status If the value is not aSynchronizableValue, the value itself is returned The future status is determined from the synchronizable value itself or from the context if needed. As the returned value is extracted from the synchronizable value, it can be anUntouchedValue- Parameters:
value- the synchronizable valuedataHolder- the data holder concerned by the valuemodelItem- the model item corresponding to the valuedataPath- the current data path of the value. Can be empty if the data is in a repeater, in a not yet existing entrycontext- the synchronization context, used to compute the future status of the value- Returns:
- the value of the synchronized value corresponding of the future status
-
getArrayValuesFromSynchronizableValue
public static Object getArrayValuesFromSynchronizableValue(SynchronizableValue synchronizableValue, ValueContext valueContext) Retrieves an array of values from the givenSynchronizableValue. If the value is not an array, create one with a single entry- Parameters:
synchronizableValue- theSynchronizableValuevalueContext- theValueContextto choose the value to retrieve (local or external)- Returns:
- an array containing the values of the
SynchronizableValue
-
isMultiple
public static boolean isMultiple(ModelItemAccessor parent, String attributePath) throws UndefinedItemPathException Check if at least one element in the attribute path is multiple from the given parent accessor.- Parameters:
parent- The parent accessorattributePath- The attribute path to explore- Returns:
falseif all elements in the path are single, otherwisetrue(can be a repeater or a multiple attribute)- Throws:
UndefinedItemPathException- if the given attribute path is not defined by the model item accessor
-
convertValues
public static Map<String,Object> convertValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values) Converts the given values according to the definitions in the givenViewItemAccessor- Parameters:
viewItemAccessor- the view item accessorvalues- the values to convert- Returns:
- the converted values
-
convertValues
public static Map<String,Object> convertValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values, BiFunction<ElementDefinition, Object, Object> convertValueFunction) Converts the given values according to the definitions in the givenViewItemAccessor- Parameters:
viewItemAccessor- the view item accessorvalues- the values to convertconvertValueFunction- The function to use to convert single values- Returns:
- the converted values
-
convertValuesWithSynchronizableValues
public static Map<String,Object> convertValuesWithSynchronizableValues(ViewItemAccessor viewItemAccessor, Map<String, Object> values, BiFunction<ElementDefinition, Object, Object> convertValueFunction, Optional<DataHolderHelper.SynchronizableValuesStatusInfos> synchronizableValuesStatusInfos) Converts the given values according to the definitions in the givenViewItemAccessor- Parameters:
viewItemAccessor- the view item accessorvalues- the values to convertconvertValueFunction- The function to use to convert single valuessynchronizableValuesStatusInfos- informations needed to choose status of createdSynchronizableValue. If empty, the status is set toExternalizableDataProvider.ExternalizableDataStatus.LOCAL- Returns:
- the converted values
-
convertValueIgnoringIncompatibleOnes
public static Object convertValueIgnoringIncompatibleOnes(ElementDefinition definition, Object value) Converts the given value according to the given definition If the value is multiple, an array is retrieved with each value converted to the right type If the value is not compatible whit the data type, no exception is thrown and the value is converted to anUntouchedValuein order to be ignored- Parameters:
definition- the definitionvalue- the value to convert- Returns:
- the converted value
-
convertValue
public static Object convertValue(ElementDefinition definition, Object value) throws BadItemTypeException Converts the given value according to the given definition If the value is multiple, an array is retrieved with each value converted to the right type- Parameters:
definition- the definitionvalue- the value to convert- Returns:
- the converted value
- Throws:
BadItemTypeException- if the value to convert is not compatible with the data type
-
createViewItemAccessorFromValues
public static ViewItemAccessor createViewItemAccessorFromValues(Collection<? extends ModelItemAccessor> modelItemAccessors, Map<String, Object> values) Create aViewItemAccessorfor the items corresponding to the given values- Parameters:
modelItemAccessors- the model containing the items corresponding to the valuesvalues- the values- Returns:
- the created
ViewItemAccessor
-
aggregateMultipleValues
public static <T> T aggregateMultipleValues(List<? extends ModelAwareDataHolder> dataHolders, String dataPath, Class managedClass) Aggregates multiple values of the data holders at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataHolders- the data holding the valuesdataPath- the path of the data to retrievemanagedClass- class of the retrieved values- Returns:
- aggregated multiple values
-
removeValuesInArray
public static Object removeValuesInArray(Object originalValues, Object valuesToRemove, ElementType elementType) Removes some values from the given original ones- Parameters:
originalValues- the original valuesvaluesToRemove- the values to remove from the original oneselementType- the type of the element concerned by the values- Returns:
- an array containing the original values, less the ones to remove
-
appendValuesInArray
public static Object appendValuesInArray(Object originalValues, Object valuesToAppend, ElementType elementType) Append some values to the given original ones- Parameters:
originalValues- the original valuesvaluesToAppend- the values to append to the original oneselementType- the type of the element concerned by the values- Returns:
- an array containing the original values, and the ones to append
-
externalDisableConditionsToSAX
public static void externalDisableConditionsToSAX(ModelAwareDataHolder dataHolder, ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext dataContext) throws SAXException, BadItemTypeException, UndefinedItemPathException Generates SAX events for external disable conditions of the items in the given view- Parameters:
dataHolder- theModelAwareDataHolderto SAXcontentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventsdataContext- The context of the data to SAX- Throws:
SAXException- if an error occurs during the SAX events generationBadItemTypeException- if the saxed value's type does not matches the stored dataUndefinedItemPathException- if an item in the view is not part of the model
-
getExternalDisableConditionsValues
public static Map<String,Boolean> getExternalDisableConditionsValues(ModelAwareDataHolder dataHolder, ViewItemAccessor viewItemAccessor, DataContext dataContext) Retrieves the values of the disable conditions of the items in the given view for the given data holder- Parameters:
dataHolder- theModelAwareDataHoldercontaining the dataviewItemAccessor- theViewItemAccessorreferencing the itemsdataContext- The context of the data- Returns:
- the disable conditions values
-
isExternalDisableConditionsAware
public static boolean isExternalDisableConditionsAware(ViewItemAccessor viewItemAccessor, boolean isEdition) Determines if the givenViewItemAccessorcan have external disabled conditions itself- Parameters:
viewItemAccessor- the view item accessorisEdition-truein edition mode,falseotherwise- Returns:
trueif the gicen accessor can have external disable conditions,falseotherwise
-