Re organize DMP controller and manager functions and added the ability to add custom organization (not configurable yet) (ref #255)
This commit is contained in:
parent
ef40c5568f
commit
4e68666089
|
@ -82,13 +82,9 @@ public class DMPs extends BaseController {
|
||||||
this.configLoader = configLoader;
|
this.configLoader = configLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@Transactional
|
/*
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
|
* Data Retrieval
|
||||||
public @ResponseBody
|
* */
|
||||||
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
|
||||||
this.dataManagementPlanManager.unlock(id);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, value = {"/paged"}, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
|
@ -102,11 +98,11 @@ public class DMPs extends BaseController {
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"{id}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
ResponseEntity getSingle(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, InstantiationException, IOException {
|
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||||
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
|
if (contentType.equals("application/xml") || contentType.equals("application/msword")) {
|
||||||
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
|
return this.dataManagementPlanManager.getDocument(id, contentType, principal, this.configLoader);
|
||||||
} else {
|
} else {
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal);
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, false);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,17 +114,11 @@ public class DMPs extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
|
|
||||||
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/overview/{id}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getOverviewSingle(@PathVariable String id,@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
ResponseEntity getOverviewSingle(@PathVariable String id,@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) {
|
||||||
try {
|
try {
|
||||||
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal);
|
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, false);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (e instanceof UnauthorisedException) {
|
if (e instanceof UnauthorisedException) {
|
||||||
|
@ -141,26 +131,71 @@ public class DMPs extends BaseController {
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/public/{id}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getSinglePublic(@PathVariable String id) {
|
ResponseEntity getSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||||
try {
|
// try {
|
||||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSinglePublic(id, this.dynamicGrantConfiguration);
|
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, true);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/publicOverview/{id}"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity getOverviewSinglePublic(@PathVariable String id) {
|
ResponseEntity getOverviewSinglePublic(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||||
try {
|
// try {
|
||||||
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSinglePublic(id);
|
DataManagementPlanOverviewModel dataManagementPlan = this.dataManagementPlanManager.getOverviewSingle(id, principal, true);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||||
} catch (Exception ex) {
|
// } catch (Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanOverviewModel>().status(ApiMessageCode.NO_MESSAGE).message(ex.getMessage()));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||||
|
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data Export
|
||||||
|
* */
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"rda/{id}"})
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity getRDAJsonDocument(@PathVariable String id, @ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IOException {
|
||||||
|
return this.dataManagementPlanManager.getRDAJsonDocument(id, datasetManager, principal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
||||||
|
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||||
|
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
|
||||||
|
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
|
||||||
|
File pdffile = datasetManager.convertToPDF(file, environment);
|
||||||
|
InputStream resource = new FileInputStream(pdffile);
|
||||||
|
logger.info("Mime Type of " + name + " is " +
|
||||||
|
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
||||||
|
HttpHeaders responseHeaders = new HttpHeaders();
|
||||||
|
responseHeaders.setContentLength(pdffile.length());
|
||||||
|
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||||
|
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
|
||||||
|
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
|
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
||||||
|
|
||||||
|
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
||||||
|
resource.close();
|
||||||
|
Files.deleteIfExists(file.getFile().toPath());
|
||||||
|
Files.deleteIfExists(pdffile.toPath());
|
||||||
|
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Data Management
|
||||||
|
* */
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
|
@ -199,37 +234,6 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/dynamic"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<List<Tuple<String, String>>>> getWithCriteria(@RequestBody RequestItem<DynamicFieldsCriteria> criteriaRequestItem, Principal principal) throws InstantiationException, IllegalAccessException {
|
|
||||||
List<Tuple<String, String>> dataTable = this.dataManagementPlanManager.getDynamicFields(criteriaRequestItem.getCriteria().getId(), this.dynamicGrantConfiguration, criteriaRequestItem.getCriteria());
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<Tuple<String, String>>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType,
|
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
|
||||||
FileEnvelope file = this.dataManagementPlanManager.getWordDocument(id, principal, configLoader);
|
|
||||||
String name = file.getFilename().substring(0, file.getFilename().length() - 5);
|
|
||||||
File pdffile = datasetManager.convertToPDF(file, environment);
|
|
||||||
InputStream resource = new FileInputStream(pdffile);
|
|
||||||
logger.info("Mime Type of " + name + " is " +
|
|
||||||
new MimetypesFileTypeMap().getContentType(file.getFile()));
|
|
||||||
HttpHeaders responseHeaders = new HttpHeaders();
|
|
||||||
responseHeaders.setContentLength(pdffile.length());
|
|
||||||
responseHeaders.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
|
||||||
responseHeaders.set("Content-Disposition", "attachment;filename=" + name + ".pdf");
|
|
||||||
responseHeaders.set("Access-Control-Expose-Headers", "Content-Disposition");
|
|
||||||
responseHeaders.get("Access-Control-Expose-Headers").add("Content-Type");
|
|
||||||
|
|
||||||
byte[] content = org.apache.poi.util.IOUtils.toByteArray(resource);
|
|
||||||
resource.close();
|
|
||||||
Files.deleteIfExists(file.getFile().toPath());
|
|
||||||
Files.deleteIfExists(pdffile.toPath());
|
|
||||||
return new ResponseEntity<>(content, responseHeaders, HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||||
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception {
|
public ResponseEntity<ResponseItem> dmpUpload(@RequestParam("file") MultipartFile[] files, Principal principal) throws Exception {
|
||||||
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
|
if (files[0].getContentType().equals(APPLICATION_JSON.toString())) {
|
||||||
|
@ -241,29 +245,6 @@ public class DMPs extends BaseController {
|
||||||
.status(ApiMessageCode.SUCCESS_MESSAGE));
|
.status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
|
|
||||||
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
|
|
||||||
@RequestParam String fieldsGroup) throws Exception {
|
|
||||||
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody
|
|
||||||
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
|
||||||
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
|
|
||||||
|
|
||||||
DMPQuery query = criteria.buildQuery(dbRepo);
|
|
||||||
|
|
||||||
List<Map> models = query.getQuery().toListWithFields();
|
|
||||||
DataTableData<Map> dmp = new DataTableData<>();
|
|
||||||
dmp.setData(models);
|
|
||||||
dmp.setTotalCount(query.getQuery().count());
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
|
@RequestMapping(method = RequestMethod.GET, value = {"/makepublic/{id}"})
|
||||||
public ResponseEntity<ResponseItem<DMP>> makePublic(@PathVariable String id, Principal principal) {
|
public ResponseEntity<ResponseItem<DMP>> makePublic(@PathVariable String id, Principal principal) {
|
||||||
try {
|
try {
|
||||||
|
@ -285,6 +266,10 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* DOI Generation
|
||||||
|
* */
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/createZenodoDoi/{id}"})
|
||||||
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
|
public ResponseEntity<ResponseItem<String>> createZenodoDoi(@PathVariable String id, Principal principal) {
|
||||||
|
@ -297,7 +282,11 @@ public class DMPs extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@javax.transaction.Transactional
|
/*
|
||||||
|
* Data Index
|
||||||
|
* */
|
||||||
|
|
||||||
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> generateIndex(Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<Dataset>> generateIndex(Principal principal) throws Exception {
|
||||||
|
@ -305,11 +294,45 @@ public class DMPs extends BaseController {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Generated").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@javax.transaction.Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
@RequestMapping(method = RequestMethod.DELETE, value = {"/index"})
|
||||||
public @ResponseBody
|
public @ResponseBody
|
||||||
ResponseEntity<ResponseItem<Dataset>> clearIndex(Principal principal) throws Exception {
|
ResponseEntity<ResponseItem<Dataset>> clearIndex(Principal principal) throws Exception {
|
||||||
this.dataManagementPlanManager.clearIndex(principal);
|
this.dataManagementPlanManager.clearIndex(principal);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Cleared").payload(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Misc
|
||||||
|
* */
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = {"/test"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DataTableData<Map>>> test(@RequestBody DMPCriteria criteria, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||||
|
DatabaseRepository dbRepo = this.getApiContext().getOperationsContext().getDatabaseRepository();
|
||||||
|
|
||||||
|
DMPQuery query = criteria.buildQuery(dbRepo);
|
||||||
|
|
||||||
|
List<Map> models = query.getQuery().toListWithFields();
|
||||||
|
DataTableData<Map> dmp = new DataTableData<>();
|
||||||
|
dmp.setData(models);
|
||||||
|
dmp.setTotalCount(query.getQuery().count());
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<Map>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPublicPaged(@RequestBody DataManagmentPlanPublicTableRequest dmpTableRequest,
|
||||||
|
@ClaimedAuthorities(claims = {Authorities.ADMIN, Authorities.MANAGER, Authorities.USER, Authorities.ANONYMOUS}) Principal principal,
|
||||||
|
@RequestParam String fieldsGroup) throws Exception {
|
||||||
|
DataTableData<DataManagementPlanListingModel> dmp = this.dataManagementPlanManager.getPublicPaged(dmpTableRequest, fieldsGroup, principal);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dmp));
|
||||||
|
}*/
|
||||||
|
/*@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = {"{id}/unlock"}, produces = "application/json")
|
||||||
|
public @ResponseBody
|
||||||
|
ResponseEntity<ResponseItem<DMP>> unlock(@PathVariable(value = "id") UUID id, Principal principal) throws Exception {
|
||||||
|
this.dataManagementPlanManager.unlock(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Unlocked"));
|
||||||
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.exceptions.security;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseStatus;
|
||||||
|
|
||||||
|
@ResponseStatus(value = HttpStatus.FORBIDDEN)
|
||||||
|
public class ForbiddenException extends RuntimeException {
|
||||||
|
public ForbiddenException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForbiddenException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ForbiddenException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -68,19 +68,23 @@ public class Organisation implements DataModel<eu.eudat.data.entities.Organisati
|
||||||
this.id = entity.getId().toString();
|
this.id = entity.getId().toString();
|
||||||
this.name = entity.getLabel();
|
this.name = entity.getLabel();
|
||||||
this.label = entity.getUri();
|
this.label = entity.getUri();
|
||||||
|
if (entity.getReference() != null) {
|
||||||
this.reference = entity.getReference();
|
this.reference = entity.getReference();
|
||||||
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
this.key = entity.getReference().substring(0, entity.getReference().indexOf(":"));
|
||||||
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public eu.eudat.data.entities.Organisation toDataModel() {
|
public eu.eudat.data.entities.Organisation toDataModel() {
|
||||||
eu.eudat.data.entities.Organisation organisationEntity = new eu.eudat.data.entities.Organisation();
|
eu.eudat.data.entities.Organisation organisationEntity = new eu.eudat.data.entities.Organisation();
|
||||||
|
if (this.key != null && this.reference != null) {
|
||||||
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
|
if ((this.key + ":").equals(this.reference.substring(0, this.key.length() + 1))) {
|
||||||
organisationEntity.setReference(this.reference);
|
organisationEntity.setReference(this.reference);
|
||||||
} else {
|
} else {
|
||||||
organisationEntity.setReference(this.key + ":" + this.reference);
|
organisationEntity.setReference(this.key + ":" + this.reference);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
organisationEntity.setLabel(this.name);
|
organisationEntity.setLabel(this.name);
|
||||||
organisationEntity.setUri(this.label);
|
organisationEntity.setUri(this.label);
|
||||||
organisationEntity.setCreated(new Date());
|
organisationEntity.setCreated(new Date());
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { CommonFormsModule } from '@common/forms/common-forms.module';
|
||||||
import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module';
|
import { FormValidationErrorsDialogModule } from '@common/forms/form-validation-errors-dialog/form-validation-errors-dialog.module';
|
||||||
import { CommonUiModule } from '@common/ui/common-ui.module';
|
import { CommonUiModule } from '@common/ui/common-ui.module';
|
||||||
import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.module';
|
import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dialog/multiple-choice-dialog.module';
|
||||||
|
import { AddOrganizationComponent } from './editor/add-organization/add-organization.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -67,14 +68,16 @@ import { MultipleChoiceDialogModule } from '@common/modules/multiple-choice-dial
|
||||||
PeopleTabComponent,
|
PeopleTabComponent,
|
||||||
GrantTabComponent,
|
GrantTabComponent,
|
||||||
DatasetsTabComponent,
|
DatasetsTabComponent,
|
||||||
DmpCloneComponent
|
DmpCloneComponent,
|
||||||
|
AddOrganizationComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
DmpInvitationDialogComponent,
|
DmpInvitationDialogComponent,
|
||||||
AddResearcherComponent,
|
AddResearcherComponent,
|
||||||
AvailableProfilesComponent,
|
AvailableProfilesComponent,
|
||||||
DmpFinalizeDialogComponent,
|
DmpFinalizeDialogComponent,
|
||||||
DmpUploadDialogue
|
DmpUploadDialogue,
|
||||||
|
AddOrganizationComponent
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class DmpModule { }
|
export class DmpModule { }
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<form *ngIf="formGroup" [formGroup]="formGroup">
|
||||||
|
<h1 mat-dialog-title>{{'ADDORGANIZATION-EDITOR.TITLE' | translate}}</h1>
|
||||||
|
<div mat-dialog-content class="row">
|
||||||
|
<mat-form-field class="col-12">
|
||||||
|
<input matInput formControlName="name" placeholder="{{'ADDORGANIZATION-EDITOR.NAME' | translate}}" required>
|
||||||
|
<mat-error *ngIf="formGroup.get('name').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
<!-- <mat-form-field class="col-12">
|
||||||
|
<input matInput formControlName="lastName" placeholder="{{'ADDORGANIZATION-EDITOR.LAST_NAME' | translate}}" required>
|
||||||
|
<mat-error *ngIf="formGroup.get('lastName').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field> -->
|
||||||
|
<div class="col-12">
|
||||||
|
<div class="row">
|
||||||
|
<div class="ml-auto col-auto"><button mat-raised-button mat-dialog-close type="button">{{'ADDORGANIZATION-EDITOR.ACTIONS.CANCEL' | translate}}</button></div>
|
||||||
|
<div class="col-auto"><button mat-raised-button [disabled]="!isFormValid()" color="primary" (click)="addOrganization()" type="button">{{'ADDORGANIZATION-EDITOR.ACTIONS.SAVE' | translate}}</button></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { Component, Inject, OnInit } from '@angular/core';
|
||||||
|
import { FormGroup } from '@angular/forms';
|
||||||
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
|
import { ExternalResearcherService } from '@app/core/services/external-sources/researcher/external-researcher.service';
|
||||||
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
import { OrganizationEditorModel } from './add-organization.model';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-add-organization-component',
|
||||||
|
templateUrl: 'add-organization.component.html',
|
||||||
|
})
|
||||||
|
export class AddOrganizationComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
|
public formGroup: FormGroup;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private externalResearcherService: ExternalResearcherService,
|
||||||
|
public dialogRef: MatDialogRef<AddOrganizationComponent>,
|
||||||
|
@Inject(MAT_DIALOG_DATA) public data: any
|
||||||
|
) { super(); }
|
||||||
|
|
||||||
|
ngOnInit(): void {
|
||||||
|
const researcher = new OrganizationEditorModel();
|
||||||
|
this.formGroup = researcher.buildForm();
|
||||||
|
}
|
||||||
|
|
||||||
|
send(value: any) {
|
||||||
|
this.externalResearcherService.createResearcher(this.formGroup.value)
|
||||||
|
.pipe(takeUntil(this._destroyed))
|
||||||
|
.subscribe(
|
||||||
|
null, null, () => this.dialogRef.close()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
addOrganization() {
|
||||||
|
this.dialogRef.close(this.formGroup.value);
|
||||||
|
}
|
||||||
|
|
||||||
|
isFormValid() {
|
||||||
|
return this.formGroup.valid;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||||
|
import { ResearcherModel } from '@app/core/model/researcher/researcher';
|
||||||
|
import { BackendErrorValidator } from '@common/forms/validation/custom-validator';
|
||||||
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||||
|
import { ValidationContext } from '@common/forms/validation/validation-context';
|
||||||
|
import { OrganizationModel } from '@app/core/model/organisation/organization';
|
||||||
|
|
||||||
|
export class OrganizationEditorModel {
|
||||||
|
public id: String;
|
||||||
|
public name: String;
|
||||||
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
|
|
||||||
|
fromModel(item: OrganizationModel): OrganizationEditorModel {
|
||||||
|
this.id = item.id;
|
||||||
|
this.name = item.name;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||||
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
const formGroup = new FormBuilder().group({
|
||||||
|
name: [{ value: this.name, disabled: disabled }, context.getValidation('name').validators]
|
||||||
|
});
|
||||||
|
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
createValidationContext(): ValidationContext {
|
||||||
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
|
baseContext.validation.push({ key: 'name', validators: [BackendErrorValidator(this.validationErrorModel, 'name')] });
|
||||||
|
return baseContext;
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,6 +46,9 @@
|
||||||
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
|
<mat-error *ngIf="formGroup.get('organisations').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' |
|
||||||
translate}}</mat-error>
|
translate}}</mat-error>
|
||||||
<mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint>
|
<mat-hint>{{'DMP-EDITOR.FIELDS.ORGANISATIONS-HINT' | translate}}</mat-hint>
|
||||||
|
<button matSuffix class="input-btn" [disabled]="canAddOrganizations()" type="button" (click)="addOrganization($event)">
|
||||||
|
<mat-icon class="icon-btn">add_circle</mat-icon>
|
||||||
|
</button>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="row pt-3">
|
<div class="row pt-3">
|
||||||
|
|
|
@ -20,6 +20,8 @@ import { BaseComponent } from '@common/base/base.component';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { map, takeUntil } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
|
import { AddOrganizationComponent } from '../add-organization/add-organization.component';
|
||||||
|
import { isNullOrUndefined } from 'util';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-general-tab',
|
selector: 'app-general-tab',
|
||||||
|
@ -170,6 +172,36 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOrganization(event: MouseEvent) {
|
||||||
|
event.stopPropagation();
|
||||||
|
const dialogRef = this.dialog.open(AddOrganizationComponent, {
|
||||||
|
data: this.formGroup.get('organisations')
|
||||||
|
});
|
||||||
|
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
|
||||||
|
if (result) {
|
||||||
|
const fullName = result.name;
|
||||||
|
const newItem = {
|
||||||
|
label: null,
|
||||||
|
name: fullName,
|
||||||
|
id: null,
|
||||||
|
status: 0,
|
||||||
|
key: "Internal",
|
||||||
|
};
|
||||||
|
const organizationsArray = this.formGroup.get('organisations').value || [];
|
||||||
|
organizationsArray.push(newItem);
|
||||||
|
this.formGroup.get('organisations').setValue(organizationsArray);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
canAddOrganizations(): boolean {
|
||||||
|
if (!isNullOrUndefined(this.formGroup.get('organizations'))) {
|
||||||
|
return this.formGroup.get('organiztions').disabled;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
availableProfiles(event: MouseEvent) {
|
availableProfiles(event: MouseEvent) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
const dialogRef = this.dialog.open(AvailableProfilesComponent, {
|
||||||
|
|
|
@ -106,10 +106,10 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit {
|
||||||
this.breadCrumbs = observableOf(breadCrumbs);
|
this.breadCrumbs = observableOf(breadCrumbs);
|
||||||
}, (error: any) => {
|
}, (error: any) => {
|
||||||
if (error.status === 404) {
|
if (error.status === 404) {
|
||||||
return this.onFetchingDeletedCallbackError('/plans/');
|
return this.onFetchingDeletedCallbackError('/explore-plans');
|
||||||
}
|
}
|
||||||
if (error.status === 403) {
|
if (error.status === 403) {
|
||||||
return this.onFetchingForbiddenCallbackError('/plans/');
|
return this.onFetchingForbiddenCallbackError('/explore-plans');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -953,6 +953,14 @@
|
||||||
"CANCEL": "Cancel"
|
"CANCEL": "Cancel"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ADDORGANIZATION-EDITOR": {
|
||||||
|
"TITLE": "Add an Organization",
|
||||||
|
"NAME": "Name",
|
||||||
|
"ACTIONS": {
|
||||||
|
"SAVE": "Save",
|
||||||
|
"CANCEL": "Cancel"
|
||||||
|
}
|
||||||
|
},
|
||||||
"DMP-WIZARD": {
|
"DMP-WIZARD": {
|
||||||
"FIRST-STEP": {
|
"FIRST-STEP": {
|
||||||
"DMP": "DMP Editor",
|
"DMP": "DMP Editor",
|
||||||
|
|
|
@ -525,6 +525,10 @@
|
||||||
"ERROR": {
|
"ERROR": {
|
||||||
"DELETED-DMP": "El PGD solicitado está borrado",
|
"DELETED-DMP": "El PGD solicitado está borrado",
|
||||||
"FORBIDEN-DMP": "You are not allowed to access this DMP"
|
"FORBIDEN-DMP": "You are not allowed to access this DMP"
|
||||||
|
},
|
||||||
|
"MULTIPLE-DIALOG": {
|
||||||
|
"ZENODO-LOGIN": "Login with Zenodo",
|
||||||
|
"USE-DEFAULT": "Use Default Token"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-LISTING": {
|
"DATASET-LISTING": {
|
||||||
|
@ -825,7 +829,8 @@
|
||||||
"ACTIONS": {
|
"ACTIONS": {
|
||||||
"SAVE": "Grabar",
|
"SAVE": "Grabar",
|
||||||
"CANCEL": "Cancelar",
|
"CANCEL": "Cancelar",
|
||||||
"DELETE": "Borrar"
|
"DELETE": "Borrar",
|
||||||
|
"UPDATE": "Update"
|
||||||
},
|
},
|
||||||
"VERSION-DIALOG": {
|
"VERSION-DIALOG": {
|
||||||
"ABOUT": "Versionado es automático.",
|
"ABOUT": "Versionado es automático.",
|
||||||
|
@ -948,6 +953,14 @@
|
||||||
"CANCEL": "Cancelar"
|
"CANCEL": "Cancelar"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"ADDORGANIZATION-EDITOR": {
|
||||||
|
"TITLE": "Add an Organization",
|
||||||
|
"NAME": "Name",
|
||||||
|
"ACTIONS": {
|
||||||
|
"SAVE": "Save",
|
||||||
|
"CANCEL": "Cancel"
|
||||||
|
}
|
||||||
|
},
|
||||||
"DMP-WIZARD": {
|
"DMP-WIZARD": {
|
||||||
"FIRST-STEP": {
|
"FIRST-STEP": {
|
||||||
"DMP": "Editor PGD",
|
"DMP": "Editor PGD",
|
||||||
|
@ -1086,6 +1099,12 @@
|
||||||
"SHOW-ALL": "Mostrar todo",
|
"SHOW-ALL": "Mostrar todo",
|
||||||
"CREATOR": "Creador",
|
"CREATOR": "Creador",
|
||||||
"MEMBER": "Miembro"
|
"MEMBER": "Miembro"
|
||||||
|
},
|
||||||
|
"ZENODO": {
|
||||||
|
"LOGIN": "Login to Zenodo",
|
||||||
|
"LOGOUT": "Remove Zenodo",
|
||||||
|
"TITLE": "Zenodo Account",
|
||||||
|
"DESCRIPTION": "Linked Zenodo Account:"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"DATASET-REFERENCED-MODELS": {
|
"DATASET-REFERENCED-MODELS": {
|
||||||
|
|
Loading…
Reference in New Issue