Package org.ametys.cms.data.type
Class AbstractReferenceElementType
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.core.model.type.AbstractModelItemType
-
- org.ametys.core.model.type.AbstractElementType<Reference>
-
- org.ametys.cms.data.type.AbstractReferenceElementType
-
- All Implemented Interfaces:
ElementType<Reference>
,ModelItemType
,LogEnabled
,PluginAware
,Component
,Serviceable
- Direct Known Subclasses:
ReferenceRepositoryElementType
public abstract class AbstractReferenceElementType extends AbstractElementType<Reference>
Abstract class for reference type of elements
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
__SEPARATOR
The separator between the type and the value for the string representation of a reference-
Fields inherited from class org.ametys.core.model.type.AbstractElementType
_jsonUtils
-
-
Constructor Summary
Constructors Constructor Description AbstractReferenceElementType()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>>
_compareMultipleValues(Reference[] value1, Reference[] value2)
Compares the given multiple values and retrieves the changes as a stream ofTriple
s.protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>>
_compareSingleValues(Reference value1, Reference value2)
Compares the given single values and retrieves the changes as a stream ofTriple
s.private Reference
_json2Reference(Map<String,Object> json)
protected Reference
_singleValueFromXML(Element element, Optional<Object> additionalData)
Retrieves a single typed value from the given DOM nodeprotected Object
_singleValueToJSON(Reference value, DataContext context)
Convert the single value into a JSON objectprotected void
_singleValueToSAX(ContentHandler contentHandler, String tagName, Reference value, Optional<ViewItem> viewItem, DataContext context, AttributesImpl attributes)
Generates SAX events for the given single valueprotected boolean
_useJSONForEdition()
Determine if the JSON format has to be used in edition mode for this element typeReference
convertValue(Object value)
Try to convert the given value.Object
fromJSONForClient(Object json)
Convert the given client side JSON object to the types valueboolean
isSimple()
Determines if this type is simple or not.String
toString(Reference value)
Cast a typed value to a String-
Methods inherited from class org.ametys.core.model.type.AbstractElementType
_getValueAttributes, _isValueFromXMLMultiple, _valueToSAX, _valueToSAX, _valueToSAXForEdition, castValue, compareValues, getManagedClass, getManagedClassArray, isCompatible, parseConfiguration, service, valueFromXML, valueToJSONForClient, 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
-
__SEPARATOR
protected static final String __SEPARATOR
The separator between the type and the value for the string representation of a reference- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractReferenceElementType
public AbstractReferenceElementType()
-
-
Method Detail
-
convertValue
public Reference convertValue(Object value)
Description copied from class:AbstractElementType
Try to convert the given value.- Overrides:
convertValue
in classAbstractElementType<Reference>
- Parameters:
value
- the value to convert- Returns:
- the converted value or null if it's not possible.
-
toString
public String toString(Reference value)
Description copied from interface:ElementType
Cast a typed value to a String- Specified by:
toString
in interfaceElementType<Reference>
- Overrides:
toString
in classAbstractElementType<Reference>
- Parameters:
value
- the value to cast- Returns:
- the String representation of the value
-
fromJSONForClient
public Object fromJSONForClient(Object json)
Description copied from interface:ElementType
Convert the given client side JSON object to the types value- Parameters:
json
- the JSON object to convert- Returns:
- the typed value corresponding to the JSON object
-
_json2Reference
private Reference _json2Reference(Map<String,Object> json)
-
_singleValueToJSON
protected Object _singleValueToJSON(Reference value, DataContext context)
Description copied from class:AbstractElementType
Convert the single value into a JSON object- Overrides:
_singleValueToJSON
in classAbstractElementType<Reference>
- Parameters:
value
- the value to convertcontext
- The context of the data to convert- Returns:
- The value as JSON
-
_singleValueFromXML
protected Reference _singleValueFromXML(Element element, Optional<Object> additionalData) throws TransformerException, IOException
Description copied from class:AbstractElementType
Retrieves a single typed value from the given DOM node- Overrides:
_singleValueFromXML
in classAbstractElementType<Reference>
- Parameters:
element
- the DOM element containing the single valueadditionalData
- additional data needed to get the typed value- Returns:
- the value
- Throws:
TransformerException
- if an error occurs while parsing the DOM nodeIOException
- if an error occurs while parsing a value using the I/O API
-
_singleValueToSAX
protected void _singleValueToSAX(ContentHandler contentHandler, String tagName, Reference value, 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<Reference>
- Parameters:
contentHandler
- theContentHandler
that will receive the SAX eventstagName
- the tag name of the SAX event to generate.value
- 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
-
_compareMultipleValues
protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>> _compareMultipleValues(Reference[] value1, Reference[] value2) throws IOException
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<Reference>
- 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 - Throws:
IOException
- if an error occurs while comparing values using the I/O API
- the general type of the change (added, modified or removed) as a
-
_compareSingleValues
protected Stream<Triple<DataChangeType,DataChangeTypeDetail,String>> _compareSingleValues(Reference value1, Reference value2) throws IOException
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<Reference>
- 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 - Throws:
IOException
- if an error occurs while comparing values using the I/O API
- 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
-
_useJSONForEdition
protected boolean _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<Reference>
- Returns:
true
if the JSON format has to be used,false
otherwise
-
-