Documentation
¶
Overview ¶
Package storage implements access to a local SQLite database and an Ethereum ledger for storing open feedback.
Index ¶
- func Int64ToNull(n int64) sql.NullInt64
- func NullToInt64(ni sql.NullInt64) int64
- func NullToString(ns sql.NullString) string
- func StringToNull(s string) sql.NullString
- type Storage
- func (st *Storage) BuildSearchIndicies() (err error)
- func (st *Storage) Close()
- func (st *Storage) CreateCollection(uid int64, title string) (collectionId int64, err error)
- func (st *Storage) CreateExpertBookmark(uid int64, expertId int64) (err error)
- func (st *Storage) CreateExpertProfile(uid int64, orcId string) (err error)
- func (st *Storage) CreateFeedback(uid int64, recordId int64, relevance int64, presentation int64, ...) (err error)
- func (st *Storage) CreateInterest(uid int64, subjectId int64) (err error)
- func (st *Storage) CreateRecordBookmark(uid int64, recordId int64) (err error)
- func (st *Storage) CreateRecordDislike(uid int64, recordId int64) (err error)
- func (st *Storage) CreateTestPublications() (err error)
- func (st *Storage) CreateUser(u *model.User) (err error)
- func (st *Storage) DeleteCollection(uid int64, collectionId int64) (err error)
- func (st *Storage) DeleteExpertBookmark(uid int64, expertId int64) (err error)
- func (st *Storage) DeleteInterest(uid int64, subjectId int64) (err error)
- func (st *Storage) DeleteOrcId(uid int64) (err error)
- func (st *Storage) DeleteRecordBookmark(uid int64, recordId int64) (err error)
- func (st *Storage) DeleteUserById(uid int64) (err error)
- func (st *Storage) ReadAllSubjects() (subs ploc.Subjects, err error)
- func (st *Storage) ReadBibHashByRecordId(recordId int64) (bibHash string, err error)
- func (st *Storage) ReadCollections(uid int64) (collections ploc.Collections, err error)
- func (st *Storage) ReadExpertBookmarks(uid int64) (rawBookmarks []json.RawMessage, err error)
- func (st *Storage) ReadExpertDetails(expertId int64) (rawDetails json.RawMessage, err error)
- func (st *Storage) ReadExpertFeed(uid int64, offset int64, limit int64) (rawExperts []json.RawMessage, err error)
- func (st *Storage) ReadFeedback(recordId int64) (feedbacks ploc.Feedbacks, err error)
- func (st *Storage) ReadFeedbackFeed(uid int64, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
- func (st *Storage) ReadOrcId(uid int64) (orcId string, err error)
- func (st *Storage) ReadRecordBookmarks(uid int64) (rawBookmarks []json.RawMessage, err error)
- func (st *Storage) ReadRecordDetails(uid int64, recordId int64) (rawDetails json.RawMessage, err error)
- func (st *Storage) ReadRecordFeed(uid int64, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
- func (st *Storage) ReadRecordFeedCount(uid int64) (recordCount int64, err error)
- func (st *Storage) ReadUserInterests(uid int64) (subjects ploc.Subjects, err error)
- func (st *Storage) SearchExpertFeed(uid int64, searchTerm string, offset int64, limit int64) (rawExperts []json.RawMessage, err error)
- func (st *Storage) SearchRecordFeed(uid int64, searchTerm string, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
- func (st *Storage) UpdateCollection(uid int64, collectionId int64, title string) (err error)
- func (st *Storage) UpdateCollectionsBookmarkLink(uid int64, recordId int64, collectionIds []int64) (err error)
- func (st *Storage) UserByGUID(guid string) (user *model.User, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Int64ToNull ¶
Int64ToNull converts an int64 to nullable int64, setting null if the integer value is zero.
func NullToInt64 ¶
NullToInt64 converts a nullable int to a standard int64, returning 0 if value is null.
func NullToString ¶
func NullToString(ns sql.NullString) string
NullToString converts a nullable string to a standard string, returning an empty string if value is null.
func StringToNull ¶
func StringToNull(s string) sql.NullString
StringToNull converts a string to nullable string, setting null if the string is empty.
Types ¶
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage encapsulates the state of the database. All CRUD-operations are defined for this type, which makes the code more readable.
func Open ¶
func Open(conf *config.StorageConfiguration) *Storage
Open connects to the SQLite database and initializes the schema if not done yet.
func (*Storage) BuildSearchIndicies ¶
BuildSearchIndicies repopulates the search indices for publication and experts. Must be called after new records were added to the database.
func (*Storage) Close ¶
func (st *Storage) Close()
Close writes all pending transactions to the database and disconnects from it.
func (*Storage) CreateCollection ¶
CreateCollection creates a new named bookmark collection. The user-ID specifies the authorized user profile to which this operation is related.
func (*Storage) CreateExpertBookmark ¶
CreateExpertBookmark bookmarks an expert. The user-ID specifies the authorized user profile to which this operation is related.
func (*Storage) CreateExpertProfile ¶
CreateExpertProfile registers an user that has an ORCiD as an expert.
func (*Storage) CreateFeedback ¶
func (st *Storage) CreateFeedback(uid int64, recordId int64, relevance int64, presentation int64, methodology int64) (err error)
CreateFeedback adds a user's feedback to a record. The feedback consists of binary flags for relevance, quality of presentation and the soundness of the methodology (0 = false, 1 = true).
func (*Storage) CreateInterest ¶
CreateInterest defines a user's interest in a subject.
func (*Storage) CreateRecordBookmark ¶
CreateRecordBookmark bookmarks a specific record. The user-ID specifies the user to which bookmark is related.
func (*Storage) CreateRecordDislike ¶
CreateRecordDislike defines a user's disinterest in a specific record. Such records are of no interest and should be avoided in future search results.
func (*Storage) CreateTestPublications ¶
CreateTestPublications populates the database with test entries like records, creators and subjects. The test entries are used for the purpose of unit tests only.
func (*Storage) CreateUser ¶
CreateUser registers a new user by creating a new user-ID. Access to profile is controlled by a user-specified, secret passphrase, or its hash in specific.
func (*Storage) DeleteCollection ¶
DeleteCollection deletes a specific bookmark collection of a user and all the bookmarks in that collection.
func (*Storage) DeleteExpertBookmark ¶
DeleteExpertBookmark deletes a bookmarked expert from a user's profile.
func (*Storage) DeleteInterest ¶
DeleteInterest removes a single subject from the user's list of interest.
func (*Storage) DeleteOrcId ¶
DeleteOrcId withdraws a user's expert status by removing its ORCiD identity.
func (*Storage) DeleteRecordBookmark ¶
DeleteRecordBookmark removes a bookmarked record from a user's profile.
func (*Storage) DeleteUserById ¶
DeleteUserById removes a user's identity and all user-related information. Note that while even the user's feedback is removed from local database, it still remains in the public ledger.
func (*Storage) ReadAllSubjects ¶
ReadAllSubjects returns all supported subjects from the publication database. These subjects can be used to define the user's interests.
func (*Storage) ReadBibHashByRecordId ¶
ReadBibHashByRecordId reads the bibliographic hash for the specified record. On error the returned bibliographic hash is undefinied.
func (*Storage) ReadCollections ¶
func (st *Storage) ReadCollections(uid int64) (collections ploc.Collections, err error)
ReadCollections returns all the bookmark collections without the records for a user.
func (*Storage) ReadExpertBookmarks ¶
func (st *Storage) ReadExpertBookmarks(uid int64) (rawBookmarks []json.RawMessage, err error)
ReadExpertBookmarks returns all the experts that a user has bookmarked.
func (*Storage) ReadExpertDetails ¶
func (st *Storage) ReadExpertDetails(expertId int64) (rawDetails json.RawMessage, err error)
ReadExpertDetails returns a detailed profile about a specific expert. The profile includes information like name, ORCiD and publications. The profile is returned as a precomputed JSON data structure for performance reasons.
func (*Storage) ReadExpertFeed ¶
func (st *Storage) ReadExpertFeed(uid int64, offset int64, limit int64) (rawExperts []json.RawMessage, err error)
ReadExpertFeed returns the specified subsegment of a list with popular experts that match a user's interest. The experts' short profiles are returned as a precomputed JSON data structure for performance reasons. The list is descendingly ordered by the relevance of the experts. The returned list depend on the user's defined interests and dislikes. Access to the full list is handled in subsegments via offset and limit, so that a client can read only the segments that are shown to the user.
func (*Storage) ReadFeedback ¶
ReadFeedback returns all feedback related to a specific publication record.
func (*Storage) ReadFeedbackFeed ¶
func (st *Storage) ReadFeedbackFeed(uid int64, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
ReadFeedbackFeed returns a list of publications that a user is expert of and that the user may provide feedback to. The records are returned as a precomputed JSON data structure for performance reasons. The list is descendingly ordered by the number of matching subjects of interest. Access to the full list is handled in subsegments via offset and limit, so that a client can read only the segments that are shown to the user.
func (*Storage) ReadOrcId ¶
ReadOrcId returns a user's associated ORCiD identifiert, which is empty in the case the user has none.
func (*Storage) ReadRecordBookmarks ¶
func (st *Storage) ReadRecordBookmarks(uid int64) (rawBookmarks []json.RawMessage, err error)
ReadRecordBookmarks returns all records that were bookmarked by a user.
func (*Storage) ReadRecordDetails ¶
func (st *Storage) ReadRecordDetails(uid int64, recordId int64) (rawDetails json.RawMessage, err error)
ReadRecordDetails returns detailed information about a specific publication record. The detailed information includes information like title, creator names, keywords, DOI and links. The details are returned as a precomputed JSON data structure for performance reasons.
func (*Storage) ReadRecordFeed ¶
func (st *Storage) ReadRecordFeed(uid int64, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
ReadRecordFeed returns a list of publications that match the user's subjects of interest. The list is descendingly ordered by year of publication and within that year by relevance. The list is accessed segment-wise, so that a client can read only that segment that is shown to the user and not the whole list. The publications are returned as a precomputed JSON data structure for performance reasons.
func (*Storage) ReadRecordFeedCount ¶
ReadRecordFeedCount returns the total number of records that matches a user's interest.
func (*Storage) ReadUserInterests ¶
ReadUserInterests returns a list of all the subjects that a user has specified as interesting.
func (*Storage) SearchExpertFeed ¶
func (st *Storage) SearchExpertFeed(uid int64, searchTerm string, offset int64, limit int64) (rawExperts []json.RawMessage, err error)
SearchExpertFeed makes a full text search within a user's expert feed and returns a summary for all the experts with matching textual content. The searched fields include name, publication titles and subjects. The experts are returned as a precomputed JSON data structure for performance reasons.
func (*Storage) SearchRecordFeed ¶
func (st *Storage) SearchRecordFeed(uid int64, searchTerm string, offset int64, limit int64) (rawRecords []json.RawMessage, err error)
SearchRecordFeed makes a full text search within a user's publication feed and returns a summary for all the publication records with matching textual content. The searched fields include title, abstract, subjects and author names. The publications are returned as a precomputed JSON data structure for performance reasons.
func (*Storage) UpdateCollection ¶
UpdateCollection allows a user to change the title for one of its existing collections.
func (*Storage) UpdateCollectionsBookmarkLink ¶
func (st *Storage) UpdateCollectionsBookmarkLink(uid int64, recordId int64, collectionIds []int64) (err error)
UpdateRecordBookmarkCollections allows a user to specify to which of its bookmark collections a publiction corresponds. With help of this function a publication can be added or removed from any of the user's bookmark collections.
func (*Storage) UserByGUID ¶
UserByGUID returns the major user information like database ID, ORCiD identifier and the hashed secret, based on the user's public GUID. This function is primarily used for handling authorization during the routing process.