diff --git a/.deployment/docker-compose.yml b/.deployment/docker-compose.yml index 68ec014..523accc 100644 --- a/.deployment/docker-compose.yml +++ b/.deployment/docker-compose.yml @@ -26,14 +26,28 @@ services: - "traefik.http.routers.http-catchall.middlewares=redirect-to-https" - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https" + tapas-db: + image: mongo + restart: unless-stopped + container_name: tapas_mongodb + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: password + ports: + - "27017:27017" + command: mongod --quiet --logpath /dev/null + tapas-tasks: image: openjdk command: "java -jar /data/tapas-tasks-0.0.1-SNAPSHOT.jar" restart: unless-stopped + depends_on: + - tapas-db volumes: - ./:/data/ environment: roster.uri: http://roster:8082 + spring.data.mongodb.uri: mongodb://root:password@mongodb:27017 labels: - "traefik.enable=true" - "traefik.http.routers.tapas-tasks.rule=Host(`tapas-tasks.${PUB_IP}.nip.io`)" @@ -47,6 +61,8 @@ services: image: openjdk command: "java -jar /data/tapas-auction-house-0.0.1-SNAPSHOT.jar" restart: unless-stopped + depends_on: + - tapas-db volumes: - ./:/data/ environment: @@ -64,6 +80,8 @@ services: image: openjdk command: "java -jar /data/roster-0.0.1-SNAPSHOT.jar" restart: unless-stopped + depends_on: + - tapas-db volumes: - ./:/data/ environment: @@ -71,6 +89,7 @@ services: executor-robot.uri: http://executor-robot:8084 executor-computation.uri: http://executor-computation:8085 mqtt.broker.uri: tcp://broker.hivemq.com:1883 + spring.data.mongodb.uri: mongodb://root:password@mongodb:27017 labels: - "traefik.enable=true" - "traefik.http.routers.roster.rule=Host(`roster.${PUB_IP}.nip.io`)" @@ -84,10 +103,13 @@ services: image: openjdk command: "java -jar /data/executor-pool-0.0.1-SNAPSHOT.jar" restart: unless-stopped + depends_on: + - tapas-db volumes: - ./:/data/ environment: mqtt.broker.uri: tcp://broker.hivemq.com:1883 + spring.data.mongodb.uri: mongodb://root:password@mongodb:27017 labels: - "traefik.enable=true" - "traefik.http.routers.executor-pool.rule=Host(`executor-pool.${PUB_IP}.nip.io`)" @@ -104,6 +126,7 @@ services: depends_on: - executor-pool - roster + - tapas-db volumes: - ./:/data/ environment: @@ -124,6 +147,7 @@ services: depends_on: - executor-pool - roster + - tapas-db volumes: - ./:/data/ environment: diff --git a/docker-compose.yaml b/docker-compose.yaml index 1364b66..0612f50 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,62 +1,77 @@ version: "3.6" services: - tapas-tasks: - container_name: tapas-tasks - build: - context: "./tapas-tasks" - dockerfile: "Dockerfile" - target: development + # tapas-tasks: + # container_name: tapas-tasks + # build: + # context: "./tapas-tasks" + # dockerfile: "Dockerfile" + # target: development + # ports: + # - "8081:8081" + # - "5005:5005" + # volumes: + # - ./tapas-tasks/src:/opt/app/src + # - ./tapas-tasks/target:/opt/app/target + # assignment: + # container_name: assignment + # build: + # context: "./assignment" + # dockerfile: "Dockerfile" + # target: development + # ports: + # - "8082:8082" + # - "5006:5005" + # volumes: + # - ./assignment/src:/opt/app/src + # - ./assignment/target:/opt/app/target + # executor-pool: + # container_name: executor-pool + # build: + # context: "./executor-pool" + # dockerfile: "Dockerfile" + # target: development + # ports: + # - "8083:8083" + # - "5007:5005" + # volumes: + # - ./executor-pool/src:/opt/app/src + # - ./executor-pool/target:/opt/app/target + # executor1: + # container_name: executor1 + # build: + # context: "./executor1" + # dockerfile: "Dockerfile" + # target: development + # ports: + # - "8084:8084" + # - "5008:5005" + # volumes: + # - ./executor1/src:/opt/app/src + # - ./executor1/target:/opt/app/target + # executor2: + # container_name: executor2 + # build: + # context: "./executor2" + # dockerfile: "Dockerfile" + # target: development + # ports: + # - "8085:8085" + # - "5009:5005" + # volumes: + # - ./executor2/src:/opt/app/src + # - ./executor2/target:/opt/app/target + tapas-db: + image: mongo + restart: unless-stopped + container_name: tapas_mongodb + environment: + MONGO_INITDB_ROOT_USERNAME: root + MONGO_INITDB_ROOT_PASSWORD: password ports: - - "8081:8081" - - "5005:5005" - volumes: - - ./tapas-tasks/src:/opt/app/src - - ./tapas-tasks/target:/opt/app/target - assignment: - container_name: assignment - build: - context: "./assignment" - dockerfile: "Dockerfile" - target: development + - "27017:27017" + command: mongod --quiet --logpath /dev/null + hivemq: + image: hivemq/hivemq4 + restart: unless-stopped ports: - - "8082:8082" - - "5006:5005" - volumes: - - ./assignment/src:/opt/app/src - - ./assignment/target:/opt/app/target - executor-pool: - container_name: executor-pool - build: - context: "./executor-pool" - dockerfile: "Dockerfile" - target: development - ports: - - "8083:8083" - - "5007:5005" - volumes: - - ./executor-pool/src:/opt/app/src - - ./executor-pool/target:/opt/app/target - executor1: - container_name: executor1 - build: - context: "./executor1" - dockerfile: "Dockerfile" - target: development - ports: - - "8084:8084" - - "5008:5005" - volumes: - - ./executor1/src:/opt/app/src - - ./executor1/target:/opt/app/target - executor2: - container_name: executor2 - build: - context: "./executor2" - dockerfile: "Dockerfile" - target: development - ports: - - "8085:8085" - - "5009:5005" - volumes: - - ./executor2/src:/opt/app/src - - ./executor2/target:/opt/app/target + - "1883:1883" 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 f281b4f..582b57f 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 @@ -34,11 +34,11 @@ public class Executor extends ExecutorBase { double result = Double.NaN; - // try { - // TimeUnit.SECONDS.sleep(5); - // } catch (InterruptedException e) { - // e.printStackTrace(); - // } + try { + TimeUnit.SECONDS.sleep(5); + } catch (InterruptedException e) { + e.printStackTrace(); + } if (operator.equalsIgnoreCase("+")) { String[] parts = inputData.split("\\+"); diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/ExecutorPoolApplication.java b/executor-pool/src/main/java/ch/unisg/executorpool/ExecutorPoolApplication.java index 5cd0108..89847bb 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/ExecutorPoolApplication.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/ExecutorPoolApplication.java @@ -1,13 +1,31 @@ package ch.unisg.executorpool; +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; + +import ch.unisg.executorpool.adapter.out.persistence.mongodb.ExecutorRepository; +import ch.unisg.executorpool.application.port.out.LoadExecutorPort; +import ch.unisg.executorpool.domain.ExecutorPool; @SpringBootApplication +@EnableMongoRepositories(basePackageClasses = ExecutorRepository.class) public class ExecutorPoolApplication { + @Autowired + private LoadExecutorPort loadExecutorPort; + public static void main(String[] args) { SpringApplication.run(ExecutorPoolApplication.class, args); } + @PostConstruct + public void initializeExecutorPool() { + // Is this allowed in main or does it need to be in a service? + ExecutorPool.getExecutorPool().initExecutorPool(loadExecutorPort.loadAllExecutors()); + } + } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorPersistenceAdapter.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorPersistenceAdapter.java index a165096..06bd98a 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorPersistenceAdapter.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorPersistenceAdapter.java @@ -1,5 +1,8 @@ package ch.unisg.executorpool.adapter.out.persistence.mongodb; +import java.util.ArrayList; +import java.util.List; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -12,7 +15,7 @@ import lombok.RequiredArgsConstructor; @Component @RequiredArgsConstructor public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecutorPort, LoadExecutorPort { - + @Autowired private final ExecutorRepository executorRepository; @@ -26,8 +29,7 @@ public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecut @Override public void removeExecutor(ExecutorClass executorClass) { - MongoExecutorDocument mongoExecutorDocument = executorMapper.mapToMongoDocument(executorClass); - executorRepository.delete(mongoExecutorDocument); + executorRepository.deleteByExecutorUri(executorClass.getExecutorUri().getValue().toString()); } @Override @@ -37,4 +39,13 @@ public class ExecutorPersistenceAdapter implements AddExecutorPort, RemoveExecut return executorClass; } + @Override + public List loadAllExecutors() { + List executorClasses = new ArrayList<>(); + for (MongoExecutorDocument exe : executorRepository.findAll()) { + executorClasses.add(executorMapper.mapToDomainEntity(exe)); + } + return executorClasses; + } + } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorRepository.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorRepository.java index 36c3fd0..a2752c9 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorRepository.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/ExecutorRepository.java @@ -11,5 +11,7 @@ public interface ExecutorRepository extends MongoRepository findByExecutorTaskType(String executorTaskType); - + + public void deleteByExecutorUri(String executorUri); + } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/MongoExecutorDocument.java b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/MongoExecutorDocument.java index 3c94ae7..1286f2d 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/MongoExecutorDocument.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/adapter/out/persistence/mongodb/MongoExecutorDocument.java @@ -1,15 +1,18 @@ package ch.unisg.executorpool.adapter.out.persistence.mongodb; +import org.springframework.data.mongodb.core.mapping.Document; + import lombok.Data; @Data +@Document(collection = "executors") public class MongoExecutorDocument { - + public String executorUri; public String executorTaskType; public MongoExecutorDocument(String executorUri, String executorTaskType) { - + this.executorUri = executorUri; this.executorTaskType = executorTaskType; } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/out/LoadExecutorPort.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/out/LoadExecutorPort.java index d7cb18a..792255e 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/application/port/out/LoadExecutorPort.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/port/out/LoadExecutorPort.java @@ -1,9 +1,13 @@ package ch.unisg.executorpool.application.port.out; +import java.util.List; + import ch.unisg.executorpool.domain.ExecutorClass; public interface LoadExecutorPort { - + ExecutorClass loadExecutor(ExecutorClass.ExecutorUri executorUri, ExecutorClass.ExecutorTaskType executorTaskType); + List loadAllExecutors(); + } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java index 0fc724c..4adb209 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/application/service/RemoveExecutorFromExecutorPoolService.java @@ -31,11 +31,10 @@ public class RemoveExecutorFromExecutorPoolService implements RemoveExecutorFrom if(removedExecutor.isPresent()){ var executorRemovedEvent = new ExecutorRemovedEvent(removedExecutor.get()); + removeExecutorFromRepositoryPort.removeExecutor(removedExecutor.get()); executorRemovedEventPort.publishExecutorRemovedEvent(executorRemovedEvent); } - removeExecutorFromRepositoryPort.removeExecutor(removedExecutor); - return removedExecutor; } } diff --git a/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java index 0ca0d5e..dbca642 100644 --- a/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java +++ b/executor-pool/src/main/java/ch/unisg/executorpool/domain/ExecutorPool.java @@ -67,6 +67,12 @@ public class ExecutorPool { return Optional.empty(); } + public void initExecutorPool(List executors){ + for (ExecutorClass executor : executors) { + listOfExecutors.value.add(executor); + } + } + @Value public static class ListOfExecutors { private List value; diff --git a/executor-pool/src/main/resources/application.properties b/executor-pool/src/main/resources/application.properties index 0c9ba7e..c8f67f1 100644 --- a/executor-pool/src/main/resources/application.properties +++ b/executor-pool/src/main/resources/application.properties @@ -1,3 +1,6 @@ server.port=8083 mqtt.broker.uri=tcp://localhost:1883 + +spring.data.mongodb.uri=mongodb://root:password@localhost:27017 +spring.data.mongodb.database=tapas-executors diff --git a/roster/pom.xml b/roster/pom.xml index 8596ef7..32d79d9 100644 --- a/roster/pom.xml +++ b/roster/pom.xml @@ -76,6 +76,11 @@ org.springframework.data spring-data-mongodb + 3.2.6 + + + org.springframework.boot + spring-boot-starter-data-mongodb diff --git a/roster/src/main/java/ch/unisg/roster/RosterApplication.java b/roster/src/main/java/ch/unisg/roster/RosterApplication.java index 58cd429..e21a679 100644 --- a/roster/src/main/java/ch/unisg/roster/RosterApplication.java +++ b/roster/src/main/java/ch/unisg/roster/RosterApplication.java @@ -4,11 +4,14 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.PostConstruct; + import ch.unisg.roster.roster.adapter.out.persistence.mongodb.RosterRepository; import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort; import ch.unisg.roster.roster.domain.Roster; import ch.unisg.roster.roster.domain.RosterItem; import org.eclipse.paho.client.mqttv3.MqttException; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.core.env.ConfigurableEnvironment; @@ -26,14 +29,14 @@ public class RosterApplication { private static ConfigurableEnvironment ENVIRONMENT; - private static final LoadRosterItemPort loadRosterItemPort; + @Autowired + private LoadRosterItemPort loadRosterItemPort; public static void main(String[] args) { SpringApplication rosterApp = new SpringApplication(RosterApplication.class); ENVIRONMENT = rosterApp.run(args).getEnvironment(); bootstrapMarketplaceWithMqtt(); - initialiseRoster(); } /** @@ -52,9 +55,9 @@ public class RosterApplication { } } - private static void initialiseRoster(){ - List rosterItemList = loadRosterItemPort.loadAllRosterItems(); - Roster.getInstance().initialiseRoster(rosterItemList); + @PostConstruct + private void initialiseRoster(){ + Roster.getInstance().initialiseRoster(loadRosterItemPort.loadAllRosterItems()); } } diff --git a/roster/src/main/java/ch/unisg/roster/roster/adapter/out/persistence/mongodb/RosterPersistenceAdapter.java b/roster/src/main/java/ch/unisg/roster/roster/adapter/out/persistence/mongodb/RosterPersistenceAdapter.java index 9239ff0..a83ba30 100644 --- a/roster/src/main/java/ch/unisg/roster/roster/adapter/out/persistence/mongodb/RosterPersistenceAdapter.java +++ b/roster/src/main/java/ch/unisg/roster/roster/adapter/out/persistence/mongodb/RosterPersistenceAdapter.java @@ -1,6 +1,5 @@ package ch.unisg.roster.roster.adapter.out.persistence.mongodb; - import ch.unisg.roster.roster.application.port.in.AddRosterItemPort; import ch.unisg.roster.roster.application.port.in.DeleteRosterItem; import ch.unisg.roster.roster.application.port.in.LoadRosterItemPort; diff --git a/roster/src/main/resources/application.properties b/roster/src/main/resources/application.properties index b7233ff..d90d1c3 100644 --- a/roster/src/main/resources/application.properties +++ b/roster/src/main/resources/application.properties @@ -3,3 +3,6 @@ executor-robot.uri=http://127.0.0.1:8084 executor-computation.uri=http://127.0.0.1:8085 task-list.uri=http://127.0.0.1:8081 mqtt.broker.uri=tcp://localhost:1883 + +spring.data.mongodb.uri=mongodb://root:password@localhost:27017/ +spring.data.mongodb.database=tapas-roster diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/MongoTaskDocument.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/MongoTaskDocument.java index 442e01e..02c3a47 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/MongoTaskDocument.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/MongoTaskDocument.java @@ -15,18 +15,23 @@ public class MongoTaskDocument { public String taskType; public String originalTaskUri; public String taskStatus; + public String inputData; + public String outputData; public String taskListName; public MongoTaskDocument(String taskId, String taskName, String taskType, String originalTaskUri, - String taskStatus, String taskListName) { + String taskStatus, String inputData, String outputData, + String taskListName) { this.taskId = taskId; this.taskName = taskName; this.taskType = taskType; this.originalTaskUri = originalTaskUri; this.taskStatus = taskStatus; + this.inputData = inputData; + this.outputData = outputData; this.taskListName = taskListName; } } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/TaskMapper.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/TaskMapper.java index 0af73b6..43ac2f9 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/TaskMapper.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/adapter/out/persistence/mongodb/TaskMapper.java @@ -2,18 +2,23 @@ package ch.unisg.tapastasks.tasks.adapter.out.persistence.mongodb; import ch.unisg.tapastasks.tasks.domain.Task; import ch.unisg.tapastasks.tasks.domain.TaskList; + +import java.util.Objects; + import org.springframework.stereotype.Component; @Component class TaskMapper { Task mapToDomainEntity(MongoTaskDocument task) { - return Task.withIdNameTypeOriginaluriStatus( + return Task.createTaskWithIdNameTypeOriginaluriStatusInputAndOutputData( new Task.TaskId(task.taskId), new Task.TaskName(task.taskName), new Task.TaskType(task.taskType), new Task.OriginalTaskUri(task.originalTaskUri), - new Task.TaskStatus(Task.Status.valueOf(task.taskStatus)) + new Task.TaskStatus(Task.Status.valueOf(task.taskStatus)), + new Task.InputData(task.inputData), + new Task.OutputData(task.outputData) ); } @@ -22,8 +27,10 @@ class TaskMapper { task.getTaskId().getValue(), task.getTaskName().getValue(), task.getTaskType().getValue(), - task.getOriginalTaskUri().getValue(), + Objects.isNull(task.getOriginalTaskUri()) ? null : task.getOriginalTaskUri().getValue(), task.getTaskStatus().getValue().toString(), + Objects.isNull(task.getInputData()) ? null : task.getInputData().getValue(), + Objects.isNull(task.getOutputData()) ? null : task.getOutputData().getValue(), TaskList.getTapasTaskList().getTaskListName().getValue() ); } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java index b390548..9f50ccb 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/application/service/AddNewTaskToTaskListService.java @@ -13,6 +13,8 @@ import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; import org.springframework.stereotype.Service; +import java.util.Objects; + import javax.transaction.Transactional; @RequiredArgsConstructor @@ -29,7 +31,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase public Task addNewTaskToTaskList(AddNewTaskToTaskListCommand command) { TaskList taskList = TaskList.getTapasTaskList(); - taskListLock.lockTaskList(taskList.getTaskListName()); + // taskListLock.lockTaskList(taskList.getTaskListName()); Task newTask; @@ -47,7 +49,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase } addTaskToRepositoryPort.addTask(newTask); - taskListLock.releaseTaskList(taskList.getTaskListName()); + // taskListLock.releaseTaskList(taskList.getTaskListName()); //Here we are using the application service to emit the domain event to the outside of the bounded context. //This event should be considered as a light-weight "integration event" to communicate with other services. @@ -60,7 +62,7 @@ public class AddNewTaskToTaskListService implements AddNewTaskToTaskListUseCase taskList.getTaskListName().getValue(), newTask.getTaskId().getValue(), newTask.getTaskType().getValue(), - newTask.getInputData().getValue() + Objects.isNull(newTask.getInputData()) ? null : newTask.getInputData().getValue() ); newTaskAddedEventPort.publishNewTaskAddedEvent(newTaskAdded); } diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java index 666a16a..db650be 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/Task.java @@ -81,18 +81,18 @@ public class Task { } public Task(TaskId taskId, TaskName taskName, TaskType taskType, OriginalTaskUri taskUri, - TaskStatus taskStatus) { -this.taskId = taskId; -this.taskName = taskName; -this.taskType = taskType; -this.originalTaskUri = taskUri; -this.taskStatus = taskStatus; -this.inputData = null; -this.outputData = null; -} + TaskStatus taskStatus, InputData inputData, OutputData outputData) { + this.taskId = taskId; + this.taskName = taskName; + this.taskType = taskType; + this.originalTaskUri = taskUri; + this.taskStatus = taskStatus; + this.inputData = inputData; + this.outputData = outputData; + } + protected static Task createTaskWithNameAndType(TaskName name, TaskType type) { return new Task(name, type); - } public static Task createTaskWithNameAndTypeAndOriginalTaskUri(TaskName name, TaskType type, @@ -110,11 +110,10 @@ this.outputData = null; return new Task(name, type, originalTaskUri, inputData); } - public static Task withIdNameTypeOriginaluriStatus(TaskId taskId, TaskName taskName, - TaskType taskType, - OriginalTaskUri originalTaskUri, - TaskStatus taskStatus) { - return new Task(taskId, taskName, taskType, originalTaskUri, taskStatus); + public static Task createTaskWithIdNameTypeOriginaluriStatusInputAndOutputData(TaskId taskId, + TaskName taskName, TaskType taskType, OriginalTaskUri originalTaskUri, TaskStatus taskStatus, + InputData inputData, OutputData outputData) { + return new Task(taskId, taskName, taskType, originalTaskUri, taskStatus, inputData, outputData); } @Value diff --git a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java index 5c2913d..af1e82f 100644 --- a/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java +++ b/tapas-tasks/src/main/java/ch/unisg/tapastasks/tasks/domain/TaskList.java @@ -74,9 +74,12 @@ public class TaskList { //However, we skip this here as it makes the core even more complex (e.g., we have to implement a light-weight //domain event publisher and subscribers (see "Implementing Domain-Driven Design by V. Vernon, pp. 296ff). listOfTasks.value.add(newTask); - logger.log(Level.INFO, "New task created! Id: " + newTask.getTaskId().getValue() + - " | Name: " + newTask.getTaskName().getValue() + - " | InputData: " + newTask.getInputData().getValue()); + String message = "New task created! Id: " + newTask.getTaskId().getValue() + + " | Name: " + newTask.getTaskName().getValue(); + if (newTask.getInputData() != null) { + message += " | Input data: " + newTask.getInputData().getValue(); + } + logger.log(Level.INFO, message); logger.log(Level.INFO, "Number of tasks: {0}", listOfTasks.value.size()); } diff --git a/tapas-tasks/src/main/resources/application.properties b/tapas-tasks/src/main/resources/application.properties index 3b5922b..69f84ad 100644 --- a/tapas-tasks/src/main/resources/application.properties +++ b/tapas-tasks/src/main/resources/application.properties @@ -1,6 +1,5 @@ server.port=8081 -spring.data.mongodb.uri=mongodb://127.0.0.1:27017 -#spring.data.mongodb.uri=mongodb://root:8nP7s0a@mongodb:27017/ +spring.data.mongodb.uri=mongodb://root:password@localhost:27017/ spring.data.mongodb.database=tapas-tasks baseuri=https://tapas-tasks.86-119-34-23.nip.io/