Documentation
¶
Index ¶
- func SortByUniqueKey(slice interface{}) map[int]int
- func UpdateIDs(mdl interface{}, IDName string, changes map[int]int)
- type BlockRange
- func (m *BlockRange) Equals(m2 Model) bool
- func (m *BlockRange) ID() int
- func (BlockRange) MakeSlice(mdl []Model) []*BlockRange
- func (m BlockRange) MarshalJSON() ([]byte, error)
- func (m *BlockRange) PrettyPrint(db *Database) string
- func (m *BlockRange) RelatedEntries(db *Database) Related
- func (m *BlockRange) SetID(id int)
- func (m *BlockRange) UniqueKey() string
- type Bookmark
- func (m *Bookmark) Equals(m2 Model) bool
- func (m *Bookmark) ID() int
- func (Bookmark) MakeSlice(mdl []Model) []*Bookmark
- func (m Bookmark) MarshalJSON() ([]byte, error)
- func (m *Bookmark) PrettyPrint(db *Database) string
- func (m *Bookmark) RelatedEntries(db *Database) Related
- func (m *Bookmark) SetID(id int)
- func (m *Bookmark) UniqueKey() string
- type Database
- type InputField
- func (m *InputField) Equals(m2 Model) bool
- func (m *InputField) ID() int
- func (InputField) MakeSlice(mdl []Model) []*InputField
- func (m InputField) MarshalJSON() ([]byte, error)
- func (m *InputField) PrettyPrint(db *Database) string
- func (m *InputField) RelatedEntries(db *Database) Related
- func (m *InputField) SetID(id int)
- func (m *InputField) UniqueKey() string
- type Location
- func (m *Location) Equals(m2 Model) bool
- func (m *Location) ID() int
- func (Location) MakeSlice(mdl []Model) []*Location
- func (m Location) MarshalJSON() ([]byte, error)
- func (m *Location) PrettyPrint(db *Database) string
- func (m *Location) RelatedEntries(db *Database) Related
- func (m *Location) SetID(id int)
- func (m *Location) UniqueKey() string
- type Model
- type Note
- func (m *Note) Equals(m2 Model) bool
- func (m *Note) ID() int
- func (Note) MakeSlice(mdl []Model) []*Note
- func (m Note) MarshalJSON() ([]byte, error)
- func (m *Note) PrettyPrint(db *Database) string
- func (m *Note) RelatedEntries(db *Database) Related
- func (m *Note) SetID(id int)
- func (m *Note) UniqueKey() string
- type Related
- type Tag
- func (m *Tag) Equals(m2 Model) bool
- func (m *Tag) ID() int
- func (Tag) MakeSlice(mdl []Model) []*Tag
- func (m Tag) MarshalJSON() ([]byte, error)
- func (m *Tag) PrettyPrint(db *Database) string
- func (m *Tag) RelatedEntries(db *Database) Related
- func (m *Tag) SetID(id int)
- func (m *Tag) UniqueKey() string
- type TagMap
- func (m *TagMap) Equals(m2 Model) bool
- func (m *TagMap) ID() int
- func (TagMap) MakeSlice(mdl []Model) []*TagMap
- func (m TagMap) MarshalJSON() ([]byte, error)
- func (m *TagMap) PrettyPrint(db *Database) string
- func (m *TagMap) RelatedEntries(db *Database) Related
- func (m *TagMap) SetID(id int)
- func (m *TagMap) UniqueKey() string
- type UserMark
- func (m *UserMark) Equals(m2 Model) bool
- func (m *UserMark) ID() int
- func (UserMark) MakeSlice(mdl []Model) []*UserMark
- func (m UserMark) MarshalJSON() ([]byte, error)
- func (m *UserMark) PrettyPrint(db *Database) string
- func (m *UserMark) RelatedEntries(db *Database) Related
- func (m *UserMark) SetID(id int)
- func (m *UserMark) UniqueKey() string
- type UserMarkBlockRange
- func (m *UserMarkBlockRange) Equals(m2 Model) bool
- func (m *UserMarkBlockRange) ID() int
- func (UserMarkBlockRange) MakeSlice(mdl []Model) []*UserMarkBlockRange
- func (m UserMarkBlockRange) MarshalJSON() ([]byte, error)
- func (m *UserMarkBlockRange) PrettyPrint(db *Database) string
- func (m *UserMarkBlockRange) RelatedEntries(db *Database) Related
- func (m *UserMarkBlockRange) SetID(id int)
- func (m *UserMarkBlockRange) UniqueKey() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SortByUniqueKey ¶
SortByUniqueKey sorts the given pointer to a slice of Model by UniqueKey, removes unnecessary nil-entries (except at position 0), and also updates the IDs accordingly. It tracks these changes by a map, for which the key represents the old ID, and value represents the new ID.
Types ¶
type BlockRange ¶
type BlockRange struct { BlockRangeID int BlockType int Identifier int StartToken sql.NullInt32 EndToken sql.NullInt32 UserMarkID int }
BlockRange represents the BlockRange table inside the JW Library database
func (*BlockRange) Equals ¶
func (m *BlockRange) Equals(m2 Model) bool
Equals checks if the BlockRange is equal to the given one.
func (BlockRange) MakeSlice ¶
func (BlockRange) MakeSlice(mdl []Model) []*BlockRange
MakeSlice converts a slice of the generice interface model
func (BlockRange) MarshalJSON ¶
func (m BlockRange) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the entry
func (*BlockRange) PrettyPrint ¶
func (m *BlockRange) PrettyPrint(db *Database) string
PrettyPrint prints BlockRange in a human readable format and adds information about related entries if helpful.
func (*BlockRange) RelatedEntries ¶
func (m *BlockRange) RelatedEntries(db *Database) Related
RelatedEntries returns entries that are related to this one
func (*BlockRange) UniqueKey ¶
func (m *BlockRange) UniqueKey() string
UniqueKey returns the key that makes this BlockRange unique, so it can be used as a key in a map.
type Bookmark ¶
type Bookmark struct { BookmarkID int LocationID int PublicationLocationID int Slot int Title string Snippet sql.NullString BlockType int BlockIdentifier sql.NullInt32 }
Bookmark represents the Bookmark table inside the JW Library database
func (*Bookmark) Equals ¶
Equals checks if the Bookmark is equal to the given one. The check won't include the BookmarkID
func (Bookmark) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*Bookmark) PrettyPrint ¶
PrettyPrint prints Bookmark in a human readable format and adds information about related entries if helpful.
func (*Bookmark) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type Database ¶
type Database struct { BlockRange []*BlockRange Bookmark []*Bookmark InputField []*InputField Location []*Location Note []*Note Tag []*Tag TagMap []*TagMap UserMark []*UserMark // ContainsPlaylists indicates if the imported backup contains playlists. ContainsPlaylists bool // SkipPlaylists allows to skip prevention of merging if playlists exist in the database. // It is meant as a temporary workaround until merging of playlists is implemented. SkipPlaylists bool }
Database represents the JW Library database as a struct
func MakeDatabaseCopy ¶
MakeDatabaseCopy creates a deep copy of the given Database, so elements of the copy can be safely updated without affecting the original one.
func (*Database) ExportJWLBackup ¶
ExportJWLBackup creates a .jwlibrary backup file out of a Database{} struct
func (*Database) FetchFromTable ¶
FetchFromTable tries to fetch a entry with the given ID. If it can't find it or the entry is empty it returns nil.
func (*Database) ImportJWLBackup ¶
ImportJWLBackup unzips a given JW Library Backup file and imports the included SQLite DB to the Database struct
func (*Database) PurgeTables ¶
PurgeTables removes all entries from the tables mentioned in the tables slice, which are named by the fields of the Database slice. If a table doesn't exist, an error will be returned.
type InputField ¶
type InputField struct { LocationID int TextTag string Value string // contains filtered or unexported fields }
InputField represents the InputField table inside the JW Library database
func (*InputField) Equals ¶
func (m *InputField) Equals(m2 Model) bool
Equals checks if the InputField is equal to the given one.
func (*InputField) ID ¶
func (m *InputField) ID() int
ID returns the ID of the entry. As the InputField table does not have an ID, we are using a pseudoID, so the rest of the merge logic is still able to run as usual.
func (InputField) MakeSlice ¶
func (InputField) MakeSlice(mdl []Model) []*InputField
MakeSlice converts a slice of the generice interface model.
func (InputField) MarshalJSON ¶
func (m InputField) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the entry.
func (*InputField) PrettyPrint ¶
func (m *InputField) PrettyPrint(db *Database) string
PrettyPrint prints InputField in a human readable format and adds information about related entries if helpful.
func (*InputField) RelatedEntries ¶
func (m *InputField) RelatedEntries(db *Database) Related
RelatedEntries returns entries that are related to this one.
func (*InputField) SetID ¶
func (m *InputField) SetID(id int)
SetID sets the ID of the entry. As the InputField table does not have an ID, this function does nothing.
func (*InputField) UniqueKey ¶
func (m *InputField) UniqueKey() string
UniqueKey returns the key that makes this InputField unique, so it can be used as a key in a map.
type Location ¶
type Location struct { LocationID int BookNumber sql.NullInt32 ChapterNumber sql.NullInt32 DocumentID sql.NullInt32 Track sql.NullInt32 IssueTagNumber int KeySymbol sql.NullString MepsLanguage sql.NullInt32 LocationType int Title sql.NullString }
Location represents the Location table inside the JW Library database
func (Location) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*Location) PrettyPrint ¶
PrettyPrint prints Location in a human readable format and adds information about related entries if helpful.
func (*Location) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type Model ¶
type Model interface { ID() int SetID(int) UniqueKey() string Equals(m2 Model) bool RelatedEntries(db *Database) Related PrettyPrint(db *Database) string // contains filtered or unexported methods }
Model represents a general table of the JW Library database and defines methods that are needed so entries are mergeable.
func MakeModelCopy ¶
MakeModelCopy copies the content of the given Model (pointer to a model-implementing struct) to a new Model
func MakeModelSlice ¶
MakeModelSlice converts a slice of pointers of model-implementing structs to []model
type Note ¶
type Note struct { NoteID int GUID string UserMarkID sql.NullInt32 LocationID sql.NullInt32 Title sql.NullString Content sql.NullString LastModified string Created string BlockType int BlockIdentifier sql.NullInt32 }
Note represents the Note table inside the JW Library database
func (Note) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*Note) PrettyPrint ¶
PrettyPrint prints Note in a human readable format and adds information about related entries if helpful.
func (*Note) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type Related ¶
type Related struct { BlockRange []*BlockRange `json:"blockRange"` Bookmark *Bookmark `json:"bookmark"` Location *Location `json:"location"` PublicationLocation *Location `json:"publicationLocation"` Note *Note `json:"note"` Tag *Tag `json:"tag"` TagMap *TagMap `json:"tagMap"` UserMark *UserMark `json:"userMark"` UserMarkBlockRange *UserMarkBlockRange `json:"userMarkBlockRange"` }
Related combines entries that are related to a given model
type Tag ¶
Tag represents the Tag table inside the JW Library database
func (*Tag) Equals ¶
Equals checks if the Tag is equal to the given one. The check won't include the TagID.
func (Tag) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*Tag) PrettyPrint ¶
PrettyPrint prints Tag in a human readable format and adds information about related entries if helpful.
func (*Tag) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type TagMap ¶
type TagMap struct { TagMapID int PlaylistItemID sql.NullInt32 LocationID sql.NullInt32 NoteID sql.NullInt32 TagID int Position int }
TagMap represents the TagMap table inside the JW Library database
func (TagMap) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*TagMap) PrettyPrint ¶
PrettyPrint prints TagMap in a human readable format and adds information about related entries if helpful.
func (*TagMap) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type UserMark ¶
type UserMark struct { UserMarkID int ColorIndex int LocationID int StyleIndex int UserMarkGUID string Version int }
UserMark represents the UserMark table inside the JW Library database
func (UserMark) MarshalJSON ¶
MarshalJSON returns the JSON encoding of the entry
func (*UserMark) PrettyPrint ¶
PrettyPrint prints UserMark in a human readable format and adds information about related entries if helpful.
func (*UserMark) RelatedEntries ¶
RelatedEntries returns entries that are related to this one
type UserMarkBlockRange ¶
type UserMarkBlockRange struct { UserMark *UserMark BlockRanges []*BlockRange }
UserMarkBlockRange represents a UserMark joined with its BlockRange entries. It does NOT represent an actual table in the JWLibrary backup file!
func (*UserMarkBlockRange) Equals ¶
func (m *UserMarkBlockRange) Equals(m2 Model) bool
Equals checks if the UserMarkBlockRange is equal to the given one. It will both check its UserMark and all BlockRanges.
func (*UserMarkBlockRange) ID ¶
func (m *UserMarkBlockRange) ID() int
ID returns the ID of the UserMark representing the whole UserMarkBlockRange{}
func (UserMarkBlockRange) MakeSlice ¶
func (UserMarkBlockRange) MakeSlice(mdl []Model) []*UserMarkBlockRange
MakeSlice converts a slice of the generice interface model
func (UserMarkBlockRange) MarshalJSON ¶
func (m UserMarkBlockRange) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of the entry
func (*UserMarkBlockRange) PrettyPrint ¶
func (m *UserMarkBlockRange) PrettyPrint(db *Database) string
PrettyPrint prints UserMarkBlockRange in a human readable format and adds information about related entries if helpful.
func (*UserMarkBlockRange) RelatedEntries ¶
func (m *UserMarkBlockRange) RelatedEntries(db *Database) Related
RelatedEntries returns entries that are related to this one
func (*UserMarkBlockRange) SetID ¶
func (m *UserMarkBlockRange) SetID(id int)
SetID sets the ID of the entry, which is the UserMarkID representing the whole UserMarkBlockRange{}
func (*UserMarkBlockRange) UniqueKey ¶
func (m *UserMarkBlockRange) UniqueKey() string
UniqueKey returns the key that makes this UserMarkBlockRange unique, so it can be used as a key in a map.