Start page / Advanced topics / Tracking changes / Example: Between revisions

Changes between two revisions

GUI zur Auswahl der Revisionsgrenzen

In the second example, the revisions can be selected conveniently via a GUI. To do so, a new script has to be created in the project's template store first.

Input components for selecting a start and an end date for the desired revision limits can be configured in the form area of the script:

Similarly to the first example, the corresponding revisions can then be retrieved using the selected data:

data = context.showForm();
if (data != null) {
context.logInfo("data=" + data);
from = data.get(context.getProject().getMasterLanguage(),
"from").get();
to = data.get(context.getProject().getMasterLanguage(),
"enddate").get();

if (from != null) {
context.logInfo(from + " -- " + to);
start = project.getRevision(from);
end = project.getRevision(to);
context.logInfo("startRev=" + start.id + ", endRev=" + end.id);

if (start.id <= end.id) {
revisions = project.getRevisions(start, end, 0, null);
} else {
revisions = project.getRevisions(end, start, 0, null);
}
context.logInfo("found '" + revisions.size() + "' revisions -> first=" + revisions.get(0) + ", last=" +
revisions.get(revisions.size() - 1));
checkChanges(revisions);
}}

In checkChanges, the changes that took place in this revision are found. In this example, changes to project content of operation types DELETE and CREATE (within the page store) are taken into account. In addition, changes to the project's database content are determined.

Changes due to removing elements in the page store:

case RevisionOperation.OperationType.DELETE:
deleteRoot = operation.getDeleteRootElement();
if (deleteRoot.getStoreType() == Store.Type.PAGESTORE) {
// include only pagestore
context.logInfo("found delete in pagestore (deleted node=" +
deleteRoot.getUid() + ") in revision=" +
getRevisionString(revision));
}
break;

Changes due to adding elements in the project:

case RevisionOperation.OperationType.CREATE:
created = operation.getCreatedElement();
parent = operation.getParent();
context.logInfo("found created element in store '" +
created.getStoreType() + "' (created node=" +
created.getUid() + ", parent node=" + parent.getUid() + ") in
revision=" + getRevisionString(revision));
break;

Changes due to creating, deleting, changing or releasing database content:

case RevisionOperation.OperationType.CONTENT_COMMIT:
created = operation.getCreatedEntities();
changed = operation.getChangedEntities();
deleted = operation.getDeletedEntities();
released = operation.getReleasedEntities();
context.logInfo("found content changes in revision=" +
getRevisionString(revision));
context.logInfo("\t created entities(" + created.size() + ") "
+ created);
context.logInfo("\t changed entities(" + changed.size() + ") "
+ changed);
context.logInfo("\t deleted entities(" + deleted.size() + ") "
+ deleted);
context.logInfo("\t released entities(" + released.size() + ")
" + released);
break;

The script is output via the Java console:

..
INFO 20.05.2008 15:44:50.317
startRev=6804, endRev=7677
found created element in store 'PAGESTORE' (created node=Testpage_131, parent node=Test_6C22873) in revision=7335
- Thu May 15 16:02:51 CEST 2008 (importStoreElement) - Admin – CREATE
..

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.12 | Data privacy