Skip to content

Commit

Permalink
removing AuditSearchType form schema and usages in code
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Aug 26, 2021
1 parent 23442a4 commit fe8b80c
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8043,8 +8043,7 @@
<xsd:complexType name="ProportionalExpressionEvaluatorType">
<xsd:annotation>
<xsd:documentation>
Expression gets IntegerStatType as an input, IntegerStatType is derived from audit search.
But this is all experimental. Later it will probably get entire AuditSearchType object.
Expression gets IntegerStatType as an input, IntegerStatType is derived from collection.
This expression evaluator may autodetect that input is a ObjectCollectionType and find IntegerStatType inside.
</xsd:documentation>
<xsd:appinfo>
Expand Down Expand Up @@ -15125,28 +15124,6 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="auditSearch" type="tns:AuditSearchType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Specification of an explicit or implicit object collection that will be used as data source for the view.

EXTREMELY ABSOLUTELY GIGANTICALLY ENORMOUSLY MEGA GIGA TERA SUPER HYPER EXPERIMENTAL

This is almost certain to change in the future. It does not even belong here well
as this is supposed to be *object* collection and not audit collection. But for now it solves a
couple of problems in dashboards and report functionality, which is also experimental.
Therefore this is a good temporary choice.
However, if you ever rely on this element the karma will get you, eventually.
If that happens, don't come to us crying. You have been warned.
</xsd:documentation>
<xsd:appinfo>
<a:displayName>ObjectCollectionType.auditSearch</a:displayName>
<a:experimental>true</a:experimental>
<a:deprecated>true</a:deprecated>
<a:plannedRemoval>4.4</a:plannedRemoval>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="baseCollection" type="tns:CollectionRefSpecificationType" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
Expand Down Expand Up @@ -15343,55 +15320,6 @@
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="AuditSearchType">
<xsd:annotation>
<xsd:documentation>
Specification of search criteria for audit trails.
EXTREMELY EXPERIMENTAL. This is almost certain to change in the future.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>4.0</a:since>
<a:experimental>true</a:experimental>
<a:deprecated>true</a:deprecated>
<a:plannedRemoval>4.4</a:plannedRemoval>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="recordQuery" type="xsd:string" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AuditSearchType.recordQuery</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="domainQuery" type="xsd:string" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AuditSearchType.domainQuery</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="interval" type="xsd:duration" minOccurs="0" maxOccurs="1">
<xsd:annotation>
<xsd:documentation>
TODO
</xsd:documentation>
<xsd:appinfo>
<a:displayName>AuditSearchType.interval</a:displayName>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long"/>
</xsd:complexType>

<xsd:complexType name="InternalsConfigurationType">
<xsd:annotation>
<xsd:documentation>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@
*/
package com.evolveum.midpoint.model.api.util;

import java.util.Date;
import java.util.Map;

import javax.xml.datatype.Duration;

import com.evolveum.midpoint.model.api.ModelService;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.task.api.Task;
import com.evolveum.midpoint.util.QNameUtil;
import com.evolveum.midpoint.util.exception.*;
import com.evolveum.midpoint.xml.ns._public.common.audit_3.AuditEventRecordType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;

import org.apache.commons.lang3.StringUtils;

import com.evolveum.midpoint.common.Clock;
import com.evolveum.midpoint.util.annotation.Experimental;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
Expand Down Expand Up @@ -149,40 +141,6 @@ public static String getQueryForListRecords(String query) {
return query;
}

public static String createQuery(ObjectCollectionType collectionForQuery, Map<String, Object> parameters,
boolean forDomain, Clock clock) {
if(collectionForQuery == null) {
return null;
}
AuditSearchType auditSearch = collectionForQuery.getAuditSearch();
if(auditSearch != null && StringUtils.isNotBlank(auditSearch.getRecordQuery())) {
Duration interval = auditSearch.getInterval();
if(interval == null) {
return auditSearch.getRecordQuery();
}
String origQuery = auditSearch.getRecordQuery();
if(forDomain) {
origQuery = auditSearch.getDomainQuery();
if(origQuery == null) {
return null;
}
}
String [] partsOfQuery = origQuery.split("where");
if(interval.getSign() == 1) {
interval = interval.negate();
}
Date date = new Date(clock.currentTimeMillis());
interval.addTo(date);
String query = partsOfQuery[0] + "where " + TIMESTAMP_VALUE_NAME + " >= " + ":from" + " ";
parameters.put(PARAMETER_FROM, date);
if(partsOfQuery.length > 1) {
query+= "and" +partsOfQuery[1];
}
return query;
}
return null;
}

public static boolean isAuditCollection(CollectionRefSpecificationType collectionRef, ModelService modelService, Task task, OperationResult result) {
if (collectionRef == null) {
return false;
Expand All @@ -194,10 +152,6 @@ public static boolean isAuditCollection(CollectionRefSpecificationType collectio
if (collection != null && QNameUtil.match(collection.asObjectable().getType(), AuditEventRecordType.COMPLEX_TYPE)) {
return true;
}
if (collection != null && collection.asObjectable().getAuditSearch() != null
&& collection.asObjectable().getAuditSearch().getRecordQuery() != null) {
return true;
}
} catch (Exception e) {
LOGGER.error("Couldn't get object collection from oid " + collectionRef.getCollectionRef().getOid());
}
Expand Down

0 comments on commit fe8b80c

Please sign in to comment.