Package org.ametys.cms.data.type
Class AbstractRichTextElementType
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.model.type.AbstractModelItemType
-
- org.ametys.core.model.type.AbstractElementType<RichText>
-
- org.ametys.cms.data.type.AbstractRichTextElementType
-
- All Implemented Interfaces:
ElementType<RichText>
,ModelItemType
,LogEnabled
,PluginAware
,Component
,Serviceable
- Direct Known Subclasses:
RichTextRepositoryElementType
public abstract class AbstractRichTextElementType extends AbstractElementType<RichText>
Abstract class for rich text type of elements
-
-
Field Summary
Fields Modifier and Type Field Description protected ServiceManager
_manager
Avalon service managerprotected AmetysObjectResolver
_resolver
Ametys object resolverprotected RichTextImportHandlerFactory
_richTextHandlerFactory
Rich text metadata handlerprotected RichTextTransformer
_richTextTransformer
Rich text transformer-
Fields inherited from class org.ametys.core.model.type.AbstractElementType
_jsonUtils
-
-
Constructor Summary
Constructors Constructor Description AbstractRichTextElementType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>>
_compareMultipleValues(RichText[] value1, RichText[] value2)
Compares the given multiple values and retrieves the changes as a stream ofTriple
s.protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>>
_compareSingleValues(RichText value1, RichText value2)
Compares the given single values and retrieves the changes as a stream ofTriple
s.protected ContentHandler
_getLocalMediaObjectContentHandler(ContentHandler contentHandler, DataContext context)
Retrieves the content handler to use to transform local media objectsprotected RichText
_singleValueFromXML(Element element, Optional<Object> additionalData)
Retrieves a single typed value from the given DOM nodeprotected Object
_singleValueToJSON(RichText value, DataContext context)
Convert the single value into a JSON objectprotected Object
_singleValueToJSONForEdition(RichText value, DataContext context)
Convert the single value into a JSON object to use in edition modeprotected void
_singleValueToSAX(ContentHandler contentHandler, String tagName, RichText richText, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes)
Generates SAX events for the given single valueprotected void
_valueToSAXForEdition(ContentHandler contentHandler, String tagName, Object value, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes)
Generates SAX events for the given value in edition mode.RichText
convertValue(Object value)
Try to convert the given value, that is not of the managed typeObject
fromJSONForClient(Object json, DataContext context)
Convert the given client side JSON object to the types valueboolean
isSimple()
Determines if this type is simple or not.void
service(ServiceManager manager)
String
toString(RichText value)
Cast a typed value to a String-
Methods inherited from class org.ametys.core.model.type.AbstractElementType
_getValueAttributes, _isMultiple, _isSingle, _isValueFromXMLMultiple, _useJSONForEdition, _valueToJSON, _valueToSAX, _valueToSAX, castValue, compareValues, getManagedClass, getManagedClassArray, isCompatible, parseConfiguration, valueFromXML, valueToJSONForClient, valueToJSONForEdition, 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 Detail
-
_richTextTransformer
protected RichTextTransformer _richTextTransformer
Rich text transformer
-
_richTextHandlerFactory
protected RichTextImportHandlerFactory _richTextHandlerFactory
Rich text metadata handler
-
_resolver
protected AmetysObjectResolver _resolver
Ametys object resolver
-
_manager
protected ServiceManager _manager
Avalon service manager
-
-
Constructor Detail
-
AbstractRichTextElementType
public AbstractRichTextElementType()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractElementType<RichText>
- Throws:
ServiceException
-
convertValue
public RichText convertValue(Object value)
Description copied from class:AbstractElementType
Try to convert the given value, that is not of the managed type- Overrides:
convertValue
in classAbstractElementType<RichText>
- Parameters:
value
- the value to convert- Returns:
- the converted value or null if it's not possible.
-
toString
public String toString(RichText value)
Description copied from interface:ElementType
Cast a typed value to a String- Specified by:
toString
in interfaceElementType<RichText>
- Overrides:
toString
in classAbstractElementType<RichText>
- Parameters:
value
- the value to cast- Returns:
- the String representation of the value
-
fromJSONForClient
public Object fromJSONForClient(Object json, DataContext context)
Description copied from interface:ElementType
Convert the given client side JSON object to the types value- Parameters:
json
- the JSON object to convertcontext
- the context of the data to retrieve- Returns:
- the typed value corresponding to the JSON object
-
_singleValueToJSON
protected Object _singleValueToJSON(RichText value, DataContext context)
Description copied from class:AbstractElementType
Convert the single value into a JSON object- Overrides:
_singleValueToJSON
in classAbstractElementType<RichText>
- Parameters:
value
- the value to convertcontext
- The context of the data to convert- Returns:
- The value as JSON
-
_singleValueToJSONForEdition
protected Object _singleValueToJSONForEdition(RichText value, DataContext context)
Description copied from class:AbstractElementType
Convert the single value into a JSON object to use in edition mode- Overrides:
_singleValueToJSONForEdition
in classAbstractElementType<RichText>
- Parameters:
value
- the value to convertcontext
- The context of the data to convert- Returns:
- The value as JSON
-
_singleValueFromXML
protected RichText _singleValueFromXML(Element element, Optional<Object> additionalData)
Description copied from class:AbstractElementType
Retrieves a single typed value from the given DOM node- Overrides:
_singleValueFromXML
in classAbstractElementType<RichText>
- Parameters:
element
- the DOM element containing the single valueadditionalData
- additional data needed to get the typed value- Returns:
- the value
-
_valueToSAXForEdition
protected void _valueToSAXForEdition(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 in edition mode. This default implementation generates SAX event using theAbstractElementType.valueToJSONForClient(Object, DataContext)
method- Overrides:
_valueToSAXForEdition
in classAbstractElementType<RichText>
- 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
-
_singleValueToSAX
protected void _singleValueToSAX(ContentHandler contentHandler, String tagName, RichText richText, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes) throws SAXException
Description copied from class:AbstractElementType
Generates SAX events for the given single value- Overrides:
_singleValueToSAX
in classAbstractElementType<RichText>
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventstagName
- the tag name of the SAX event to generate.richText
- the single 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 event to generate- Throws:
SAXException
- if an error occurs during the SAX events generation
-
_getLocalMediaObjectContentHandler
protected ContentHandler _getLocalMediaObjectContentHandler(ContentHandler contentHandler, DataContext context)
Retrieves the content handler to use to transform local media objects- Parameters:
contentHandler
- the initialContentHandler
context
- The context of the data to SAX- Returns:
- the content handler
-
_compareMultipleValues
protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>> _compareMultipleValues(RichText[] value1, RichText[] 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<RichText>
- 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,String>> _compareSingleValues(RichText value1, RichText 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<RichText>
- 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
public boolean 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- Returns:
true
if the type is simple,false
otherwise
-
-