7373import org .tweetyproject .arg .delp .syntax .DefeasibleLogicProgram ;
7474import org .tweetyproject .arg .dung .reasoner .AbstractExtensionReasoner ;
7575import org .tweetyproject .arg .dung .semantics .Extension ;
76+ import org .tweetyproject .web .pyargservices .aba .AbaGetSemanticsResponse ;
7677import org .tweetyproject .web .pyargservices .aba .AbaReasonerCalleeFactory ;
7778import org .tweetyproject .web .pyargservices .aba .AbaReasonerGetModelsCallee ;
7879import org .tweetyproject .web .pyargservices .aba .AbaReasonerPost ;
@@ -91,16 +92,15 @@ public class RequestController {
9192 private final int SERVICES_TIMEOUT_DELP = 600 ;
9293 private final int SERVICES_TIMEOUT_INCMES = 300 ;
9394
94- private AbaReasonerResponse handleQueryAbaRequest (AbaReasonerPost AbaReasonerPost ){
95-
96-
97- return null ;
98- }
99-
10095 @ PostMapping (value = "/aba" , produces = "application/json" , consumes = "application/json" )
10196 @ ResponseBody
10297 public Response handleRequest (
103- @ RequestBody AbaReasonerPost AbaReasonerPost ) throws ParserException , IOException {
98+ @ RequestBody AbaReasonerPost AbaReasonerPost ) throws ParserException , IOException , JSONException , org .codehaus .jettison .json .JSONException {
99+
100+
101+ if (AbaReasonerPost .getCmd ().equals ("semantics" )) {
102+ return handleGetSemantics (AbaReasonerPost );
103+ }
104104
105105
106106 // DungTheory dungTheory =
@@ -173,8 +173,11 @@ public Response handleRequest(
173173 // handle timeout
174174 if (AbaReasonerPost .getCmd ().equals ("get_models" ) || AbaReasonerPost .getCmd ().equals ("get_model" )) {
175175 Future <Collection <AbaExtension <Formula >>> future = executor .submit (callee );
176+
177+ System .out .print ("Run command: " + AbaReasonerPost .getCmd () + " with timeout: " + user_timeout + "....." );
176178 Pair <Collection <AbaExtension <Formula >>, Long > result = Utils .runServicesWithTimeout (future ,
177179 user_timeout , unit );
180+ System .out .println ("DONE!" );
178181 reasonerResponse .setTime (result .getValue ());
179182 reasonerResponse .setAnswer (result .getKey ().toString ());
180183 reasonerResponse .setStatus ("SUCCESS" );
@@ -496,4 +499,31 @@ private InconsistencyGetMeasuresResponse handleGetMeasures(InconsistencyPost que
496499 return response ;
497500 }
498501
502+
503+ /**
504+ * Handles the "List semanctics" command for aba
505+ *
506+ * @param query some query
507+ * @return the reply
508+ * @throws JSONException if some JSON issue occurs.
509+ * @throws org.codehaus.jettison.json.JSONException
510+ */
511+ private AbaGetSemanticsResponse handleGetSemantics (AbaReasonerPost query )
512+ throws JSONException , org .codehaus .jettison .json .JSONException {
513+ AbaGetSemanticsResponse response = new AbaGetSemanticsResponse ();
514+ List <HashMap <String , String >> value = new LinkedList <HashMap <String , String >>();
515+ HashMap <String , String > jsonMes ;
516+ for (org .tweetyproject .web .pyargservices .aba .GeneralAbaReasonerFactory .Semantics m : GeneralAbaReasonerFactory .Semantics .values ()) {
517+ jsonMes = new HashMap <String , String >();
518+ jsonMes .put (InconsistencyMeasurementService .JSON_ATTR_ID , m .id );
519+ jsonMes .put (InconsistencyMeasurementService .JSON_ATTR_LABEL , m .label );
520+ value .add (jsonMes );
521+ }
522+ response .setSemantics (value );
523+ response .setEmail (query .getEmail ());
524+ response .reply (query .getCmd ());
525+ return response ;
526+ }
527+
528+
499529}
0 commit comments