Data Providers
Overview
A data provider is a component to provide data from a data source (e.g. the ListDataProvider to query a SharePoint lists). It can be used in combination with several Web Parts, e.g. Data Grid Web Part. These Web Parts are then defining a transformation to render the information returned by the specified data provider.
The following Web Parts can be configured with Data Providers:
- The Data Grid Web Part displays results in a grid view.
- The Composite Web Part allows the definition of a custom layout for displaying results.
- The Search Result WebPart (because it is a pre-configured Composite Web Part).
- The Chart Web Part displays results in a chart view.
Also, the CompositeField within a Form Web Part can be configured with a data provider.
The following subsections introduce the different kinds of data providers, first the built in ones and then a short introduction to custom data providers. The following sections in this chapter provide a generic overview on the data provider concept.
Built-In DataProviders
The following Data Providers are included in MatchPoint:
- ListDataProvider (aggregates data from a SharePoint list)
- ModelDataProvider (queries data from a MatchPoint entity model configuration)
- WorkspaceDataProvider (aggregates data from workspaces)
- DbDataProvides (queries data from an external data base)
- ExpressionDataProvider (aggregates data from an expression)
- SiteDataProvider (aggregates data from multiple lists within a site)
- BdcDataProvider (aggregates data from a business data catalog)
- SearchDataProvider (uses the standard SharePoint search)
Some data providers and data adapters access external data bases. By using a `ConnectionStringConfiguration` element, the connection to the database can be specified. This can be either directly on the configuration element, or by referencing an element from the MatchPoint credential store.
An IISRESET / AppPool recycle might be necessary when managed property attribute (e.g. Allow Multiple Values) changes. This is required, since MatchPoint has a cache for some meta data information about managed properties.
Search Data Provider
The SearchDataProvider utilizes the SharePoint Search Service Application to provide search result for a Web Part. Within the configuration interface, the data provider can be configured using the available managed property names. The SearchDataProvider executes searches against the default search service application as it is configured within the search service associations on the SharePoint Central Administration site. MatchPoint requires four managed properties to be created on this service application:
- MATCHPOINTCONTENTTYPE
- MATCHPOINTMODIFIEDBY
- MATCHPOINTTAGS
- MATCHPOINTTERMS
This data provider supports all managed properties that are available on the default search service application, including tag- and term-based searches. It also supports caching and views.
Managed properties with multiple mappings return multiple values (as Array[]).
If the data provider is configured in combination with a Refinement Web Part,
this might lead to incorrect result counts for this managed property.
The SearchDataProvider is part of the solution Colygon.MatchPoint.Server
which can only be used within SharePoint Server environments. If a farm is
based on SharePoint Foundation, this data provider cannot be used. For more information,
please refer to the document MatchPoint Installation Guide.
Custom Data Providers
Custom Data Providers can be implemented by extending BaseDataProvider and BaseDataProviderInstance or by extending DataProviderWithConditions and DataProviderWithConditionsInstance. The Custom Data Provider Example shows how this can be done.
Furthermore, BaseDataProviderInstance provides hooks to add a custom contextual menu and ribbon buttons.
Ribbon buttons
Some data providers can be configured with ribbon button actions. In the table below a short overview of available Ribbon button actions is given:
Add | Edit | Delete | Alert Me | |
---|---|---|---|---|
ListDataProvider | Opens the list's new item form or the Upload document dialog for document libraries. | Edit the currently selected element in the list's edit form. | Delete the currently selected element. | N / A |
WorkspaceDataProvider | Opens a dialog with the new item form specified in the workspace template configuration. | N / A | N / A | N / A |
ModelDataProvider | Opens a dialog with the entity's new item form. | N / A | N / A | N / A |
SearchDataProvider | N / A | N / A | N / A | Registers the user for alerts, when the selected content changes. |
Most actions are shown only, when the user has adequate permissions. Furthermore, e.g. the add action on the Workspace Data Provider shows only, when the a item form URL is specified in the corresponding Template Configuration.
Data Provider Conditions
For data providers that can be configured with conditions (DataProviderWithConditions), following condition types are available:
- AndGroupCondition (combine multiple conditions with logical AND)
- OrGroupCondition (combine multiple conditions with logical OR)
- ExpressionCondition (evaluates an expression assuming, that it returns a condition, e.g. from a Refinement Web Part)
- FieldCondition (compare a property of the items, e.g. SPListItem, with a predefined value using a specified comparator)
- FullTextCondition (use a full text condition)
- TagCondition (checks, whether the items are tagged with a specific MatchPoint Tag)
- TermCondition (checks, whether the items have a specific term)
- TimeSpanCondition (available only via API)
If a condition contains more than one value (e.g. a TagCondition that contains multiple tags) these values will be concatenated with the logical operator specified by the parent group condition in the condition tree. By default, this is the AND operator. If condition values should be connected with OR, the OrGroupCondition can be used as the parent object of the condition.
The Refinement Web Part will automatically register itself as a consumer, to be notified when new results are loaded by the data provider.
These conditions are a generic representation of all condition types required by the query type required for a specific data source. They extend BaseCondition and are automatically transformed to the required condition type (e.g. KQL / FQL). Custom conditions can be implemented by extending BaseCondition or some of the specific conditions extending BaseCondition.
Data Provider Return Types
Most data providers will return result items using one or more interface wrappers. The following interfaces are available:
IResultRecord |
Provides access to properties of the result item. Will be returned by most MatchPoint Data Providers. This interface provides dynamic extensions for names and therefore allows easy access to properties of a result element using the expression engine, e.g. DataItem.Title |
ISPItem |
Provides access to properties of a SharePoint item (e.g. SPListItem) Will be returned by Data Providers, that work on SharePoint List data sources. This interface provides the following properties:
|
ITagResultRecord |
Additional methods for accessing tag related functionality. Data providers retrieving data from a taggable data source will return elements that implement ITagResultRecord, which provides following two methods to access tags:
|
ITermResultRecord |
Specifies methods for retrieving terms from a result record. Elements with terms returned from data providers implement ITermResultRecord to provide methods for accessing the GUIDs of the terms:
|
For some configuration elements (e.g. PatternTransformer) within a Web Part that uses a data provider, the DataItem expression variable is available. This object can be used to access the current item provided. Any property that is available on that item can be accessed and combined with other expressions.
Typically, the result type of that variable will be one of the interfaces described above. However, depending on the configuration of the data provider, the DataItem expression variable might also return a type from the SharePoint object model (e.g. SPListItem).
The following table provides an overview on the return types of SharePoint list columns for data providers that allow access to SharePoint content:
Field Type | ListDataProvider | SiteDataProvider | SearchDataProvider | |||
---|---|---|---|---|---|---|
Return Type | Empty Value | Return Value | Empty Value | Return Value | Empty Value | |
String | String | null | String | null | String | null |
Boolean | Boolean | Boolean | String (0/1) | String | Boolean | Boolean |
Number | Double | null | String | null | Double | null |
Date Field | DateTime | null | String | null | DateTime | null |
Choice Multi Choice |
String String[] |
null [0] |
String String[] |
null | String[] | null |
Lookup Multi Lookup |
SPLookupValue
SPLookupValue[] |
null [0] |
SPLookupValue
n/s (null) |
null |
String String[] |
null |
Person Multi Person |
SPUserValue
SPUserValue[] |
null [0] |
SPLookupValue
n/s (null) |
null |
String String[] |
null |
Link | LinkValue | null | String | null | String | null |
Tag | Tag[] | [0] | Tag[] | [0] | Tag[] | [0] |
Term Multi Term |
IChoiceItem
IChoiceItem[] |
null [0] |
SPLookupValue
n/s (null) |
null | String String[] |
null |
Model Lookup | ILookupValue[] | [0] | String[] | null | String[] | null |
Bdc Lookup | LookupValue | null | String | null | String | null |
Caching
Some data providers support caching. It can be used to reduce network traffic and page loading times. The caching settings are always configured on the data provider and therefore are not restricted to a specific MatchPoint Web Part.
Caching is configured using a CachePolicy specifying Granularity and ExpirationMinutes. The Granularity's domain is specified by the CacheGranularity Enum. The cache expiration time can be configured by the ExpirationMinutes parameter, which specifies after how many minutes the cache data is fetched again.
Cache Granularity | Functionality |
---|---|
No Cache | Data is fetched on every request (per request cache) |
Global | Data can be shown to any user, no security trimming |
User | Data is security trimmed, one cache per user
The setting User can be memory-expensive in environments with many users. |
Furthermore, the cache expiration time can be configured: the CacheExpirationMinutes attribute specifies after how many minutes the cache data is fetched.
If the data provider contains dynamic conditions (e.g. a ConnectionData.<...>
expression),
the query string is also cached and upon new requests the provider's
query string is compared with that cached string so data is fetched only
if necessary.
- If tags are parsed, a tag cache needs to be maintained on every front end server.
- If many data providers are configured (especially with per user granularity), the cache has to be filled multiple times (for every user and every data provider on every front end server).
- Different cache states can result in different views (i.e. paging within a Data Grid).
- If the front end servers are not configured identically, inconsistent behavior might result.
- Page caches might also cause performance loss.
Sort Fields
Some data providers can be configured with SortField elements. These elements will define a sorting based on a field within the search result and a sort direction. For each data provider, up to three sort fields can be defined. Please note that the sorting condition in this case will be included directly into the search query.
Within a Data Grid Web Part, an additional sorting mechanism for views is available: ViewSortColumn. This configuration element allows sorting for any of the specified columns within the Data Grid. The sorting condition in this case will be evaluated by MatchPoint when the view is applied.