Interface ModelAwareDataHolder
-
- All Superinterfaces:
DataHolder
- All Known Subinterfaces:
CommentableContent,Content,ModelAwareDataAwareAmetysObject,ModelAwareJCRAmetysObject,ModifiableContent,ModifiableModelAwareDataAwareAmetysObject,ModifiableModelAwareDataHolder,ModifiableWebContent,ModifiableWorkflowAwareContent,ProgramPart,SharedContent,TraversableProgramPart,WebContent,WorkflowAwareContent
- All Known Implementing Classes:
AbstractProgram,AbstractProgramPart,AbstractTraversableProgramPart,Catalog,Container,ContentBackupAmetysObject,ContentValue,Course,CourseList,CoursePart,DefaultContent,DefaultModelAwareDataHolder,DefaultModifiableModelAwareDataHolder,DefaultSharedContent,DefaultWebContent,DefaultWorkflowAwareContent,ModelAwareComposite,ModelAwareRepeaterEntry,ModifiableDefaultContent,ModifiableDefaultWebContent,ModifiableModelAwareComposite,ModifiableModelAwareRepeaterEntry,OrgUnit,Person,Program,Site,SubProgram
public interface ModelAwareDataHolder extends DataHolder
Interface for data containers with models
-
-
Field Summary
Fields Modifier and Type Field Description static StringALTERNATIVE_SUFFIXSuffix used for the alternative valuestatic StringSTATUS_SUFFIXSuffix used for the status value
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voiddataToSAX(ContentHandler contentHandler)Generates SAX events for the data in the model of the currentDataHoldervoiddataToSAX(ContentHandler contentHandler, Locale locale)Generates SAX events for the data in the model of the currentDataHolderdefault voiddataToSAX(ContentHandler contentHandler, ViewItemContainer viewItemContainer)Generates SAX events for the data in the given view in the currentDataHolderdefault voiddataToSAX(ContentHandler contentHandler, ViewItemContainer viewItemContainer, Locale locale)Generates SAX events for the data in the given view in the currentDataHolderModelAwareCompositegetComposite(String compositePath)Retrieves the composite at the given pathCollection<String>getDataNames()Retrieves the names of data contained by this data holder Retrieves only the data at first level, does not check composite dataModelItemgetDefinition(String path)Retrieves the definition of the data at the given pathModelAwareCompositegetExternalComposite(String compositePath)Retrieves the external composite at the given pathModelAwareRepeatergetExternalRepeater(String repeaterPath)Retrieves the external repeater at the given path<T> TgetExternalValue(String dataPath)Retrieves the external value of the data at the given pathModelAwareCompositegetLocalComposite(String compositePath)Retrieves the local composite at the given pathModelAwareRepeatergetLocalRepeater(String repeaterPath)Retrieves the local repeater at the given path<T> TgetLocalValue(String dataPath)Retrieves the local value of the data at the given pathCollection<? extends ModelItemContainer>getModel()Retrieves the data holder's modelModelAwareRepeatergetRepeater(String repeaterPath)Retrieves the repeater at the given pathExternalizableDataProvider.ExternalizableDataStatusgetStatus(String dataPath)Retrieves the status of the externalizable data at the given pathdefault RepositoryModelItemTypegetType(String path)Retrieves the type of the data at the given pathdefault <T> TgetValue(String dataPath)Retrieves the value of the data at the given path<T> TgetValue(String dataPath, boolean allowMultiValuedPathSegments)Retrieves the value of the data at the given path<T> TgetValue(String dataPath, boolean useDefaultFromModel, T defaultValue)Retrieves the value of the data at the given path, or the default value The returned value is one of those ones, in the order: The value of the data if exists and is not empty The default value from the model if useDefaultFromModel istrueand there is a default value defined by the model The given default valuebooleanhasDefinition(String path)Checks if there is a definition at the given pathbooleanhasExternalValue(String dataPath)Checks if there is an external value for the data at the given pathbooleanhasLocalValue(String dataPath)Checks if there is a local value for the data at the given pathbooleanhasValue(String dataPath)Checks if there is a value for the data at the given pathdefault booleanisMultiple(String path)Checks if the definition of the element at the given path is multiple-
Methods inherited from interface org.ametys.plugins.repository.data.holder.DataHolder
copyTo, dataToSAX, dataToSAX, getRepositoryData
-
-
-
-
Field Detail
-
ALTERNATIVE_SUFFIX
static final String ALTERNATIVE_SUFFIX
Suffix used for the alternative value- See Also:
- Constant Field Values
-
STATUS_SUFFIX
static final String STATUS_SUFFIX
Suffix used for the status value- See Also:
- Constant Field Values
-
-
Method Detail
-
getComposite
ModelAwareComposite getComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the composite at the given path- Specified by:
getCompositein interfaceDataHolder- Parameters:
compositePath- path of the composite to retrieve- Returns:
- the composite or
nullif not exists or is empty - Throws:
UndefinedItemPathException- 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 multipleIllegalArgumentException- if the given composite path is null or emptyBadItemTypeException- if the stored value at the given path is not a composite
-
getLocalComposite
ModelAwareComposite getLocalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the local composite at the given path- 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
ModelAwareComposite getExternalComposite(String compositePath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the external composite at the given path- 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
ModelAwareRepeater getRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the repeater at the given path- 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
ModelAwareRepeater getLocalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the local repeater at the given path- 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
ModelAwareRepeater getExternalRepeater(String repeaterPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the external repeater at the given path- 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
-
hasValue
boolean hasValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException
Checks if there is a value for the data at the given path- Specified by:
hasValuein interfaceDataHolder- Parameters:
dataPath- path of the data- Returns:
trueif the data at the given path is defined by the model, if there is a value for the data (even empty) and if the type of this value matches the type of the definition.falseotherwise- Throws:
BadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multipleIllegalArgumentException- if the given data path is null or empty
-
hasLocalValue
boolean hasLocalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException
Checks if there is a local value for the data at the given path- 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
-
hasExternalValue
boolean hasExternalValue(String dataPath) throws IllegalArgumentException, BadDataPathCardinalityException
Checks if there is an external value for the data at the given path- 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
-
getDataNames
Collection<String> getDataNames()
Retrieves 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- Returns:
- the names of the data contained by this data holder and that are defined by the model
-
getValue
default <T> T getValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the value of the data at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the data- Returns:
- the value of the data or
nullif not exists or is empty. The object returned may be of a generic class defined by the storage (if the model is unknown). For example, an url may be returned as a String. - Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the modelBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
getValue
<T> T getValue(String dataPath, boolean allowMultiValuedPathSegments) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the value of the data at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the dataallowMultiValuedPathSegments-trueto allow multi-valued segments in the path (not necessarily at the last segment),falseotherwise. Iftrue, if there is no indicated entry for a repeater, the values of all the entries are retrieved Iftrueand if there are multiple values, all data are retrieved in one array- Returns:
- the value of the data or
nullif managesMutiples isfalseand there is no non empty value. The object returned may be of a generic class defined by the storage (if the model is unknown). For example, an url may be returned as a String. - Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the modelBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueBadDataPathCardinalityException- if the managesMultiples boolean isfalseand the definition of a part of the data path is multiple. Only the last part can be multiple
-
getValue
<T> T getValue(String dataPath, boolean useDefaultFromModel, T defaultValue) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the value of the data at the given path, or the default value The returned value is one of those ones, in the order:- The value of the data if exists and is not empty
- The default value from the model if useDefaultFromModel is
trueand there is a default value defined by the model - The given default value
- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the datauseDefaultFromModel- true to use the default value from the model, false to use the given default valuedefaultValue- default value used if value is null and useDefaultFromModel is false, or if there is no default value on model- Returns:
- the value of the data at the given path
- Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the modelBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
getLocalValue
<T> T getLocalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the local value of the data at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the externalizable data- Returns:
- the local value of the data or
nullif not exists or is empty. The object returned may be of a generic class defined by the storage (if the model is unknown). For example, an url may be returned as a String. - Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the modelBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
getExternalValue
<T> T getExternalValue(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadItemTypeException, BadDataPathCardinalityException
Retrieves the external value of the data at the given path- Type Parameters:
T- type of the value to retrieve- Parameters:
dataPath- path of the externalizable data- Returns:
- the external value of the data or
nullif not exists or is empty. The object returned may be of a generic class defined by the storage (if the model is unknown). For example, an url may be returned as a String. - Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the modelBadItemTypeException- if the type defined by the model doesn't match the type of the stored valueBadDataPathCardinalityException- if the definition of a part of the data path is multiple. Only the last part can be multiple
-
getStatus
ExternalizableDataProvider.ExternalizableDataStatus getStatus(String dataPath) throws IllegalArgumentException, UndefinedItemPathException, BadDataPathCardinalityException
Retrieves the status of the externalizable data at the given path- 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 emptyUndefinedItemPathException- 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
-
isMultiple
default boolean isMultiple(String path) throws IllegalArgumentException, UndefinedItemPathException
Checks if the definition of the element at the given path is multiple- Parameters:
path- path of the element. No matter if it is a definition or data path (with repeater entry positions)- Returns:
trueif the element is multiple,falseotherwise- Throws:
IllegalArgumentException- if the given path is null or emptyUndefinedItemPathException- if the given path is not defined by the model
-
getType
default RepositoryModelItemType getType(String path) throws IllegalArgumentException, UndefinedItemPathException
Retrieves the type of the data at the given path- Parameters:
path- path of the data. No matter if it is a definition or data path (with repeater entry positions)- Returns:
- the type of the data
- Throws:
IllegalArgumentException- if the given data path is null or emptyUndefinedItemPathException- if the given data path is not defined by the model
-
getModel
Collection<? extends ModelItemContainer> getModel()
Retrieves the data holder's model- Returns:
- the data holder's model
-
getDefinition
ModelItem getDefinition(String path) throws IllegalArgumentException, UndefinedItemPathException
Retrieves the definition of the data at the given path- 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
-
hasDefinition
boolean hasDefinition(String path) throws IllegalArgumentException
Checks if there is a definition at the given path- Parameters:
path- path of the data. No matter if it is a definition or data path (with repeater entry positions)- Returns:
trueif there is definition at the given path,falseotherwise- Throws:
IllegalArgumentException- if the given path is null or empty
-
dataToSAX
default void dataToSAX(ContentHandler contentHandler) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the model of the currentDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX events- Throws:
SAXException- if an error occurs during the SAX events generationIOException- if an error occurs while reading a value using the I/O APIBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
void dataToSAX(ContentHandler contentHandler, Locale locale) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the model of the currentDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventslocale- The locale to use for localized data, such asMultilingualString. Can benullto generate SAX events for all existingLocales.- Throws:
SAXException- if an error occurs during the SAX events generationIOException- if an error occurs while reading a value using the I/O APIBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
default void dataToSAX(ContentHandler contentHandler, ViewItemContainer viewItemContainer) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the given view in the currentDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemContainer- theViewItemContainercontaining referencing the model item for which generate SAX events- Throws:
SAXException- if an error occurs during the SAX events generationIOException- if an error occurs while reading a value using the I/O APIBadItemTypeException- if the saxed value's type does not matches the stored data
-
dataToSAX
default void dataToSAX(ContentHandler contentHandler, ViewItemContainer viewItemContainer, Locale locale) throws SAXException, IOException, BadItemTypeException
Generates SAX events for the data in the given view in the currentDataHolder- Parameters:
contentHandler- theContentHandlerthat will receive the SAX eventsviewItemContainer- theViewItemContainercontaining referencing the model item for which generate SAX eventslocale- The locale to use for localized data, such asMultilingualString. Can benullto generate SAX events for all existingLocales.- Throws:
SAXException- if an error occurs during the SAX events generationIOException- if an error occurs while reading a value using the I/O APIBadItemTypeException- if the saxed value's type does not matches the stored data
-
-