From 0bd1afc1323f4232201c10cb5df6e5fec39c0fc3 Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Tue, 27 Jul 2021 22:48:06 +0200 Subject: [PATCH 1/5] added boilerplate SceneGenerationEndpoint to mud config --- .../calum/mud/content/ContentController.java | 1 - .../calum/mud/world/SceneController.java | 30 +++++++++++++++++++ src/main/webapp/WEB-INF/mudserver.ttl | 1 + 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/mackervoy/calum/mud/world/SceneController.java diff --git a/src/main/java/com/mackervoy/calum/mud/content/ContentController.java b/src/main/java/com/mackervoy/calum/mud/content/ContentController.java index 9e9b887..e6d652c 100644 --- a/src/main/java/com/mackervoy/calum/mud/content/ContentController.java +++ b/src/main/java/com/mackervoy/calum/mud/content/ContentController.java @@ -6,7 +6,6 @@ import com.mackervoy.calum.mud.AbstractMUDController; import com.mackervoy.calum.mud.vocabularies.MUDCharacter; -import java.io.StringReader; import java.util.Optional; import javax.ws.rs.POST; diff --git a/src/main/java/com/mackervoy/calum/mud/world/SceneController.java b/src/main/java/com/mackervoy/calum/mud/world/SceneController.java new file mode 100644 index 0000000..79b45e3 --- /dev/null +++ b/src/main/java/com/mackervoy/calum/mud/world/SceneController.java @@ -0,0 +1,30 @@ +package com.mackervoy.calum.mud.world; + +import com.mackervoy.calum.mud.AbstractMUDController; + +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.core.Response; +import org.apache.jena.rdf.model.Model; + +/** + * @author Calum Mackervoy + * Provides endpoints to help generate objects into a scene + * (e.g. a character walks into a bar and expects to see occupants) + */ +@Path("/mud/scene/") +public class SceneController extends AbstractMUDController { + //NOTE: the ContentContoller POST must receives objects with RDF type set, or it will ignore them + @POST + public Response post(String requestBody) { + // the request object will contain the scene as passed by the client + // e.g. the clientside characters and the selected building + // TODO: context and social context passed in with the scene + Model scene = this.serializeTurtleRequestToModel(requestBody); + + // TODO: for now we just add a hard-coded character to the scene + // ... + + return Response.ok(serializeModelToTurtle(scene)).build(); + } +} diff --git a/src/main/webapp/WEB-INF/mudserver.ttl b/src/main/webapp/WEB-INF/mudserver.ttl index f5e3ac0..2373db9 100644 --- a/src/main/webapp/WEB-INF/mudserver.ttl +++ b/src/main/webapp/WEB-INF/mudserver.ttl @@ -5,6 +5,7 @@ :configuration a mud:Configuration ; mud:worldEndpoint ; + mud:sceneGenerationEndpoint ; mudcontent:SceneDescriptionEndpoint ; mudcontent:SimpleObjectDescriptionEndpoint ; mudlogic:actionDiscoveryEndpoint ; From 37165b2ce2f18cdb63f2e2a7147529a5d2a747b5 Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Thu, 29 Jul 2021 00:14:16 +0200 Subject: [PATCH 2/5] scene generation reads template character from pod --- .../java/com/mackervoy/calum/mud/world/SceneController.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/mackervoy/calum/mud/world/SceneController.java b/src/main/java/com/mackervoy/calum/mud/world/SceneController.java index 79b45e3..14b7a0e 100644 --- a/src/main/java/com/mackervoy/calum/mud/world/SceneController.java +++ b/src/main/java/com/mackervoy/calum/mud/world/SceneController.java @@ -6,6 +6,7 @@ import javax.ws.rs.Path; import javax.ws.rs.core.Response; import org.apache.jena.rdf.model.Model; +import org.apache.jena.rdf.model.ModelFactory; /** * @author Calum Mackervoy @@ -22,8 +23,8 @@ public Response post(String requestBody) { // TODO: context and social context passed in with the scene Model scene = this.serializeTurtleRequestToModel(requestBody); - // TODO: for now we just add a hard-coded character to the scene - // ... + // for now we just add a hard-coded character to the scene + scene = scene.union(ModelFactory.createDefaultModel().read("https://calum.inrupt.net/public/collections/scenedemo.ttl", "TURTLE")); return Response.ok(serializeModelToTurtle(scene)).build(); } From 86ce8b44f7ef8c5cdd7b30ea004815b2baba1b17 Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Wed, 20 Oct 2021 20:41:05 +0200 Subject: [PATCH 3/5] fix config issues --- src/main/webapp/WEB-INF/mudserver.ttl | 4 ++-- src/main/webapp/WEB-INF/web.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/WEB-INF/mudserver.ttl b/src/main/webapp/WEB-INF/mudserver.ttl index 2373db9..5f46a07 100644 --- a/src/main/webapp/WEB-INF/mudserver.ttl +++ b/src/main/webapp/WEB-INF/mudserver.ttl @@ -8,5 +8,5 @@ mud:sceneGenerationEndpoint ; mudcontent:SceneDescriptionEndpoint ; mudcontent:SimpleObjectDescriptionEndpoint ; - mudlogic:actionDiscoveryEndpoint ; - mudlogic:Transit . + mudlogic:actionDiscoveryEndpoint ; + mudlogic:Transit . diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index c51165d..828d0a0 100755 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -26,7 +26,7 @@ com.mackervoy.calum.mud.BASE_URL http://localhost:8080/ - The base URL which the site is deployed to e.g. + The base URL which the site is deployed to From 2421759dbc52248683c805249c1367486f738619 Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Wed, 20 Oct 2021 20:42:37 +0200 Subject: [PATCH 4/5] added more info to actions returned by discovery --- .../com/mackervoy/calum/mud/behaviour/ActionController.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/com/mackervoy/calum/mud/behaviour/ActionController.java b/src/main/java/com/mackervoy/calum/mud/behaviour/ActionController.java index effb389..b7b9a20 100644 --- a/src/main/java/com/mackervoy/calum/mud/behaviour/ActionController.java +++ b/src/main/java/com/mackervoy/calum/mud/behaviour/ActionController.java @@ -4,6 +4,7 @@ import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Resource; import org.apache.jena.vocabulary.RDF; +import org.apache.jena.vocabulary.RDFS; import java.util.Set; @@ -43,6 +44,11 @@ public Response discoverActions(String requestBody) { for(String key : keys) { Model m = ModelFactory.createDefaultModel().read(key, "TURTLE"); Resource r = m.getResource(key); + String name = r.hasProperty(RDFS.label) ? r.getProperty(RDFS.label, "en").getString() : ""; + String description = r.hasProperty(RDFS.comment) ? r.getProperty(RDFS.comment, "en").getString() : ""; + + result.add(r, RDFS.label, name); + result.add(r, RDFS.comment, description); result.add(r, RDF.type, r.getPropertyResourceValue(RDF.type)); result.add(r, MUDLogic.actAt, this.getActAtURL(r)); } From a9f9e50a631f0ab4010802be87e757776c32cd4d Mon Sep 17 00:00:00 2001 From: Calum Mackervoy Date: Wed, 3 Nov 2021 20:17:15 +0100 Subject: [PATCH 5/5] added parameterConstraintsShape to MUDLogic vocab --- src/main/java/com/mackervoy/calum/mud/vocabularies/MUDLogic.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/mackervoy/calum/mud/vocabularies/MUDLogic.java b/src/main/java/com/mackervoy/calum/mud/vocabularies/MUDLogic.java index 8d42d57..7591826 100644 --- a/src/main/java/com/mackervoy/calum/mud/vocabularies/MUDLogic.java +++ b/src/main/java/com/mackervoy/calum/mud/vocabularies/MUDLogic.java @@ -31,6 +31,7 @@ protected static final Property property( String local ) public final static Resource Task = resource( "Task" ); public final static Resource Transit = resource( "Transit" ); public final static Property actAt = property( "actAt" ); + public final static Property parameterConstraintsShape = property("parameterConstraintsShape"); public final static Property taskImplements = property( "taskImplements" ); public final static Property isComplete = property( "isComplete" ); public final static Property endState = property( "endState" );