Skip to content
Snippets Groups Projects
Commit 187162d8 authored by Lukáš Majdan's avatar Lukáš Majdan Committed by Karolína Dočkalová Burská
Browse files

Added allocation_id to model

parent b20eb162
No related branches found
No related tags found
1 merge request!127Develop
......@@ -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() +
'}';
}
......
......@@ -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 +
......
......@@ -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);
}
......
alter table training_run add column sandbox_allocation_id int8;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment