Class TargetAssocAutoCompletePlugin
- All Implemented Interfaces:
AutoCompletePlugin
- Direct Known Subclasses:
DataListItemAutoCompletePlugin,LinkedValueAutoCompletePlugin,ListValueAutoCompletePlugin
TargetAssocAutoCompletePlugin class.
Default autocomplete used to suggest target associations.
Example:
<control template="/org/alfresco/components/form/controls/autocomplete-association.ftl">
<control-param name="ds">becpg/autocomplete/targetassoc/associations/bcpg:product?classNames=bcpg:entityTplAspect&excludeProps=bcpg:entityTplEnabled%7Cfalse</control-param>
<control-param name="pageLinkTemplate">entity-data-lists?list=View-properties&nodeRef={nodeRef}</control-param>
</control>
Datasources:
ds: /becpg/autocomplete/targetassoc/associations/{className}?classNames={classNames?}&excludeProps={excludeProps?}&path={path?}&filter={}
param: {className} type of item to retrieve.
param: {classNames} (optional) comma-separated list of classNames; can be used to filter by aspect or boost certain types (e.g., inc_ or ^).
param: {extra.searchTemplate} (optional) allows defining a custom search template.
Examples:
With aspect:
classNames=bcpg:entityTplAspect
Includes aspect (OR):
classNames=inc_bcpg:entityTplAspect,inc_gs1:gs1Aspect
Boost specific types:
classNames=bcpg:rawMaterial^2
param: {andProps} (optional/deprecated) comma-separated property|value pairs that items should have (filter=prop_to_filter|value).
param: {filter} (optional) same as andProps.
Filter Examples:
filter=prop_to_filter|value
filter=cm:name|samplename
filter=cm:name|{cm:title}
filter=bcpg:code|{bcpg:code},cm:name|MP*
filter=au:market|{au:market}
filter=gs1:sortingBonusCriteria_or|{gs1:sortingBonusCriteria} (when field is multiple; the default operator is AND; _or allows changing that).
filter=bcpg:ingTypeV2|{htmlPropValue} (use the value of parent or parentAssoc control-param; @Since 4.2)
Parameters:
param: {excludeProps} (optional) comma-separated property|value pairs that items should not have.
param: {excludeClassNames} (optional) comma-separated lists of classNames to exclude.
param: {path} (optional) retrieve items in a specific path; if the path doesn't contain /, it is relative to the current entity.
Example Path:
path=System/Characts/bcpg:entityLists/Contacts
Additional Parameters:
param: {extra.filterByAssoc} return items that have the same association as the current entity.
If a parent is provided, use it as the target association.
If itemId is provided, use itemId as the entity; otherwise, use currentEntity.
Examples:
becpg/autocomplete/product?extra.filterByAssoc=bcpg:plant becpg/autocomplete/product?extra.filterByAssoc=bcpg:plant_or
Example Control:
<control template="/org/alfresco/components/form/controls/autocomplete-association.ftl">
<control-param name="ds">becpg/autocomplete/targetassoc/associations/bcpg:entityV2?extra.filterByAssoc=bcpg:trademarkRef</control-param>
<control-param name="parentAssoc">sample_plTrademark</control-param>
</control>
param: {extra.getByAssoc} return items that are in association
If a parent is provided, use it as the target association.
If itemId is provided, use itemId as the entity; otherwise, use currentEntity.
Examples:
becpg/autocomplete/bcpg:plant?extra.getByAssoc=bcpg:plant
Example Control:
<control template="/org/alfresco/components/form/controls/autocomplete-association.ftl">
<control-param name="ds">becpg/autocomplete/targetassoc/associations/bcpg:ing?extra.getByAssoc=bcpg:linkedSearchAssociation&extra.characNameFormat={ml_bcpg:charactName} - {bcpg:casNumber}</control-param>
<control-param name="parentAssoc">bcpg_ingListIng</control-param>
</control>
- Version:
- $Id: $Id
- Author:
- matthieu
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AssociationServiceprotected AttributeExtractorServiceprotected AutoNumServiceprotected static final StringConstantcharactSearchTemplate="%(bcpg:charactName bcpg:legalName)"protected static final StringConstantsearchTemplate="%(cm:name bcpg:erpCode bcpg:code bcpg:l"{trunked}protected org.alfresco.service.cmr.dictionary.DictionaryServiceprotected EntityDictionaryServiceprivate static final List<org.alfresco.service.namespace.QName> Properties holding the label of a suggestion of any type, read in this order until one is set.protected static final StringConstantlistValueSearchTemplate="%(bcpg:lvValue bcpg:legalName)"private static final org.apache.commons.logging.LogConstantloggerprotected static final StringConstantmixedSearchTemplate="%(cm:name bcpg:erpCode bcpg:code bcpg:c"{trunked}protected org.alfresco.service.namespace.NamespaceServiceprotected org.alfresco.service.cmr.repository.NodeServiceprotected static final StringConstantPARAM_VALUES_SEPARATOR=","protected static final StringConstantpersonSearchTemplate="%(cm:userName cm:firstName cm:lastName "{trunked}protected static final StringConstantPROP_CHARAC_NAME_FORMAT="characNameFormat"protected static final StringConstantPROP_FILTER_BY_ASSOC="filterByAssoc"protected static final StringConstantPROP_GET_BY_ASSOC="getByAssoc"protected static final StringConstantSOURCE_TYPE_TARGET_ASSOC="targetassoc"private SystemConfigurationServiceprotected TargetAssocAutoCompleteExtractorprotected static final StringPrefix of the system configuration key holding the search template of a target type, eg. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected BeCPGQueryBuilderexcludeByClass(BeCPGQueryBuilder queryBuilder, String[] arrClassNames) excludeByClass.protected BeCPGQueryBuilderexcludeByProp(BeCPGQueryBuilder queryBuilder, String[] arrExcluseProps) excludeByProp.private voidexcludeSources(List<org.alfresco.service.cmr.repository.NodeRef> ret, String itemId, String fieldName) excludeSources.private List<org.alfresco.service.cmr.repository.NodeRef> extractAllSources(org.alfresco.service.cmr.repository.NodeRef source, org.alfresco.service.namespace.QName fieldQname, List<org.alfresco.service.cmr.repository.NodeRef> allSources) extractAllSources.protected org.alfresco.service.cmr.repository.NodeRefextractEntityNodeRef(Map<String, Serializable> props) extractEntityNodeRef.protected List<org.alfresco.service.cmr.repository.NodeRef> filter(BeCPGQueryBuilder queryBuilder, String path, String[] arrClassNames, Integer pageSize, Map<String, Serializable> props) filter.private List<org.alfresco.service.cmr.repository.NodeRef> filterByAssoc(BeCPGQueryBuilder queryBuilder, Integer pageSize, org.alfresco.service.cmr.repository.NodeRef entityNodeRef, String filterByAssoc, org.alfresco.service.cmr.repository.NodeRef targetNodeRef) filterByAssoc.protected BeCPGQueryBuilderfilterByClass(BeCPGQueryBuilder queryBuilder, String[] arrClassNames) filterByClass.private voidfilterByPath(BeCPGQueryBuilder queryBuilder, String path, org.alfresco.service.cmr.repository.NodeRef entityNodeRef) filterByPath.protected BeCPGQueryBuilderfilterByQueryFilter(BeCPGQueryBuilder queryBuilder, String queryFilters, org.alfresco.service.cmr.repository.NodeRef entityNodeRef, String propParent) filterByQueryFilter.private List<org.alfresco.service.cmr.repository.NodeRef> getByAssoc(String assocName, Map<String, Serializable> props) getByAssoc.String[]getHandleSourceTypes.protected AutoCompleteExtractor<org.alfresco.service.cmr.repository.NodeRef> Getter for the fieldtargetAssocValueExtractor.protected booleanisAllQuery(String query) isAllQuery.private booleanisFilteredByAssoc(Map<String, Serializable> props) Tells whether the suggestions are filtered by the targets of an association.booleanisQueryMatch(String query, String entityName) isQueryMatch.protected StringprepareQuery(String query) prepareQuery.private StringreadLabel(org.alfresco.service.cmr.repository.NodeRef nodeRef, List<org.alfresco.service.namespace.QName> labelProperties) Reads the label a suggestion is searched and shown on.(package private) List<org.alfresco.service.namespace.QName> resolveLabelProperties(org.alfresco.service.namespace.QName type) Returns the properties a suggestion of the given type is labelled with, read in this order until one is set.(package private) StringresolveTypeSearchTemplate(org.alfresco.service.namespace.QName type, String defaultTemplate) Returns the search template the system configuration sets for a target type, so that a type searched on its own codes (eg. the ISO codes of a geographic origin) needs no control parameter on every form field pointing at it.(package private) List<org.alfresco.service.cmr.repository.NodeRef> sortByRelevance(String query, List<org.alfresco.service.namespace.QName> labelProperties, List<org.alfresco.service.cmr.repository.NodeRef> suggestions) Puts the suggestions whose label best matches the query first, keeping the search engine order between equally relevant ones.suggest(String sourceType, String query, Integer pageNum, Integer pageSize, Map<String, Serializable> props) suggest.private List<org.alfresco.service.cmr.repository.NodeRef> suggestByRelevance(BeCPGQueryBuilder queryBuilder, String query, org.alfresco.service.namespace.QName type, String path, String[] arrClassNames, Integer pageSize, Map<String, Serializable> props) Runs the suggestion query and puts the suggestions whose label best matches the query first, keeping the search engine order between equally relevant ones.protected AutoCompletePagesuggestDatalistItem(org.alfresco.service.cmr.repository.NodeRef entityNodeRef, org.alfresco.service.namespace.QName datalistType, org.alfresco.service.namespace.QName propertyQName, String query, Integer pageNum, Integer pageSize) Suggest a dalist itemsuggestTargetAssoc(String path, org.alfresco.service.namespace.QName type, String query, Integer pageNum, Integer pageSize, String[] arrClassNames, Map<String, Serializable> props) Suggest target class according to query Query path : +PATH:"/app:company_home/cm:System/cm:Lists/cm:Nuts/*" +TYPE:"bcpg:nut" +@cm\:name:"Nut1*".
-
Field Details
-
logger
private static final org.apache.commons.logging.Log loggerConstantlogger -
PROP_FILTER_BY_ASSOC
ConstantPROP_FILTER_BY_ASSOC="filterByAssoc"- See Also:
-
PROP_GET_BY_ASSOC
ConstantPROP_GET_BY_ASSOC="getByAssoc"- See Also:
-
PROP_CHARAC_NAME_FORMAT
ConstantPROP_CHARAC_NAME_FORMAT="characNameFormat"- See Also:
-
SOURCE_TYPE_TARGET_ASSOC
ConstantSOURCE_TYPE_TARGET_ASSOC="targetassoc"- See Also:
-
DEFAULT_SEARCH_TEMPLATE
ConstantsearchTemplate="%(cm:name bcpg:erpCode bcpg:code bcpg:l"{trunked}- See Also:
-
MIXED_SEARCH_TEMPLATE
ConstantmixedSearchTemplate="%(cm:name bcpg:erpCode bcpg:code bcpg:c"{trunked}- See Also:
-
LABEL_PROPERTIES
Properties holding the label of a suggestion of any type, read in this order until one is set. -
CHARACT_SEARCH_TEMPLATE
ConstantcharactSearchTemplate="%(bcpg:charactName bcpg:legalName)"- See Also:
-
LISTVALUE_SEARCH_TEMPLATE
ConstantlistValueSearchTemplate="%(bcpg:lvValue bcpg:legalName)"- See Also:
-
PERSON_SEARH_TEMPLATE
ConstantpersonSearchTemplate="%(cm:userName cm:firstName cm:lastName "{trunked}- See Also:
-
TYPE_SEARCH_TEMPLATE_CONF_PREFIX
Prefix of the system configuration key holding the search template of a target type, eg.beCPG.autocomplete.searchTemplate.bcpg_geoOrigin- See Also:
-
PARAM_VALUES_SEPARATOR
ConstantPARAM_VALUES_SEPARATOR=","- See Also:
-
nodeService
@Autowired @Qualifier("NodeService") protected org.alfresco.service.cmr.repository.NodeService nodeService -
namespaceService
@Autowired protected org.alfresco.service.namespace.NamespaceService namespaceService -
dictionaryService
@Autowired protected org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService -
entityDictionaryService
-
autoNumService
-
attributeExtractorService
-
targetAssocValueExtractor
-
associationService
-
systemConfigurationService
-
-
Constructor Details
-
TargetAssocAutoCompletePlugin
public TargetAssocAutoCompletePlugin()
-
-
Method Details
-
getHandleSourceTypes
getHandleSourceTypes.
- Specified by:
getHandleSourceTypesin interfaceAutoCompletePlugin- Returns:
- sourceType that the plugin handle
-
suggest
public AutoCompletePage suggest(String sourceType, String query, Integer pageNum, Integer pageSize, Map<String, Serializable> props) suggest.
-
suggestTargetAssoc
public AutoCompletePage suggestTargetAssoc(String path, org.alfresco.service.namespace.QName type, String query, Integer pageNum, Integer pageSize, String[] arrClassNames, Map<String, Serializable> props) Suggest target class according to query Query path : +PATH:"/app:company_home/cm:System/cm:Lists/cm:Nuts/*" +TYPE:"bcpg:nut" +@cm\:name:"Nut1*". -
suggestByRelevance
private List<org.alfresco.service.cmr.repository.NodeRef> suggestByRelevance(BeCPGQueryBuilder queryBuilder, String query, org.alfresco.service.namespace.QName type, String path, String[] arrClassNames, Integer pageSize, Map<String, Serializable> props) Runs the suggestion query and puts the suggestions whose label best matches the query first, keeping the search engine order between equally relevant ones. People are left in the search engine order, their label being made of several properties, and so are suggestions filtered by association, whose unbounded query is not bulk fetched.- Parameters:
queryBuilder- the suggestion queryquery- the text typed by the usertype- the type of the suggested itemspath- the path filterarrClassNames- the class filterpageSize- the page sizeprops- the autocomplete parameters- Returns:
- the suggestions sorted by relevance
-
isFilteredByAssoc
Tells whether the suggestions are filtered by the targets of an association.- Parameters:
props- the autocomplete parameters, may be null- Returns:
- true when a filter by association is requested
-
resolveLabelProperties
List<org.alfresco.service.namespace.QName> resolveLabelProperties(org.alfresco.service.namespace.QName type) Returns the properties a suggestion of the given type is labelled with, read in this order until one is set.- Parameters:
type- the type of the suggested items- Returns:
- the label properties, empty when the suggestions are not ranked
-
sortByRelevance
List<org.alfresco.service.cmr.repository.NodeRef> sortByRelevance(String query, List<org.alfresco.service.namespace.QName> labelProperties, List<org.alfresco.service.cmr.repository.NodeRef> suggestions) Puts the suggestions whose label best matches the query first, keeping the search engine order between equally relevant ones.- Parameters:
query- the text typed by the userlabelProperties- the properties holding the label, read in this order until one is setsuggestions- the suggestions, in the search engine order- Returns:
- the suggestions sorted by relevance
-
readLabel
private String readLabel(org.alfresco.service.cmr.repository.NodeRef nodeRef, List<org.alfresco.service.namespace.QName> labelProperties) Reads the label a suggestion is searched and shown on.- Parameters:
nodeRef- the suggested nodelabelProperties- the properties holding the label, read in this order until one is set- Returns:
- the label, empty when the node has none
-
resolveTypeSearchTemplate
Returns the search template the system configuration sets for a target type, so that a type searched on its own codes (eg. the ISO codes of a geographic origin) needs no control parameter on every form field pointing at it.- Parameters:
type- the type of the suggested itemsdefaultTemplate- the template used when the configuration sets none for the type- Returns:
- the configured template, or
defaultTemplate
-
getByAssoc
private List<org.alfresco.service.cmr.repository.NodeRef> getByAssoc(String assocName, Map<String, Serializable> props) getByAssoc.
-
filter
protected List<org.alfresco.service.cmr.repository.NodeRef> filter(BeCPGQueryBuilder queryBuilder, String path, String[] arrClassNames, Integer pageSize, Map<String, Serializable> props) filter.
-
extractEntityNodeRef
protected org.alfresco.service.cmr.repository.NodeRef extractEntityNodeRef(Map<String, Serializable> props) extractEntityNodeRef.
- Parameters:
props- aMapobject- Returns:
- a
NodeRefobject
-
excludeSources
private void excludeSources(List<org.alfresco.service.cmr.repository.NodeRef> ret, String itemId, String fieldName) excludeSources.
-
extractAllSources
private List<org.alfresco.service.cmr.repository.NodeRef> extractAllSources(org.alfresco.service.cmr.repository.NodeRef source, org.alfresco.service.namespace.QName fieldQname, List<org.alfresco.service.cmr.repository.NodeRef> allSources) extractAllSources.
-
filterByAssoc
private List<org.alfresco.service.cmr.repository.NodeRef> filterByAssoc(BeCPGQueryBuilder queryBuilder, Integer pageSize, org.alfresco.service.cmr.repository.NodeRef entityNodeRef, String filterByAssoc, org.alfresco.service.cmr.repository.NodeRef targetNodeRef) filterByAssoc.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobjectpageSize- aIntegerobjectentityNodeRef- aNodeRefobjectfilterByAssoc- aStringobjecttargetNodeRef- aNodeRefobject- Returns:
- a
Listobject
-
filterByPath
private void filterByPath(BeCPGQueryBuilder queryBuilder, String path, org.alfresco.service.cmr.repository.NodeRef entityNodeRef) filterByPath.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobjectpath- aStringobjectentityNodeRef- aNodeRefobject
-
getTargetAssocValueExtractor
protected AutoCompleteExtractor<org.alfresco.service.cmr.repository.NodeRef> getTargetAssocValueExtractor()Getter for the field
targetAssocValueExtractor.- Returns:
- a
AutoCompleteExtractorobject.
-
filterByClass
filterByClass.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobject.arrClassNames- an array ofStringobjects.- Returns:
- a
BeCPGQueryBuilderobject.
-
filterByQueryFilter
protected BeCPGQueryBuilder filterByQueryFilter(BeCPGQueryBuilder queryBuilder, String queryFilters, org.alfresco.service.cmr.repository.NodeRef entityNodeRef, String propParent) filterByQueryFilter.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobjectqueryFilters- aStringobjectentityNodeRef- aNodeRefobjectpropParent- aStringobject- Returns:
- a
BeCPGQueryBuilderobject
-
excludeByProp
excludeByProp.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobjectarrExcluseProps- an array ofStringobjects- Returns:
- a
BeCPGQueryBuilderobject
-
excludeByClass
excludeByClass.
- Parameters:
queryBuilder- aBeCPGQueryBuilderobjectarrClassNames- an array ofStringobjects- Returns:
- a
BeCPGQueryBuilderobject
-
isAllQuery
isAllQuery.
- Parameters:
query- aStringobject.- Returns:
- a boolean.
-
prepareQuery
prepareQuery.
-
isQueryMatch
isQueryMatch.
-
suggestDatalistItem
protected AutoCompletePage suggestDatalistItem(org.alfresco.service.cmr.repository.NodeRef entityNodeRef, org.alfresco.service.namespace.QName datalistType, org.alfresco.service.namespace.QName propertyQName, String query, Integer pageNum, Integer pageSize) Suggest a dalist item- Parameters:
entityNodeRef- aNodeRefobject.datalistType- aQNameobject.propertyQName- aQNameobject.query- aStringobject.pageNum- aIntegerobject.pageSize- aIntegerobject.- Returns:
- a
AutoCompletePageobject.
-