Package org.ametys.cms.data.type
Class AbstractFileElementType
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.model.type.AbstractModelItemType
org.ametys.core.model.type.AbstractElementType<File>
org.ametys.cms.data.type.AbstractFileElementType
- All Implemented Interfaces:
ElementType<File>
,ModelItemType
,LogEnabled
,PluginAware
,Component
,Configurable
,Contextualizable
,Serviceable
- Direct Known Subclasses:
FileRepositoryElementType
public abstract class AbstractFileElementType
extends AbstractElementType<File>
implements Configurable, Contextualizable
Abstract class for file type of elements
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
Type of he file from explorerprotected String
Type of the binaryprotected Context
Coocon's contextprotected AmetysObjectResolver
Ametys object resolverprotected UploadManager
protected CurrentUserProvider
Fields inherited from class org.ametys.core.model.type.AbstractElementType
_jsonUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Stream<Triple<DataChangeType,
DataChangeTypeDetail, String>> _compareMultipleValues
(File[] value1, File[] value2) Compares the given multiple values and retrieves the changes as a stream ofTriple
s.protected Stream<Triple<DataChangeType,
DataChangeTypeDetail, String>> _compareSingleValues
(File value1, File value2) Compares the given single values and retrieves the changes as a stream ofTriple
s.protected boolean
_isMultiple
(Object value) Checks if the given value is considered as multiple for this element typeprotected boolean
Checks if the given value is considered as single for this element typeprotected File
_singleValueFromXML
(Element element, Optional<Object> additionalData) Retrieves a single typed value from the given DOM nodeprotected boolean
Determine if the JSON format has to be used in edition mode for this element typeprotected void
_valueToSAX
(ContentHandler contentHandler, String tagName, Object value, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes) Generates SAX events for the given valuevoid
configure
(Configuration configuration) void
contextualize
(Context context) convertValue
(Object value) Try to convert the given value, that is not of the managed typefromJSONForClient
(Object json, DataContext context) Convert the given client side JSON object to the types valueboolean
isCompatible
(Object value) Checks if the value is compatible with the element typeboolean
isSimple()
Determines if this type is simple or not.void
service
(ServiceManager manager) Cast a typed value to a StringvalueToJSONForClient
(Object value, DataContext context) Convert the value into a JSON object to use client sidevalueToJSONForEdition
(Object value, DataContext context) Convert the value into a JSON object to use in edition modeMethods inherited from class org.ametys.core.model.type.AbstractElementType
_getValueAttributes, _isValueFromXMLMultiple, _singleValueToJSON, _singleValueToJSONForEdition, _singleValueToSAX, _valueToJSON, _valueToSAX, _valueToSAXForEdition, castValue, compareValues, getManagedClass, getManagedClassArray, parseConfiguration, valueFromXML, valueToSAX, valueToSAXForEdition
Methods inherited from class org.ametys.core.model.type.AbstractModelItemType
_getContextAttributes, getId, setPluginInfo
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.ametys.runtime.model.type.ModelItemType
getId, valueToSAX
Methods inherited from interface org.ametys.runtime.plugin.component.PluginAware
setPluginInfo
-
Field Details
-
__EXPLORER_FILE_TYPE
Type of he file from explorer- See Also:
-
_resolver
Ametys object resolver -
_binaryType
Type of the binary -
_uploadManager
-
_userProvider
-
_context
Coocon's context
-
-
Constructor Details
-
AbstractFileElementType
public AbstractFileElementType()
-
-
Method Details
-
contextualize
- Specified by:
contextualize
in interfaceContextualizable
- Throws:
ContextException
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractElementType<File>
- Throws:
ServiceException
-
configure
- Specified by:
configure
in interfaceConfigurable
- Throws:
ConfigurationException
-
convertValue
Description copied from class:AbstractElementType
Try to convert the given value, that is not of the managed type- Overrides:
convertValue
in classAbstractElementType<File>
- Parameters:
value
- the value to convert- Returns:
- the converted value or null if it's not possible.
-
toString
Description copied from interface:ElementType
Cast a typed value to a String- Specified by:
toString
in interfaceElementType<File>
- Overrides:
toString
in classAbstractElementType<File>
- Parameters:
value
- the value to cast- Returns:
- the String representation of the value
-
fromJSONForClient
Description copied from interface:ElementType
Convert the given client side JSON object to the types value- Specified by:
fromJSONForClient
in interfaceElementType<File>
- Parameters:
json
- the JSON object to convertcontext
- the context of the data to retrieve- Returns:
- the typed value corresponding to the JSON object
-
valueToJSONForEdition
Description copied from interface:ElementType
Convert the value into a JSON object to use in edition mode- Specified by:
valueToJSONForEdition
in interfaceElementType<File>
- Overrides:
valueToJSONForEdition
in classAbstractElementType<File>
- Parameters:
value
- the value to convertcontext
- The context of the data to convert. Can not be null.- Returns:
- The value as JSON
-
valueToJSONForClient
Description copied from interface:ElementType
Convert the value into a JSON object to use client side- Specified by:
valueToJSONForClient
in interfaceElementType<File>
- Overrides:
valueToJSONForClient
in classAbstractElementType<File>
- Parameters:
value
- the value to convertcontext
- The context of the data to convert. Can not be null.- Returns:
- The value as JSON
-
isCompatible
Description copied from interface:ElementType
Checks if the value is compatible with the element type- Specified by:
isCompatible
in interfaceElementType<File>
- Overrides:
isCompatible
in classAbstractElementType<File>
- Parameters:
value
- the value to check- Returns:
true
if the value matches the current type,false
otherwise
-
_singleValueFromXML
Description copied from class:AbstractElementType
Retrieves a single typed value from the given DOM node- Overrides:
_singleValueFromXML
in classAbstractElementType<File>
- Parameters:
element
- the DOM element containing the single valueadditionalData
- additional data needed to get the typed value- Returns:
- the value
-
_valueToSAX
protected void _valueToSAX(ContentHandler contentHandler, String tagName, Object value, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes) throws SAXException Description copied from class:AbstractElementType
Generates SAX events for the given value- Overrides:
_valueToSAX
in classAbstractElementType<File>
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventstagName
- the tag name of the SAX event to generate.value
- the value to SAXviewItem
- The optional view item corresponding item that is currently saxed. This view item gives context for the SAX event that will be generated here.context
- The context of the data to SAXattributes
- the attributes for the SAX events to generate- Throws:
SAXException
- if an error occurs during the SAX events generation
-
_compareMultipleValues
protected Stream<Triple<DataChangeType,DataChangeTypeDetail, _compareMultipleValuesString>> (File[] value1, File[] value2) Description copied from class:AbstractElementType
Compares the given multiple values and retrieves the changes as a stream ofTriple
s. TheTriple
s contains:- the general type of the change (added, modified or removed) as a
DataChangeType
, - some details about this change if possible (after or before for a date, more or less for a number, ...) as a
DataChangeTypeDetail
- The data concerned by this change if not the element itself (or an empty String)
- Overrides:
_compareMultipleValues
in classAbstractElementType<File>
- Parameters:
value1
- the 1st multiple valuevalue2
- the 2nd multiple value- Returns:
- the changes between the two given multiple values as a stream of
Triple
. Retrieves an empty stream if there is no change
- the general type of the change (added, modified or removed) as a
-
_compareSingleValues
protected Stream<Triple<DataChangeType,DataChangeTypeDetail, _compareSingleValuesString>> (File value1, File value2) Description copied from class:AbstractElementType
Compares the given single values and retrieves the changes as a stream ofTriple
s. TheTriple
contains:- the general type of the change (added, modified or removed) as a
DataChangeType
, - some details about this change if possible (after or before for a date, more or less for a number, ...) as a
DataChangeTypeDetail
- The data concerned by this change if not the element itself (or an empty String)
- Overrides:
_compareSingleValues
in classAbstractElementType<File>
- Parameters:
value1
- the 1st single valuevalue2
- the 2nd single value- Returns:
- the changes between the two given single values as a stream of
Triple
. Retrieves an empty stream if there is no change
- the general type of the change (added, modified or removed) as a
-
isSimple
Description copied from interface:ElementType
Determines if this type is simple or not. A simple element type is a type of elements that can be edited in a grid- Specified by:
isSimple
in interfaceElementType<File>
- Returns:
true
if the type is simple,false
otherwise
-
_useJSONForEdition
Description copied from class:AbstractElementType
Determine if the JSON format has to be used in edition mode for this element type- Overrides:
_useJSONForEdition
in classAbstractElementType<File>
- Returns:
true
if the JSON format has to be used,false
otherwise
-
_isMultiple
Description copied from class:AbstractElementType
Checks if the given value is considered as multiple for this element type- Overrides:
_isMultiple
in classAbstractElementType<File>
- Parameters:
value
- the value to check- Returns:
true
if the value is multiple,false
otherwise
-
_isSingle
Description copied from class:AbstractElementType
Checks if the given value is considered as single for this element type- Overrides:
_isSingle
in classAbstractElementType<File>
- Parameters:
value
- the value to check- Returns:
true
if the value is single,false
otherwise
-