Extension point for SearchView customization

Using the new extension point com.heiler.ppm.search.ui.searchViewAdditions you can customize certain SearchViews without subclassing them.

Predefined search parameters

Sometimes it is useful to add additionally search parameters to each search which is triggered in a SearchView. This "predefined" search parameters are invisible for the user and will be ("and-") conjuncted with other search parameters defined by the user.

There are two ways to define predefined search parameters:

  1. via extension:

    <extension
    point="com.heiler.ppm.search.ui.searchViewAdditions">
    <searchView
    searchViewId="com.heiler.ppm.article.ui.views.ArticleSearchView">
    <searchParameter
    fieldIdentifier="ArticleLang.DescriptionShort">
    <searchValue
    caseSensitive="false"
    operator="contains"
    value="hammer">
    </searchValue>
    <logicalKey
    identifier="ArticleLangType.LK.Language"
    value="7">
    </logicalKey>
    </searchParameter>
    </searchView>
    </extension>
  2. via class:

    public class ArticlePredefinedSearchParameters implements PredefinedSearchParameters
    {
    @Override
    public Expression getPredefinedSearchExpression()
    {
    RepositoryService repositoryService = RepositoryComponent.getRepositoryService();
    Field field = repositoryService.getFieldByIdentifier( "ArticleLang.DescriptionShort" ); //$NON-NLS-1$
    FieldPath fieldPath = RepositoryUtils.getFieldPath( field );
    fieldPath.setData( SearchView.KEY_INITIAL_IDENTIFIER, field.getInitialIdentifier() );
    fieldPath.setData( SearchView.KEY_IDENTIFIER, field.getIdentifier() );
    fieldPath.setData( SearchView.KEY_NAME, field.getName() );
    fieldPath.setData( SearchView.KEY_NAME_FROM_TOP, field.getNameFromTop() );
    fieldPath.getEntityPath()
    .setLogicalKeyValue( "ArticleLangType.LK.Language", 9 ); //$NON-NLS-1$
    FieldPathExpression fieldPathExpression = new FieldPathExpression( fieldPath );
    ValueExpression valueExpression = new ValueExpression( "hammer" ); //$NON-NLS-1$
    Expression operation = fieldPathExpression.contains( valueExpression );
    return operation;
    }
    }
    <extension
    point="com.heiler.ppm.search.ui.searchViewAdditions">
    <searchView
    predefinedSearchParameters="com.heiler.ppm.custom.article.ui.internal.ArticlePredefinedSearchParameters"
    searchViewId="com.heiler.ppm.article.ui.views.ArticleSearchView">
    </searchView>
    </extension>

In both cases, each search which is performed in the ArticleSearchView will be "erniched" with the additional search parameter for the field "Short description".

You can also use both ways together. In this case all predefined search parameters will be and-conjuncted.

Different result view

Generally the result of the search will be shown in the default view for the root search entity. The root search entity is defined in the search view contribution as an initialization parameter (e.g. com.heiler.ppm.articlesearch.ui.internal.view.ArticleSearchView:Article). The default view for the root entity will be obtained from the repository. Additionally you can define a different result view which should be used to show the search result. Just use the same extension point and specify the result view ID:

<extension
point="com.heiler.ppm.search.ui.searchViewAdditions">
<searchView
resultViewId="com.heiler.ppm.custom.article.ui.CustomArticleView"
searchViewId="com.heiler.ppm.article.ui.views.ArticleSearchView">
</searchView>
</extension>

In this case the result of the search performed in the ArticleSearchView will be always shown in the CustomArticleView.

Download

You can find a full source code example for this here.