Rothamsted / knetminer

KnetMiner - webapp to search and visualize genome-scale knowledge graphs
https://knetminer.com
MIT License
25 stars 16 forks source link

Support for public vs private resources #587

Open KeywanHP opened 3 years ago

KeywanHP commented 3 years ago

When deploying a KnetMiner dataset, an admin should be able to declare in maven-settings.xml if the deployed resource will be public (eg wheat, rice, Arabidopsis, COVID-19) or private (paid species). Public resources can be accessed by anyone but private resources are restricted to certain users (subscription based).

Once this backend setting is added, the knetminer-knetspace client team will add functionality to check if (resource.status()=="private" AND user.subscriptions.contains(this.resource)) before allowing them to use the SEARCH, otherwise show a CTA (call to action) message to ask users to subscribe to the resource first.

success-master commented 3 years ago

Current knetspace has basic APIs to check if a user is subscribed to an resource, but not for public/ private.

AjitPS commented 3 years ago

thanks, let's keep the issue open till I add 1) this public/private in knetminer here, and also I have to add code 2) to check that knetspace API from inside knetminer.

AjitPS commented 3 years ago

pls add knetspace API link here too @success-master

success-master commented 3 years ago

GET /resources/{id}/getResourceDetails - retrieve specific resource in full GET /resources/getResources_Subed - retrieve subscripbed resources in full GET /resources/getResources_Unsubed - retrieve unsubscribed resources

marco-brandizi commented 2 years ago

The API functions above shouldn't be part of knetspace, since, logically, they're dataset properties, so it should be possible to get private/public info, as well as resourceDetails from the data.

This is related to the ongoing metadata descriptor work.

AjitPS commented 2 years ago

knetspace already retains metadata and info about each saved dataset and user/plans/ organisational accounts.

also each dataset could have variants that are enterprise wide or free or pro so not really a dataset property but a knetspace subscription property.

but private/public setting be in knetminer.

marco-brandizi commented 2 years ago

yes, sorry, I mean those functions that are only about the dataset are best managed as dataset description info (user subscriptions are for knetspace). Moreover, this doesn't prevent applications around from getting such info from their primary source and keeping a cache-like copy.

AjitPS commented 2 years ago

For this to work, 1) in knetminer/dataset/../maven-settings.xml, I can add a setting for public/private resource (and each resource has unique dataSourceId like araknet: <knetminer.dataSourceId>araknet</knetminer.dataSourceId>, wheatknet, solknet, and so on already).

I would also need from knetspace: 2) https://dev.knetminer.com/beta/knetspace/api/v1/users/ to show list[] of resources each knetspace user is subscribed too. Does it have it already @success-master or not? and 3) each resource https://dev.knetminer.com/beta/knetspace/api/v1/resources/ should have unique id similar to what we/I have added for knetmaps to use inside knetspace already via knetminer.dataSourceId: https://github.com/Rothamsted/knetspace/blob/master/website/assets/src/js/containers/Network/index.js#L369? these 2 are needed in knetspace before I can make this new feature work in knetminer, fyi.

success-master commented 2 years ago

Yes, knetspace already has API for getting a list of subscribed resources. GET /resources/getResources_Subed - retrieve subscripbed resources in full But each resources have auto generated unique id in knetspace now.

AjitPS commented 2 years ago

use dataSourceID like https://github.com/Rothamsted/knetspace/blob/master/website/assets/src/js/containers/Network/index.js#L369 fyi @success-master I added these already in knetspace to use when clicking "check for updates" feature to go back to knetminer

AjitPS commented 2 years ago

can you use these IDs for resources soon? so then in knetminer we can check which knetspace user has access to which resource. I can then work on this feature next week.

KeywanHP commented 2 years ago

I thought a bit more about the flow and the logic... The new resource dashboard could list 100s of free, paid, upcoming resources that will be added through the knetspace admin/api interfaces... For some of them we will have knetminer instances/datasets already, but not for all... So there are two options... When we create all resources in knetspace, it will generate a unique id (like it's doing now) which the person who creates the knetminer dataset would need to add to the knetminer dataset pom file (e.g. resourceId:1a2a4398-9516-4e2f-80a4-02958d6b0cc3). The other option is we first create knetminer datasets and then add to knetspace as a resource with eg id:wheatknet. I feel the first option is more logical and scalable. KnetSpace would manage all the resource metadata, and kentminer can fetch all the info through APIs to create the necessary config files, all it would need is the resourceId:1a2a4398-9516-4e2f-80a4-02958d6b0cc3.

Let me know if I am missing something?

AjitPS commented 2 years ago

fyi, solution (to be implemented by colleague in early 2022): 1) add unique knetspace resource IDs (alread in dev.knetspace) to each knetminer dataset maven-settings.xml, 2) using new knetspace resourceID, in knetminer UI and genepage, call knetspace API to get info, for example: https://dev.knetminer.com/beta/knetspace/api/v1/resources/0157415a-7a23-42de-9179-2da3bec63881/getResourceDetails

3) in knetminer client (UI) and genepage.jsp, implement this logic:

#if user not logged in:
     ##if resource public: allow search
     ##if resource private: ask user to log in
#else if user logged in:
     ##if resource public: allow search
     ##if resource private: check if they have access (subscribed to this resource):
          ###if yes: allow search
          ###no_subscription: please subscribe

4) first test with local aratiny (make a mock resource in dev.knetspace). 5) then redeploy latest prod. knetspace and test real resources one by one (arabidopsis, wheat, poaceae, etc).

KeywanHP commented 2 years ago

http://ec2-3-9-25-240.eu-west-2.compute.amazonaws.com/beta/knetspace/api/v1/resources/6dd73cd6-996b-4cb0-91ef-fbbf91ffcbb7/getResourceDetails/

{"resourceName": "Wheat", "resourceDes": "Wheat is a grass widely cultivated for its seed", "resourceSubscribedPrice": "", "resourceExpiryDate": "", "resourceSubStatus": "", "resources_m": "", "genome_assembly": "IWGSCv1", "genome_annotation": "RefSeqv1", "total_genes": 107891, "example_gene_id": "TRAESCS3D02G468400", "included_genomes": "Maize, Barley, Rice, Arabidopsis", "speciesTaxid": "4565", "dbDateCreated": "2021-02-17T04:00:09.622Z", "is_public": true}

http://ec2-3-9-25-240.eu-west-2.compute.amazonaws.com/beta/knetspace/api/v1/resources/getResources_Subed/

[{"resourceId": "02fe6f58-7a79-4257-8ceb-e0d0734147bf", "resourceName": "Poaceae", "resourceSubscribedPrice": "300000", "resourceExpiryDate": {"$date": 1645717231566}, "resourceSubStatus": "price_1INjG8LH21lcEXYPVGuIL5CM", "resourseSubscriptionId": "sub_J0QK98GWbhi2G4", "resourceOwner": 40, "resourceDescription": "A multi-species knowledge graph for poaceae (grain) species", "resources_m": [{"user_id": 40, "user_name": "Dev"}, {"user_id": 5, "user_name": "keywan"}]}]