3.10.4.2. 查看实体日志

实体日志内容可以在 Administration > Entity Log 上的专用界面上查看。

除此之外,也能在其它应用程序界面访问实体更改日志,只要加载 EntityLogItem 集合及其关联的 EntityLogAttr 实例到数据源,再创建连接到这些数据源的可视化组件。例如:

  1. <dsContext>
  2. <datasource id="customerDs"
  3. class="com.sample.sales.entity.Customer"
  4. view="customerEdit"/>
  5. <collectionDatasource id="logDs"
  6. class="com.haulmont.cuba.security.entity.EntityLogItem"
  7. view="logView">
  8. <query>
  9. select i from sec$EntityLog i
  10. where i.entityRef.entityId = :ds$customerDs order by i.eventTs
  11. </query>
  12. <collectionDatasource id="logAttrDs"
  13. property="attributes"/>
  14. </collectionDatasource>
  15. </dsContext>
  16. <layout>
  17. ...
  18. <split orientation="vertical" width="100%" height="100%">
  19. <table id="logTable" width="100%" height="100%">
  20. <columns>
  21. <column id="eventTs"/>
  22. <column id="user.login"/>
  23. <column id="type"/>
  24. </columns>
  25. <rows datasource="logDs"/>
  26. </table>
  27. <table id="logAttrTable" width="100%" height="100%">
  28. <columns>
  29. <column id="name"/>
  30. <column id="value"/>
  31. </columns>
  32. <rows datasource="logAttrDs"/>
  33. </table>
  34. </split>
  35. ...
  36. </layout>

要显示本地化的值,启用日志记录的属性应包含@LocalizedValue注解。有此注解时,日志记录机制将填写 EntityLogAttr.messagesPack 字段,从而上面示例中的表格可以使用 locValue 列代替 value 列来显示本地化值:

  1. <table id="logAttrTable" width="100%" height="100%">
  2. <columns>
  3. <column id="name"/>
  4. <column id="locValue"/>
  5. </columns>
  6. <rows datasource="logAttrDs"/>
  7. </table>