Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/com/mackervoy/calum/mud/world/SceneController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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;
import org.apache.jena.rdf.model.ModelFactory;

/**
* @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);

// 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();
}
}
5 changes: 3 additions & 2 deletions src/main/webapp/WEB-INF/mudserver.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

:configuration a mud:Configuration ;
mud:worldEndpoint <http://localhost:8080/mud/world/> ;
mud:sceneGenerationEndpoint <http://localhost:8080/mud/scene/> ;
mudcontent:SceneDescriptionEndpoint <http://localhost:8080/mud/content/> ;
mudcontent:SimpleObjectDescriptionEndpoint <http://localhost:8080/mud/content/> ;
mudlogic:actionDiscoveryEndpoint <http://localhost:8000/mud/act/discover/> ;
mudlogic:Transit <http://localhost:8000/mud/act/task/> .
mudlogic:actionDiscoveryEndpoint <http://localhost:8080/mud/act/discover/> ;
mudlogic:Transit <http://localhost:8080/mud/act/task/> .
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<context-param>
<param-name>com.mackervoy.calum.mud.BASE_URL</param-name>
<param-value>http://localhost:8080/</param-value>
<description>The base URL which the site is deployed to e.g.</description>
<description>The base URL which the site is deployed to</description>
</context-param>

<context-param>
Expand Down