Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Entity Snapshots #3

Closed
7 tasks done
knstvk opened this issue Feb 13, 2020 · 4 comments
Closed
7 tasks done

Entity Snapshots #3

knstvk opened this issue Feb 13, 2020 · 4 comments
Assignees
Milestone

Comments

@knstvk
Copy link
Contributor

knstvk commented Feb 13, 2020

Progress

2021-08-24: 100%

Parts of task:

  • Move the data model
  • Move all services
  • Move diff-viewer and rework it to screen API
  • Refactoring "difference" data model
  • To make storage mechanism more flexible.
  • Write tests
  • Code review
@knstvk knstvk transferred this issue from jmix-projects/jmix-old Sep 9, 2020
@knstvk knstvk added this to the 0.2.0 milestone Sep 9, 2020
@knstvk knstvk modified the milestones: 0.2.0, 0.3.0 Dec 7, 2020
@knstvk knstvk removed this from the 0.3.0 milestone Jan 18, 2021
@knstvk knstvk changed the title Entity Snapshots API & backend Entity Snapshots Mar 18, 2021
@a616101
Copy link

a616101 commented Jun 15, 2021

Hi, Is there an implementation plan?

@alexbudarov alexbudarov added this to the 1.1.0 milestone Jul 5, 2021
@alexbudarov
Copy link

It would be ideal if we could also make storage mechanism to be flexible.
E.g. provide a "repository" class encapculating loading and saving logic.
Storing snapshots in one database table leads to huge table that is difficult to maintain (e.g. difficult to delete old unnecessary data).
In Sherlock we had to override some beans in order to be able to store snapshots in a partitioned table.

@knstvk knstvk added this to Release 1.1 (October 2021) in Jmix Roadmap - OUTDATED Aug 10, 2021
plakhov added a commit that referenced this issue Aug 17, 2021
plakhov added a commit that referenced this issue Aug 18, 2021
plakhov added a commit that referenced this issue Aug 18, 2021
change after CR
plakhov added a commit that referenced this issue Aug 20, 2021
change after CR
plakhov added a commit that referenced this issue Aug 23, 2021
change after CR
plakhov added a commit that referenced this issue Aug 23, 2021
change after CR
plakhov added a commit that referenced this issue Aug 24, 2021
@plakhov
Copy link
Contributor

plakhov commented Aug 24, 2021

For saving snapshots needed add the following code into the UI controller:

    @Autowired
    private EntitySnapshotManager entitySnapshotManager;

    @Subscribe
    public void onAfterCommitChanges(AfterCommitChangesEvent event) {
        entitySnapshotManager.createSnapshot(getEditedEntity(), getEditedEntityContainer().getFetchPlan());
    }

Viewing snapshots for arbitrary entities is possible using the io\jmix\auditui\screen\snapshot\snapshot-diff.xml fragment.
The snapshots should be loaded into the frame from the edit screen controller:

    @Autowired
    private SnapshotDiffViewer snapshotDiff;

    @Autowired
    private EntityStates entityStates;
    
    @Subscribe
    public void onBeforeShow(BeforeShowEvent event) {
        Object editedEntity = getEditedEntity();
        if (editedEntity != null && !entityStates.isNew(editedEntity)) {
            snapshotDiff.loadVersions(editedEntity);
        }
    }

@lovtsovaik lovtsovaik assigned konyashkina and unassigned lovtsovaik Aug 24, 2021
plakhov added a commit that referenced this issue Aug 25, 2021
plakhov added a commit that referenced this issue Aug 25, 2021
fix spotbug
plakhov added a commit that referenced this issue Aug 25, 2021
fix spotbugs
@konyashkina
Copy link

Tested on
Jmix version: 1.1.0-SNAPSHOT
Jmix Studio plugin version: 1.1.SNAPSHOT3462-211
IntelliJ version: IntelliJ IDEA 2021.1.3 (Community Edition)

@knstvk knstvk removed this from October 2021 feature release 1.1 in Jmix Roadmap - OUTDATED Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants