Multi-User-Domain / mud-jena

0 stars 0 forks source link

Deployment: initializing world from template #9

Open calummackervoy opened 3 years ago

calummackervoy commented 3 years ago

At the moment in MUDApplication a demo world is created on startup using hardcoded calls to the Jena API. I have in mind that we could instead pass a Turtle file through the web.xml and via that import the configured template into the world dataset. There may be a better design I'm overlooking

TODOs in code referencing this issue

calummackervoy commented 3 years ago

Deploying templates to Tomcat along with the .WAR file

e.g. a directory /templates/ which is deployed to the server when I hit run server in eclipse or deploy to a docker container

I think we need a similar thing to work with Jena reasoners, e.g. I'm working at the moment on the logic "if the RDF type is of Building and the class Building is a subclass of mud:Locatable then the instance is also a mud:Locatable" (https://stackoverflow.com/questions/32670869/how-to-use-transitive-reasoner-with-jena) ... writing a rule file like in the SO answer clearly the reusable way to do it but I'm not sure how to have this deploy with the Java app to a relative directory that I can access at runtime

@MattTennison does it make sense? Do you know to do this in a Java project? Are you interested in it?

MattTennison commented 3 years ago

Ahh, do you mean replacing this block of code with something less...hardcoded? https://github.com/Multi-User-Domain/mud-jena/blob/022c3f7a983a5cad5173f69375ee4ac3305535d5/src/main/java/com/mackervoy/calum/mud/MUDApplication.java#L57-L98

If so, I get what you're saying - pull that out into a separate file that gets loaded in dynamically. That feels like a good first step, but we'd probably want to take it further, and remove it from the code altogether, instead relying on a DB or something more permanent (so updates to the initial world state don't involve a fresh deployment of the code).

Happy to take a closer look, sounds like an interesting problem :smile: Is it blocking the logic you're building right now?

calummackervoy commented 3 years ago

yeah definitely that's what the issue is about - but the first step to that I think is being able to deploy a file directory onto the Tomcat server alongside the WAR?

We do store it in a DB (using Apache Jena's Triplestore/NoSQL database engine), but the init data here (for a demo) could be read from a turtle "template"/import file I think? And the second checkbox is about having the template/import file configured by the web.xml so that it can easily be changed/deployed with some other data. What do you think?

calummackervoy commented 3 years ago

Nah it's not blocking :) I think that we will need to deploy rules files to the server with the WAR for more complex/exciting inferences as part of describers and things (e.g. "I'm a Tottenham fan and so I can deduce that Millwall scarves are not to my taste"), but for inferring that "a Fish is also an animal" I can hardcode it in the meantime, or temporarily add another RDF property to the POST data as a workaround

MattTennison commented 3 years ago

yeah definitely that's what the issue is about - but the first step to that I think is being able to deploy a file directory onto the Tomcat server alongside the WAR?

We do store it in a DB (using Apache Jena's Triplestore/NoSQL database engine), but the init data here (for a demo) could be read from a turtle "template"/import file I think? And the second checkbox is about having the template/import file configured by the web.xml so that it can easily be changed/deployed with some other data. What do you think?

Gotcha! Okay, so we could have an example template in the codebase as it's own file, but we don't mandate people use it, or modify that specific file - rather they point to a different location at their version via the web.xml.

Yeah, I can pick this up :smile:

calummackervoy commented 3 years ago

@MattTennison I'm not sure if the first task on this list is necessary? #34

If running the Java server is the responsibility of the application using Mud-Jena (particularly if the specifics of that - i.e. Tomcat - aren't a part of this repo), then we can assume that they will do their own template upload or use a URL from somewhere else on the web

Then all we need to do is add some custom web.xml config values for a file name or URI and then load the template from there during init

calummackervoy commented 3 years ago

I suppose that the first task is still great if you've already done it, and we'd just want to move it to a mud-tomcat repository

calummackervoy commented 3 years ago

For the second task... I think that in Jersey/JAX-RS this is fairly straightforward: https://stackoverflow.com/questions/17324075/get-configuration-data-from-web-xml-when-using-a-jersey-servletcontainer

I've already started doing this task for #23 so I could pick it up, we need to synchronise on this issue I think :sweat_smile: