Allow to update Dataset Templates by uploading dataset Template .xml files (ref #7793)
This commit is contained in:
parent
912a3cc095
commit
3aff6ac90e
|
@ -167,19 +167,25 @@ public class Admin extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
@RequestMapping(method = RequestMethod.POST, value = {"/upload", "/upload/{id}"})
|
||||||
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
public ResponseEntity<Object> setDatasetProfileXml(@RequestParam("file") MultipartFile file,
|
||||||
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws IllegalAccessException, IOException {
|
@PathVariable(value = "id") String id,
|
||||||
|
@ClaimedAuthorities(claims = {ADMIN, DATASET_PROFILE_MANAGER}) Principal principal) throws Exception {
|
||||||
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
eu.eudat.logic.utilities.documents.xml.datasetProfileXml.datasetProfileModel.DatasetProfile datasetProfileModel = this.datasetProfileManager.createDatasetProfileFromXml(file);
|
||||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
eu.eudat.models.data.admin.composite.DatasetProfile datasetProfileEntity = datasetProfileModel.toAdminCompositeModel(file.getOriginalFilename());
|
||||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
eu.eudat.data.entities.DatasetProfile modelDefinition;
|
||||||
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
if (id == null) {
|
||||||
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
modelDefinition = AdminManager.generateViewStyleDefinition(datasetProfileEntity, getApiContext());
|
||||||
userDatasetProfile.setDatasetProfile(datasetProfile);
|
eu.eudat.data.entities.DatasetProfile datasetProfile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().createOrUpdate(modelDefinition);
|
||||||
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
UserDatasetProfile userDatasetProfile = new UserDatasetProfile();
|
||||||
userDatasetProfile.setUser(userInfo);
|
userDatasetProfile.setDatasetProfile(datasetProfile);
|
||||||
userDatasetProfile.setRole(0);
|
UserInfo userInfo = getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||||
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
userDatasetProfile.setUser(userInfo);
|
||||||
|
userDatasetProfile.setRole(0);
|
||||||
|
getApiContext().getOperationsContext().getDatabaseRepository().getUserDatasetProfileDao().createOrUpdate(userDatasetProfile);
|
||||||
|
} else {
|
||||||
|
modelDefinition = datasetProfileManager.createNewVersionDatasetProfile(id, datasetProfileEntity);
|
||||||
|
}
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue