Example of Audit search panel configuration

Last modified 22 Apr 2021 17:31 +02:00

This example describe how to configure time interval search item.

Adding next code to systemConfiguration.

<systemConfiguration>
    <adminGuiConfiguration>
        <objectCollectionViews>
            .
            .
            .
            <objectCollectionView>
                <identifier>auditRecords</identifier>
                <searchBoxConfiguration>
                    <searchItems>
                        <searchItem>
                            <filterExpression>
                                <script>
                                    <code>
                                       import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType;

                                       String interval = "";
                                       if ("oneHour".equals(timeInterval)) {
                                          interval = "-PT1H";
                                       } else if ("24h".equals(timeInterval)) {
                                          interval = "-P1D";
                                       } else if ("week".equals(timeInterval)) {
                                          interval = "-P7D";
                                       } else if ("mount".equals(timeInterval)) {
                                          interval = "-P1M";
                                       } else {
                                          return null;
                                       }

                                       calendar = basic.addDuration(basic.currentDateTime(), interval);
                                       filter = prismContext.queryFor(AuditEventRecordType.class).item(AuditEventRecordType.F_TIMESTAMP).gt(calendar).buildFilter();
                                       return prismContext.getQueryConverter().createSearchFilterType(filter)
                                    </code>
                                </script>
                            </filterExpression>
                            <displayName>Time interval</displayName>
                            <parameter>
                                <name>timeInterval</name>
                                <type>string</type>
                                <allowedValuesExpression>
                                    <script>
                                        <code>
                                         import com.evolveum.midpoint.web.component.search.SearchValue;

                                         List list = new ArrayList();
                                         list.add(new SearchValue("oneHour", "Last hour"));
                                         list.add(new SearchValue("24h", "Last 24 hours"));
                                         list.add(new SearchValue("week", "Per week"));
                                         list.add(new SearchValue("mount", "Per mount"));
                                         return list;
                                      </code>
                                    </script>
                                </allowedValuesExpression>
                            </parameter>
                        </searchItem>
                    </searchItems>
                </searchBoxConfiguration>
                <type>AuditEventRecordType</type>
            </objectCollectionView>
            .
            .
            .
        </objectCollectionViews>
    </adminGuiConfiguration>
</systemConfiguration>
image2021 1 19 13 15 0
Was this page helpful?
YES NO
Thanks for your feedback