...
Create a JAVA class that should implement in the JAVA callback interface as a part of the callback code.
QueryFilters parameter holds all the filters applied in the query. The callback code iterates over all the filters to identify those that need resolution via an appropriate flag in the filter object. Subsequently, every callback filter is resolved against the received GUID/ID, replacing it with the actual list of values within the same filter object before returning it.
The JAVA class created in Step 1 needs to be packaged in a JAR file. This JAR file needs to be uploaded in Kyvos via Kyvos Manager. Along with jar, you must configure the name of the class (full qualified name including package name) created in step 1 in Kyvos Manager.
...
Code Block |
---|
package cohortfilters; import com.kyvos.commons.callback.query.IFilterCallback; import com.kyvos.commons.entity.olap.viewer.Filter; import com.kyvos.commons.entity.olap.viewer.Filters; import com.kyvos.commons.queryanalyze.QueryInfoBean; import java.io.FileReader; import java.util.Arrays; import java.util.Iterator; import java.util.logging.SimpleFormatter; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; public class CallBack implements IFilterCallback { public Filters getResolvedFilters(Filters queryFilters, QueryInfoBean queryInfoBean) { Filter filter = (Filter)queryFilters.getFilters().get(0); String guid = filter.getFirstValue(); String userName = queryInfoBean.getUserName(); String values = getValueByUsernameAndGUID(userName, guid); filter.setFirstValue(values); return queryFilters; } public static String getValueByUsernameAndGUID(String userName, String guid) { String location = "pathToFiltersJson"; FileReader reader = new FileReader(location); JSONParser parser = new JSONParser(); JSONObject jsonObject = (JSONObject)parser.parse(reader); JSONArray adminArray = (JSONArray)jsonObject.get(userName); if (adminArray != null) { Iterator var8 = adminArray.iterator(); while(var8.hasNext()) { Object adminObj = var8.next(); JSONObject admin = (JSONObject)adminObj; JSONArray guidArray = (JSONArray)admin.get(guid); if (guidArray != null && guidArray.size() > 0) { JSONObject valueObj = (JSONObject)guidArray.get(0); return (String)valueObj.get("VALUE"); } } } return null; } } filters json :: { "userName":[ { "GUID1":[ { "VALUE":"'',''" } ] } , { "GUID2":[ { "VALUE":"'',''" } ] } ] } |
...
To upload the JAR file you have created via Kyvos Manager, perform the following steps.
Log into Kyvos Manager.
Click Toolbox, navigate to Security > Data Security.
On the Data Security page, select the Enable Custom Filter checkbox to enable CUSTOMKYVOSFILTER filter in Kyvos to handle large cohort value.
Upload the Custom Filter Callback JAR file.
Specify the Callback JAVA Class name, providing the fully qualified class name, including the package name.
Click Save.
Restart the BI Server.