Add the "Datasource" inside the "Task" class and include it in the Assignment.
This commit is contained in:
parent
d20fcf9cce
commit
787299b5b7
|
@ -2,9 +2,11 @@ package eu.openaire.urls_controller.controllers;
|
|||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
import eu.openaire.urls_controller.models.Assignment;
|
||||
import eu.openaire.urls_controller.models.Datasource;
|
||||
import eu.openaire.urls_controller.models.Task;
|
||||
import eu.openaire.urls_controller.payloads.responces.AssignmentResponse;
|
||||
import eu.openaire.urls_controller.util.FileUtils;
|
||||
import eu.openaire.urls_controller.util.GenericUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -71,7 +73,8 @@ public class UrlController {
|
|||
break;
|
||||
}
|
||||
|
||||
tasks.add(new Task(pair.getKey(), pair.getValue()));
|
||||
int randomNum = GenericUtils.getRandomNumber(1, 5);
|
||||
tasks.add(new Task(pair.getKey(), pair.getValue(), new Datasource("ID_" + randomNum, "NAME_" + randomNum)));
|
||||
}// end pairs-for-loop
|
||||
|
||||
if ( tasksLimitReached ) {
|
||||
|
|
|
@ -18,6 +18,29 @@ public class Datasource {
|
|||
@JsonProperty("name")
|
||||
String name;
|
||||
|
||||
public Datasource() {}
|
||||
|
||||
public Datasource(String id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -7,7 +7,8 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonPropertyOrder({
|
||||
"id",
|
||||
"url"
|
||||
"url",
|
||||
"datasource"
|
||||
})
|
||||
public class Task {
|
||||
|
||||
|
@ -17,9 +18,15 @@ public class Task {
|
|||
@JsonProperty("url")
|
||||
private String url;
|
||||
|
||||
public Task(String id, String url) {
|
||||
@JsonProperty("datasource")
|
||||
private Datasource datasource;
|
||||
|
||||
public Task() {}
|
||||
|
||||
public Task(String id, String url, Datasource datasource) {
|
||||
this.id = id;
|
||||
this.url = url;
|
||||
this.datasource = datasource;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
|
@ -38,11 +45,20 @@ public class Task {
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public Datasource getDatasource() {
|
||||
return datasource;
|
||||
}
|
||||
|
||||
public void setDatasource(Datasource datasource) {
|
||||
this.datasource = datasource;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Task{" +
|
||||
"id='" + id + '\'' +
|
||||
", url='" + url + '\'' +
|
||||
", datasource=" + datasource +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class FileUtils {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new Task(idStr, urlStr);
|
||||
return new Task(idStr, urlStr, null);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package eu.openaire.urls_controller.util;
|
||||
|
||||
public class GenericUtils {
|
||||
|
||||
|
||||
public static int getRandomNumber(int min, int max) {
|
||||
return (int)(Math.random() * (max - min +1) + min);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue