Class AttributeExtractorServiceImpl

java.lang.Object
fr.becpg.repo.helper.impl.AttributeExtractorServiceImpl
All Implemented Interfaces:
AttributeExtractorService

@Service("attributeExtractorService") public class AttributeExtractorServiceImpl extends Object implements AttributeExtractorService

AttributeExtractorServiceImpl class.

Version:
$Id: $Id
Author:
matthieu
  • Field Details

  • Constructor Details

    • AttributeExtractorServiceImpl

      public AttributeExtractorServiceImpl()
  • Method Details

    • getAttributeExtractorPlugin

      private AttributeExtractorService.AttributeExtractorPlugin getAttributeExtractorPlugin(org.alfresco.service.namespace.QName type)

      getAttributeExtractorPlugin.

      Parameters:
      type - a QName object
      Returns:
      a AttributeExtractorPlugin object
    • getStringValue

      public String getStringValue(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable v, PropertyFormats propertyFormats)

      getStringValue.

      Specified by:
      getStringValue in interface AttributeExtractorService
      Parameters:
      propertyDef - a PropertyDefinition object.
      v - a Serializable object.
      propertyFormats - a PropertyFormats object.
      Returns:
      a String object.
    • getStringValue

      private String getStringValue(org.alfresco.service.namespace.QName nodeType, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable v, PropertyFormats propertyFormats, boolean formatData)

      getStringValue.

      Parameters:
      nodeType - a QName object
      propertyDef - a PropertyDefinition object
      v - a Serializable object
      propertyFormats - a PropertyFormats object
      formatData - a boolean
      Returns:
      a String object
    • extractPropertyForReport

      public String extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, boolean formatData)

      extractPropertyForReport.

      Specified by:
      extractPropertyForReport in interface AttributeExtractorService
      Parameters:
      propertyDef - a PropertyDefinition object.
      value - a Serializable object.
      formatData - a boolean.
      Returns:
      a String object.
    • extractPropertyForReport

      public String extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, PropertyFormats propertyFormats, boolean formatData)

      extractPropertyForReport.

      Specified by:
      extractPropertyForReport in interface AttributeExtractorService
      Parameters:
      propertyDef - a PropertyDefinition object.
      value - a Serializable object.
      propertyFormats - a PropertyFormats object.
      formatData - a boolean.
      Returns:
      a String object.
    • readExtractStructure

      public List<AttributeExtractorServiceImpl.AttributeExtractorStructure> readExtractStructure(org.alfresco.service.namespace.QName itemType, List<AttributeExtractorField> metadataFields)

      readExtractStructure.

      Specified by:
      readExtractStructure in interface AttributeExtractorService
      Parameters:
      itemType - a QName object.
      metadataFields - a List object.
      Returns:
      a List object.
    • extractNodeData

      public Map<String,Object> extractNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName itemType, List<AttributeExtractorField> metadataFields, FormatMode mode)

      extractNodeData.

      Specified by:
      extractNodeData in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      itemType - a QName object.
      metadataFields - a List object.
      mode - a FormatMode object.
      Returns:
      a Map object.
    • extractNodeData

      public Map<String,Object> extractNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName itemType, Map<org.alfresco.service.namespace.QName,Serializable> properties, List<AttributeExtractorServiceImpl.AttributeExtractorStructure> metadataFields, FormatMode mode, AttributeExtractorService.DataListCallBack callback)

      extractNodeData.

      Specified by:
      extractNodeData in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      itemType - a QName object.
      properties - a Map object.
      metadataFields - a List object.
      mode - a FormatMode object.
      callback - a AttributeExtractorService.DataListCallBack object.
      Returns:
      a Map object.
    • getFieldDef

      private org.alfresco.service.cmr.dictionary.ClassAttributeDefinition getFieldDef(org.alfresco.service.namespace.QName itemType, AttributeExtractorServiceImpl.AttributeExtractorStructure field)

      getFieldDef.

      Parameters:
      itemType - a QName object
      field - a AttributeExtractorServiceImpl.AttributeExtractorStructure object
      Returns:
      a ClassAttributeDefinition object
    • isAssoc

      private boolean isAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition propDef)

      isAssoc.

      Parameters:
      propDef - a ClassAttributeDefinition object
      Returns:
      a boolean
    • extractNodeData

      private Object extractNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<org.alfresco.service.namespace.QName,Serializable> properties, Locale locale, org.alfresco.service.cmr.dictionary.ClassAttributeDefinition attribute, FormatMode mode, int order)

      extractNodeData.

      Parameters:
      nodeRef - a NodeRef object
      properties - a Map object
      locale - a Locale object
      attribute - a ClassAttributeDefinition object
      mode - a FormatMode object
      order - a int
      Returns:
      a Object object
    • isPropertyToExtractAsAssoc

      private boolean isPropertyToExtractAsAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition attribute)

      isPropertyToExtractAsAssoc.

      Parameters:
      attribute - a ClassAttributeDefinition object
      Returns:
      a boolean
    • extractCommonNodeData

      public Map<String,Object> extractCommonNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef)

      extractCommonNodeData.

      Specified by:
      extractCommonNodeData in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      Returns:
      a Map object.
    • extractSiteId

      public String extractSiteId(org.alfresco.service.cmr.repository.NodeRef entityNodeRef)

      extractSiteId.

      Specified by:
      extractSiteId in interface AttributeExtractorService
      Parameters:
      entityNodeRef - a NodeRef object.
      Returns:
      a String object.
    • extractPropName

      public String extractPropName(org.alfresco.service.cmr.repository.NodeRef v)

      extractPropName.

      Specified by:
      extractPropName in interface AttributeExtractorService
      Parameters:
      v - a NodeRef object.
      Returns:
      a String object.
    • extractPropName

      public String extractPropName(org.alfresco.service.namespace.QName type, org.json.JSONObject v)

      extractPropName.

      Specified by:
      extractPropName in interface AttributeExtractorService
      Parameters:
      type - a QName object
      v - a JSONObject object
      Returns:
      a String object
    • hasAttributeExtractorPlugin

      public boolean hasAttributeExtractorPlugin(org.alfresco.service.cmr.repository.NodeRef nodeRef)

      hasAttributeExtractorPlugin.

      Specified by:
      hasAttributeExtractorPlugin in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      Returns:
      a boolean.
    • extractPropName

      public String extractPropName(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef)

      extractPropName.

      Specified by:
      extractPropName in interface AttributeExtractorService
      Parameters:
      type - a QName object.
      nodeRef - a NodeRef object.
      Returns:
      a String object.
    • extractPropName

      public String extractPropName(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef, String nameFormat)
      Extracts the property name from a node based on its type.
      Specified by:
      extractPropName in interface AttributeExtractorService
      Parameters:
      type - the type of the node
      nodeRef - the reference to the node
      nameFormat - a format string
      Returns:
      the extracted property name
    • extractExpr

      public String extractExpr(String format, org.alfresco.service.cmr.repository.NodeRef nodeRef)

      extractPropName.

      Specified by:
      extractExpr in interface AttributeExtractorService
      Parameters:
      format - a String object.
      nodeRef - a NodeRef object.
      Returns:
      a String object.
    • extractMetadata

      public String extractMetadata(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef)

      extractMetadata.

      Specified by:
      extractMetadata in interface AttributeExtractorService
      Parameters:
      type - a QName object.
      nodeRef - a NodeRef object.
      Returns:
      a String object.
    • extractMetadataKey

      public String extractMetadataKey(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef)

      extractMetadataKey.

      Specified by:
      extractMetadataKey in interface AttributeExtractorService
      Parameters:
      type - a QName object.
      nodeRef - a NodeRef object.
      Returns:
      a String object.
    • defaultMetadata

      private String defaultMetadata(org.alfresco.service.namespace.QName type)

      defaultMetadata.

      Parameters:
      type - a QName object
      Returns:
      a String object
    • getTags

      public String[] getTags(org.alfresco.service.cmr.repository.NodeRef nodeRef)

      getTags.

      Specified by:
      getTags in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      Returns:
      an array of String objects.
    • hasReadAccess

      private boolean hasReadAccess(org.alfresco.service.namespace.QName nodeType, String propName)

      hasReadAccess.

      Parameters:
      nodeType - a QName object
      propName - a String object
      Returns:
      a boolean
    • getPersonDisplayName

      public String getPersonDisplayName(String userId)

      getPersonDisplayName.

      Specified by:
      getPersonDisplayName in interface AttributeExtractorService
      Parameters:
      userId - a String object.
      Returns:
      a String object.
    • matchCriteria

      public boolean matchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,String> criteriaMap)

      matchCriteria.

      Specified by:
      matchCriteria in interface AttributeExtractorService
      Parameters:
      nodeRef - a NodeRef object.
      criteriaMap - a Map object.
      Returns:
      a boolean.
    • internalMatchCriteria

      private boolean internalMatchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String,String> criteriaMap)

      internalMatchCriteria.

      Parameters:
      nodeRef - a NodeRef object
      criteriaMap - a Map object
      Returns:
      a boolean
    • matchCriterion

      private boolean matchCriterion(List<Map<String,Object>> dataList, String compKey, String critKey, String critValue)

      Matches the data extracted for a field against a criterion.

      The data holds one entry per value of the field, and the criterion matches as soon as one of them matches. A criterion holding several values - what a filter on a multiple association sends - matches as soon as one of its values is found: filtering on two plants keeps the entities made in either of them.
      Parameters:
      dataList - a List object
      compKey - a String object
      critKey - a String object
      critValue - a String object
      Returns:
      a boolean
    • matchAnyData

      private boolean matchAnyData(List<Map<String,Object>> dataList, String compKey, String critKey, String critValue)

      Tells whether one of the extracted values matches the criterion.

      Parameters:
      dataList - a List object
      compKey - a String object
      critKey - a String object
      critValue - a String object
      Returns:
      a boolean
    • splitMultiValue

      private List<String> splitMultiValue(String critValue)

      Splits a criterion holding several values, empty when it holds a single one.

      Parameters:
      critValue - a String object
      Returns:
      a List object
    • isCriterionOn

      private boolean isCriterionOn(String critKey, String compKey)

      Tells whether a criterion applies to an extracted field.

      A criterion targets either the field itself, or a property reached through it: the criterion bcpg:allergenListAllergen|bcpg:allergenCode is carried by the extracted field bcpg:allergenListAllergen, whose data matchData(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, java.util.Map<java.lang.String, java.lang.String>) then walks down.
      Parameters:
      critKey - a String object
      compKey - a String object
      Returns:
      a boolean
    • matchData

      private boolean matchData(Map<String,Object> data, String critKey, Map<String,String> criteriaMap)

      Tells whether the extracted data of a field matches the criterion carried by critKey.

      Parameters:
      data - a Map object
      critKey - a String object
      criteriaMap - a Map object
      Returns:
      a boolean
    • matchNestedData

      private boolean matchNestedData(Map<String,Object> data, String critKey, Map<String,String> criteriaMap)

      Walks down the properties reached through a field, looking for the one the criterion targets.

      Parameters:
      data - a Map object
      critKey - a String object
      criteriaMap - a Map object
      Returns:
      a boolean
    • cleanCriterionValue

      private String cleanCriterionValue(String critValue)

      Normalizes a criterion before comparing it: case, surrounding quotes and escaped spaces.

      Parameters:
      critValue - a String object
      Returns:
      a String object
    • matchValue

      private boolean matchValue(String value, String displayValue, String compValue, Map<String,Object> data)

      Compares an extracted value with a single criterion, honouring the search operators.

      Parameters:
      value - a String object
      displayValue - a String object
      compValue - a String object
      data - a Map object
      Returns:
      a boolean
    • matchRange

      private boolean matchRange(String value, String displayValue, String compValue)

      Matches a value against the bounds of a range criterion.

      Parameters:
      value - a String object
      displayValue - a String object
      compValue - a String object
      Returns:
      a boolean
    • isInRange

      private boolean isInRange(String value, String lowerBound, String upperBound)

      Tells whether a value stands between the bounds of a range.

      Numeric bounds are compared as numbers, so 15 stays out of 1..9; anything else, dates included, keeps the alphabetical order of the extracted values.
      Parameters:
      value - a String object
      lowerBound - a String object
      upperBound - a String object
      Returns:
      a boolean
    • isNumeric

      private boolean isNumeric(String value)

      Tells whether a value holds a number.

      Parameters:
      value - a String object
      Returns:
      a boolean
    • toNumber

      private double toNumber(String value)

      Reads a number written with either decimal separator.

      Parameters:
      value - a String object
      Returns:
      a double
    • isDateData

      private boolean isDateData(Map<String,Object> data)

      Tells whether extracted data holds a date.

      Parameters:
      data - a Map object
      Returns:
      a boolean
    • dateMatches

      private boolean dateMatches(String value, String compValue)

      dateMatches.

      Parameters:
      value - a String object
      compValue - a String object
      Returns:
      a boolean
    • getPropertyFormats

      public PropertyFormats getPropertyFormats(FormatMode mode, boolean useServerLocale)

      getPropertyFormats.

      Specified by:
      getPropertyFormats in interface AttributeExtractorService
      Parameters:
      mode - a FormatMode object.
      useServerLocale - a boolean.
      Returns:
      a PropertyFormats object.