Package org.ametys.cms.data.holder.impl
Class DefaultIndexableDataHolder
java.lang.Object
org.ametys.plugins.repository.data.holder.impl.DefaultModelAwareDataHolder
org.ametys.cms.data.holder.impl.DefaultIndexableDataHolder
- All Implemented Interfaces:
IndexableDataHolder,DataHolder,ModelAwareDataHolder
public class DefaultIndexableDataHolder
extends DefaultModelAwareDataHolder
implements IndexableDataHolder
Default implementation for indexable data holder.
Extends the repository-level
DefaultModelAwareDataHolder and adds indexable-specific behaviour such as Property and system property support.-
Field Summary
Fields inherited from class org.ametys.plugins.repository.data.holder.impl.DefaultModelAwareDataHolder
_itemContainers, _parent, _repositoryData, _rootFields inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
ALTERNATIVE_SUFFIX, STATUS_SUFFIX -
Constructor Summary
ConstructorsConstructorDescriptionDefaultIndexableDataHolder(RepositoryData repositoryData, Collection<? extends ModelItemContainer> itemContainers, Optional<? extends IndexableDataHolder> parent, Optional<? extends IndexableDataHolder> root) Creates a default indexable data holderDefaultIndexableDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer) Creates a default indexable data holderDefaultIndexableDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer, Optional<? extends IndexableDataHolder> parent, Optional<? extends IndexableDataHolder> root) Creates a default indexable data holder -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckDefinition(String dataPath, boolean checkStatusAvailable, String errorMsg) Check definition for data pathprotected IndexableCompositecreateCompositeInstance(RepositoryData compositeRepositoryData, CompositeDefinition compositeDefinition) Creates an instance of compositeprotected IndexableRepeatercreateRepeaterInstance(RepositoryData repeaterRepositoryData, RepeaterDefinition repeaterDefinition) Creates an instance of repeaterprotected ObjectdataToJSON(ModelItem modelItem, String dataPath, DataContext context) Converts the value of the given model item at the given data path to a JSON-serializable objectprotected voiddataToSAX(ContentHandler contentHandler, ModelItem modelItem, String dataPath, DataContext context) Generates SAX events for the given model item at the given data pathgetComposite(String compositePath) Retrieves the composite at the given pathprotected ClassRetrieves the class of the managed compositesgetDefinition(String path) Retrieves the definition of the data at the given pathprotected <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 pathgetLocalComposite(String compositePath) Retrieves the local composite at the given pathgetLocalRepeater(String repeaterPath) Retrieves the local repeater at the given pathOptional<? extends IndexableDataHolder> 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 ClassRetrieves the class of the managed repeatersprotected ClassRetrieves the class of the managed repeater entriesRetrieves theDataHolderthat is the root of the current oneprotected 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 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 org.ametys.plugins.repository.data.holder.impl.DefaultModelAwareDataHolder
checkDefinition, checkElementDifferences, checkElementDifferencesInRemoveMode, checkStatusDifferences, createSynchronizationContextInstance, dataToJSON, dataToJSON, dataToJSONForEdition, dataToMap, dataToSAX, dataToSAX, dataToSAXForEdition, doesHaveDifferences, doGetDifferences, ensureNonNullItemContainers, getComposite, getCompositeFromValue, getDataNames, getDifferences, getDifferences, getDifferencesInGroup, getExternalValue, getFinalDataName, getGroupValue, getLocalValue, getManagedClass, getModel, getMultipleValues, getRepeater, getRepeaterFromValue, getRepositoryData, getStatus, getValue, getValue, getValueOrDefault, getValueOrDefault, getValueWithMultiValuedPathSegments, hasDefaultValue, hasDifferences, hasDifferences, hasDifferencesInElement, hasDifferencesInGroup, hasExternalValue, hasExternalValueOrEmpty, hasLocalValue, hasLocalValueOrEmpty, hasValue, hasValue, hasValueOrEmpty, hasValueOrEmptyMethods 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, dataToJSON, dataToSAX, dataToSAX, getRepositoryData, getValue, getValueOrDefault, hasValue, hasValueOrEmptyMethods inherited from interface org.ametys.plugins.repository.data.holder.ModelAwareDataHolder
dataToJSON, dataToJSON, dataToJSON, dataToJSON, dataToJSONForEdition, dataToMap, dataToMap, dataToMap, dataToMap, dataToSAX, dataToSAX, dataToSAX, dataToSAX, dataToSAXForEdition, getDataNames, getDifferences, getDifferences, getDifferences, getDifferences, getExternalValue, getLocalValue, getModel, getModelItemTypeExtensionPoint, getStatus, getType, getValueOfType, getValueOfTypeOrDefault, getValueOrDefault, getValueWithMultiValuedPathSegments, hasDefinition, hasDifferences, hasDifferences, hasDifferences, hasDifferences, hasExternalValue, hasExternalValueOrEmpty, hasLocalValue, hasLocalValueOrEmpty, hasValue, isMultiple, isMultiple
-
Constructor Details
-
DefaultIndexableDataHolder
Creates a default indexable 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.
-
DefaultIndexableDataHolder
public DefaultIndexableDataHolder(RepositoryData repositoryData, ModelItemContainer itemContainer, Optional<? extends IndexableDataHolder> parent, Optional<? extends IndexableDataHolder> root) Creates a default indexable 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 rootIndexableDataHolder
-
DefaultIndexableDataHolder
public DefaultIndexableDataHolder(RepositoryData repositoryData, Collection<? extends ModelItemContainer> itemContainers, Optional<? extends IndexableDataHolder> parent, Optional<? extends IndexableDataHolder> root) Creates a default indexable 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 optional parent of the createdDataHolder, empty if the createdDataHolderis the rootDataHolderroot- the rootIndexableDataHolder
-
-
Method Details
-
getComposite
public IndexableComposite 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 interfaceIndexableDataHolder- Specified by:
getCompositein interfaceModelAwareDataHolder- Overrides:
getCompositein classDefaultModelAwareDataHolder- 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 IndexableComposite getLocalComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the local composite at the given path- Specified by:
getLocalCompositein interfaceIndexableDataHolder- Specified by:
getLocalCompositein interfaceModelAwareDataHolder- Overrides:
getLocalCompositein classDefaultModelAwareDataHolder- 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 IndexableComposite getExternalComposite(String compositePath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the external composite at the given path- Specified by:
getExternalCompositein interfaceIndexableDataHolder- Specified by:
getExternalCompositein interfaceModelAwareDataHolder- Overrides:
getExternalCompositein classDefaultModelAwareDataHolder- 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
-
getRepeater
public IndexableRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the repeater at the given path- Specified by:
getRepeaterin interfaceIndexableDataHolder- Specified by:
getRepeaterin interfaceModelAwareDataHolder- Overrides:
getRepeaterin classDefaultModelAwareDataHolder- 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 IndexableRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the local repeater at the given path- Specified by:
getLocalRepeaterin interfaceIndexableDataHolder- Specified by:
getLocalRepeaterin interfaceModelAwareDataHolder- Overrides:
getLocalRepeaterin classDefaultModelAwareDataHolder- 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 IndexableRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, BadItemTypeException, UndefinedItemPathException, BadDataPathCardinalityException Description copied from interface:ModelAwareDataHolderRetrieves the external repeater at the given path- Specified by:
getExternalRepeaterin interfaceIndexableDataHolder- Specified by:
getExternalRepeaterin interfaceModelAwareDataHolder- Overrides:
getExternalRepeaterin classDefaultModelAwareDataHolder- 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
-
hasValueForName
protected boolean hasValueForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Description copied from class:DefaultModelAwareDataHolderChecks if there is a non-empty value for the given simple data name (no path separator) with the given externalizable status- Overrides:
hasValueForNamein classDefaultModelAwareDataHolder- 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
-
hasValueOrEmptyForName
protected boolean hasValueOrEmptyForName(String dataName, Optional<ExternalizableDataProvider.ExternalizableDataStatus> status) Description copied from class:DefaultModelAwareDataHolderChecks if there is a value (possibly empty) for the given simple data name (no path separator) with the given externalizable status- Overrides:
hasValueOrEmptyForNamein classDefaultModelAwareDataHolder- 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
-
getElementValue
Description copied from class:DefaultModelAwareDataHolderRetrieves the value of the given element definition- Overrides:
getElementValuein classDefaultModelAwareDataHolder- 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
-
createCompositeInstance
protected IndexableComposite createCompositeInstance(RepositoryData compositeRepositoryData, CompositeDefinition compositeDefinition) Description copied from class:DefaultModelAwareDataHolderCreates an instance of composite- Overrides:
createCompositeInstancein classDefaultModelAwareDataHolder- Parameters:
compositeRepositoryData- the repository data of the composite to createcompositeDefinition- the definition of the composite to create- Returns:
- the created composite instance
-
createRepeaterInstance
protected IndexableRepeater createRepeaterInstance(RepositoryData repeaterRepositoryData, RepeaterDefinition repeaterDefinition) Description copied from class:DefaultModelAwareDataHolderCreates an instance of repeater- Overrides:
createRepeaterInstancein classDefaultModelAwareDataHolder- Parameters:
repeaterRepositoryData- the repository data of the repeater to createrepeaterDefinition- the definition of the repeater to create- Returns:
- the created repeater instance
-
getCompositeClass
Description copied from class:DefaultModelAwareDataHolderRetrieves the class of the managed composites- Overrides:
getCompositeClassin classDefaultModelAwareDataHolder- Returns:
- the class of the managed composites
-
getRepeaterClass
Description copied from class:DefaultModelAwareDataHolderRetrieves the class of the managed repeaters- Overrides:
getRepeaterClassin classDefaultModelAwareDataHolder- Returns:
- the class of the managed repeaters
-
getRepeaterEntryClass
Description copied from class:DefaultModelAwareDataHolderRetrieves the class of the managed repeater entries- Overrides:
getRepeaterEntryClassin classDefaultModelAwareDataHolder- Returns:
- the class of the managed repeater entries
-
getDefinition
public ModelItem getDefinition(String path) throws IllegalArgumentException, UndefinedItemPathException Description copied from interface:ModelAwareDataHolderRetrieves the definition of the data at the given path- Specified by:
getDefinitionin interfaceModelAwareDataHolder- Parameters:
path- path of the data. No matter if it is a definition or data path (with repeater entry positions)- Returns:
- the definition of the data
- Throws:
IllegalArgumentException- if the given path is null or emptyUndefinedItemPathException- if the given path is not defined by the model
-
dataToSAX
protected void dataToSAX(ContentHandler contentHandler, ModelItem modelItem, String dataPath, DataContext context) throws SAXException, BadItemTypeException Description copied from class:DefaultModelAwareDataHolderGenerates SAX events for the given model item at the given data path- Overrides:
dataToSAXin classDefaultModelAwareDataHolder- 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
-
dataToJSON
protected Object dataToJSON(ModelItem modelItem, String dataPath, DataContext context) throws BadItemTypeException Description copied from class:DefaultModelAwareDataHolderConverts the value of the given model item at the given data path to a JSON-serializable object- Overrides:
dataToJSONin classDefaultModelAwareDataHolder- 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
-
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 interfaceIndexableDataHolder- Specified by:
getParentDataHolderin interfaceModelAwareDataHolder- Overrides:
getParentDataHolderin classDefaultModelAwareDataHolder- 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 interfaceIndexableDataHolder- Specified by:
getRootDataHolderin interfaceModelAwareDataHolder- Overrides:
getRootDataHolderin classDefaultModelAwareDataHolder- Returns:
- the root
DataHolder
-
checkDefinition
Description copied from class:DefaultModelAwareDataHolderCheck definition for data path- Overrides:
checkDefinitionin classDefaultModelAwareDataHolder- Parameters:
dataPath- the data pathcheckStatusAvailable-trueto check if the definition supports externalizable data statuserrorMsg- the error message to throw
-