Activating contexts

In order to use contexts in BI Point, you must edit the entries in the config.json file. Default location: "C:\Program Files (x86)\Comarch\BI Point\instances\instance name\bipoint" Flags:
  • IsReportContextEnable 
activates context-based reports
  • IsReportContextCheckEnabled 
activates certificate validation To be able to create contexts, both flags must be set to true, as shown below: Save the config.json file after making the above changes and restart the Comarch BI Point service for the changes to take effect.

Adding contexts

Contexts can only be added from a database level. To add a new context, you need to execute the following scripts on a PostgreSQL BI Point database.
INSERT INTO rb."Contexts" ("CTX_Name") VALUES ('ContextName')
INSERT INTO rb."Parameters" ("PAR_Name") VALUES ('ParameterName') INSERT INTO rb."ContextsParameters" ("CTP_ContextId","CPT_ParameterId") VALUES (1,1)
INSERT INTO [RB].[ContextsMappings]([CTM_ContextId],[CTM_ContextMapping],[CTM_MappingName]) VALUES (1,'ExternalContextName','ContextName') After you execute the above code, the NewContext will be visible. The API will use the name ExternalContextName. You can optionally add translations for conexts: INSERT INTO rb."ContextTranslations" ("CTL_Id", "CTL_ContextId", "CTL_LocaleId", "CTL_Translation") VALUES (1, 1, 'en-EN', 'Sale')

Defining contexts in Comarch BI Point

After you successfully activate contexts from the config.json file (as described in article Activating contexts) and add a context to the database (as described in article Adding contexts), you need to define contexts directly on the repository object. To define a context, first select the appropriate object and then the "Add Context" button.
Uwaga
Contexts cannot be added if the report, dashboard, or analysis is based on a data model that contains parameters.

After you select an object, a window with sections Context and Filtered Attribute will open.

  • Context
If only one context has been added, the field remains insensitive and cannot be edited. If more contexts have been added, a drop-down list with the added contexts will appear in the field, from which you can select the appropriate one.
  • Filtered attribute
In this field, you can select an attribute from the data model of the referenced object to which the created context will be assigned. You can add multiple contexts to a single object if more than one context has been defined in the database.

Using contexts in Comarch BI Point

Using contexts

API methods must be executed directly after the BI Point instance, e.g. http://localhost:55555/api/ReportContext/GetContextReports  

Available methods:

  • api/ReportContext/GetContextReports
this method displays all reports to which the context has been assigned. It returns a list of objects containing the report ID, name, and a list of contexts. The returned list is in JSON format. 1. Request this request accepts a list of contexts and a list of users. Both parameters are optional; if neither is specified, the response will contain a list of all context reports, unfiltered by access. Adding a context ID or its name will return reports assigned to those contexts. Adding a user ID or login will filter the list and return only those reports to which the user has access. 2. Response this method returns a list of report objects grouped by users. Reports to which the user does not have access are not returned. Each report object contains an Id,ReportName, and a list of contexts (Id,Name,Caption) assigned to it.  
  • api/ReportContext/GenerateLinks
this method generates a link to the report using the list of members, the report ID, and the context number. The report ID is the minimum parameter. 1. Request the request accepts the report ID to be opened and a list of contexts. The list contains the context ID and a list of elements to be filtered. These elements may have Type and Value fields, which are limited to three supported types: 2. Unique name 3. Displayed name 4. OrgId If BI Point cannot find an element, or if the provided context is not linked to the report, the report will open without the missing elements. 5. Response this method generates a link to a report/dashboard with a GUID under which all information necessary for filtering is stored.  

Examples of how to use the methods

 
  • api/ReportContext/GetContextReports

1.Requests

  • all context reports are requested.
{"data":"{}"}
  • context reports assigned to the context "Product" are requested.
{"data":"{\"Contexts\":[{\"Name\":\"Product\"}]}"}
  • context reports assigned to the context with id 20 are requested.
{"data":"{\"Contexts\":\[{\"Id\":20}\]}"}
  • context reports assigned to the context "Product" or to the context with id 20 are requested.
{"data":"{\"Contexts\":[{\"Id\":20},{\"Name\":\"Product\"}]}"}
  • all context reports available to the user with login "ab" are queried.
{"data":"{\"Users\":[{\"Login\":\"ab\"}]}"}
  • all context reports available to the user with id 14 are queried.
{"data":"{\"Users\":[{\"Id\":14}]}"}
  • all context reports available to the user with the login ab and to the user with id 14 are queried. Reports are grouped separately for each user.
{"data":"{\"Users\":[{\"Login\":\"ab\"},{\"Id\":14}]}"}
  • context reports assigned to the contect with id 20 and grouped by the user with the login "ab" and id 14 are queried.
{"data":"{\"Users\":[{\"Login\":\"ab\"},{\"Id\":14}],\"Contexts\":[{\"Id\":20}]}"}

2.Responses

 
  • api/ReportContext/GenerateLinks

1.Requests

  • a link to the report 37530 is requested
{"data":"{\"Id\":37530}"}
  • a link to the report 37530 filtered to the element with a unique name (Type 0) in the context with id 20 is requested
{"data":"{\"Id\":37530,\"Contexts\":[{\"Id\":20,\"Members\":[{\"Type\":0,\"Value\":\"[Product].[Code].&[100010013]\"}]}]}"}
  • a link to the report 37530 filtered to the element with a displayed name (Type 1) in the context with id 20 is requested
{"data":"{\"Id\":37530,\"Contexts\":[{\"Id\":20,\"Members\":[{\"Type\":1,\"Value\":\"KAR/0024/OP\"}]}]}"}
  • a link to the report 37530 filtered to the element with OrgId (Type 2) in the context with id 20 is requested
{"data":"{\"Id\":37530,\"Contexts\":[{\"Id\":20,\"Members\":[{\"Type\":2,\"Value\":\"368:141\"}]}]}"}
  • a link to the report 37530 filtered to the element with a unique name, displayed name and OrgId in the context with id 20 is requested
{"data":"{\"Id\":37530,\"Contexts\":[{\"Id\":20,\"Members\":[{\"Type\":0,\"Value\":\"[Product].[Code].&[100010013]\"},{\"Type\":1,\"Value\":\"KAR/0024/OP\"},{\"Type\":2,\"Value\":\"368:141\"}]}]}"}
  • a link to the report 37530 filtered to the element with a displayed name in the context with id 12 and with a unique name, displayed name and OrgId in the context with id 20 is requested
{"data":"{\"Id\":37530,\"Contexts\":[{\"Id\":12,\"Members\":[{\"Type\":1,\"Value\":\"00111 test test DE-123123 Bayern\"}]},{\"Id\":20,\"Members\":[{\"Type\":0,\"Value\":\"[Product].[Code].&[100010013]\"},{\"Type\":1,\"Value\":\"KAR/0024/OP\"},{\"Type\":2,\"Value\":\"368:141\"}]}]}"}

2.Responses