diff --git a/.deployment/docker-compose.yml b/.deployment/docker-compose.yml
index a23fa53..666f162 100644
--- a/.deployment/docker-compose.yml
+++ b/.deployment/docker-compose.yml
@@ -67,9 +67,8 @@ services:
- ./:/data/
environment:
mqtt.broker.uri: tcp://broker.hivemq.com:1883
- discovery.endpoint.uri: https://tapas-auction-house.86-119-34-242.nip.io
+ discovery.endpoint.uri: https://tapas-auction-house.86.119.35.213.nip.io/discovery/
auction.house.uri: https://tapas-auction-house.86-119-35-40.nip.io
- tasks.list.uri: https://tapas-tasks.86-119-35-40.nip.io
labels:
- "traefik.enable=true"
- "traefik.http.routers.tapas-auction-house.rule=Host(`tapas-auction-house.${PUB_IP}.nip.io`)"
@@ -92,7 +91,6 @@ services:
auction.house.uri: http://tapas-auction-house:8086
executor.robot.uri: http://executor-robot:8084
executor.computation.uri: http://executor-computation:8085
- executor.humidity.uri: http://executor-humidity:8087
mqtt.broker.uri: tcp://broker.hivemq.com:1883
spring.data.mongodb.uri: mongodb://root:password@tapas-db:27017
labels:
@@ -166,24 +164,3 @@ services:
- "traefik.http.routers.executor-robot.tls=true"
- "traefik.http.routers.executor-robot.entryPoints=web,websecure"
- "traefik.http.routers.executor-robot.tls.certresolver=le"
- executor-humidity:
- image: openjdk
- command: "java -jar /data/executor-humidity-0.0.1-SNAPSHOT.jar"
- restart: unless-stopped
- depends_on:
- - executor-pool
- - roster
- - tapas-db
- volumes:
- - ./:/data/
- environment:
- EXECUTOR_POOL_URI: http://executor-pool:8083
- ROSTER_URI: http://roster:8082
- labels:
- - "traefik.enable=true"
- - "traefik.http.routers.executor-computation.rule=Host(`executor-humidity.${PUB_IP}.nip.io`)"
- - "traefik.http.routers.executor-computation.service=executor-computation"
- - "traefik.http.services.executor-computation.loadbalancer.server.port=8087"
- - "traefik.http.routers.executor-computation.tls=true"
- - "traefik.http.routers.executor-computation.entryPoints=web,websecure"
- - "traefik.http.routers.executor-computation.tls.certresolver=le"
diff --git a/.github/workflows/build-and-deploy.yml b/.github/workflows/build-and-deploy.yml
index cc46404..7290452 100644
--- a/.github/workflows/build-and-deploy.yml
+++ b/.github/workflows/build-and-deploy.yml
@@ -55,10 +55,6 @@ jobs:
run: mvn -f executor-robot/pom.xml --batch-mode --update-snapshots verify
- run: cp ./executor-robot/target/executor-robot-0.0.1-SNAPSHOT.jar ./target
- - name: Build executor-humidity service
- run: mvn -f executor-humidity/pom.xml --batch-mode --update-snapshots verify
- - run: cp ./executor-humidity/target/executor-humidity-0.0.1-SNAPSHOT.jar ./target
-
- name: Build tapas-task service
run: mvn -f tapas-tasks/pom.xml --batch-mode --update-snapshots verify
- run: cp ./tapas-tasks/target/tapas-tasks-0.0.1-SNAPSHOT.jar ./target
@@ -107,6 +103,5 @@ jobs:
cd /home/${{ secrets.SSH_USER }}/
touch acme.json
sudo chmod 0600 acme.json
- sudo docker-compose down --remove-orphans
sudo echo "PUB_IP=$(wget -qO- http://ipecho.net/plain | xargs echo)" | sed -e 's/\./-/g' > .env
- sudo docker-compose up -d
+ sudo docker-compose up -d --build --force-recreate
diff --git a/TAPAS-Final/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md b/TAPAS-Final/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md
deleted file mode 100644
index 60b14e0..0000000
--- a/TAPAS-Final/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md
+++ /dev/null
@@ -1,29 +0,0 @@
-# 2. Seperate service for Executor Pool
-
-Date: 2021-11-21
-
-## Status
-
-Accepted
-
-## Context
-
-The Executor Pool has to keep track of which Executors are online and what task types they can execute. The Roster keeps track of tasks that need to be executed and assigns Executors to tasks. The Executor Pool functionalty could be implemented in a seperate service or as a part of the Roster.
-
-## Decision
-
-The executor pool will be implemented as a seperate service.
-
-Most importantly, the Executor Pool and the Roster have quite different responsibilities and reasons to change. On one hand, the Executor Pool manages the Executors, and therefore it will change if we want to add functionality that impacts how Executors log onto the system and how we keep track of them. For example, if we want to check if an executor fulfills some requirements before logging on. On the other hand, the Roster manages the execution of tasks. TODO
-
-Single responsibility
-
-Potential Code volatility
-
-Scalability - Roster needs much more scale
-
-## Consequences
-
-The one funcionalty that is duplicated is error handling when an executor disconnects nongracefully...
-
-TODO
\ No newline at end of file
diff --git a/TAPAS-Final/doc/architecture/decisions/0012-separate-service-for-each-executor.md b/TAPAS-Final/doc/architecture/decisions/0012-separate-service-for-each-executor.md
deleted file mode 100644
index 66444c0..0000000
--- a/TAPAS-Final/doc/architecture/decisions/0012-separate-service-for-each-executor.md
+++ /dev/null
@@ -1,27 +0,0 @@
-# 12. separate service for each executor
-
-Date: 2021-11-21
-
-## Status
-
-Accepted
-
-## Context
-
-Executors must receive tasks of different types and execute them. The executors could either all be implemented within one service or as multiple services, one for each type of executor.
-
-## Decision
-
-We will have a seperate service for each type of executor.
-
-Firstly, execution time differs significantly between task types. Therefore, having seperate services will allow the executos to scale differently based on their tasks' specific needs.
-
-Secondly, the systems functioning should not be disrupted in case an Executor fails. Having each type of executor in a seperate service will increase fault tolerance in this regard.
-
-Lastly, extensibility is one of the systems most important non-functional requirement and providers of executors need to be able to easily add executors to the executor pool. These factors are also positively impacted by having seperate services.
-
-There should not be any shared data between the executors. Additionally, there should be no flow of information between them. Thus, there should be no issues due to workflow and data concerns due to this decision.
-
-## Consequences
-
-Executors share a lot of functionality when it comes to connecting to the rest of the system. Therefore, this decision means that we will either have to duplicate the code that implements the common functionality, or we have to have a way to share the code (e.g. through a common library)
diff --git a/TAPAS-Final/doc/architecture/decisions/0001-record-architecture-decisions.md b/doc/architecture/decisions/0001-record-architecture-decisions.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0001-record-architecture-decisions.md
rename to doc/architecture/decisions/0001-record-architecture-decisions.md
diff --git a/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md b/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md
new file mode 100644
index 0000000..5624c0b
--- /dev/null
+++ b/doc/architecture/decisions/0002-seperate-service-for-executor-pool.md
@@ -0,0 +1,21 @@
+# 2. Seperate service for Executor Pool
+
+Date: 2021-11-21
+
+## Status
+
+Accepted
+
+## Context
+
+The Executor Pool has to keep track of which Executors are online and what task types they can execute. The Roster keeps track of tasks that need to be executed and assigns Executors to tasks. The Executor Pool functionalty could be implemented in a seperate service or as a part of the Roster.
+
+## Decision
+
+The executor pool will be implemented as a seperate service. (TODO decision might change. Need to reevaluate)
+
+TODO explain why.
+
+## Consequences
+
+TODO
\ No newline at end of file
diff --git a/TAPAS-Final/doc/architecture/decisions/0003-seperate-service-for-roster.md b/doc/architecture/decisions/0003-seperate-service-for-roster.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0003-seperate-service-for-roster.md
rename to doc/architecture/decisions/0003-seperate-service-for-roster.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0004-seperate-service-for-task-list.md b/doc/architecture/decisions/0004-seperate-service-for-task-list.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0004-seperate-service-for-task-list.md
rename to doc/architecture/decisions/0004-seperate-service-for-task-list.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0005-event-driven-communication.md b/doc/architecture/decisions/0005-event-driven-communication.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0005-event-driven-communication.md
rename to doc/architecture/decisions/0005-event-driven-communication.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0006-one-global-database-or-one-database-per-service.md b/doc/architecture/decisions/0006-one-global-database-or-one-database-per-service.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0006-one-global-database-or-one-database-per-service.md
rename to doc/architecture/decisions/0006-one-global-database-or-one-database-per-service.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0007-seperate-service-for-auction-house.md b/doc/architecture/decisions/0007-seperate-service-for-auction-house.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0007-seperate-service-for-auction-house.md
rename to doc/architecture/decisions/0007-seperate-service-for-auction-house.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0008-switch-to-an-event-driven-microservices-architecture.md b/doc/architecture/decisions/0008-switch-to-an-event-driven-microservices-architecture.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0008-switch-to-an-event-driven-microservices-architecture.md
rename to doc/architecture/decisions/0008-switch-to-an-event-driven-microservices-architecture.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0009-common-library-for-shared-code.md b/doc/architecture/decisions/0009-common-library-for-shared-code.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0009-common-library-for-shared-code.md
rename to doc/architecture/decisions/0009-common-library-for-shared-code.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0010-executor-base-library.md b/doc/architecture/decisions/0010-executor-base-library.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0010-executor-base-library.md
rename to doc/architecture/decisions/0010-executor-base-library.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0011-seperation-of-common-and-executor-base-library.md b/doc/architecture/decisions/0011-seperation-of-common-and-executor-base-library.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0011-seperation-of-common-and-executor-base-library.md
rename to doc/architecture/decisions/0011-seperation-of-common-and-executor-base-library.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0012-seperate-service-for-each-executor.md b/doc/architecture/decisions/0012-seperate-service-for-each-executor.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0012-seperate-service-for-each-executor.md
rename to doc/architecture/decisions/0012-seperate-service-for-each-executor.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0013-microservice-architecture.md b/doc/architecture/decisions/0013-microservice-architecture.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0013-microservice-architecture.md
rename to doc/architecture/decisions/0013-microservice-architecture.md
diff --git a/TAPAS-Final/doc/architecture/decisions/0014-data-ownership.md b/doc/architecture/decisions/0014-data-ownership.md
similarity index 100%
rename from TAPAS-Final/doc/architecture/decisions/0014-data-ownership.md
rename to doc/architecture/decisions/0014-data-ownership.md
diff --git a/TAPAS-Final/doc/workflow.bpmn b/doc/workflow.bpmn
similarity index 100%
rename from TAPAS-Final/doc/workflow.bpmn
rename to doc/workflow.bpmn
diff --git a/TAPAS-Final/doc/workflow.png b/doc/workflow.png
similarity index 100%
rename from TAPAS-Final/doc/workflow.png
rename to doc/workflow.png
diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java
index aeafb4d..fca2758 100644
--- a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java
+++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorBase.java
@@ -33,11 +33,12 @@ public abstract class ExecutorBase {
Logger logger = Logger.getLogger(ExecutorBase.class.getName());
- protected ExecutorBase(ExecutorType executorType, String uri) {
+ protected ExecutorBase(ExecutorType executorType) {
logger.info("ExecutorBase | Starting Executor");
this.status = ExecutorStatus.STARTING_UP;
this.executorType = executorType;
- this.executorURI = new ExecutorURI(uri);
+ // TODO set this automaticly
+ this.executorURI = new ExecutorURI("http://localhost:8084");
// TODO do this in main
// Notify executor-pool about existence. If executor-pools response is successfull start with getting an assignment, else shut down executor.
logger.info("ExecutorBase | Notifying executor-pool about existens");
diff --git a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java
index 5ad22a7..30460e6 100644
--- a/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java
+++ b/executor-base/src/main/java/ch/unisg/executorBase/executor/domain/ExecutorType.java
@@ -1,7 +1,7 @@
package ch.unisg.executorbase.executor.domain;
public enum ExecutorType {
- COMPUTATION, SMALLROBOT, HUMIDITY;
+ COMPUTATION, ROBOT, HUMIDITY;
/**
* Checks if the give executor type exists.
diff --git a/executor-computation/pom.xml b/executor-computation/pom.xml
index c6c5167..8692c3e 100644
--- a/executor-computation/pom.xml
+++ b/executor-computation/pom.xml
@@ -67,17 +67,6 @@
org.springframework.boot
spring-boot-test
-
-
- org.graalvm.js
- js
- 21.3.0
-
-
- org.graalvm.js
- js-scriptengine
- 21.3.0
-
diff --git a/executor-computation/src/main/java/ch/unisg/executorcomputation/ExecutorcomputationApplication.java b/executor-computation/src/main/java/ch/unisg/executorcomputation/ExecutorcomputationApplication.java
index 1ee615d..ea9910a 100644
--- a/executor-computation/src/main/java/ch/unisg/executorcomputation/ExecutorcomputationApplication.java
+++ b/executor-computation/src/main/java/ch/unisg/executorcomputation/ExecutorcomputationApplication.java
@@ -15,6 +15,14 @@ public class ExecutorcomputationApplication {
static Logger logger = Logger.getLogger(ExecutorcomputationApplication.class.getName());
public static void main(String[] args) {
+
+ try {
+ TimeUnit.SECONDS.sleep(1);
+ } catch (InterruptedException e) {
+ logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
+ Thread.currentThread().interrupt();
+ }
+
SpringApplication.run(ExecutorcomputationApplication.class, args);
Executor.getExecutor();
}
diff --git a/executor-computation/src/main/java/ch/unisg/executorcomputation/executor/domain/Executor.java b/executor-computation/src/main/java/ch/unisg/executorcomputation/executor/domain/Executor.java
index bd22336..6c0cb59 100644
--- a/executor-computation/src/main/java/ch/unisg/executorcomputation/executor/domain/Executor.java
+++ b/executor-computation/src/main/java/ch/unisg/executorcomputation/executor/domain/Executor.java
@@ -1,6 +1,7 @@
package ch.unisg.executorcomputation.executor.domain;
import java.util.concurrent.TimeUnit;
+import java.util.logging.Level;
import java.util.logging.Logger;
import javax.script.ScriptEngine;
@@ -14,20 +15,21 @@ public class Executor extends ExecutorBase {
private static Logger executorLogger = Logger.getLogger(Executor.class.getName());
- private static final Executor executor = new Executor(ExecutorType.COMPUTATION, "http://localhost:8085");
+ private static final Executor executor = new Executor(ExecutorType.COMPUTATION);
public static Executor getExecutor() {
return executor;
}
- private Executor(ExecutorType executorType, String uri) {
- super(executorType, uri);
+ private Executor(ExecutorType executorType) {
+ super(executorType);
}
@Override
protected
String execution(String inputData) {
+ executorLogger.info("TEST");
executorLogger.info("Executor | Starting execution with inputData: " + inputData);
ScriptEngineManager mgr = new ScriptEngineManager();
@@ -43,11 +45,10 @@ public class Executor extends ExecutorBase {
}
try {
- TimeUnit.SECONDS.sleep(1);
+ TimeUnit.SECONDS.sleep(5);
} catch (InterruptedException e) {
- return result;
- // executorLogger.log(Level.SEVERE, e.getLocalizedMessage(), e);
- // Thread.currentThread().interrupt();
+ executorLogger.log(Level.SEVERE, e.getLocalizedMessage(), e);
+ Thread.currentThread().interrupt();
}
executorLogger.info("Executor | Finish execution");
diff --git a/executor-humidity/pom.xml b/executor-humidity/pom.xml
index f6390b0..001c752 100644
--- a/executor-humidity/pom.xml
+++ b/executor-humidity/pom.xml
@@ -11,7 +11,7 @@
ch.unisg
executor-humidity
- 0.0.1-SNAPSHOT
+ 1.0-SNAPSHOT
executor-humidity
Demo project for Spring Boot
diff --git a/executor-humidity/src/main/java/ch/unisg/executorhumidity/executor/domain/Executor.java b/executor-humidity/src/main/java/ch/unisg/executorhumidity/executor/domain/Executor.java
index 9205100..1e888aa 100644
--- a/executor-humidity/src/main/java/ch/unisg/executorhumidity/executor/domain/Executor.java
+++ b/executor-humidity/src/main/java/ch/unisg/executorhumidity/executor/domain/Executor.java
@@ -4,16 +4,17 @@ import ch.unisg.executorbase.executor.domain.ExecutorBase;
import ch.unisg.executorbase.executor.domain.ExecutorType;
import ch.unisg.executorhumidity.executor.adapter.out.GetHumidityAdapter;
import ch.unisg.executorhumidity.executor.application.port.out.GetHumidityPort;
+import org.eclipse.californium.elements.exception.ConnectorException;
+
+import java.io.IOException;
public class Executor extends ExecutorBase {
- private static final Executor executor = new Executor(ExecutorType.HUMIDITY, "http://localhost:8087");
+ private static final Executor executor = new Executor(ExecutorType.HUMIDITY);
private final GetHumidityPort getHumidityPort = new GetHumidityAdapter();
- private Executor(ExecutorType executorType, String uri) {
- super(executorType, uri);
- }
+ private Executor(ExecutorType executorType) {super(executorType);}
public static Executor getExecutor() {return executor;}
@@ -21,6 +22,8 @@ public class Executor extends ExecutorBase {
@Override
protected
String execution(String input) {
+ //TODO: Fill
+
String result = getHumidityPort.getHumidity();
return result;
diff --git a/executor-robot/pom.xml b/executor-robot/pom.xml
index 2fa8a0f..570bd18 100644
--- a/executor-robot/pom.xml
+++ b/executor-robot/pom.xml
@@ -82,10 +82,11 @@
compile
- com.github.Interactions-HSG
- wot-td-java
- master-SNAPSHOT
-
+ com.github.Interactions-HSG
+ wot-td-java
+ 0.1.1
+ compile
+
diff --git a/executor-robot/src/main/java/ch/unisg/executorrobot/ExecutorrobotApplication.java b/executor-robot/src/main/java/ch/unisg/executorrobot/ExecutorrobotApplication.java
index 15e2491..79a204f 100644
--- a/executor-robot/src/main/java/ch/unisg/executorrobot/ExecutorrobotApplication.java
+++ b/executor-robot/src/main/java/ch/unisg/executorrobot/ExecutorrobotApplication.java
@@ -11,6 +11,14 @@ import ch.unisg.executorrobot.executor.domain.Executor;
public class ExecutorrobotApplication {
public static void main(String[] args) {
+
+ try {
+ TimeUnit.SECONDS.sleep(40);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
SpringApplication.run(ExecutorrobotApplication.class, args);
Executor.getExecutor();
}
diff --git a/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/DeleteUserFromRobotAdapter.java b/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/DeleteUserFromRobotAdapter.java
new file mode 100644
index 0000000..37b605a
--- /dev/null
+++ b/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/DeleteUserFromRobotAdapter.java
@@ -0,0 +1,42 @@
+package ch.unisg.executorrobot.executor.adapter.out;
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import ch.unisg.executorrobot.executor.application.port.out.DeleteUserFromRobotPort;
+
+@Component
+@Primary
+public class DeleteUserFromRobotAdapter implements DeleteUserFromRobotPort {
+
+ @Override
+ public boolean deleteUserFromRobot(String key) {
+
+ String url = "https://api.interactions.ics.unisg.ch/leubot1/v1.3.4/user/" + key;
+
+ var request = HttpRequest.newBuilder()
+ .uri(URI.create(url))
+ .header("Content-Type", "application/json")
+ .DELETE()
+ .build();
+
+ var client = HttpClient.newHttpClient();
+
+ try {
+ var response = client.send(request, HttpResponse.BodyHandlers.ofString());
+ System.out.println(response.statusCode());
+ return true;
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+}
diff --git a/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/InstructionToRobotAdapter.java b/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/InstructionToRobotAdapter.java
new file mode 100644
index 0000000..763e530
--- /dev/null
+++ b/executor-robot/src/main/java/ch/unisg/executorrobot/executor/adapter/out/InstructionToRobotAdapter.java
@@ -0,0 +1,121 @@
+package ch.unisg.executorrobot.executor.adapter.out;
+import java.io.IOException;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+
+import ch.unisg.ics.interactions.wot.td.ThingDescription;
+import ch.unisg.ics.interactions.wot.td.affordances.ActionAffordance;
+import ch.unisg.ics.interactions.wot.td.affordances.Form;
+import ch.unisg.ics.interactions.wot.td.clients.TDHttpRequest;
+import ch.unisg.ics.interactions.wot.td.clients.TDHttpResponse;
+import ch.unisg.ics.interactions.wot.td.io.TDGraphReader;
+import ch.unisg.ics.interactions.wot.td.schemas.DataSchema;
+import ch.unisg.ics.interactions.wot.td.schemas.ObjectSchema;
+import ch.unisg.ics.interactions.wot.td.schemas.StringSchema;
+import ch.unisg.ics.interactions.wot.td.security.APIKeySecurityScheme;
+import ch.unisg.ics.interactions.wot.td.vocabularies.TD;
+import org.springframework.context.annotation.Primary;
+import org.springframework.stereotype.Component;
+
+import ch.unisg.executorrobot.executor.application.port.out.InstructionToRobotPort;
+
+@Component
+@Primary
+public class InstructionToRobotAdapter implements InstructionToRobotPort {
+
+ @Override
+ public boolean instructionToRobot(String key) {
+
+ String endpoint = "https://api.interactions.ics.unisg.ch/search/searchEngine";
+
+ String input = "@prefix dct: . select ?title where { ?title dct:title 'leubot1' }";
+
+ var httpRequest = HttpRequest.newBuilder()
+ .uri(URI.create(endpoint))
+ .header("Content-Type", "application/json")
+ .POST(HttpRequest.BodyPublishers.ofString(input))
+ .build();
+
+ var client = HttpClient.newHttpClient();
+
+ try {
+ var description = client.send(httpRequest, HttpResponse.BodyHandlers.ofString()).body();
+
+ // Parse a TD from a string
+ ThingDescription td = TDGraphReader.readFromString(ThingDescription.TDFormat.RDF_TURTLE, description);
+
+ // Create the payload to be sent with the Http request
+ Map elbowPayload = new HashMap<>();
+ elbowPayload.put("http://www.w3.org/2001/XMLSchema#int", 400);
+
+ // Get the affordance "setElbow" from the TD
+ Optional action = td.getActionByName("setElbow");
+
+ // Get the first form
+ if (action.isPresent()) {
+ Optional