Last modified 16 years ago
Last modified on 07/09/09 12:38:42
Analysis
Overview
The goal of this task is to provide persistence of stickies.
Task requirements
- The user should be able to persist annotation sets.
- Annotation sets are resources which can contain stickies, highlights and audio annotations. Currently only stickies are implemented.
- Annotation sets should be persisted in zip files, just like Sophie books are saved (which are resources too).
- "All annotations" palette should contain the following buttons:
- Import Annotations...
- When clicked, a file dialog for zip files is opened.
- If the file is not a valid annotation set, an error message is displayed ("Invalid file.").
- If the annotation set does not refer to current book, an error message is displayed ("These annotations do not refer current book").
- The annotation set is loaded in current book's window (not added in the book).
- The annotation set is set as current for current book.
- Export Annotations...
- When clicked, a file dialog for zip files is opened.
- If a file name is selected, current annotation set for current book is stored in the selected file.
- If an error occurs, for example user wants to save on read-only media, an error message is displayed.
- Import Annotations...
- By default, annotation sets are not saved with the book. A book can be annotated by reviewers and their annotations can be saved in external files.
- (In another task) Annotation sets can be added to book's resources so they will be saved with the book.
Task result
- Source code.
Implementation idea
- Create a FileDialogInput for zip files and use the DialogManager to display the dialog.
- Create a persister between AnnotationSet and Storage.
- Use ZipPackagePersister to persist between Storage and zip files.
Related
How to demo
- Open Sophie.
- Create two stickies.
- Save the annotation set to a file.
- Close the annotation set (using the Close Extra button). The stickies should disappear.
- Open the annotation set from a file and check if the stickies are displayed again.
Design
- Create a package org.sophie2.extra.func.annotations.persistence.
- Set the kind of AnnotationSet to be "annotation-set".
- Create a class AnnotationsPersister that extends Persister<String, Storage>.
- Schema: "resource:annotation-set|storage|r3"
- Children:
- book (reference to the book)
- stickies
- (in next revisions) highlights, audioAnnotations
- Attributes:
- entityId
- Create a class StickyPersister that extends Persister<Ref<Sticky>, Storage>.
- Schema: "sticky|storage|r3"
- For each sticky persist its text, page reference, date, color and bounds.
- Schema: "sticky|storage|r3"
- In AnnotationsLogic:
- Loading annotations:
- Create a new FileDialogInput for zip files and display it using the DialogManager.
- Load the zip file in a Storage using the schema "storage:resource|package-file:zip|r3".
- Convert the storage to AnnotationSet using the schema "resource|storage|r3".
- If an error occurs, display "Invalid file." using DialogUtils.showErrorDialog.
- If the referred book is not the currently open book, display error message.
- If none of the above issues is present, add the annotation set to current book's window shownExtras list,
- then use CurrentAnnotationsMap.setAsCurrent.
- Saving annotations:
- Create a new FileDialogInput for zip files and display it using the DialogManager.
- Store current annotation set to storage using the schema "resource|storage|r3".
- Loading annotations:
- Source code: branches/private/mitex/annotations-r1/
Implementation
Merged to the trunk [4116].
Testing
(Place the testing results here.)
Comments
(Write comments for this or later revisions here.)