The databases allow you to dynamically set up view query clauses (view or treeview) in a dynamic way, which will be combined with the view query (by and).
They can be used to process the compartmentalization of data sources, depending on the context of the request (the connected user in particular, but also the schedule for example).
Bases are instances of PreparedWhere to set as query attribute.

Standard attributes

To determine the bases; at each query execution, we start by looking at whether there is a query attribute called init_base_rest_<name of the view> type wsnoheto. engine. PreparedWhere. If it exists, we use this one. Otherwise, we look for one called init_base_rest. If so, then we use it.
Then, we add all the found databases that are listed for the view in its configuration.

Bases in view configuration

The base property allows you to specify a table of bases that will be used for each query with this view, in addition to the standard attributes.
For example:

{
  "objectname": "asset",
  "description": "description",
  "query": "",
  "bases": [ "StatusOnLine", "NotExpired" ],
  "orderby":"pid",
  "secured":true,
  "max":0,
  "from":0,
  "fulltext":"",
  "props": [ "id", "name", "status.id", "status.name" ],
  "aggs": {
    "fieldname1": {
      "props":["id", "name", "status.id"]
    }
  }
}


JSP

The JSP to use to generate the databases is /bov3/common/init/init_base_rest.jsp up to and including 11.9. As of 11.9.1 and after, the URL is /_restapi/init/init/init_base_rest.jsp.

Prepared where service

Prepared where services (ie com.noheto.preparedwhere.PreparedWhereService) can be referenced in dam and data API since 11.25.

The principle is a mapping between the API context and the Prepared Where Service context system. Each service Each service has its own context and it is possible to indicate which context of Prepared Where Services to use for it.

The mapping can be configured in the API Admin (Base wheres mapping icon):

Simplified syntax

The configuration consists of a json that defines which Prepared Where Service context should be used for a given API service context, in the form of associations API context = PWS context (or list of PWS contexts).

API Contexts

Here is the list of API contexts (ie the key in mappings):

Full syntax

For each association, you can set:

Defaults

{
	"search": "base_search_list",
	"aggs": "base_search_list",
	"list": "base_list",
	"tree": "base_list"
}

Business Service

It is possible to manage bases by Java code. To do this, simply create a plugin and copy the jar restapibs.jar () into its lib folder. Then make a class that extends com.noheto.restapi.APIBaseWhereBusinessServiceAdapter.

The principle is to code a method that returns a PreparedWhere (or null for any base) that will be combined by and with the main query, according to a call context (a service, a configuration, a requested object, a user, etc).

method PreparedWhere getPreparedWhere(Context context)

Overrides this method to provide a base where.

method PreparedWhere getPreparedWhere(Context context, String id)

Overrides this method to provide the base where corresponding to a specific standard id (see Bases in view configuration).

Argument context

This argument provides access to the call context.

getRequest

Returns the http servlet request instance.

getSurfer

Returns the surfer.

getLocale

Returns the locale of the query (could be different than the surfer locale).

getServiceId

Returns the service id. Refer to the com.noheto.restapi.ServiceId class for identifiers.

getConfigId

Returns the configuration id.

getObjectName

Returns the name of the object (object type).

getMethod

Returns the real method (do not use getMethod() of HTtpServletRequest for this).

Example

package fr.wedia.myplugin;

import com.noheto.restapi.APIBaseWhereBusinessServiceAdapter;
import com.noheto.restapi.Context;
import com.noheto.restapi.ServiceId;

import wsnoheto.engine.PreparedWhere;

public class DemoBaseWhere extends APIBaseWhereBusinessServiceAdapter {

    @Override
    public PreparedWhere getPreparedWhere(Context context) {
        // if service endpoint is api/rest/dam/asset
        if ( ServiceId.DAM_ASSET.equals(context.getServiceId()) ) {
            // select only activated and published assets
            return PreparedWhere.load("pactivated=1 && pstatus=2");
        }
        // else do the default behavior (return null, so no base where)
        return super.getPreparedWhere(context);
    }
	
}


Dependancy and agregates base wheres

From 2022.4, two types of extensions are provided: