diff --git a/src/main/java/cz/muni/ics/kypo/training/adaptive/domain/training/TrainingRun.java b/src/main/java/cz/muni/ics/kypo/training/adaptive/domain/training/TrainingRun.java index ffd173e61afffceb876063ddf7be206ce90a285f..85444b6a83cd63ab474e918046ff90016265e4a0 100644 --- a/src/main/java/cz/muni/ics/kypo/training/adaptive/domain/training/TrainingRun.java +++ b/src/main/java/cz/muni/ics/kypo/training/adaptive/domain/training/TrainingRun.java @@ -130,6 +130,8 @@ public class TrainingRun implements Serializable { private TrainingInstance trainingInstance; @Column(name = "sandbox_instance_ref_id", length = 36) private String sandboxInstanceRefId; + @Column(name = "sandbox_instance_allocation_id") + private Long sandboxInstanceAllocationId; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id", nullable = false) private User participantRef; @@ -265,7 +267,7 @@ public class TrainingRun implements Serializable { /** * Gets id of sandbox instance associated with Training run * - * @return the sandbox instance ref id + * @return the sandbox instance reference id */ public String getSandboxInstanceRefId() { return sandboxInstanceRefId; @@ -274,12 +276,29 @@ public class TrainingRun implements Serializable { /** * Sets id of sandbox instance associated with Training run * - * @param sandboxInstanceRefId the sandbox instance ref id + * @param sandboxInstanceRefId the sandbox instance reference id */ public void setSandboxInstanceRefId(String sandboxInstanceRefId) { this.sandboxInstanceRefId = sandboxInstanceRefId; } + /** + * Gets sandbox instance allocation id associated with Training run + * + * @return the sandbox instance allocation id + */ + public Long getSandboxInstanceAllocationId() { + return sandboxInstanceAllocationId; + } + + /** + * Sets sandbox instance allocation id associated with Training run + * @param sandboxInstanceAllocationId the sandbox instance allocation id + */ + public void setSandboxInstanceAllocationId(Long sandboxInstanceAllocationId) { + this.sandboxInstanceAllocationId = sandboxInstanceAllocationId; + } + /** * Gets number of failed attempts by trainee to submit correct answer on current phase * @@ -392,6 +411,7 @@ public class TrainingRun implements Serializable { ", incorrectAnswerCount=" + this.getIncorrectAnswerCount() + ", solutionTaken=" + this.isSolutionTaken() + ", sandboxInstanceRefId=" + this.getSandboxInstanceRefId() + + ", sandboxInstanceAllocationId=" + this.getSandboxInstanceAllocationId() + ", phaseAnswered=" + this.isPhaseAnswered() + '}'; } diff --git a/src/main/java/cz/muni/ics/kypo/training/adaptive/dto/trainingrun/TrainingRunDTO.java b/src/main/java/cz/muni/ics/kypo/training/adaptive/dto/trainingrun/TrainingRunDTO.java index 476e06ea469afa0ae71284a1b4af8c426983dbc5..ad72ceb37664f012e177c099c32c57f5256cdd58 100644 --- a/src/main/java/cz/muni/ics/kypo/training/adaptive/dto/trainingrun/TrainingRunDTO.java +++ b/src/main/java/cz/muni/ics/kypo/training/adaptive/dto/trainingrun/TrainingRunDTO.java @@ -31,6 +31,8 @@ public class TrainingRunDTO { private TRState state; @ApiModelProperty(value = "Reference to the received sandbox.") private String sandboxInstanceRefId; + @ApiModelProperty(value = "Allocation id to the received sandbox.") + private Long sandboxInstanceAllocationId; @ApiModelProperty(value = "Reference to participant of training run.") private UserRefDTO participantRef; @ApiModelProperty(value = "Boolean to check whether event logging works.", example = "true") @@ -128,6 +130,24 @@ public class TrainingRunDTO { this.sandboxInstanceRefId = sandboxInstanceRefId; } + /** + * Gets sandbox instance allocation id. + * + * @return the sandbox instance allocation id + */ + public Long getSandboxInstanceAllocationId() { + return sandboxInstanceAllocationId; + } + + /** + * Sets sandbox instance allocation id. + * + * @param sandboxInstanceAllocationId the sandbox instance allocation id + */ + public void setSandboxInstanceAllocationId(Long sandboxInstanceAllocationId) { + this.sandboxInstanceAllocationId = sandboxInstanceAllocationId; + } + /** * Gets participant ref. * @@ -191,6 +211,7 @@ public class TrainingRunDTO { ", endTime=" + endTime + ", state=" + state + ", sandboxInstanceRefId=" + sandboxInstanceRefId + + ", sandboxInstanceAllocationId" + sandboxInstanceAllocationId + ", participantRef=" + participantRef + ", eventLoggingState=" + eventLoggingState + ", commandLoggingState=" + commandLoggingState + diff --git a/src/main/java/cz/muni/ics/kypo/training/adaptive/service/training/TrainingRunService.java b/src/main/java/cz/muni/ics/kypo/training/adaptive/service/training/TrainingRunService.java index 7375dd9934b56d8bf6115c7fc5685b662ed97f1e..eb5f4af32387f96aa3875f33061bd14966b05092 100644 --- a/src/main/java/cz/muni/ics/kypo/training/adaptive/service/training/TrainingRunService.java +++ b/src/main/java/cz/muni/ics/kypo/training/adaptive/service/training/TrainingRunService.java @@ -605,6 +605,7 @@ public class TrainingRunService { */ public TrainingRun assignSandbox(TrainingRun trainingRun, long poolId) { String sandboxInstanceRef = this.sandboxServiceApi.getAndLockSandboxForTrainingRun(poolId); + Long sandboxInstanceAllocationId = this.sandboxServiceApi.getAndLockSandboxForTrainingRun(poolId).get(); trainingRun.setSandboxInstanceRefId(sandboxInstanceRef); return trainingRunRepository.save(trainingRun); } diff --git a/src/main/resources/db/migration/V11__db_training_run_sandbox_allocation_id.sql b/src/main/resources/db/migration/V11__db_training_run_sandbox_allocation_id.sql new file mode 100644 index 0000000000000000000000000000000000000000..3a60cd13f5ef2e14e61fc9c8a6f3bbde5da9427d --- /dev/null +++ b/src/main/resources/db/migration/V11__db_training_run_sandbox_allocation_id.sql @@ -0,0 +1 @@ +alter table training_run add column sandbox_allocation_id int8;