core-geonetwork
core-geonetwork copied to clipboard
Favourites Lists
This is for @josegar74 review.
WIP
Hi! this looks like a WIP towards having a better "favorites" system for metadata records, is that right? I would be interested to know a bit more if this is intended to be part of the main branch eventually. For GeoNetwork-UI we implemented a favorites system by relying on the user selections API.
@jahow the current favorites system in GeoNetwork is quite limited, allowing only 1 list per user.
With this work, a user can create several favorites lists. Also administratror users can share the favorites lists.
I'm not sure how it's implemented in GeoNetwork-UI with the user selections API, but user selections rely on the user session afaik. This work allows to persist the favorites information, so can be reused between sessions.
@davidblasby, the translations files should not be changed in GitHub, only the English one.
The others should be updated in Transifex and are updated periodically in GitHub, please remove all the translation files, except the English one, thanks.
I'm not sure how it's implemented in GeoNetwork-UI with the user selections API, but user selections rely on the user session afaik. This work allows to persist the favorites information, so can be reused between sessions.
The user selections API currently already allows saving multiple lists of "favorite" records in the database. Possible lists are determined by the administrator (currently only through the API IIRC), and then a logged in user can save (or "bookmark") a record in whichever list they want.
There is also a system to save records in the browser session storage but we don't use because obviously it's not very useful. Also we added indexation of the amount of time each record has been saved as favorite, FYI.
I'm just mentioning this because I feel like this work might be at least partially redundant with existing systems.
@jahow I think I misunderstood you with the selection buckets.
Related to the user selections, GeoNetwork has the table Selections
with 2 hardcoded entries (I think is the same in the UI): PreferredList and WatchList.
The idea with this work is to allow users to create new named selections and store / share them, replacing the current user selection system.
Ok, rolled back changes in those files.
@davidblasby, the translations files should not be changed in GitHub, only the English one.
The others should be updated in Transifex and are updated periodically in GitHub, please remove all the translation files, except the English one, thanks.
There, currently, isn't any UI to create a list or to add to it (you can view and delete from existing lists).
To create a new list, do something like this;
curl -X POST "http://localhost:8080/geonetwork/srv/api/favouriteslist" \
-H "accept: application/json" \
-H "X-XSRF-TOKEN: ccc" \
-H $'Cookie: XSRF-TOKEN=ccc' \
-d "name=dave&listType=WatchList&metadataUuids=00255b42-2428-4793-8d74-f6468279ee4d&metadataUuids=00d7bf23-4f72-4931-9a50-dfef60c84a29&metadataUuids=010e3650-b45f-4bfe-9d41-65421335f1b3&metadataUuids=01aa5e78-87cd-4034-933f-6f79d9e27595&metadataUuids=01e2e94f-e0a9-466b-b1f9-58eb7237fd08&metadataUuids=0206c230-e2e8-476a-91c0-772e7d0ed2fe&metadataUuids=02ac9297-4c7b-4999-8676-b14cb0bae12a&metadataUuids=032fa88f-509c-4330-9321-4c7317f16259&metadataUuids=03451063-6ba5-4fc1-a01e-a904365bb8e9&metadataUuids=04a93de0-294b-4861-a888-b190622ccd06&metadataUuids=04e0aa89-a02d-4942-b9ac-48b512d0d8f0&metadataUuids=050bafd6-9088-46d9-ba73-5a3c3e06acc0&metadataUuids=055d5f62-e0ff-4c97-a6f9-40fec1b502b0&metadataUuids=057eb8f5-095c-48c6-8be5-e39c441e7bca&metadataUuids=05878a9c-f8a7-448f-8c7c-aeda8869fa06&metadataUuids=05dd1594-a22e-4bca-a177-0262f6e70903&metadataUuids=0669587b-6a91-48b5-9419-d089921d1f5f&metadataUuids=069c9d6c-9fcb-40e7-8a0a-829bfd8f33e6&metadataUuids=07359652-8252-4cc6-b240-12961f679381&metadataUuids=0783a504-2444-41e6-baba-4327d1b9110a&metadataUuids=07a156bd-8bda-43f8-82d3-dd8e2747271a&metadataUuids=07ac1629-6ce0-4c4f-9589-b14d00f9b629&metadataUuids=07d6febd-64e7-4c72-bc1f-073929a94635&metadataUuids=082cb550-5bb5-4859-9a59-c07aa4ffda3c&metadataUuids=083f1948-17be-4fe4-baa8-0ac0c30c7d7c&metadataUuids=086a0bad-993d-44f2-aa3c-2a125f90e6fa&metadataUuids=089af4db-090d-462e-a25b-c98aaf5b3b71&metadataUuids=08b28e14-01d7-4142-ae8e-217bf2a8d21b&metadataUuids=08c1ffa4-a5e2-4712-86fa-8bc15ce333a8&metadataUuids=08f2d71c-4fa9-441d-9171-2e2e77bbb00d&metadataUuids=08f783f5-4312-49a5-a410-8aa66bec1b30&metadataUuids=09ccc2d3-b3a9-435d-a0b0-c2d0cb79e2d9&metadataUuids=09f47641-0d89-4a6c-9060-f89afe74a6bc&metadataUuids=0a7bc33b-0a7b-4e10-965a-327c385e8041&metadataUuids=0ab3446b-d591-4732-a297-124d92a117e7&metadataUuids=0aba3762-cabb-4d76-a644-ccc5b3c8ab33&metadataUuids=0b072d40-a750-4b46-8a60-5c8bb8f01380&metadataUuids=0b3adc85-e027-4f27-a206-265f6f67464b&metadataUuids=0b4a3226-e0a1-40a3-a692-3017ed297e80&metadataUuids=0c667a02-94a7-4b8e-a7cd-ede433dafdcb&metadataUuids=0c9983e1-4277-48ff-8927-8944492f0fe8&metadataUuids=0cb8fdab-1dff-427d-94c4-4bce674dd90f&metadataUuids=0cc51810-56ba-49ff-be08-91a83b1333a5&metadataUuids=0cc96f57-a784-4cda-b7e5-43a585c5b045&metadataUuids=0db9349b-b29c-46a8-8dfc-817031c259db&metadataUuids=0e4a9cc0-13ae-4ab7-b8d5-88a21df5e0c5&metadataUuids=0eba0529-32f7-46da-9aed-8bbb7e3625b4&metadataUuids=0edd9a35-457d-454f-827c-01fea9a04283&metadataUuids=0f5e9789-c9fc-4d39-a98b-09727712fe90&metadataUuids=0fa64d73-c5d7-4885-8b0e-ff9a3b3ffc32&metadataUuids=100c3700-b51f-40a7-bd1a-809faa3e18c1&metadataUuids=102d5399-4a4a-441e-aa5c-17110a44f015&metadataUuids=109877d1-3954-4098-8821-66b15060ecac&metadataUuids=10bc92ad-8ebb-483f-aac0-4932dc2ca209&metadataUuids=10d86cd3-93d6-4056-906b-01c9bedcf6f0&metadataUuids=11174fbc-fcdb-4964-90fe-c78b828dba42&metadataUuids=12458053-2e29-4269-9b91-d320fac5bd03&metadataUuids=1267fb50-a0a9-4504-97de-88ec5b46dafe&metadataUuids=12ceacb7-804e-4924-806d-ccbc2664be55&metadataUuids=12e08411-8587-46da-a30e-9ff5821a05fa&metadataUuids=138272a3-b2b8-43ae-aa9d-0abe6b96f861&metadataUuids=13cf5322-3faf-4f1b-a02e-c172e644c316&metadataUuids=15ab3979-5ab6-4e01-ad09-f30935879ab6&metadataUuids=13ead2c2-5589-46a3-9dee-3f98ed337315&metadataUuids=144eb16a-fc6e-448a-b7a7-665f2c4bd349&metadataUuids=146e17ab-8403-42ea-b5d7-cf58d69ca486&metadataUuids=15911c55-48a1-4570-9338-0369dc161f39&metadataUuids=185b3439-f924-4de3-89af-99ad6b2b5807&metadataUuids=185ceb95-b694-4d58-a62e-07923bd0a689&metadataUuids=18b6dfea-f5db-4338-8bd9-9d0b1d760b7a&metadataUuids=18bdf859-cacc-4eee-8924-c17f79b08aeb&metadataUuids=18e4cd33-b049-42e3-95c9-00de420f929c&metadataUuids=19063f0f-8ecf-4721-bdb8-97bf4620038f&metadataUuids=195db58e-d265-4892-b5a2-3937cb89214e&metadataUuids=196d9a8f-2a72-43aa-8d39-27dccc1e6bd5"
The uuids must be in your DB or you'll get an error. This will create a session based list named "dave". to make it public (so others can access it) go to the gn DB:
update favouritemetadatalist set ispublic = true;
If you login as admin, you'll have full access to the list - i.e. can delete or make it private.
Related to the user selections, GeoNetwork has the table
Selections
with 2 hardcoded entries (I think is the same in the UI): PreferredList and WatchList.The idea with this work is to allow users to create new named selections and store / share them, replacing the current user selection system.
There is already an API for adding selection sets: https://github.com/geonetwork/core-geonetwork/blob/main/services/src/main/java/org/fao/geonet/api/selections/UserSelectionsApi.java#L120
But indeed it's not exactly the same logic as what you're describing. Anyway, I think it would be awkward to have the two systems coexist side-by-side.
Sure, the idea is to replace with the new one.
@jahow can you describe how is this implemented or point to the relevant code in GeoNetwork-UI:
For GeoNetwork-UI we implemented a favorites system by relying on the user selections API.
In the current API, can be added new new favourite lists, but seem only allowed to UserAdmin and Administrator.
In the DataHub, I see an option to mark a metadata as favourite:
Are you using the preferred list selection? Or created a new one?
We want to check how it works in your system, to make it as much compatible as possible the new API.
Thanks for taking this into consideration @josegar74, here is the service that handles reading and adding/removing favorites:
https://github.com/geonetwork/geonetwork-ui/blob/main/libs/feature/search/src/lib/favorites/favorites.service.ts
I mean we could probably adapt this to a different API, as long as it offers the same functionalities.
One of the important parts of the system was that the amount of times a record was saved as favorite is indexed for sorting, this is done here: https://github.com/geonetwork/core-geonetwork/blob/136ee71a57b1cb246e156b7bf03f9087880954c1/core/src/main/java/org/fao/geonet/kernel/datamanager/base/BaseMetadataIndexer.java#L547-L549
Checking the code, it seems you are using the existing Preferred list:
https://github.com/geonetwork/geonetwork-ui/blob/2c16a0dd26f71877b1355c80b4d981e79f8aedf6/libs/feature/search/src/lib/favorites/favorites.service.ts#L15
The new API should be quite similar, mostly no need of the userId parameter as takes it from the user session, not really sure why the existing API requires that parameter. Anyway we'll check so the changes are minimised.
Hi @davidblasby, could you maybe give us an update on the status of this work? Do you have any time frame in mind? Thanks :)