Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
added mudlogic:actedAt to serialization in ActionController
Browse files Browse the repository at this point in the history
  • Loading branch information
calummackervoy committed Jul 9, 2021
1 parent bc8dc07 commit 999d9a4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.rdf.model.ResIterator;
import org.apache.jena.vocabulary.RDF;

import java.io.StringReader;
import java.util.Set;

import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

import com.mackervoy.calum.mud.AbstractMUDController;
import com.mackervoy.calum.mud.MUDApplication;
import com.mackervoy.calum.mud.behaviour.task.TaskActorFactory;
import com.mackervoy.calum.mud.vocabularies.MUDLogic;

/**
* @author Calum Mackervoy
Expand All @@ -24,6 +23,11 @@

@Path("/mud/act/discover/")
public class ActionController extends AbstractMUDController {
private String getActAtURL(Resource action) {
String base = MUDApplication.getSiteUrl() + "mud/act/";
return action.getPropertyResourceValue(RDF.type) == MUDLogic.Task ? base + "task/" : base;
}

// pass a URI in the query string for an object
// expect to get back the configured endpoints for actions and tasks on this object
@POST
Expand All @@ -40,6 +44,7 @@ public Response discoverActions(String requestBody) {
Model m = ModelFactory.createDefaultModel().read(key, "TURTLE");
Resource r = m.getResource(key);
result.add(r, RDF.type, r.getPropertyResourceValue(RDF.type));
result.add(r, MUDLogic.actAt, this.getActAtURL(r));
}

String responseData = result.isEmpty() ? null : serializeModelToTurtle(result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected static final Property property( String local )
public final static Resource Action = resource( "Action" );
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 taskImplements = property( "taskImplements" );
public final static Property isComplete = property( "isComplete" );
public final static Property endState = property( "endState" );
Expand Down

0 comments on commit 999d9a4

Please sign in to comment.