-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding UcdlEditorController and UcdlEditorService (#26)
* Adding UcdlEditorController and UcdlEditorService * Changed PostMapping to PutMapping * Added JavaDoc * Update server/src/main/java/de/uftos/controller/UcdlEditorController.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/ConstraintArgument.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/ConstraintInstance.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/ConstraintParameter.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/ConstraintSignature.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/Curriculum.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> * Update server/src/main/java/de/uftos/entities/LessonsCount.java Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com> --------- Co-authored-by: Daniel Dietzler <36593685+danieldietzler@users.noreply.github.com>
- Loading branch information
1 parent
c6c16ad
commit e6caa09
Showing
9 changed files
with
136 additions
and
1 deletion.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
server/src/main/java/de/uftos/controller/UcdlEditorController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package de.uftos.controller; | ||
|
||
import de.uftos.dto.parser.ParsingResponse; | ||
import de.uftos.services.UcdlEditorService; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* The REST controller for the UCDL editor. | ||
* This controller handles /editor HTTP requests. | ||
*/ | ||
@RestController | ||
@RequestMapping("/editor") | ||
public class UcdlEditorController { | ||
private final UcdlEditorService editorService; | ||
|
||
/** | ||
* Creates an editor controller. | ||
* | ||
* @param editorService the service for the UCDL editor. | ||
*/ | ||
@Autowired | ||
public UcdlEditorController(UcdlEditorService editorService) { | ||
this.editorService = editorService; | ||
} | ||
|
||
/** | ||
* Maps the HTTP POST request, to set the UCDL code, to the | ||
* {@link UcdlEditorService#setUcdl(MultipartFile)} function of the editor service. | ||
* | ||
* @param file the file which contains the new UCDL code. | ||
* @return a response whether the file could be parsed successfully or not. | ||
*/ | ||
@PutMapping() | ||
public ParsingResponse set(@RequestBody MultipartFile file) { | ||
return this.editorService.setUcdl(file); | ||
} | ||
|
||
/** | ||
* Maps the HTTP GET request for the current UCDL code, to the | ||
* {@link UcdlEditorService#getUcdl()} function of the editor service. | ||
* | ||
* @return a file containing the current UCDL code. | ||
*/ | ||
@GetMapping() | ||
public MultipartFile getUcdl() { | ||
return this.editorService.getUcdl(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
server/src/main/java/de/uftos/services/UcdlEditorService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package de.uftos.services; | ||
|
||
import de.uftos.dto.parser.ParsingResponse; | ||
import de.uftos.repositories.ucdl.UcdlRepository; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.multipart.MultipartFile; | ||
|
||
/** | ||
* The service for editing the UCDL-File. | ||
*/ | ||
@Service | ||
public class UcdlEditorService { | ||
private final UcdlRepository ucdlRepository; | ||
|
||
/** | ||
* Creates a UCDL editor service. | ||
* | ||
* @param ucdlRepository the repository for accessing the UCDL parser. | ||
*/ | ||
@Autowired | ||
public UcdlEditorService(UcdlRepository ucdlRepository) { | ||
this.ucdlRepository = ucdlRepository; | ||
} | ||
|
||
/** | ||
* Sets the UCDL code and attempts to parse it. | ||
* | ||
* @param file the file containing the new UCDL code. | ||
* @return a response whether parsing the file was successful or not. | ||
*/ | ||
public ParsingResponse setUcdl(MultipartFile file) { | ||
//todo: set String of repository | ||
return ucdlRepository.parseFile(); | ||
} | ||
|
||
/** | ||
* Gets the current UCDL file. | ||
* | ||
* @return the current UCDL file. | ||
*/ | ||
public MultipartFile getUcdl() { | ||
//todo: return actual file | ||
return null; | ||
} | ||
|
||
} |