Class BeCPGSpelFunctions.BeCPGSpelFunctionsWrapper

java.lang.Object
fr.becpg.repo.formulation.spel.BeCPGSpelFunctions.BeCPGSpelFunctionsWrapper
Enclosing class:
BeCPGSpelFunctions

public class BeCPGSpelFunctions.BeCPGSpelFunctionsWrapper extends Object
  • Field Details

  • Constructor Details

    • BeCPGSpelFunctionsWrapper

      public BeCPGSpelFunctionsWrapper(RepositoryEntity entity)
  • Method Details

    • entity

      public RepositoryEntity entity()
      Helper @beCPG.entity()
      Returns:
      current entity
    • findOne

      public RepositoryEntity findOne(org.alfresco.service.cmr.repository.NodeRef nodeRef)
      Helper @beCPG.findOne($nodeRef) Example : @beCPG.findOne(nodeRef).qty
      Parameters:
      nodeRef -
      Returns:
      repository entity for nodeRef
    • propValue

      public Serializable propValue(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname)
      Helper @beCPG.propValue($nodeRef, $qname) Example : @beCPG.propValue(nodeRef,'bcpg:productQty')
      Parameters:
      nodeRef -
      qname -
      Returns:
      node property value
    • propValue

      public Serializable propValue(RepositoryEntity item, String qname)
      Helper @beCPG.propValue($entity, $qname)
      Parameters:
      item -
      qname -
      Returns:
      entity property value
    • propValue

      public Serializable propValue(String qname)
      Helper @beCPG.propValue( $qname)
      Parameters:
      qname -
      Returns:
      property value in current entity
    • setValue

      public Serializable setValue(RepositoryEntity item, String qname, Serializable value)
      Helper @beCPG.setValue($entity, $qname, $value) Set property value on entity
      Parameters:
      item -
      qname -
      value -
      Returns:
      value being set
    • setValue

      public Serializable setValue(String qname, Serializable value)
      Helper @beCPG.setValue( $qname, $value) Set property value on current entity
      Parameters:
      qname -
      value -
      Returns:
      value being set
    • propMLValue

      public String propMLValue(org.alfresco.service.cmr.repository.MLText mlText, String locale)
      Helper @beCPG.propMLValue($mltext, $locale) Get the value of an MLText for the given locale.
      Parameters:
      mlText - the multilingual text
      locale - the locale string (e.g. "en", "fr_FR")
      Returns:
      the localized value, or the closest available value if none exists
    • propMLValue

      public Serializable propMLValue(String qname)
      Helper @beCPG.propMLValue($qname) Get the property value as an MLText.
      Parameters:
      qname - property qualified name (string form)
      Returns:
      the property value (expected to be MLText) or null if not found
    • propMLValue

      public Serializable propMLValue(String qname, String locale)
      Helper @beCPG.propMLValue($qname, $locale) Get the localized value of a property.
      Parameters:
      qname - property qualified name (string form)
      locale - the locale string
      Returns:
      the localized property value, or null if none
    • propMLValue

      public Serializable propMLValue(RepositoryEntity item, String qname)
      Helper @beCPG.propMLValue($entity, $qname) Get the multilingual property value for a given entity.
      Parameters:
      item - repository entity
      qname - property qualified name (string form)
      Returns:
      the property value (expected to be MLText), or null if not found
    • propMLValue

      public Serializable propMLValue(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname)
      Helper @beCPG.propMLValue($nodeRef, $qname) Get the multilingual property value for a given node.
      Parameters:
      nodeRef - Alfresco node reference
      qname - property qualified name (string form)
      Returns:
      the property value (expected to be MLText), or null if not found
    • propMLValue

      public Serializable propMLValue(RepositoryEntity item, String qname, String locale)
      Helper @beCPG.propMLValue($entity, $qname, $locale) Get the localized value of a property for the given entity.
      Parameters:
      item - repository entity
      qname - property qualified name (string form)
      locale - locale string (e.g. "en", "fr_FR")
      Returns:
      the localized value, or null if not found
    • propMLValue

      public Serializable propMLValue(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname, String locale)
      Helper @beCPG.propMLValue($nodeRef, $qname, $locale) Get the localized value of a property for the given node.
      Parameters:
      nodeRef - Alfresco node reference
      qname - property qualified name (string form)
      locale - locale string (e.g. "en", "fr_FR")
      Returns:
      the localized value, or null if not found
    • propMLConstraint

      public String propMLConstraint(String value, String propQName, String locale)
      Helper @beCPG.propMLConstraint($value, $qname, $locale) Translate a property constraint value into a localized label if possible.
      Parameters:
      value - the raw property value
      propQName - property qualified name (string form)
      locale - locale string
      Returns:
      the localized display label if found, otherwise the raw value
    • updateMLText

      public org.alfresco.service.cmr.repository.MLText updateMLText(org.alfresco.service.cmr.repository.MLText mlText, String locale, String value)
      Helper @beCPG.updateMLText($mltext, $locale, $value) Update or remove the localized value inside an MLText.
      Parameters:
      mlText - the multilingual text to update (can be null)
      locale - the locale string
      value - the new value (if null or empty, the locale entry is removed)
      Returns:
      the updated MLText
    • setMLValue

      public String setMLValue(RepositoryEntity item, String qname, String locale, String value)
      Set the localized property value for the given entity.
      Parameters:
      item - repository entity
      qname - property qualified name (string form)
      locale - locale string
      value - value to set
      Returns:
      the value being set
    • setMLValue

      public String setMLValue(String qname, String locale, String value)
      Set the localized property value for the default entity.
      Parameters:
      qname - property qualified name (string form)
      locale - locale string
      value - value to set
      Returns:
      the value being set
    • setAssocs

      public void setAssocs(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname, List<org.alfresco.service.cmr.repository.NodeRef> assocNodeRefs)
      Helper @beCPG.setAssocs($nodeRef, $qname, $assocNodeRefs)
      Parameters:
      nodeRef -
      qname -
      assocNodeRefs -
    • setAssocs

      public void setAssocs(RepositoryEntity entity, String qname, List<org.alfresco.service.cmr.repository.NodeRef> assocNodeRefs)
    • setAssocs

      public void setAssocs(String qname, List<org.alfresco.service.cmr.repository.NodeRef> assocNodeRefs)
    • setAssoc

      public void setAssoc(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname, org.alfresco.service.cmr.repository.NodeRef assocNodeRef)
      Helper {@code @beCPG.setAssoc($nodeRef, $qname, $assocNodeRef)}
      Parameters:
      nodeRef -
      qname -
      assocNodeRef -
    • setAssoc

      public void setAssoc(String qname, org.alfresco.service.cmr.repository.NodeRef assocNodeRef)
    • setAssoc

      public void setAssoc(RepositoryEntity entity, String qname, org.alfresco.service.cmr.repository.NodeRef assocNodeRef)
    • assocValue

      public org.alfresco.service.cmr.repository.NodeRef assocValue(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname)
      Helper @beCPG.assocValue($nodeRef, $qname)
      Parameters:
      nodeRef -
      qname -
      Returns:
      association nodeRef
    • assocValue

      public org.alfresco.service.cmr.repository.NodeRef assocValue(String qname)
    • assocValue

      public org.alfresco.service.cmr.repository.NodeRef assocValue(RepositoryEntity entity, String qname)
    • assocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocValues(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname)
      Helper @beCPG.assocValues($entity, $qname)
      Parameters:
      nodeRef -
      qname -
      Returns:
      collection of association nodeRefs
    • assocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocValues(RepositoryEntity entity, String qname)
    • assocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocValues(String qname)
    • sourcesAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> sourcesAssocValues(org.alfresco.service.cmr.repository.NodeRef nodeRef, String qname)
      Helper @beCPG.sourcesAssocValues($nodeRef, $qname)
      Parameters:
      nodeRef -
      qname -
      Returns:
      association nodeRef
    • sourcesAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> sourcesAssocValues(RepositoryEntity entity, String qname)
    • sourcesAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> sourcesAssocValues(String qname)
    • assocPropValues

      public List<Serializable> assocPropValues(org.alfresco.service.cmr.repository.NodeRef nodeRef, String assocQname, String propQName)
      Helper @beCPG.assocPropValues($nodeRef, $assocQname, $propQName)
      Parameters:
      nodeRef -
      assocQname -
      propQName -
      Returns:
      collection of association property values
    • assocPropValues

      public List<Serializable> assocPropValues(RepositoryEntity entity, String assocQname, String propQName)
    • assocPropValues

      public List<Serializable> assocPropValues(String assocQname, String propQName)
    • assocAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocAssocValues(org.alfresco.service.cmr.repository.NodeRef nodeRef, String assocQname, String assocAssocQName)
      Helper @beCPG.assocAssocValues($nodeRef, $assocQname, $assocAssocQName)
      Parameters:
      nodeRef -
      assocAssocQName -
      Returns:
      collection of association association values
    • assocAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocAssocValues(RepositoryEntity entity, String assocQname, String assocAssocQName)
    • assocAssocValues

      public List<org.alfresco.service.cmr.repository.NodeRef> assocAssocValues(String assocQname, String assocAssocQName)
    • assocPropValue

      public Serializable assocPropValue(org.alfresco.service.cmr.repository.NodeRef nodeRef, String assocQname, String propQName)
      Helper @beCPG.assocPropValue($nodeRef, $assocQname, $propQName) Example : var val = @beCPG.assocPropValue(nodeRef, "bcpg:geoOrigin", "bcpg:isoCode"); #val!=null ? @beCPG.setValue($nodeRef, "cm:title", @beCPG.assocPropValue("bcpg:geoOrigin", "bcpg:isoCode")) : "";  or @beCPG.setValue("cm:title", @beCPG.assocPropValue("bcpg:geoOrigin", "bcpg:isoCode"))
      Parameters:
      nodeRef -
      assocQname -
      propQName -
      Returns:
      value of association property
    • assocPropValue

      public Serializable assocPropValue(String assocQname, String propQName)
    • findDuplicates

      public <T> Set<T> findDuplicates(Collection<? extends T> collection)
      Helper @beCPG.findDuplicates($collection)
      Returns:
      Set of duplicates
    • removeDuplicates

      public <T> List<T> removeDuplicates(Collection<? extends T> collection)
      Helper @beCPG.removeDuplicates($collection)
      Returns:
      Remove duplicates on the collection
    • getQName

      public org.alfresco.service.namespace.QName getQName(String qName)
      Helper @beCPG.getQName($qname)
      Parameters:
      qName -
      Returns:
      QName from string
    • runScript

      public void runScript(String scriptNode)
      @beCPG.runScript($nodeRef)
      Parameters:
      scriptNode -
    • runScript

      public void runScript(org.alfresco.service.cmr.repository.NodeRef scriptNode)
    • sum

      public Double sum(Collection<RepositoryEntity> range, String formula)
       @beCPG.sum($range, $formula)
      
                          Example :
       @beCPG.sum(compoListView.compoList.?[parent ==
                                                   null],"entity.costList[0].value
                                                   + dataListItem.qty")
       @beCPG.sum(compoListView.compoList.?[parent ==
                                                   null],"@beCPG.propValue(dataListItem.nodeRef,'bcpg:compoListQty')")
       
      Parameters:
      range -
      formula -
      Returns:
      sum of formula results apply on range
    • sum

      public Double sum(Collection<Double> range)
      @beCPG.sum($range)
      Parameters:
      range -
      Returns:
      sum range of double
    • avg

      public Double avg(Collection<RepositoryEntity> range, String formula)
      @beCPG.avg($range, $formula)
      Parameters:
      range -
      formula -
      Returns:
      average of formula results apply on range
    • avg

      public Double avg(Collection<Double> range)
      @beCPG.avg($range)
      Parameters:
      range -
      Returns:
      average range of double
    • max

      public Double max(Collection<RepositoryEntity> range, String formula)
      @beCPG.max($range, $formula)
      Parameters:
      range -
      formula -
      Returns:
      get max of formula results apply on range
    • max

      public Double max(Collection<Double> range)
      @beCPG.max($range)
      Parameters:
      range -
      Returns:
      get max of range of double
    • join

      public String join(String pattern, List<String> range)
      @beCPG.join($pattern, $range)
      Parameters:
      pattern -
      range -
      Returns:
      get join from pattern and range
    • join

      public String join(String pattern, List<String> range1, List<String> range2)
      @beCPG.join($pattern, $range) @beCPG.join($pattern, $range1, $range2)
      Parameters:
      pattern -
      range1 -
      range2 -
      Returns:
      get join from pattern and ranges
    • min

      public Double min(Collection<RepositoryEntity> range, String formula)
      @beCPG.min($range, $formula)
      Parameters:
      range -
      formula -
      Returns:
      get min of formula results apply on range
    • min

      public Double min(Collection<Double> range)
      @beCPG.min($range)
      Parameters:
      range -
      Returns:
      get min of range of double
    • extractCustomList

      public Collection<RepositoryEntity> extractCustomList(org.alfresco.service.cmr.repository.NodeRef nodeRef, String listType)
      @beCPG.extractCustomList($nodeRef, $listType) @param listType
      Returns:
      list
    • extractCustomList

      public Collection<RepositoryEntity> extractCustomList(String listType)
      @beCPG.extractCustomList($listType) @param listType
      Returns:
      list
    • saveCustomList

      public void saveCustomList(Collection<RepositoryEntity> range)
      @beCPG.saveCustomList($range)
      Parameters:
      range -
    • applyFormulaToList

      public void applyFormulaToList(Collection<RepositoryEntity> range, String formula)
      @beCPG.applyFormulaToList($range, $formula)
      Parameters:
      range -
      formula -
    • filter

      public <T> Collection<T> filter(Collection<T> range, String formula)
      Helper @beCPG.filter($range, formula)
      Parameters:
      range -
      formula -
      Returns:
      filter collection with spel formula
    • replaceByFormula

      public <T> Collection<T> replaceByFormula(Collection<T> range, String formula)
      Helper @beCPG.replaceByFormula($rangeR, formula)
      Parameters:
      range -
      formula -
      Returns:
      for each item return a new item based on formula
    • groupingByFormula

      public <T> Map<Object,List<T>> groupingByFormula(Collection<T> range, String groupingFormula)
      Helper @beCPG.groupingByFormula($range, groupingFormula)
      Parameters:
      range -
      groupingFormula -
      Returns:
      group the list by formula
    • filterByAssoc

      public List<org.alfresco.service.cmr.repository.NodeRef> filterByAssoc(Collection<org.alfresco.service.cmr.repository.NodeRef> range, String assocName, Collection<org.alfresco.service.cmr.repository.NodeRef> values)
      Helper @beCPG.filterByAssoc($range, $assocQname, $values)
      Parameters:
      range -
      assocName -
      values -
      Returns:
      filter nodeRef collection by assoc values
    • getOrDefault

      public <T> T getOrDefault(List<T> range, int index, T defaultValue)
      Helper @beCPG.getOrDefault($range, $index, $defaultValue)
      Parameters:
      range -
      index -
      defaultValue -
      Returns:
      defaultValue id list index doesn't exists
    • children

      public <T> Collection<CompositeDataItem<T>> children(CompositeDataItem<T> parent, Collection<CompositeDataItem<T>> compositeList)
      Helper @beCPG.children($parent, $compositeList)
      Parameters:
      parent -
      compositeList -
      Returns:
      children of parent item
    • formatNumber

      public String formatNumber(Number number)
      Helper @beCPG.formatNumber($number)
      Parameters:
      number -
      Returns:
      standard becpg number format
    • formatNumber

      public String formatNumber(Number number, String format)
      Helper @beCPG.formatNumber($number, $format ) Example:@beCPG.formatNumber(10.00005d, "0.##")
      Parameters:
      number -
      format -
      Returns:
      formated number to provided format
    • formatDate

      public String formatDate(Date date)
      Helper @beCPG.formatDate($date ) Example: @beCPG.formatDate(new java.util.Date() )
      Parameters:
      date -
      Returns:
      standard becpg date format
    • formatDate

      public String formatDate(Date date, String format)
      @beCPG.formatDate($date, $format ) Example: @beCPG.formatDate(new java.util.Date(),"dd/mm/YYYY" )
      Parameters:
      date -
      Returns:
      standard becpg number format
    • updateDate

      public Date updateDate(Date date, int field, int amount)
      @beCPG.updateDate($date, $field, $amount ) Example: @beCPG.updateDate(new java.util.Date(), java.util.Calendar.DAY_OF_MONTH, -5 ) cf Calendar JavaDoc
      Parameters:
      date -
      Returns:
      date
    • interpolate

      public Double interpolate(Double val, List<Double> values, List<Double> thresholds)
      @beCPG.interpolate($val, $values, $thresholds) Example: @beCPG.interpolate(0.05, List.of(10.0, 8.0, 6.0, 4.0, 2.0, 0.0), List.of(0.0, 0.0001, 0.001, 0.01, 0.1, 1.0)) This function performs linear interpolation based on a list of threshold values and their corresponding output values. The thresholds can be in ascending or descending order.
      Parameters:
      val - the input value to be interpolated
      values - the list of output values corresponding to each threshold
      thresholds - the list of input thresholds defining the interpolation ranges
      Returns:
      the interpolated value for the given input val
      Throws:
      IllegalArgumentException - if the sizes of values and thresholds do not match, or if thresholds are constant (which would lead to division by zero)
      IllegalStateException - if interpolation cannot be performed due to invalid inputs
    • copy

      public void copy(org.alfresco.service.cmr.repository.NodeRef fromNodeRef, Collection<String> propQNames, Collection<String> listQNames)
      Helper @beCPG.copy($fromNodeRef, $propQNames, $listQNames) Copy properties from an entity to current entity Example: @beCPG.copy(compoListView.compoList[0].product,{"bcpg:suppliers","bcpg:legalName"},{"bcpg:costList"}); Example: @beCPG.copy(compoListView.compoList[0].product,{"bcpg:suppliers","bcpg:legalName"},{"bcpg:costList|true"}); // Force full copy of costList
      Parameters:
      fromNodeRef -
      propQNames -
      listQNames -
    • copy

      public void copy(RepositoryEntity from, Collection<String> propQNames, Collection<String> listQNames)
    • copy

      public void copy(RepositoryEntity to, RepositoryEntity from, Collection<String> propQNames, Collection<String> listQNames)
    • copyLists

      private void copyLists(RepositoryEntity to, RepositoryEntity from, Collection<String> listQNames, Set<org.alfresco.service.namespace.QName> treatedList, boolean force)
    • copyEntityProperties

      public void copyEntityProperties(RepositoryEntity to, RepositoryEntity from, Collection<String> listQNames, Collection<String> propQNames, Set<org.alfresco.service.namespace.QName> treatedProp, Set<org.alfresco.service.namespace.QName> treatedList) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
      Throws:
      IllegalAccessException
      InvocationTargetException
      NoSuchMethodException
    • handleList

      private void handleList(org.alfresco.service.namespace.QName listQName, Object from, Object to, PropertyDescriptor pd, Set<org.alfresco.service.namespace.QName> treatedList) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
      Throws:
      IllegalAccessException
      InvocationTargetException
      NoSuchMethodException
    • cloneDataList

      private void cloneDataList(Object data, Object oldData, Object to, PropertyDescriptor pd) throws IllegalAccessException, InvocationTargetException, NoSuchMethodException
      Throws:
      IllegalAccessException
      InvocationTargetException
      NoSuchMethodException
    • clone

      private <T extends RepositoryEntity> List<T> clone(Collection<T> data)
    • copyExtraProperties

      private void copyExtraProperties(RepositoryEntity to, RepositoryEntity from, Collection<String> propQNames, Set<org.alfresco.service.namespace.QName> treatedProp)
    • assertIsNotMappedQname

      private void assertIsNotMappedQname(RepositoryEntity item, org.alfresco.service.namespace.QName qName, boolean allowWrite)