Class RepositoryScriptHelper
java.lang.Object
org.ametys.plugins.repository.script.RepositoryScriptHelper
Helper methods to manipulate some objects in the script tool. Arrays and lists are not managed the same way depending of JS engine used in the JVM.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
convertSingleToMultipleProperty
(javax.jcr.Node node, String propertyName) Helper to convert a single-valued property to a multi-valued property.static void
setModelAwareValue
(ModifiableModelAwareDataHolder dataHolder, String name, Object value) Set the value of aModifiableModelAwareDataHolder
.static void
setModelLessValue
(ModifiableModelLessDataHolder dataHolder, String name, Object value, String type) Set the value of aModifiableModelLessDataHolder
.static void
setProperty
(javax.jcr.Node node, String name, Object values) Helper to set ambiguous object values from a node property
-
Method Details
-
setProperty
public static void setProperty(javax.jcr.Node node, String name, Object values) throws javax.jcr.RepositoryException Helper to set ambiguous object values from a node property- Parameters:
node
- the nodename
- the property namevalues
- the property values as String[] or Value[]- Throws:
javax.jcr.RepositoryException
- if an error occurred
-
convertSingleToMultipleProperty
public static boolean convertSingleToMultipleProperty(javax.jcr.Node node, String propertyName) throws javax.jcr.RepositoryException Helper to convert a single-valued property to a multi-valued property. This helper checks that property exists and that it is not already multiple.- Parameters:
node
- the node holding the propertypropertyName
- the property's name- Returns:
- true if changes was made
- Throws:
javax.jcr.RepositoryException
- if an error occurred
-
setModelLessValue
public static void setModelLessValue(ModifiableModelLessDataHolder dataHolder, String name, Object value, String type) Set the value of aModifiableModelLessDataHolder
. If a multiple value is provided as aList
instead of an array, this method will try to convert it into an array based on the availableElementType
of theDataHolder
.- Parameters:
dataHolder
- the data holder to updatename
- the attribute name to updatevalue
- the valuetype
- the type of the data
-
setModelAwareValue
public static void setModelAwareValue(ModifiableModelAwareDataHolder dataHolder, String name, Object value) Set the value of aModifiableModelAwareDataHolder
. If a multiple value is provided as aList
instead of an array, this method will try to convert it into an array based on the managed class of the type of data at path name.- Parameters:
dataHolder
- the data holder to updatename
- the attribute name to updatevalue
- the value
-