2023-03-27 13:58:45 +02:00
|
|
|
package eu.eudat.controllers;
|
|
|
|
|
2023-10-18 17:52:03 +02:00
|
|
|
import eu.eudat.authorization.Permission;
|
2023-03-27 13:58:45 +02:00
|
|
|
import eu.eudat.logic.managers.DatasetProfileManager;
|
|
|
|
import eu.eudat.logic.services.ApiContext;
|
|
|
|
import eu.eudat.models.data.helpers.responses.ResponseItem;
|
|
|
|
import eu.eudat.types.ApiMessageCode;
|
2023-10-18 17:52:03 +02:00
|
|
|
import gr.cite.commons.web.authz.service.AuthorizationService;
|
2023-03-27 13:58:45 +02:00
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
2023-10-03 16:29:45 +02:00
|
|
|
import jakarta.transaction.Transactional;
|
2023-03-27 13:58:45 +02:00
|
|
|
|
|
|
|
@RestController
|
|
|
|
@CrossOrigin
|
|
|
|
@RequestMapping(value = {"/api/management/"})
|
|
|
|
public class ManagementController extends BaseController {
|
|
|
|
|
2023-10-18 17:52:03 +02:00
|
|
|
private final DatasetProfileManager datasetProfileManager;
|
|
|
|
private final AuthorizationService authorizationService;
|
2023-03-27 13:58:45 +02:00
|
|
|
|
|
|
|
@Autowired
|
2023-10-18 17:52:03 +02:00
|
|
|
public ManagementController(ApiContext apiContext, DatasetProfileManager datasetProfileManager, AuthorizationService authorizationService){
|
2023-03-27 13:58:45 +02:00
|
|
|
super(apiContext);
|
|
|
|
this.datasetProfileManager = datasetProfileManager;
|
2023-10-18 17:52:03 +02:00
|
|
|
this.authorizationService = authorizationService;
|
2023-03-27 13:58:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
2023-05-19 11:34:08 +02:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/addSemantics"})
|
2023-10-18 17:52:03 +02:00
|
|
|
public ResponseEntity addSemanticsInDatasetProfiles() throws Exception {
|
|
|
|
this.authorizationService.authorizeForce(Permission.AdminRole);
|
2023-03-27 13:58:45 +02:00
|
|
|
try {
|
2023-05-19 11:34:08 +02:00
|
|
|
this.datasetProfileManager.addSemanticsInDatasetProfiles();
|
2023-04-20 09:12:55 +02:00
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
|
|
|
} catch (Exception exception) {
|
|
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Transactional
|
2023-05-19 11:34:08 +02:00
|
|
|
@RequestMapping(method = RequestMethod.POST, value = {"/addRdaInSemantics"})
|
2023-10-18 17:52:03 +02:00
|
|
|
public ResponseEntity addRdaInSemanticsInDatasetProfiles() throws Exception {
|
|
|
|
this.authorizationService.authorizeForce(Permission.AdminRole);
|
2023-04-20 09:12:55 +02:00
|
|
|
try {
|
2023-05-19 11:34:08 +02:00
|
|
|
this.datasetProfileManager.addRdaInSemanticsInDatasetProfiles();
|
2023-04-20 09:12:55 +02:00
|
|
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Void>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
2023-03-27 13:58:45 +02:00
|
|
|
} catch (Exception exception) {
|
|
|
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<Void>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|