Validation Script or Rule
A validation rule or script is used to validate the data entered on a report form. For example, if a value is required for a specific filter for the report to run, that field can be validated as being non-null by a ValidationRule or ValidationScript.
A Validation script contains the code inline, wrapped in a <Source> element.
<ValidationScript>
<Source>
import java.util.*;
import sailpoint.reporting.*;
import sailpoint.object.*;
List messages = new ArrayList();
… (validation code goes here - see rule example below)
return messages;
</Source>
</ValidationScript>
A validation Rule is called by reference:
<ValidationRule>
<Reference class="sailpoint.object.Rule" id="4028460238ed9b8e0138ed9bf61300ff" name="Privileged Access Report Validation Rule"/>
</ValidationRule>
This validation rule checks the field on the Privileged Account Attributes form for a null (or empty) value; the report requires that a value be specified for this field, so an error message is displayed and the report does not run if this field does not pass this validation. A validation script or rule returns a list of messages; if the form passes validation, this list should be empty.
<Rule language="beanshell" type="ReportValidator" name="Privileged Access Report Validation Rule">
<Description>
This rule validates the Privileged Access Report Form
</Description>
<Signature returnType="java.util.List">
<Inputs>
<Argument name="context">
<Description>
A sailpoint.api.SailPointContext object that can be used to query the database if necessary.
</Description>
</Argument>
<Argument name="report">
<Description>
The report object
</Description>
</Argument>
<Argument name="form">
<Description>
The submitted sailpoint Form object.
</Description>
</Argument>
</Inputs>
<Returns>
<Argument name="messages">
<Description>
A list of error messages.
</Description>
</Argument>
</Returns>
</Signature>
<Source>
<![CDATA[
import java.util.*;
import sailpoint.object.*;
import sailpoint.tools.Message;
List messages = new ArrayList();
Form.Section section = form.getSection("Priviledged Account Attributes");
boolean found = false;
for(FormItem item : section.getItems()){
Field field = (Field)item;
if(field.getValue() != null && field.getValue() != "") {
found = true;
}
}
if (!found)
messages.add(Message.localize("rept_priv_access_err_no_attr"));
return messages;
]]>
</Source>
</Rule>
ReportSummary: Summary Table
The <ReportSummary> element describes the summary table in the summary section of the report.
The table header is specified in the title attribute.
<ReportSummary title="Uncorrelated Account Details">
The report summary has its own datasource; it does not use the same datasource as the report detail grid. The datasource for the report summary can be specified as a script or a rule. A script is most commonly used, but the datasource beanshell can be encapsulated in a rule for reusability if desired. Both are expressed as nested elements (<DataSourceScript> or <DataSourceRule>).
The DataSourceScript or DataSourceRule for the ReportSummary is passed these parameters:
DataSourceScript or Rule Parameters |
Contents/Purpose |
Context |
A SailPoint Context object for executing the search |
reportArgs |
The TaskDefinition argument/attribute map |
Report |
The entire LiveReport report definition |
baseHql |
The from and where clause used in the report detail search if the report DataSource was an HQL datasource; null if DataSource type was not HQL |
baseQueryOptions |
The QueryOptions (specifying the "where" clause criteria) used in the report detail search if the report DataSource was a Filter datasource; null if Datasource type was not Filter |
The summary table is usually built from data retrieved through one or more database queries that are specified and executed by the script or rule through the context (SailPointContext object), passing it a QueryOptions object populated with the necessary Filter objects. The example here illustrates how this is done.
<ReportSummary title="Uncorrelated Account Details">
<DataSourceScript>
<Source>
import java.util.*;
import sailpoint.tools.Util;
import java.lang.Math;
import sailpoint.object.*;
import sailpoint.api.ObjectUtil;
QueryOptions ops = new QueryOptions();
ops.addGroupBy("correlated");
String sources = "";
// retrieve list of apps in reportArgs argument map; add IDs to
// filter and names to CSV list to display as summary's "Sources" value
if (reportArgs.containsKey("correlatedApps")){
List apps = reportArgs.getList("correlatedApps");
if (apps != null){
ops.addFilter(Filter.in("links.application.id", apps));
List appNames = ObjectUtil.convertIdsToNames(context, Application.class, apps);
sources = Util.listToCsv(appNames);
}
}
List fields = new ArrayList();
fields.add("correlated");
fields.add("count(*)");
int correlated = 0;
int uncorrelated = 0;
// get counts per Identity with links on the named applications,
// subdivided by "correlated" flag
Iterator results = context.search(Identity.class, ops, fields);
while(results.hasNext()){
Object[] row = results.next();
int count = Util.otoi(row[1]);
// add counts to correlated or uncorrelated totals based on correlated
// flag
if ((Boolean)row[0]){
correlated += count;
} else {
uncorrelated += count;
}
}
// calculate percentage of accounts that are correlated
float percent = correlated != 0 ? (float)uncorrelated/correlated : 0;
String percentString = ((int)Math.floor(percent * 100)) + "%";
// add values to hashmap; these name/value pairs are displayed in the
// report summary through the XML's LiveReportSummaryValue elements
Map map = new HashMap();
map.put("sources", sources);
map.put("correlatedIdentities", correlated);
map.put("uncorrelatedIdentities", uncorrelated);
map.put("totalIdentities", correlated + uncorrelated);
map.put("percentCorrelated", percentString);
return map;
</Source>
</DataSourceScript>
A datasource rule would be specified as a nested element (<DataSourceRule>) that contains a rule reference.
<DataSourceRule>
<Reference class="sailpoint.object.Rule" id="4028460238ed9b8e0138ed9beff9090f" name="UncorrelatedAcct Report Summary Rule"/>
</DataSourceRule>
The datasource script or rule returns a hashMap of values that are used to populate the corresponding LiveReportSummaryValue elements (based on their name attributes) in the ReportSummary's Values list. The LiveReportSummaryValue elements each include a unique name and a label attribute. The label can be specified as a string or a localizable message key and is displayed alongside the value in the Report's summary section.<ReportSummary title="Uncorrelated Account Details">
<DataSourceScript>
<Source>
…
Map map = new HashMap();
map.put("sources", sources);
map.put("correlatedIdentities", correlated);
map.put("uncorrelatedIdentities", uncorrelated);
map.put("totalIdentities", correlated + uncorrelated);
map.put("percentCorrelated", percentString);
return map;
</Source>
</DataSourceScript>
<Values>
<LiveReportSummaryValue label="rept_uncorrelated_ids_grid_label_auth_sources" name="sources"/>
<LiveReportSummaryValue label="rept_uncorrelated_ids_summary_correlated" name="correlatedIdentities"/>
<LiveReportSummaryValue label="rept_uncorrelated_ids_summary_uncorrelated" name="uncorrelatedIdentities"/>
<LiveReportSummaryValue label="rept_uncorrelated_ids_summary_total_ids" name="totalIdentities"/>
<LiveReportSummaryValue label="rept_uncorrelated_ids_summary_percent" name="percentCorrelated"/>
</Values>
</ReportSummary>