Skip to content

Commit 5e62020

Browse files
committed
added api for aba
1 parent 1df4230 commit 5e62020

7 files changed

Lines changed: 530 additions & 214 deletions

File tree

org-tweetyproject-web/src/main/java/org/tweetyproject/web/pyargservices/RequestController.java

Lines changed: 249 additions & 113 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package org.tweetyproject.web.pyargservices.aba;
22

3-
import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
4-
import org.tweetyproject.arg.dung.syntax.DungTheory;
3+
import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
4+
import org.tweetyproject.arg.aba.syntax.AbaTheory;
5+
import org.tweetyproject.arg.aba.syntax.Assumption;
6+
import org.tweetyproject.commons.Formula;
7+
import org.tweetyproject.logics.fol.syntax.FolFormula;
8+
import org.tweetyproject.logics.pl.syntax.PlFormula;
59
import org.tweetyproject.web.pyargservices.Callee;
610

711

@@ -10,18 +14,19 @@
1014
public class AbaReasonerCalleeFactory {
1115
public enum Command{
1216
GET_MODELS ("get_models", "Get all models"),
17+
QUERY ("query", "query aba framework"),
1318
GET_MODEL ("get_model", "Get some model");
1419
/**id*/
1520
public String id;
1621
/**label*/
1722
public String label;
18-
23+
1924
Command(String id, String label){
2025
this.id = id;
21-
this.label = label;
26+
this.label = label;
2227
}
2328
/**
24-
*
29+
*
2530
* @param id ID
2631
* @return the measure
2732
*/
@@ -32,7 +37,7 @@ public static Command getCommand(String id){
3237
return null;
3338
}
3439
}
35-
40+
3641
public static Command [] getCommands(){
3742
return Command.values();
3843
}
@@ -42,13 +47,30 @@ public static Command getCommand(String id){
4247
* @param im some identifier of an inconsistency measure.
4348
* @return the requested inconsistency measure.
4449
*/
45-
public static Callee getCallee(Command cmd, AbstractExtensionReasoner reasoner, DungTheory bbase){
50+
public static <T extends Formula> Callee getCallee(Command cmd, GeneralAbaReasoner<T> reasoner, AbaTheory<T> bbase, Assumption<T> a){
51+
// Create an instance of the object using the constructor
4652
switch(cmd){
4753
case GET_MODELS:
48-
return new AbaReasonerGetModelsCallee(reasoner, bbase);
54+
return new AbaReasonerGetModelsCallee<T>(reasoner, bbase);
55+
56+
case GET_MODEL:
57+
return new AbaReasonerGetModelCallee<T>(reasoner, bbase);
58+
59+
case QUERY:
60+
return new AbaReasonerQueryCallee<T>(reasoner, bbase, a);
61+
4962
default:
5063
throw new RuntimeException("Command not found: " + cmd.toString());
5164
}
5265
}
53-
66+
// public static Callee getCallee(org.tweetyproject.web.pyargservices.dung.DungReasonerCalleeFactory.Command command,
67+
// GeneralAbaReasoner<PlFormula> r1, AbaTheory<PlFormula> abat1) {
68+
// switch(command){
69+
// case GET_MODELS:
70+
// return new AbaReasonerGetModelsCallee<PlFormula>(r1, abat1);
71+
// default:
72+
// throw new RuntimeException("Command not found: " + command.toString());
73+
// }
74+
// }
75+
5476
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.tweetyproject.web.pyargservices.aba;
2+
3+
4+
5+
import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
6+
import org.tweetyproject.arg.aba.semantics.AbaExtension;
7+
import org.tweetyproject.arg.aba.syntax.AbaTheory;
8+
import org.tweetyproject.commons.Formula;
9+
import org.tweetyproject.web.pyargservices.Callee;
10+
11+
public class AbaReasonerGetModelCallee<T extends Formula> extends Callee {
12+
GeneralAbaReasoner<T> reasoner;
13+
AbaTheory<T> bbase;
14+
public AbaReasonerGetModelCallee(GeneralAbaReasoner<T> reasoner, AbaTheory<T> bbase){
15+
this.reasoner = reasoner;
16+
this.bbase = bbase;
17+
}
18+
@Override
19+
public AbaExtension<T> call() throws Exception {
20+
return this.reasoner.getModel(this.bbase);
21+
}
22+
}

org-tweetyproject-web/src/main/java/org/tweetyproject/web/pyargservices/aba/AbaReasonerGetModelsCallee.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,18 @@
55
import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
66
import org.tweetyproject.arg.aba.semantics.AbaExtension;
77
import org.tweetyproject.arg.aba.syntax.AbaTheory;
8-
import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
9-
import org.tweetyproject.arg.dung.semantics.Extension;
10-
import org.tweetyproject.arg.dung.syntax.DungTheory;
8+
import org.tweetyproject.commons.Formula;
119
import org.tweetyproject.web.pyargservices.Callee;
1210

13-
// public class AbaReasonerGetModelsCallee extends Callee {
14-
// GeneralAbaReasoner<T> reasoner;
15-
// AbaTheory<T> bbase;
16-
// public T AbaReasonerGetModelsCallee(GeneralAbaReasoner<T> reasoner, AbaTheory<T> bbase){
17-
// this.reasoner = reasoner;
18-
// this.bbase = bbase;
19-
// }
20-
// @Override
21-
// public T Collection<AbaExtension<T>> call() throws Exception {
22-
// return this.reasoner.getModels(this.bbase);
23-
// }
24-
25-
// }
11+
public class AbaReasonerGetModelsCallee<T extends Formula> extends Callee {
12+
GeneralAbaReasoner<T> reasoner;
13+
AbaTheory<T> bbase;
14+
public AbaReasonerGetModelsCallee(GeneralAbaReasoner<T> reasoner, AbaTheory<T> bbase){
15+
this.reasoner = reasoner;
16+
this.bbase = bbase;
17+
}
18+
@Override
19+
public Collection<AbaExtension<T>> call() throws Exception {
20+
return this.reasoner.getModels(this.bbase);
21+
}
22+
}
Lines changed: 123 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,43 @@
11
package org.tweetyproject.web.pyargservices.aba;
22

3-
import java.util.List;
3+
import java.util.Objects;
44

55
public class AbaReasonerPost
66
{
77

88
private String cmd;
99
private String email;
10-
private int nr_of_arguments;
11-
private List<List<Integer>> attacks;
10+
private String kb;
11+
private String kb_format;
12+
private String fol_signature;
13+
public String getFol_signature() {
14+
return fol_signature;
15+
}
16+
17+
public void setFol_signature(String fol_signature) {
18+
this.fol_signature = fol_signature;
19+
}
20+
21+
private String query_assumption;
1222
private String semantics;
13-
private String solver;
14-
private int timeout; // Timeout in seconds
23+
private int timeout;
1524
private String unit_timeout;
1625

17-
public String getUnit_timeout() {
18-
return unit_timeout;
19-
}
2026

21-
public void setUnit_timeout(String unit_timeout) {
22-
this.unit_timeout = unit_timeout;
23-
}
27+
public AbaReasonerPost() {
28+
}
29+
30+
public AbaReasonerPost(String cmd, String email, String kb, String kb_format, String fol_signature, String query_assumption, String semantics, int timeout, String unit_timeout) {
31+
this.cmd = cmd;
32+
this.email = email;
33+
this.kb = kb;
34+
this.kb_format = kb_format;
35+
this.query_assumption = query_assumption;
36+
this.semantics = semantics;
37+
this.timeout = timeout;
38+
this.unit_timeout = unit_timeout;
39+
this.fol_signature = fol_signature;
40+
}
2441

2542
public String getCmd() {
2643
return this.cmd;
@@ -38,36 +55,36 @@ public void setEmail(String email) {
3855
this.email = email;
3956
}
4057

41-
public int getNr_of_arguments() {
42-
return this.nr_of_arguments;
58+
public String getKb() {
59+
return this.kb;
4360
}
4461

45-
public void setNr_of_arguments(int nr_of_arguments) {
46-
this.nr_of_arguments = nr_of_arguments;
62+
public void setKb(String kb) {
63+
this.kb = kb;
4764
}
4865

49-
public List<List<Integer>> getAttacks() {
50-
return this.attacks;
66+
public String getKb_format() {
67+
return this.kb_format;
5168
}
5269

53-
public void setAttacks(List<List<Integer>> attacks) {
54-
this.attacks = attacks;
70+
public void setKb_format(String kb_format) {
71+
this.kb_format = kb_format;
5572
}
5673

57-
public String getSemantics() {
58-
return this.semantics;
74+
public String getQuery_assumption() {
75+
return this.query_assumption;
5976
}
6077

61-
public void setSemantics(String semantics) {
62-
this.semantics = semantics;
78+
public void setQuery_assumption(String query_assumption) {
79+
this.query_assumption = query_assumption;
6380
}
6481

65-
public String getSolver() {
66-
return this.solver;
82+
public String getSemantics() {
83+
return this.semantics;
6784
}
6885

69-
public void setSolver(String solver) {
70-
this.solver = solver;
86+
public void setSemantics(String semantics) {
87+
this.semantics = semantics;
7188
}
7289

7390
public int getTimeout() {
@@ -78,4 +95,83 @@ public void setTimeout(int timeout) {
7895
this.timeout = timeout;
7996
}
8097

98+
public String getUnit_timeout() {
99+
return this.unit_timeout;
100+
}
101+
102+
public void setUnit_timeout(String unit_timeout) {
103+
this.unit_timeout = unit_timeout;
104+
}
105+
106+
public AbaReasonerPost cmd(String cmd) {
107+
setCmd(cmd);
108+
return this;
109+
}
110+
111+
public AbaReasonerPost email(String email) {
112+
setEmail(email);
113+
return this;
114+
}
115+
116+
public AbaReasonerPost kb(String kb) {
117+
setKb(kb);
118+
return this;
119+
}
120+
121+
public AbaReasonerPost kb_format(String kb_format) {
122+
setKb_format(kb_format);
123+
return this;
124+
}
125+
126+
public AbaReasonerPost query_assumption(String query_assumption) {
127+
setQuery_assumption(query_assumption);
128+
return this;
129+
}
130+
131+
public AbaReasonerPost semantics(String semantics) {
132+
setSemantics(semantics);
133+
return this;
134+
}
135+
136+
public AbaReasonerPost timeout(int timeout) {
137+
setTimeout(timeout);
138+
return this;
139+
}
140+
141+
public AbaReasonerPost unit_timeout(String unit_timeout) {
142+
setUnit_timeout(unit_timeout);
143+
return this;
144+
}
145+
146+
@Override
147+
public boolean equals(Object o) {
148+
if (o == this)
149+
return true;
150+
if (!(o instanceof AbaReasonerPost)) {
151+
return false;
152+
}
153+
AbaReasonerPost abaReasonerPost = (AbaReasonerPost) o;
154+
return Objects.equals(cmd, abaReasonerPost.cmd) && Objects.equals(email, abaReasonerPost.email) && Objects.equals(kb, abaReasonerPost.kb) && Objects.equals(kb_format, abaReasonerPost.kb_format) && Objects.equals(query_assumption, abaReasonerPost.query_assumption) && Objects.equals(semantics, abaReasonerPost.semantics) && timeout == abaReasonerPost.timeout && Objects.equals(unit_timeout, abaReasonerPost.unit_timeout);
155+
}
156+
157+
@Override
158+
public int hashCode() {
159+
return Objects.hash(cmd, email, kb, kb_format, query_assumption, semantics, timeout, unit_timeout);
160+
}
161+
162+
@Override
163+
public String toString() {
164+
return "{" +
165+
" cmd='" + getCmd() + "'" +
166+
", email='" + getEmail() + "'" +
167+
", kb='" + getKb() + "'" +
168+
", kb_format='" + getKb_format() + "'" +
169+
", query_assumption='" + getQuery_assumption() + "'" +
170+
", semantics='" + getSemantics() + "'" +
171+
", timeout='" + getTimeout() + "'" +
172+
", unit_timeout='" + getUnit_timeout() + "'" +
173+
"}";
174+
}
175+
176+
81177
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.tweetyproject.web.pyargservices.aba;
2+
import org.tweetyproject.arg.aba.reasoner.GeneralAbaReasoner;
3+
import org.tweetyproject.arg.aba.syntax.AbaTheory;
4+
import org.tweetyproject.arg.aba.syntax.Assumption;
5+
import org.tweetyproject.commons.Formula;
6+
7+
import org.tweetyproject.web.pyargservices.Callee;
8+
9+
public class AbaReasonerQueryCallee<T extends Formula> extends Callee {
10+
GeneralAbaReasoner<T> reasoner;
11+
AbaTheory<T> bbase;
12+
Assumption<T> assumption;
13+
public AbaReasonerQueryCallee(GeneralAbaReasoner<T> reasoner, AbaTheory<T> bbase, Assumption<T> a){
14+
this.reasoner = reasoner;
15+
this.bbase = bbase;
16+
this.assumption = a;
17+
}
18+
@Override
19+
public Boolean call() throws Exception {
20+
return this.reasoner.query(this.bbase,assumption);
21+
}
22+
}

0 commit comments

Comments
 (0)