Class AttributeExtractorServiceImpl
- All Implemented Interfaces:
AttributeExtractorService
AttributeExtractorServiceImpl class.
- Version:
- $Id: $Id
- Author:
- matthieu
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassclassprivate classNested classes/interfaces inherited from interface fr.becpg.repo.helper.AttributeExtractorService
AttributeExtractorService.AttributeExtractorPlugin, AttributeExtractorService.DataListCallBack -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate AssociationServiceprivate BeCPGCacheServiceprivate EntityDictionaryServiceprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final Stringprivate static final org.apache.commons.logging.LogConstantloggerprivate static final Stringprivate static final Stringprotected org.alfresco.service.cmr.repository.NodeServiceprivate static final Stringprivate org.alfresco.service.namespace.NamespaceServiceprivate org.alfresco.service.cmr.repository.NodeServiceprivate static final Patternprivate org.alfresco.service.cmr.security.PermissionServiceprivate PersonAttributeExtractorPluginprivate static final Stringprivate SecurityServiceprivate static final Stringprivate org.alfresco.service.cmr.tagging.TaggingServiceprivate static final StringFields inherited from interface fr.becpg.repo.helper.AttributeExtractorService
ASSOC_SUFFIX, DT_SUFFIX, PROP_SUFFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate StringcleanCriterionValue(String critValue) Normalizes a criterion before comparing it: case, surrounding quotes and escaped spaces.private booleandateMatches(String value, String compValue) dateMatches.private StringdefaultMetadata(org.alfresco.service.namespace.QName type) defaultMetadata.extractCommonNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef) extractCommonNodeData.extractExpr(String format, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractPropName.extractMetadata(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractMetadata.extractMetadataKey(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractMetadataKey.private ObjectextractNodeData(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.extractNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef, org.alfresco.service.namespace.QName itemType, List<AttributeExtractorField> metadataFields, FormatMode mode) extractNodeData.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.extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, boolean formatData) extractPropertyForReport.extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, PropertyFormats propertyFormats, boolean formatData) extractPropertyForReport.extractPropName(org.alfresco.service.cmr.repository.NodeRef v) extractPropName.extractPropName(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractPropName.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.extractPropName(org.alfresco.service.namespace.QName type, org.json.JSONObject v) extractPropName.extractSiteId(org.alfresco.service.cmr.repository.NodeRef entityNodeRef) extractSiteId.getAttributeExtractorPlugin(org.alfresco.service.namespace.QName type) getAttributeExtractorPlugin.private org.alfresco.service.cmr.dictionary.ClassAttributeDefinitiongetFieldDef(org.alfresco.service.namespace.QName itemType, AttributeExtractorServiceImpl.AttributeExtractorStructure field) getFieldDef.getPersonDisplayName(String userId) getPersonDisplayName.getPropertyFormats(FormatMode mode, boolean useServerLocale) getPropertyFormats.getStringValue(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable v, PropertyFormats propertyFormats) getStringValue.private StringgetStringValue(org.alfresco.service.namespace.QName nodeType, org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable v, PropertyFormats propertyFormats, boolean formatData) getStringValue.String[]getTags(org.alfresco.service.cmr.repository.NodeRef nodeRef) getTags.booleanhasAttributeExtractorPlugin(org.alfresco.service.cmr.repository.NodeRef nodeRef) hasAttributeExtractorPlugin.private booleanhasReadAccess(org.alfresco.service.namespace.QName nodeType, String propName) hasReadAccess.private booleaninternalMatchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String, String> criteriaMap) internalMatchCriteria.private booleanisAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition propDef) isAssoc.private booleanisCriterionOn(String critKey, String compKey) Tells whether a criterion applies to an extracted field.private booleanisDateData(Map<String, Object> data) Tells whether extracted data holds a date.private booleanTells whether a value stands between the bounds of a range.private booleanTells whether a value holds a number.private booleanisPropertyToExtractAsAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition attribute) isPropertyToExtractAsAssoc.private booleanTells whether one of the extracted values matches the criterion.booleanmatchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String, String> criteriaMap) matchCriteria.private booleanMatches the data extracted for a field against a criterion.private booleanTells whether the extracted data of a field matches the criterion carried by critKey.private booleanWalks down the properties reached through a field, looking for the one the criterion targets.private booleanmatchRange(String value, String displayValue, String compValue) Matches a value against the bounds of a range criterion.private booleanCompares an extracted value with a single criterion, honouring the search operators.readExtractStructure(org.alfresco.service.namespace.QName itemType, List<AttributeExtractorField> metadataFields) readExtractStructure.splitMultiValue(String critValue) Splits a criterion holding several values, empty when it holds a single one.private doubleReads a number written with either decimal separator.
-
Field Details
-
logger
private static final org.apache.commons.logging.Log loggerConstantlogger -
FIELD_PATH_SEPARATOR
- See Also:
-
MULTI_VALUE_SEPARATOR
- See Also:
-
RANGE_SEPARATOR
- See Also:
-
WILDCARD_OPERATOR
- See Also:
-
STARTS_WITH_OPERATOR
- See Also:
-
NUMERIC_PATTERN
-
METADATA_DATE
- See Also:
-
METADATA_DATETIME
- See Also:
-
KEY_DISPLAY_VALUE
- See Also:
-
KEY_METADATA
- See Also:
-
KEY_VALUE
- See Also:
-
KEY_VERSION
- See Also:
-
mlNodeService
@Autowired @Qualifier("mlAwareNodeService") protected org.alfresco.service.cmr.repository.NodeService mlNodeService -
nodeService
@Autowired private org.alfresco.service.cmr.repository.NodeService nodeService -
entityDictionaryService
-
associationService
-
namespaceService
@Autowired private org.alfresco.service.namespace.NamespaceService namespaceService -
taggingService
@Autowired private org.alfresco.service.cmr.tagging.TaggingService taggingService -
permissionService
@Autowired private org.alfresco.service.cmr.security.PermissionService permissionService -
securityService
-
attributeExtractorPlugins
-
personAttributeExtractorPlugin
-
beCPGCacheService
-
commonDataListCallBack
-
-
Constructor Details
-
AttributeExtractorServiceImpl
public AttributeExtractorServiceImpl()
-
-
Method Details
-
getAttributeExtractorPlugin
private AttributeExtractorService.AttributeExtractorPlugin getAttributeExtractorPlugin(org.alfresco.service.namespace.QName type) getAttributeExtractorPlugin.
- Parameters:
type- aQNameobject- Returns:
- a AttributeExtractorPlugin object
-
getStringValue
public String getStringValue(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable v, PropertyFormats propertyFormats) getStringValue.
- Specified by:
getStringValuein interfaceAttributeExtractorService- Parameters:
propertyDef- aPropertyDefinitionobject.v- aSerializableobject.propertyFormats- aPropertyFormatsobject.- Returns:
- a
Stringobject.
-
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- aQNameobjectpropertyDef- aPropertyDefinitionobjectv- aSerializableobjectpropertyFormats- aPropertyFormatsobjectformatData- a boolean- Returns:
- a
Stringobject
-
extractPropertyForReport
public String extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, boolean formatData) extractPropertyForReport.
- Specified by:
extractPropertyForReportin interfaceAttributeExtractorService- Parameters:
propertyDef- aPropertyDefinitionobject.value- aSerializableobject.formatData- a boolean.- Returns:
- a
Stringobject.
-
extractPropertyForReport
public String extractPropertyForReport(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, Serializable value, PropertyFormats propertyFormats, boolean formatData) extractPropertyForReport.
- Specified by:
extractPropertyForReportin interfaceAttributeExtractorService- Parameters:
propertyDef- aPropertyDefinitionobject.value- aSerializableobject.propertyFormats- aPropertyFormatsobject.formatData- a boolean.- Returns:
- a
Stringobject.
-
readExtractStructure
public List<AttributeExtractorServiceImpl.AttributeExtractorStructure> readExtractStructure(org.alfresco.service.namespace.QName itemType, List<AttributeExtractorField> metadataFields) readExtractStructure.
- Specified by:
readExtractStructurein interfaceAttributeExtractorService- Parameters:
itemType- aQNameobject.metadataFields- aListobject.- Returns:
- a
Listobject.
-
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:
extractNodeDatain interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.itemType- aQNameobject.metadataFields- aListobject.mode- aFormatModeobject.- Returns:
- a
Mapobject.
-
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:
extractNodeDatain interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.itemType- aQNameobject.properties- aMapobject.metadataFields- aListobject.mode- aFormatModeobject.callback- aAttributeExtractorService.DataListCallBackobject.- Returns:
- a
Mapobject.
-
getFieldDef
private org.alfresco.service.cmr.dictionary.ClassAttributeDefinition getFieldDef(org.alfresco.service.namespace.QName itemType, AttributeExtractorServiceImpl.AttributeExtractorStructure field) getFieldDef.
- Parameters:
itemType- aQNameobjectfield- aAttributeExtractorServiceImpl.AttributeExtractorStructureobject- Returns:
- a
ClassAttributeDefinitionobject
-
isAssoc
private boolean isAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition propDef) isAssoc.
- Parameters:
propDef- aClassAttributeDefinitionobject- 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- aNodeRefobjectproperties- aMapobjectlocale- aLocaleobjectattribute- aClassAttributeDefinitionobjectmode- aFormatModeobjectorder- a int- Returns:
- a
Objectobject
-
isPropertyToExtractAsAssoc
private boolean isPropertyToExtractAsAssoc(org.alfresco.service.cmr.dictionary.ClassAttributeDefinition attribute) isPropertyToExtractAsAssoc.
- Parameters:
attribute- aClassAttributeDefinitionobject- Returns:
- a boolean
-
extractCommonNodeData
public Map<String,Object> extractCommonNodeData(org.alfresco.service.cmr.repository.NodeRef nodeRef) extractCommonNodeData.
- Specified by:
extractCommonNodeDatain interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.- Returns:
- a
Mapobject.
-
extractSiteId
extractSiteId.
- Specified by:
extractSiteIdin interfaceAttributeExtractorService- Parameters:
entityNodeRef- aNodeRefobject.- Returns:
- a
Stringobject.
-
extractPropName
extractPropName.
- Specified by:
extractPropNamein interfaceAttributeExtractorService- Parameters:
v- aNodeRefobject.- Returns:
- a
Stringobject.
-
extractPropName
extractPropName.
- Specified by:
extractPropNamein interfaceAttributeExtractorService- Parameters:
type- aQNameobjectv- aJSONObjectobject- Returns:
- a
Stringobject
-
hasAttributeExtractorPlugin
public boolean hasAttributeExtractorPlugin(org.alfresco.service.cmr.repository.NodeRef nodeRef) hasAttributeExtractorPlugin.
- Specified by:
hasAttributeExtractorPluginin interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.- Returns:
- a boolean.
-
extractPropName
public String extractPropName(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractPropName.
- Specified by:
extractPropNamein interfaceAttributeExtractorService- Parameters:
type- aQNameobject.nodeRef- aNodeRefobject.- Returns:
- a
Stringobject.
-
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:
extractPropNamein interfaceAttributeExtractorService- Parameters:
type- the type of the nodenodeRef- the reference to the nodenameFormat- a format string- Returns:
- the extracted property name
-
extractExpr
extractPropName.
- Specified by:
extractExprin interfaceAttributeExtractorService- Parameters:
format- aStringobject.nodeRef- aNodeRefobject.- Returns:
- a
Stringobject.
-
extractMetadata
public String extractMetadata(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractMetadata.
- Specified by:
extractMetadatain interfaceAttributeExtractorService- Parameters:
type- aQNameobject.nodeRef- aNodeRefobject.- Returns:
- a
Stringobject.
-
extractMetadataKey
public String extractMetadataKey(org.alfresco.service.namespace.QName type, org.alfresco.service.cmr.repository.NodeRef nodeRef) extractMetadataKey.
- Specified by:
extractMetadataKeyin interfaceAttributeExtractorService- Parameters:
type- aQNameobject.nodeRef- aNodeRefobject.- Returns:
- a
Stringobject.
-
defaultMetadata
defaultMetadata.
- Parameters:
type- aQNameobject- Returns:
- a
Stringobject
-
getTags
getTags.
- Specified by:
getTagsin interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.- Returns:
- an array of
Stringobjects.
-
hasReadAccess
hasReadAccess.
- Parameters:
nodeType- aQNameobjectpropName- aStringobject- Returns:
- a boolean
-
getPersonDisplayName
getPersonDisplayName.
- Specified by:
getPersonDisplayNamein interfaceAttributeExtractorService- Parameters:
userId- aStringobject.- Returns:
- a
Stringobject.
-
matchCriteria
public boolean matchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String, String> criteriaMap) matchCriteria.
- Specified by:
matchCriteriain interfaceAttributeExtractorService- Parameters:
nodeRef- aNodeRefobject.criteriaMap- aMapobject.- Returns:
- a boolean.
-
internalMatchCriteria
private boolean internalMatchCriteria(org.alfresco.service.cmr.repository.NodeRef nodeRef, Map<String, String> criteriaMap) internalMatchCriteria.
- Parameters:
nodeRef- aNodeRefobjectcriteriaMap- aMapobject- 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. -
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.
-
splitMultiValue
Splits a criterion holding several values, empty when it holds a single one.
-
isCriterionOn
Tells whether a criterion applies to an extracted field.
A criterion targets either the field itself, or a property reached through it: the criterionbcpg:allergenListAllergen|bcpg:allergenCodeis carried by the extracted fieldbcpg:allergenListAllergen, whose datamatchData(java.util.Map<java.lang.String, java.lang.Object>, java.lang.String, java.util.Map<java.lang.String, java.lang.String>)then walks down. -
matchData
Tells whether the extracted data of a field matches the criterion carried by critKey.
-
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.
-
cleanCriterionValue
Normalizes a criterion before comparing it: case, surrounding quotes and escaped spaces.
-
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.
-
matchRange
Matches a value against the bounds of a range criterion.
-
isInRange
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. -
isNumeric
Tells whether a value holds a number.
- Parameters:
value- aStringobject- Returns:
- a boolean
-
toNumber
Reads a number written with either decimal separator.
- Parameters:
value- aStringobject- Returns:
- a double
-
isDateData
Tells whether extracted data holds a date.
- Parameters:
data- aMapobject- Returns:
- a boolean
-
dateMatches
dateMatches.
-
getPropertyFormats
getPropertyFormats.
- Specified by:
getPropertyFormatsin interfaceAttributeExtractorService- Parameters:
mode- aFormatModeobject.useServerLocale- a boolean.- Returns:
- a
PropertyFormatsobject.
-