Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagexml
titleReport 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>timeColumn<<name>timestampColumn</name>
                <path>time<<path>timestamp</path>
                <display>
                    <label>Time</label>
                </display>
            </column>
            <column>
                <name>targetColumn</name>
                <path>target<<path>targetRef</path>
                <display>
                    <label>Target</label>
                </display>
                <previousColumn>timeColumn</<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.*;
                            
                           ret = new ArrayList();
                           for (ObjectDeltaOperation delta : object) {
                              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)) + ")"  
                                    } 
                                    
                                    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)) + ")" 
                                    } 
                                    
                                    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>

...