Class DefaultModelAwareDataHolder
java.lang.Object
org.ametys.plugins.repository.data.holder.impl.DefaultModelAwareDataHolder
- All Implemented Interfaces:
DataHolder,ModelAwareDataHolder
- Direct Known Subclasses:
DefaultIndexableDataHolder,DefaultModifiableModelAwareDataHolder
Default implementation for data holder with model
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Collection<? extends ModelItemContainer> Model containers to use to get information about definitionsprotected Optional<? extends ModelAwareDataHolder> Parent of the currentDataHolderprotected RepositoryDataRepository data to use to store data in the repositoryprotected ModelAwareDataHolderRootDataHolderFields inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
ALTERNATIVE_SUFFIX, STATUS_SUFFIX -
Constructor Summary
ConstructorsConstructorDescriptionDefaultModelAwareDataHolder(RepositoryData repositoryData, Collection<? extends ModelItemContainer> itemContainers, Optional<? extends ModelAwareDataHolder> parent, Optional<? extends ModelAwareDataHolder> root) Creates a default model aware data holderDefaultModelAwareDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer) Creates a default model aware data holderDefaultModelAwareDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer, Optional<? extends ModelAwareDataHolder> parent, Optional<? extends ModelAwareDataHolder> root) Creates a default model aware data holder -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckDefinition(String dataPath, boolean checkStatusAvailable, String errorMsg) Check definition for data pathprotected voidcheckDefinition(String dataPath, String errorMsg) Check definition for data pathprotected booleancheckElementDifferences(ViewElement viewElement, SynchronizableValue value, ValueContext context) Check if there are differences between the given value and the given view element's valueprotected booleancheckElementDifferencesInRemoveMode(ViewElement viewElement, SynchronizableValue value, ValueContext context) Check if there are differences between the given value and the given view element's valueprotected booleancheckStatusDifferences(ElementDefinition definition, SynchronizableValue value, SynchronizationContext synchronizationContext, boolean doValuesContainData) Check if the data's status will have to be changedprotected ModelAwareCompositecreateCompositeInstance(RepositoryData compositeRepositoryData, CompositeDefinition compositeDefinition) Creates an instance of compositeprotected RepeatercreateRepeaterInstance(RepositoryData repeaterRepositoryData, RepeaterDefinition repeaterDefinition) Creates an instance of repeaterprotected <T extends SynchronizationContext>
TCreates an instance ofSynchronizationContextdataToJSON(String dataPath, DataContext context) Convert the data at the given path into a JSON objectprotected ObjectdataToJSON(ModelItem modelItem, String dataPath, DataContext context) Converts the value of the given model item at the given data path to a JSON-serializable objectdataToJSON(ViewItemAccessor viewItemAccessor, DataContext context) Convert the data in the given view of the currentDataHolderdataToJSONForEdition(ViewItemAccessor viewItemAccessor, DataContext context) Convert the data in the given view in edition mode in the currentDataHolderdataToMap(ViewItemAccessor viewItemAccessor, DataContext context) Retrieves data of this DataHolder as a typed-values Map.voiddataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) Generates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given pathprotected voiddataToSAX(ContentHandler contentHandler, ModelItem modelItem, String dataPath, DataContext context) Generates SAX events for the given model item at the given data pathvoiddataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) Generates SAX events for the data in the given view in the currentDataHoldervoiddataToSAXForEdition(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) Generates SAX events for the data in the given view in edition mode in the currentDataHolderprotected booleandoesHaveDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) Check if there are differences between the given values and the current onesprotected Collection<ModelItem> doGetDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the current onesprotected voidEnsures that no null item container has been given to constructorgetComposite(String compositePath) Retrieves the composite at the given pathprotected ModelAwareCompositegetComposite(String name, CompositeDefinition compositeDefinition) Retrieves the composite with the given nameprotected ClassRetrieves the class of the managed compositesprotected ModelAwareCompositegetCompositeFromValue(Object value, String compositePath) Retrieves the composite from the given valueRetrieves the names of data contained by this data holder Retrieves only the data at first level, does not check composite datagetDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values) Get the collection of model items where there are differences between the given values and the current onesgetDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) Get the collection of model items where there are differences between the given values and the current onesprotected Collection<ModelItem> getDifferencesInGroup(ModelViewItemGroup modelViewItemGroup, Map<String, Object> values, SynchronizationContext synchronizationContext) Get the collection of model items where there are differences between the given values and the given group's onesprotected <T> TgetElementValue(ElementDefinition definition, String dataName) Retrieves the value of the given element definitiongetExternalComposite(String compositePath) Retrieves the external composite at the given pathgetExternalRepeater(String repeaterPath) Retrieves the external repeater at the given path<T> TgetExternalValue(String dataPath) Retrieves the external value of the data at the given pathprotected StringgetFinalDataName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Retrieves the name of the data according to the given statusprotected <T> TgetGroupValue(ModelItem modelItem, String dataName) Retrieves the value of the given group model item (composite or repeater)getLocalComposite(String compositePath) Retrieves the local composite at the given pathgetLocalRepeater(String repeaterPath) Retrieves the local repeater at the given path<T> TgetLocalValue(String dataPath) Retrieves the local value of the data at the given pathprotected ClassgetManagedClass(ModelAwareDataHolder dataHolder, String dataPath) Retrieves the managed class for the model item at the given data path in the given data holderCollection<? extends ModelItemContainer> getModel()Retrieves the data holder's modelprotected <T> TgetMultipleValues(String dataPath) Retrieves the aggregated values when the first segment of the data path refers to a multiple data (repeater or multiple value)Optional<? extends ModelAwareDataHolder> Retrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the rootgetRepeater(String repeaterPath) Retrieves the repeater at the given pathprotected RepeatergetRepeater(String name, RepeaterDefinition repeaterDefinition) Retrieves the repeater with the given nameprotected ClassRetrieves the class of the managed repeatersprotected ClassRetrieves the class of the managed repeater entriesprotected RepeatergetRepeaterFromValue(Object value, String repeaterPath) Retrieves the repeater from the given valueRetrieves the repository data used by thisDataHolderRetrieves theDataHolderthat is the root of the current oneRetrieves the status of the externalizable data at the given path Warning: This method won't check that your data is externalizable.<T> TRetrieves the value of the data at the given pathprotected <T> TgetValue(String dataPath, boolean allowMultiValuedPathSegments, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Retrieves the value at the given data path<T> TgetValueOrDefault(String dataPath) Retrieves the value of the data at the given path if exists and is not empty, or the default value from the model<T> TgetValueOrDefault(String dataPath, T defaultValue) Retrieves the value of the data at the given path if exists and is not empty, or the given default value<T> TgetValueWithMultiValuedPathSegments(String dataPath) Retrieves the value of the data at the given path, allowing multi-valued segments in the path (not necessarily at the last segment) if there is no indicated entry for a repeater, the values of all the entries are retrieved if there are multiple values, all data are retrieved in one arrayprotected booleanhasDefaultValue(ModelItem modelItem) Check if the given model item has a default valuebooleanhasDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values) Check if there are differences between the given values and the current onesbooleanhasDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) Check if there are differences between the given values and the current onesprotected booleanhasDifferencesInElement(ViewElement viewElement, Map<String, Object> values, SynchronizationContext synchronizationContext) Check if there are differences between the given values and the given element's onesprotected booleanhasDifferencesInGroup(ModelViewItemGroup modelViewItemGroup, Map<String, Object> values, SynchronizationContext synchronizationContext) Check if there are differences between the given values and the given group's onesbooleanhasExternalValue(String dataPath) Checks if there is a non empty external value for the data at the given pathbooleanhasExternalValueOrEmpty(String dataPath) Checks if there is an external value for the data at the given pathbooleanhasLocalValue(String dataPath) Checks if there is a non empty local value for the data at the given pathbooleanhasLocalValueOrEmpty(String dataPath) Checks if there is a local value for the data at the given pathbooleanChecks if there is a non empty value for the data at the given pathprotected booleanhasValue(String dataPath, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a non-empty value for the given data path with the given externalizable statusprotected booleanhasValueForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a non-empty value for the given simple data name (no path separator) with the given externalizable statusbooleanhasValueOrEmpty(String dataPath) Checks if there is a value, even empty, for the data at the given pathprotected booleanhasValueOrEmpty(String dataPath, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a value (possibly empty) for the given data path with the given externalizable statusprotected booleanhasValueOrEmptyForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a value (possibly empty) for the given simple data name (no path separator) with the given externalizable statusMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
copyTo, copyTo, dataToJSON, dataToSAXMethods inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
dataToJSON, dataToJSON, dataToJSON, dataToMap, dataToMap, dataToMap, dataToSAX, dataToSAX, dataToSAX, getDefinition, getDifferences, getDifferences, getModelItemTypeExtensionPoint, getType, getValueOfType, getValueOfTypeOrDefault, hasDefinition, hasDifferences, hasDifferences, hasValue, isMultiple, isMultiple
-
Field Details
-
_repositoryData
Repository data to use to store data in the repository -
_parent
Parent of the currentDataHolder -
_root
RootDataHolder -
_itemContainers
Model containers to use to get information about definitions
-
-
Constructor Details
-
DefaultModelAwareDataHolder
Creates a default model aware data holder- Parameters:
repositoryData- the repository data to useitemContainer- the model container to use to get information about definitions. Must match the given repository data. A repository data can have several item containers. For example, a content can have several content types.
-
DefaultModelAwareDataHolder
public DefaultModelAwareDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer, Optional<? extends ModelAwareDataHolder> parent, Optional<? extends ModelAwareDataHolder> root) Creates a default model aware data holder- Parameters:
repositoryData- the repository data to useitemContainer- the model container to use to get information about definitions. Must match the given repository data. A repository data can have several item containers. For example, a content can have several content types.parent- the optional parent of the createdDataHolder, empty if the createdDataHolderis the rootDataHolderroot- the rootDataHolder
-
DefaultModelAwareDataHolder
public DefaultModelAwareDataHolder(RepositoryData repositoryData, Collection<? extends ModelItemContainer> itemContainers, Optional<? extends ModelAwareDataHolder> parent, Optional<? extends ModelAwareDataHolder> root) Creates a default model aware data holder- Parameters:
repositoryData- the repository data to useitemContainers- the model containers to use to get information about definitions. Must match the given repository data. A repository data can have several item containers. For example, a content can have several content types.parent- the parent of the createdDataHolder, empty if the createdDataHolderis the rootDataHolderroot- the rootDataHolder
-
-
Method Details
-
ensureNonNullItemContainers
Ensures that no null item container has been given to constructor- Throws:
NullPointerException- if a there is anullitem container
-
getComposite
public ModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:DataHolderRetrieves the composite at the given path- Specified by:
getCompositein interfaceDataHolder- Specified by:
getCompositein interfaceModelAwareDataHolder- Parameters:
compositePath- path of the composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyBadItemTypeException- if the stored value at the given path is not a compositeUndefinedItemPathException- if the data holder has a model and the given composite path is not defined by this modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
getLocalComposite
public ModelAwareComposite getLocalComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the local composite at the given path- Specified by:
getLocalCompositein interfaceModelAwareDataHolder- Parameters:
compositePath- path of the externalizable composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyBadItemTypeException- if the stored value at the given path is not a compositeUndefinedItemPathException- if the given composite 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
-
getExternalComposite
public ModelAwareComposite getExternalComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the external composite at the given path- Specified by:
getExternalCompositein interfaceModelAwareDataHolder- Parameters:
compositePath- path of the externalizable composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given composite path is null or emptyBadItemTypeException- if the stored value at the given path is not a compositeUndefinedItemPathException- if the given composite 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
-
getCompositeFromValue
protected ModelAwareComposite getCompositeFromValue(Object value, String compositePath) throws BadItemTypeException Retrieves the composite from the given value- Parameters:
value- the given value as a compositecompositePath- the path of the composite- Returns:
- the composite, or
nullif the value isnull - Throws:
BadItemTypeException- if the value is not aComposite
-
getRepeater
public Repeater getRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the repeater at the given path- Specified by:
getRepeaterin interfaceModelAwareDataHolder- Parameters:
repeaterPath- path of the repeater to retrieve- Returns:
- the repeater or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given repeater path is null or emptyBadItemTypeException- if the stored value at the given path is not a repeaterUndefinedItemPathException- if the given repeater 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
-
getLocalRepeater
public Repeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the local repeater at the given path- Specified by:
getLocalRepeaterin interfaceModelAwareDataHolder- Parameters:
repeaterPath- path of the externalizable repeater to retrieve- Returns:
- the repeater or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given repeater path is null or emptyBadItemTypeException- if the stored value at the given path is not a repeaterUndefinedItemPathException- if the given repeater 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
-
getExternalRepeater
public Repeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the external repeater at the given path- Specified by:
getExternalRepeaterin interfaceModelAwareDataHolder- Parameters:
repeaterPath- path of the externalizable repeater to retrieve- Returns:
- the repeater or
nullif not exists or is empty - Throws:
IllegalArgumentException- if the given repeater path is null or emptyBadItemTypeException- if the stored value at the given path is not a repeaterUndefinedItemPathException- if the given repeater 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
-
getRepeaterFromValue
protected Repeater getRepeaterFromValue(Object value, String repeaterPath) throws BadItemTypeException Retrieves the repeater from the given value- Parameters:
value- the given value as a repeaterrepeaterPath- the path of the repeater- Returns:
- the repeater, or
nullif the value isnull - Throws:
BadItemTypeException- if the value is not aRepeater
-
hasValue
public boolean hasValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:DataHolderChecks if there is a non empty value for the data at the given path- Specified by:
hasValuein interfaceDataHolder- Parameters:
dataPath- path of the data- Returns:
trueif there is a non empty value for the data. If the data holder has a model and the data at the given path is defined by the model and 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 data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
hasLocalValue
public boolean hasLocalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderChecks if there is a non empty local value for the data at the given path- Specified by:
hasLocalValuein interfaceModelAwareDataHolder- Parameters:
dataPath- path of the externalizable data- Returns:
trueif the data at the given path is defined by the model, if there is a non empty local 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
-
hasExternalValue
public boolean hasExternalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderChecks if there is a non empty external value for the data at the given path- Specified by:
hasExternalValuein interfaceModelAwareDataHolder- Parameters:
dataPath- path of the externalizable data- Returns:
trueif the data at the given path is defined by the model, if there is a non empty external 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
-
hasValue
protected boolean hasValue(String dataPath, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) throws IllegalArgumentException, BadDataPathCardinalityException Checks if there is a non-empty value for the given data path with the given externalizable status- Parameters:
dataPath- the path of the datastatus- the optional externalizable status to filter on, or empty to check the current value- Returns:
trueif there is a non-empty value at the given path,falseotherwise- Throws:
IllegalArgumentException- if the data path is emptyBadDataPathCardinalityException- if a segment of the data path refers to a multiple data
-
hasValueForName
protected boolean hasValueForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a non-empty value for the given simple data name (no path separator) with the given externalizable status- Parameters:
dataName- the name of the data (no path separator)status- the optional externalizable status to filter on, or empty to check the current value- Returns:
trueif there is a non-empty value for the given name,falseotherwise
-
hasValueOrEmpty
public boolean hasValueOrEmpty(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:DataHolderChecks if there is a value, even empty, for the data at the given path- Specified by:
hasValueOrEmptyin interfaceDataHolder- Parameters:
dataPath- path of the data- Returns:
trueif there is value, even empty, for the data. If the data holder has a model and the data at the given path is defined by the model and 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 data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
hasLocalValueOrEmpty
public boolean hasLocalValueOrEmpty(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderChecks if there is a local value for the data at the given path- Specified by:
hasLocalValueOrEmptyin interfaceModelAwareDataHolder- Parameters:
dataPath- path of the externalizable data- Returns:
trueif the data at the given path is defined by the model, if there is a local value for the data, even empty, 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
-
hasExternalValueOrEmpty
public boolean hasExternalValueOrEmpty(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderChecks if there is an external value for the data at the given path- Specified by:
hasExternalValueOrEmptyin interfaceModelAwareDataHolder- Parameters:
dataPath- path of the externalizable data- Returns:
trueif the data at the given path is defined by the model, if there is an external value for the data, even empty, 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
protected boolean hasValueOrEmpty(String dataPath, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) throws IllegalArgumentException, BadDataPathCardinalityException Checks if there is a value (possibly empty) for the given data path with the given externalizable status- Parameters:
dataPath- the path of the datastatus- the optional externalizable status to filter on, or empty to check the current value- Returns:
trueif there is a value at the given path (even empty),falseotherwise- Throws:
IllegalArgumentException- if the data path is emptyBadDataPathCardinalityException- if a segment of the data path refers to a multiple data
-
hasValueOrEmptyForName
protected boolean hasValueOrEmptyForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Checks if there is a value (possibly empty) for the given simple data name (no path separator) with the given externalizable status- Parameters:
dataName- the name of the data (no path separator)status- the optional externalizable status to filter on, or empty to check the current value- Returns:
trueif there is a value for the given name (even empty),falseotherwise
-
getValue
public <T> T getValue(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:DataHolderRetrieves the value of the data at the given path- Specified by:
getValuein interfaceDataHolder- Type Parameters:
T- type of the value to retrieve. If the data holder has a model, the type of the value is defined by this model. Otherwise, the type of the value will be deduced from the stored data. In some cases, the type can be wrong. For example, it is impossible to know if a stored date is a date or a date time- Parameters:
dataPath- path of the data- Returns:
- the value of the data or
nullif not exists or is empty. A typed array is returned for multiple empty data, and an empty string is returned for single empty string data - Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the data holder has a model and the type defined by the model doesn't match the type of the stored value, or if value at the sub data path of the given one is not a compositeUndefinedItemPathException- if the data holder has a model and the given data path is not defined by this modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
getLocalValue
public <T> T getLocalValue(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the local value of the data at the given path- Specified by:
getLocalValuein interfaceModelAwareDataHolder- Type Parameters:
T- type of the value to retrieve. The type of the value is defined by the model.- Parameters:
dataPath- path of the externalizable data- Returns:
- the local value of the data or
nullif not exists or is empty. A typed array is returned for multiple empty data, and an empty string is returned for single empty string data - 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
-
getExternalValue
public <T> T getExternalValue(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the external value of the data at the given path- Specified by:
getExternalValuein interfaceModelAwareDataHolder- Type Parameters:
T- type of the value to retrieve. The type of the value is defined by the model.- Parameters:
dataPath- path of the externalizable data- Returns:
- the external value of the data or
nullif not exists or is empty. A typed array is returned for multiple empty data, and an empty string is returned for single empty string data - 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
-
getValueWithMultiValuedPathSegments
public <T> T getValueWithMultiValuedPathSegments(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the value of the data at the given path, allowing multi-valued segments in the path (not necessarily at the last segment) if there is no indicated entry for a repeater, the values of all the entries are retrieved if there are multiple values, all data are retrieved in one array- Specified by:
getValueWithMultiValuedPathSegmentsin interfaceModelAwareDataHolder- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the data- Returns:
- the value of the data
- 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 managesMultiples boolean isfalseand the definition of a part of the data path is multiple. Only the last part can be multiple
-
getValue
protected <T> T getValue(String dataPath, boolean allowMultiValuedPathSegments, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Retrieves the value at the given data path- Type Parameters:
T- the expected type of the value- Parameters:
dataPath- the path of the dataallowMultiValuedPathSegments-trueto allow multiple-valued intermediate path segments and aggregate their valuesstatus- the optional externalizable status to filter on, or empty to retrieve the current value- Returns:
- the value at the given path, or
nullif there is no value - Throws:
IllegalArgumentException- if the data path is emptyBadItemTypeException- if the type stored in the repository does not match the expected typeUndefinedItemPathException- if the path does not match any definitionBadDataPathCardinalityException- if a non-terminal segment of the data path refers to a multiple data
-
getStatus
public ExternalizableDataProvider.ExternalizableDataStatus getStatus(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the status of the externalizable data at the given path Warning: This method won't check that your data is externalizable. But there is no sense to call it with a non externalizable data- Specified by:
getStatusin interfaceModelAwareDataHolder- Parameters:
dataPath- path of the externalizable data- Returns:
- the status of the externalizable data at the given path
- Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if the given data path is composed of an item with type defined by the model that 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
-
getElementValue
protected <T> T getElementValue(ElementDefinition definition, String dataName) throws BadItemTypeException Retrieves the value of the given element definition- Type Parameters:
T- the expected type of the value- Parameters:
definition- the definition of the elementdataName- the final name (possibly altered with a status suffix) to use to read the repository data- Returns:
- the value read from the repository, possibly coerced from single to multiple or vice versa
- Throws:
BadItemTypeException- if the type defined by the model doesn't match the type of the stored value
-
getGroupValue
Retrieves the value of the given group model item (composite or repeater)- Type Parameters:
T- the expected type of the value- Parameters:
modelItem- the model item (must be aCompositeDefinitionor aRepeaterDefinition)dataName- the name of the data to retrieve- Returns:
- the composite, repeater or repeater entry, or
nullif it does not exist - Throws:
BadItemTypeException- if the type defined by the model doesn't match the type of the stored value
-
getComposite
protected ModelAwareComposite getComposite(String name, CompositeDefinition compositeDefinition) throws BadItemTypeException Retrieves the composite with the given name- Parameters:
name- name of the composite to retrievecompositeDefinition- the definition of the composite to retrieve- Returns:
- the composite
- Throws:
BadItemTypeException- if the value stored in the repository with the given name is not a composite
-
createCompositeInstance
protected ModelAwareComposite createCompositeInstance(RepositoryData compositeRepositoryData, CompositeDefinition compositeDefinition) Creates an instance of composite- Parameters:
compositeRepositoryData- the repository data of the composite to createcompositeDefinition- the definition of the composite to create- Returns:
- the created composite instance
-
getRepeater
protected Repeater getRepeater(String name, RepeaterDefinition repeaterDefinition) throws BadItemTypeException Retrieves the repeater with the given name- Parameters:
name- name of the repeater to retrieverepeaterDefinition- the definition of the repeater to retrieve- Returns:
- the repeater
- Throws:
BadItemTypeException- if the value stored in the repository with the given name is not a repeater
-
createRepeaterInstance
protected Repeater createRepeaterInstance(RepositoryData repeaterRepositoryData, RepeaterDefinition repeaterDefinition) Creates an instance of repeater- Parameters:
repeaterRepositoryData- the repository data of the repeater to createrepeaterDefinition- the definition of the repeater to create- Returns:
- the created repeater instance
-
getMultipleValues
Retrieves the aggregated values when the first segment of the data path refers to a multiple data (repeater or multiple value)- Type Parameters:
T- the expected type of the aggregated values- Parameters:
dataPath- the full data path whose first segment is multiple-valued- Returns:
- an array aggregating the values obtained from each entry of the multiple segment
-
getManagedClass
Retrieves the managed class for the model item at the given data path in the given data holder- Parameters:
dataHolder- the data holder owning the datadataPath- the path of the data- Returns:
- the managed class (element type, composite, repeater or repeater entry class depending on the model item)
-
getRepeaterEntryClass
Retrieves the class of the managed repeater entries- Returns:
- the class of the managed repeater entries
-
getRepeaterClass
Retrieves the class of the managed repeaters- Returns:
- the class of the managed repeaters
-
getCompositeClass
Retrieves the class of the managed composites- Returns:
- the class of the managed composites
-
getValueOrDefault
public <T> T getValueOrDefault(String dataPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the value of the data at the given path if exists and is not empty, or the default value from the model- Specified by:
getValueOrDefaultin interfaceModelAwareDataHolder- Type Parameters:
T- type of the value to retrieve. The type of the value is defined by the model.- Parameters:
dataPath- path of the data- Returns:
- the value of the data, or the default value from the model if the value does not exist 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
-
hasDefaultValue
Check if the given model item has a default value- Parameters:
modelItem- the model item to check- Returns:
trueif the model item has a default value,falseotherwise
-
getValueOrDefault
public <T> T getValueOrDefault(String dataPath, T defaultValue) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:DataHolderRetrieves the value of the data at the given path if exists and is not empty, or the given default value- Specified by:
getValueOrDefaultin interfaceDataHolder- Type Parameters:
T- type of the value to retrieve. If the data holder has a model, the type of the value is defined by this model. Otherwise, the type of the value will be deduced from the stored data. In some cases, the type can be wrong. For example, it is impossible to know if a stored date is a date or a date time- Parameters:
dataPath- path of the datadefaultValue- default value- Returns:
- the value of the data, or the given default value if the value does not exist or is empty
- Throws:
IllegalArgumentException- if the given data path is null or emptyBadItemTypeException- if value at the sub data path of the given one is not a compositeUndefinedItemPathException- if the data holder has a model and the given data path is not defined by this modelBadDataPathCardinalityException- if the data holder has a model and the definition of a part of the data path is multiple. Only the last part can be multiple
-
getFinalDataName
protected String getFinalDataName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Retrieves the name of the data according to the given status- Parameters:
dataName- the name of the datastatus- the status- Returns:
- the final name of the data
-
getModel
Description copied from interface:ModelAwareDataHolderRetrieves the data holder's model- Specified by:
getModelin interfaceModelAwareDataHolder- Returns:
- the data holder's model
-
getDataNames
Description copied from interface:ModelAwareDataHolderRetrieves the names of data contained by this data holder Retrieves only the data at first level, does not check composite data- Specified by:
getDataNamesin interfaceDataHolder- Specified by:
getDataNamesin interfaceModelAwareDataHolder- Returns:
- the names of the data contained by this data holder and that are defined by the model
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, String dataPath, DataContext context) throws SAXException, BadItemTypeException, UndefinedItemPathException Description copied from interface:DataHolderGenerates SAX events for the data at the given data path in the currentDataHolderDo not generate any event if there is no values at the given path- Specified by:
dataToSAXin interfaceDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsdataPath- the path of the data to SAXcontext- 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 the data holder has a model and the given data path is not defined by this model
-
dataToSAX
protected void dataToSAX(ContentHandler contentHandler, ModelItem modelItem, String dataPath, DataContext context) throws SAXException, BadItemTypeException Generates SAX events for the given model item at the given data path- Parameters:
contentHandler- the content handler to use to generate SAX eventsmodelItem- the model item describing the datadataPath- the path of the datacontext- the context of the data- Throws:
SAXException- if an error occurs while generating SAX eventsBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
public void dataToSAX(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException Description copied from interface:ModelAwareDataHolderGenerates SAX events for the data in the given view in the currentDataHolder- Specified by:
dataToSAXin interfaceModelAwareDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- 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 data
-
dataToSAXForEdition
public void dataToSAXForEdition(ContentHandler contentHandler, ViewItemAccessor viewItemAccessor, DataContext context) throws SAXException, BadItemTypeException Description copied from interface:ModelAwareDataHolderGenerates SAX events for the data in the given view in edition mode in the currentDataHolder- Specified by:
dataToSAXForEditionin interfaceModelAwareDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemAccessor- theViewItemAccessorreferencing the items for which generate SAX eventscontext- 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 data
-
dataToJSON
public Object dataToJSON(String dataPath, DataContext context) throws BadItemTypeException, UndefinedItemPathException Description copied from interface:DataHolderConvert the data at the given path into a JSON object- Specified by:
dataToJSONin interfaceDataHolder- Parameters:
dataPath- the path of the data to convertcontext- The context of the data to convert- Returns:
- The value as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored dataUndefinedItemPathException- if the data holder has a model and the given data path is not defined by this model
-
dataToJSON
protected Object dataToJSON(ModelItem modelItem, String dataPath, DataContext context) throws BadItemTypeException Converts the value of the given model item at the given data path to a JSON-serializable object- Parameters:
modelItem- the model item describing the datadataPath- the path of the datacontext- the context of the data- Returns:
- the JSON-serializable representation of the value, or
nullif there is no value - Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToJSON
public Map<String,Object> dataToJSON(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Description copied from interface:ModelAwareDataHolderConvert the data in the given view of the currentDataHolder- Specified by:
dataToJSONin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convert- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToJSONForEdition
public Map<String,Object> dataToJSONForEdition(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Description copied from interface:ModelAwareDataHolderConvert the data in the given view in edition mode in the currentDataHolder- Specified by:
dataToJSONForEditionin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- theViewItemAccessorreferencing the items to convertcontext- The context of the data to convert- Returns:
- The data of the given view as JSON
- Throws:
BadItemTypeException- if the value's type does not matches the stored data
-
dataToMap
public Map<String,Object> dataToMap(ViewItemAccessor viewItemAccessor, DataContext context) throws BadItemTypeException Description copied from interface:ModelAwareDataHolderRetrieves data of this DataHolder as a typed-values Map.- Specified by:
dataToMapin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- 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
-
hasDifferences
public boolean hasDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values) throws BadItemTypeExceptionDescription copied from interface:ModelAwareDataHolderCheck if there are differences between the given values and the current ones- Specified by:
hasDifferencesin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to check- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
hasDifferences
public boolean hasDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) throws BadItemTypeExceptionDescription copied from interface:ModelAwareDataHolderCheck if there are differences between the given values and the current ones- Specified by:
hasDifferencesin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
doesHaveDifferences
protected boolean doesHaveDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) throws BadItemTypeExceptionCheck if there are differences between the given values and the current ones- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to checkcontext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
getDifferences
public Collection<ModelItem> getDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values) throws BadItemTypeExceptionDescription copied from interface:ModelAwareDataHolderGet the collection of model items where there are differences between the given values and the current ones- Specified by:
getDifferencesin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to check- Returns:
- a collection of model items with differences
- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
getDifferences
public Collection<ModelItem> getDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) throws BadItemTypeExceptionDescription copied from interface:ModelAwareDataHolderGet the collection of model items where there are differences between the given values and the current ones- Specified by:
getDifferencesin interfaceModelAwareDataHolder- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
doGetDifferences
protected Collection<ModelItem> doGetDifferences(ViewItemAccessor viewItemAccessor, Map<String, Object> values, SynchronizationContext context) throws BadItemTypeExceptionGet the collection of model items where there are differences between the given values and the current ones- Parameters:
viewItemAccessor- TheViewItemAccessorfor all items to checkvalues- the values to checkcontext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
hasDifferencesInGroup
protected boolean hasDifferencesInGroup(ModelViewItemGroup modelViewItemGroup, Map<String, Object> values, SynchronizationContext synchronizationContext) throws BadItemTypeExceptionCheck if there are differences between the given values and the given group's ones- Parameters:
modelViewItemGroup- the groupvalues- the values to checksynchronizationContext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
getDifferencesInGroup
protected Collection<ModelItem> getDifferencesInGroup(ModelViewItemGroup modelViewItemGroup, Map<String, Object> values, SynchronizationContext synchronizationContext) throws BadItemTypeExceptionGet the collection of model items where there are differences between the given values and the given group's ones- Parameters:
modelViewItemGroup- the groupvalues- the values to checksynchronizationContext- the context of the synchronization- Returns:
- a collection of model items with differences
- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
hasDifferencesInElement
protected boolean hasDifferencesInElement(ViewElement viewElement, Map<String, Object> values, SynchronizationContext synchronizationContext) throws BadItemTypeExceptionCheck if there are differences between the given values and the given element's ones- Parameters:
viewElement- the elementvalues- the values to checksynchronizationContext- the context of the synchronization- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model of one of the Map's key doesn't match the corresponding value
-
checkElementDifferences
protected boolean checkElementDifferences(ViewElement viewElement, SynchronizableValue value, ValueContext context) throws BadItemTypeException Check if there are differences between the given value and the given view element's value- Parameters:
viewElement- the elementvalue- the value to checkcontext- context of the data to check- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model doesn't match the given value to set
-
checkElementDifferencesInRemoveMode
protected boolean checkElementDifferencesInRemoveMode(ViewElement viewElement, SynchronizableValue value, ValueContext context) throws BadItemTypeException Check if there are differences between the given value and the given view element's value- Parameters:
viewElement- the elementvalue- the value to checkcontext- context of the data to check- Returns:
trueif there are differences,falseotherwise- Throws:
BadItemTypeException- if the type defined by the model doesn't match the given value to set
-
checkStatusDifferences
protected boolean checkStatusDifferences(ElementDefinition definition, SynchronizableValue value, SynchronizationContext synchronizationContext, boolean doValuesContainData) Check if the data's status will have to be changed- Parameters:
definition- definition of the datavalue- the valuesynchronizationContext- the context of the synchronizationdoValuesContainData-trueif the values contain the data,falseotherwise- Returns:
trueif the status has changed,falseotherwise
-
createSynchronizationContextInstance
Creates an instance ofSynchronizationContext- Type Parameters:
T- the type of theSynchronizationContext- Returns:
- the created
SynchronizationContext
-
getRepositoryData
Description copied from interface:DataHolderRetrieves the repository data used by thisDataHolder- Specified by:
getRepositoryDatain interfaceDataHolder- Returns:
- the repository data used by this
DataHolder
-
getParentDataHolder
Description copied from interface:DataHolderRetrieves the optional parent of the currentDataHolderThere can be no parent if the currentDataHolderis the root- Specified by:
getParentDataHolderin interfaceDataHolder- Specified by:
getParentDataHolderin interfaceModelAwareDataHolder- Returns:
- the parent of the current
DataHolder
-
getRootDataHolder
Description copied from interface:DataHolderRetrieves theDataHolderthat is the root of the current one- Specified by:
getRootDataHolderin interfaceDataHolder- Specified by:
getRootDataHolderin interfaceModelAwareDataHolder- Returns:
- the root
DataHolder
-
checkDefinition
Check definition for data path- Parameters:
dataPath- the data patherrorMsg- the error message to throw- Throws:
UndefinedItemPathException- if the definition is not found for the given data path
-
checkDefinition
protected void checkDefinition(String dataPath, boolean checkStatusAvailable, String errorMsg) throws UndefinedItemPathException Check definition for data path- Parameters:
dataPath- the data pathcheckStatusAvailable-trueto check if the definition supports externalizable data statuserrorMsg- the error message to throw- Throws:
UndefinedItemPathException- if the definition is not found for the given data path
-