2562 Use the new endpoint for adding authors

This commit is contained in:
Andreas Svanberg 2022-05-19 17:38:02 +02:00
parent 942070a147
commit 26f81ae5fe
3 changed files with 11 additions and 7 deletions
core/src/main/java/se/su/dsv/scipro/daisyExternal/http
daisy-integration/src/main/java/se/su/dsv/scipro/io/impl

@ -34,7 +34,7 @@ public interface DaisyAPI {
Response createProject(ThesisToBeCreated project);
Response addAuthor(Integer projectId, StudentProjectParticipant author);
Response addAuthor(Integer projectId, AddThesisAuthor author);
Response deleteProject(Integer projectId);

@ -177,10 +177,10 @@ public class DaisyAPIImpl implements DaisyAPI {
}
@Override
public Response addAuthor(Integer projectId, StudentProjectParticipant author) {
public Response addAuthor(Integer projectId, AddThesisAuthor author) {
return thesis()
.path(String.valueOf(projectId))
.path(STUDENT)
.path("author")
.request(MediaType.APPLICATION_XML_TYPE)
.post(xml(author));
}

@ -23,6 +23,7 @@ public class ExternalExporterDaisyImpl implements ExternalExporter {
private static final Logger LOGGER = LoggerFactory.getLogger(ExternalExporterDaisyImpl.class);
static final int MAX_TITLE_LENGTH = 255;
private static final int DSV = 4;
private static Map<DegreeType, EducationalLevel> classMap = new HashMap<>() {
{
put(DegreeType.NONE, EducationalLevel.UNKNOWN);
@ -87,15 +88,18 @@ public class ExternalExporterDaisyImpl implements ExternalExporter {
public void addStudentToProject(Project project, User user)
throws ExternalExportException {
Person personDTO = new Person();
AddThesisAuthorStudent personDTO = new AddThesisAuthorStudent();
personDTO.setId(user.getIdentifier());
Course course = new Course();
UnitWithID department = new UnitWithID();
department.setId(DSV);
AddThesisAuthorCourse course = new AddThesisAuthorCourse();
course.setLevel(toDaisyLevel(project));
course.setDepartment(department);
StudentProjectParticipant studentDTO = new StudentProjectParticipant();
AddThesisAuthor studentDTO = new AddThesisAuthor();
studentDTO.setCourse(course);
studentDTO.setPerson(personDTO);
studentDTO.setStudent(personDTO);
Response response = api.addAuthor(project.getIdentifier(), studentDTO);