-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'docs/cleanup-4.8' into support-4.8
- Loading branch information
Showing
5 changed files
with
109 additions
and
427 deletions.
There are no files selected for viewing
116 changes: 16 additions & 100 deletions
116
docs/misc/reports/examples/audit-report-with-changed-attributes.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,116 +1,32 @@ | ||
= Example of Collection report: Audit report with changed attributes | ||
= Collection report: Audit report, attribute changes | ||
:page-nav-title: Audit report with changed attributes | ||
:page-wiki-name: Example of new report: Audit report with changed attributes | ||
:page-wiki-name: Collection report: Audit report, attribute changes | ||
:page-wiki-id: 52003081 | ||
:page-wiki-metadata-create-user: lskublik | ||
:page-wiki-metadata-create-date: 2020-08-18T15:06:52.473+02:00 | ||
:page-wiki-metadata-modify-user: lskublik | ||
:page-wiki-metadata-modify-date: 2020-09-07T09:26:13.342+02:00 | ||
:page-upkeep-status: yellow | ||
:page-upkeep-status: Green | ||
|
||
Please see xref:/midpoint/reference/misc/reports/configuration/#new-report[Report configuration] for basic information about configuration variables. | ||
|
||
== Usecase | ||
|
||
We need create report for audit events of modification with column for changed items. | ||
== Example use-case | ||
|
||
We need to create a report for audit events of modifications with a column for changed items. | ||
|
||
== Configuration | ||
|
||
We need import only report, because we use object collection from initial objects. | ||
|
||
.Report XML | ||
[source,xml] | ||
---- | ||
<report> | ||
<name>Audit report with changed attributes</name> | ||
<assignment> | ||
<targetRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</targetRef> | ||
</assignment> | ||
<archetypeRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</archetypeRef> | ||
<roleMembershipRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</roleMembershipRef> | ||
<objectCollection> | ||
<collection> | ||
<collectionRef oid="00000000-0000-0000-0001-000000000002" relation="default" type="ObjectCollectionType"> | ||
<!-- Modification audit records --> | ||
</collectionRef> | ||
</collection> | ||
<view> | ||
<column> | ||
<name>timestampColumn</name> | ||
<path>timestamp</path> | ||
</column> | ||
<column> | ||
<name>targetColumn</name> | ||
<path>targetRef</path> | ||
<previousColumn>timestampColumn</previousColumn> | ||
</column> | ||
<column> | ||
<name>changedAttributesColumn</name> | ||
<path>delta</path> | ||
<display> | ||
<label>Changed attributes</label> | ||
</display> | ||
<previousColumn>targetColumn</previousColumn> | ||
<export> | ||
<expression> | ||
<script> | ||
<code> | ||
import com.evolveum.midpoint.schema.ObjectDeltaOperation; | ||
import com.evolveum.midpoint.prism.delta.ItemDelta; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
import com.evolveum.midpoint.schema.DeltaConvertor; | ||
Configuration for this use case consists only from the report itself, because we use an object collection from the initial objects. | ||
|
||
ret = new ArrayList(); | ||
for (ObjectDeltaOperationType deltaType : input) { | ||
delta = DeltaConvertor.createObjectDeltaOperation(deltaType, midpoint.getPrismContext()); | ||
for (ItemDelta itemDelta : delta.getObjectDelta().getModifications()){ | ||
if(!itemDelta.getPath().toString().startsWith("metadata")) { | ||
stringItem = itemDelta.getElementName().toString(); | ||
if (itemDelta.isAdd()) { | ||
stringItem = stringItem + " (Add values: "; | ||
for (addValue in itemDelta.getValuesToAdd()) { | ||
stringItem = stringItem + addValue.getRealValue() | ||
stringItem = stringItem + "," | ||
} | ||
stringItem = stringItem.substring(0, (stringItem.length()-1)) + ")" | ||
} | ||
.*Example Report Configuration* | ||
[%collapsible] | ||
==== | ||
sampleRef::samples/reports/audit-report-changed-attrs.xml[] | ||
==== | ||
|
||
if (itemDelta.isDelete()) { | ||
stringItem = stringItem + " (Delete values: "; | ||
for (deleteValue in itemDelta.getValuesToDelete()) { | ||
stringItem = stringItem + deleteValue.getRealValue() | ||
stringItem = stringItem + "'" | ||
} | ||
stringItem = stringItem.substring(0, (stringItem.length()-1)) + ")" | ||
} | ||
== See Also | ||
|
||
if (itemDelta.isReplace()) { | ||
stringItem = stringItem + " (Replace values: "; | ||
for (replaceValue in itemDelta.getValuesToReplace()) { | ||
stringItem = stringItem + replaceValue.getRealValue() | ||
stringItem = stringItem + "," | ||
} | ||
stringItem = stringItem.substring(0, (stringItem.length()-1)) + ")" | ||
} | ||
ret.add(stringItem); | ||
} | ||
} | ||
} | ||
return ret | ||
</code> | ||
</script> | ||
</expression> | ||
</export> | ||
</column> | ||
</view> | ||
</objectCollection> | ||
</report> | ||
---- | ||
- xref:/midpoint/reference/misc/reports/examples/[Report Examples] | ||
- xref:/midpoint/reference/misc/reports/configuration/[Report Configuration] | ||
- xref:/midpoint/reference/misc/reports/configuration/collection-report.adoc[Collection Based Reports] | ||
- xref:/midpoint/reference/misc/reports/configuration/dashboard-report.adoc[Dashboard Based Reports] |
185 changes: 34 additions & 151 deletions
185
...ports/examples/comparing-attributes-of-shadow-and-attributes-of-user-in-mp.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,168 +1,51 @@ | ||
= Example of Collection report: Comparing attributes of shadow and attributes of user in midPoint | ||
= Collection report: Comparing attributes of shadow and attributes of user in midPoint | ||
:page-nav-title: Comparing attributes of shadow and attributes of user in midPoint | ||
:page-wiki-name: Example of new report: Comparing attributes of shadow and attributes of user in mP | ||
:page-wiki-name: Collection report: Comparing attributes of shadow and attributes of user in midPoint | ||
:page-wiki-id: 52003075 | ||
:page-wiki-metadata-create-user: lskublik | ||
:page-wiki-metadata-create-date: 2020-08-18T14:15:45.548+02:00 | ||
:page-wiki-metadata-modify-user: lskublik | ||
:page-wiki-metadata-modify-date: 2020-08-18T15:03:38.032+02:00 | ||
:page-upkeep-status: yellow | ||
:page-upkeep-status: green | ||
|
||
Please see xref:/midpoint/reference/misc/reports/configuration/#new-report[Report configuration] for basic information about configuration variables. | ||
|
||
|
||
== Usecase | ||
== Example use-case | ||
|
||
We need report users with mismatched attributes, so we have to compare attributes of account of user and attributes of user in Midpoint. We create example which compare email prefix of user in Midpoint with firstname and lastname attributes of account chained by '.'. | ||
|
||
|
||
== Configuration | ||
|
||
We need import object collection and report. | ||
|
||
|
||
.Object collection XML | ||
[source,xml] | ||
---- | ||
<objectCollection oid="72b1f98e-f587-4b9f-b92b-72e251dbb244"> | ||
<name>Account shadow R1</name> | ||
<type>ShadowType</type> | ||
<filter> | ||
<and> | ||
<ref> | ||
<path>resourceRef</path> | ||
<value oid="----OID_OF_YOUR_RESOURCE----"/> | ||
</ref> | ||
<equal> | ||
<path>kind</path> | ||
<value>account</value> | ||
</equal> | ||
</and> | ||
</filter> | ||
</objectCollection> | ||
---- | ||
|
||
Please replace '----OID_OF_YOUR_RESOURCE----' with oid of your resource. | ||
|
||
.Report XML | ||
[source,xml] | ||
---- | ||
<report> | ||
<name>Comparing attributes</name> | ||
<assignment> | ||
<targetRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</targetRef> | ||
</assignment> | ||
<archetypeRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</archetypeRef> | ||
<roleMembershipRef oid="00000000-0000-0000-0000-000000000171" relation="default" type="ArchetypeType"> | ||
<!-- Collection report --> | ||
</roleMembershipRef> | ||
<objectCollection> | ||
<collection> | ||
<collectionRef oid="72b1f98e-f587-4b9f-b92b-72e251dbb244" relation="default" type="ObjectCollectionType"> | ||
<!-- Account shadow R1 --> | ||
</collectionRef> | ||
</collection> | ||
<view> | ||
<identifier>default-shadow</identifier> | ||
<column> | ||
<name>nameColumn</name> | ||
<path>attributes/login</path> | ||
<display> | ||
<label>Login</label> | ||
</display> | ||
</column> | ||
<column> | ||
<name>firstNameColumn</name> | ||
<path>attributes/firstname</path> | ||
<display> | ||
<label>First name</label> | ||
</display> | ||
<previousColumn>nameColumn</previousColumn> | ||
</column> | ||
<column> | ||
<name>lastNameColumn</name> | ||
<path>attributes/lastname</path> | ||
<display> | ||
<label>Last name</label> | ||
</display> | ||
<previousColumn>firstNameColumn</previousColumn> | ||
</column> | ||
<column> | ||
<name>emailInMpColumn</name> | ||
<display> | ||
<label>Email in mP</label> | ||
</display> | ||
<previousColumn>lastNameColumn</previousColumn> | ||
<export> | ||
<expression> | ||
<script> | ||
<code> | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import org.apache.commons.lang3.StringUtils; | ||
user = midpoint.searchShadowOwner(object.getOid()); | ||
return user.asObjectable().getEmailAddress(); | ||
</code> | ||
</script> | ||
</expression> | ||
</export> | ||
</column> | ||
<type>ShadowType</type> | ||
</view> | ||
<condition> | ||
<script> | ||
<code> | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.UserType; | ||
import com.evolveum.midpoint.prism.path.ItemPath; | ||
import org.apache.commons.lang3.StringUtils; | ||
shadowAttributes = object.getAttributes().asPrismContainerValue() | ||
login = shadowAttributes.findProperty(ItemPath.create("login")).getRealValue(); | ||
user = midpoint.searchShadowOwner(object.getOid()); | ||
System.out.println("LOGIN: " + login) | ||
System.out.println("USER: " + user) | ||
if (user != null && user.asObjectable() != null) { | ||
email = user.asObjectable().getEmailAddress(); | ||
if (StringUtils.isEmpty(email)) { | ||
return true; | ||
} | ||
firstName = shadowAttributes.findProperty(ItemPath.create("firstname")); | ||
lastName = shadowAttributes.findProperty(ItemPath.create("lastname")); | ||
if (firstName == null && lastName == null) { | ||
return false; | ||
} | ||
prefix = ""; | ||
if (firstName != null && firstName.getRealValue() != null) { | ||
prefix = firstName.getRealValue().toLowerCase().replace(" ", "."); | ||
} | ||
if (lastName != null && lastName.getRealValue() != null) { | ||
if (StringUtils.isNotEmpty(prefix)) { | ||
prefix = prefix + "." | ||
} | ||
prefix = prefix + lastName.getRealValue().toLowerCase().replace(" ", "."); | ||
} | ||
if (StringUtils.isEmpty(prefix)) { | ||
return true; | ||
} | ||
if (!prefix.equals(email.substring(0,email.indexOf("@")))) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
</code> | ||
</script> | ||
</condition> | ||
<useOnlyReportView>true</useOnlyReportView> | ||
</objectCollection> | ||
</report> | ||
---- | ||
.*Example Resource Configuration* | ||
[%collapsible] | ||
==== | ||
sampleRef::samples/resources/csv/resource-csv-username.xml[] | ||
==== | ||
|
||
.*Example CSV Source File* | ||
[%collapsible] | ||
==== | ||
sampleRef::samples/resources/csv/midpoint-username.csv[] | ||
==== | ||
|
||
.*Example Object Collection* | ||
[%collapsible] | ||
==== | ||
sampleRef::samples/objectCollection/resource-account-shadows.xml[] | ||
==== | ||
|
||
.*Example Report Configuration* | ||
[%collapsible] | ||
==== | ||
sampleRef::samples/reports/comparing-attributes.xml[] | ||
==== | ||
|
||
== See Also | ||
|
||
- xref:/midpoint/reference/misc/reports/examples/[Report Examples] | ||
- xref:/midpoint/reference/misc/reports/configuration/[Report Configuration] | ||
- xref:/midpoint/reference/misc/reports/configuration/collection-report.adoc[Collection Based Reports] | ||
- xref:/midpoint/reference/misc/reports/configuration/dashboard-report.adoc[Dashboard Based Reports] |
Oops, something went wrong.