Merge branch 'ui-refactoring' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into ui-refactoring
This commit is contained in:
commit
ddf0b8c53c
|
@ -34,12 +34,14 @@ import static eu.eudat.types.Authorities.ADMIN;
|
|||
@RequestMapping(value = {"/api/admin/"})
|
||||
public class Admin extends BaseController {
|
||||
|
||||
DatasetProfileManager datasetProfileManager;
|
||||
private DatasetProfileManager datasetProfileManager;
|
||||
private UserManager userManager;
|
||||
|
||||
@Autowired
|
||||
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, Logger logger) {
|
||||
public Admin(ApiContext apiContext, DatasetProfileManager datasetProfileManager, UserManager userManager, Logger logger) {
|
||||
super(apiContext);
|
||||
this.datasetProfileManager = datasetProfileManager;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -77,14 +79,14 @@ public class Admin extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofiles/getPaged"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetProfileListingModel>>> getPaged(@RequestBody DatasetProfileTableRequestItem datasetProfileTableRequestItem, Principal principal) throws Exception {
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getPaged(this.getApiContext(), datasetProfileTableRequestItem);
|
||||
DataTableData<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getPaged(datasetProfileTableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/preview"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getPreview(@RequestBody DatasetProfile profile, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile modelDefinition = AdminManager.generateViewStyleDefinition(profile, getApiContext());
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(modelDefinition);
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(modelDefinition);
|
||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||
|
@ -93,7 +95,7 @@ public class Admin extends BaseController {
|
|||
@org.springframework.transaction.annotation.Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id);
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||
|
@ -102,7 +104,7 @@ public class Admin extends BaseController {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, Principal principal){
|
||||
ResponseEntity<ResponseItem<DatasetProfile>> inactivate(@PathVariable String id, Principal principal) {
|
||||
try {
|
||||
eu.eudat.data.entities.DatasetProfile ret = AdminManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
|
@ -116,7 +118,7 @@ public class Admin extends BaseController {
|
|||
public ResponseEntity getDatasetProfileXml(@PathVariable String id, @RequestHeader("Content-Type") String contentType, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException, IOException, InstantiationException {
|
||||
if (contentType.equals("application/xml")) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = UserManager.generateDatasetProfileModel(profile);
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetProfile = userManager.generateDatasetProfileModel(profile);
|
||||
datasetProfile.setStatus(profile.getStatus());
|
||||
return this.datasetProfileManager.getDocument(datasetProfile, profile.getLabel());
|
||||
} else {
|
||||
|
|
|
@ -45,21 +45,21 @@ public class DMPProfileController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMPProfile>> createOrUpdate(@RequestBody DataManagementPlanProfileListingModel dataManagementPlan, Principal principal) throws Exception {
|
||||
this.dataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMPProfile>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getSingle/{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataManagementPlanProfileListingModel>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal);
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlanProfileListingModel));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
||||
DataTableData<DataManagementPlanProfileListingModel> dataTable = this.dataManagementProfileManager.getPaged(this.getApiContext(), dataManagementPlanProfileTableRequest, principal);
|
||||
DataTableData<DataManagementPlanProfileListingModel> dataTable = this.dataManagementProfileManager.getPaged(dataManagementPlanProfileTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class DMPProfileController extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity getXml( @RequestHeader("Content-Type") String contentType, @PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException, IOException {
|
||||
if (contentType.equals("application/xml")) {
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpProfileDao(), id, principal);
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = this.dataManagementProfileManager.getSingle(id, principal);
|
||||
return this.dataManagementProfileManager.getDocument(dataManagementPlanProfileListingModel,dataManagementPlanProfileListingModel.getLabel());
|
||||
}else {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DataManagementPlanProfileListingModel>().status(ApiMessageCode.ERROR_MESSAGE).message("NOT AUTHORIZE"));
|
||||
|
@ -79,7 +79,7 @@ public class DMPProfileController extends BaseController {
|
|||
@ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws IllegalAccessException,IOException,Exception{
|
||||
eu.eudat.logic.utilities.documents.xml.dmpXml.dmpProfileModel.DmpProfile dmpProfileModel = this.dataManagementProfileManager.createDmpProfileFromXml(file);
|
||||
DataManagementPlanProfileListingModel dataManagementPlan = dmpProfileModel.toDmpProfileCompositeModel(file.getOriginalFilename());
|
||||
this.dataManagementProfileManager.createOrUpdate(this.getApiContext(), dataManagementPlan, principal);
|
||||
this.dataManagementProfileManager.createOrUpdate(dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.data.entities.DatasetProfile>>()
|
||||
.status(ApiMessageCode.SUCCESS_MESSAGE).message(""));
|
||||
}
|
||||
|
|
|
@ -53,27 +53,29 @@ public class DMPs extends BaseController {
|
|||
private DynamicProjectConfiguration dynamicProjectConfiguration;
|
||||
private Environment environment;
|
||||
private DataManagementPlanManager dataManagementPlanManager;
|
||||
|
||||
private DatasetManager datasetManager;
|
||||
@Autowired
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment, DataManagementPlanManager dataManagementPlanManager) {
|
||||
public DMPs(ApiContext apiContext, DynamicProjectConfiguration dynamicProjectConfiguration, Environment environment,
|
||||
DataManagementPlanManager dataManagementPlanManager, DatasetManager datasetManager) {
|
||||
super(apiContext);
|
||||
this.dynamicProjectConfiguration = dynamicProjectConfiguration;
|
||||
this.environment = environment;
|
||||
this.dataManagementPlanManager = dataManagementPlanManager;
|
||||
this.datasetManager = datasetManager;
|
||||
}
|
||||
|
||||
@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(this.getApiContext(), id);
|
||||
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")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DataManagementPlanListingModel>>> getPaged(@Valid @RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest,@RequestParam String fieldsGroup, Principal principal) throws Exception {
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(this.getApiContext(), dataManagementPlanTableRequest, principal, fieldsGroup);
|
||||
DataTableData<DataManagementPlanListingModel> dataTable = this.dataManagementPlanManager.getPaged(dataManagementPlanTableRequest, principal, fieldsGroup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DataManagementPlanListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
|
@ -83,11 +85,11 @@ public class DMPs extends BaseController {
|
|||
if(contentType.equals("application/xml") || contentType.equals("application/msword")){
|
||||
DMPDao dmpDao = this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao();
|
||||
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
|
||||
ResponseEntity<byte[]> document = this.dataManagementPlanManager.getDocument(this.environment, dmpDao, id, visibilityRuleService, contentType);
|
||||
ResponseEntity<byte[]> document = this.dataManagementPlanManager.getDocument(id, contentType);
|
||||
return document;
|
||||
}
|
||||
else{
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, principal, this.dynamicProjectConfiguration);
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlan = this.dataManagementPlanManager.getSingle(id, principal, this.dynamicProjectConfiguration);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataManagementPlan>().status(ApiMessageCode.NO_MESSAGE).payload(dataManagementPlan));
|
||||
}
|
||||
}
|
||||
|
@ -103,14 +105,14 @@ public class DMPs extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/new/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> newVersion(@PathVariable UUID id, @Valid @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
this.dataManagementPlanManager.newVersion(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
this.dataManagementPlanManager.newVersion(id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> clone(@PathVariable UUID id, @RequestBody eu.eudat.models.data.dmp.DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
this.dataManagementPlanManager.clone(this.getApiContext(), id, dataManagementPlan, principal);
|
||||
this.dataManagementPlanManager.clone(id, dataManagementPlan, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -119,7 +121,7 @@ public class DMPs extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DMP>> delete(@PathVariable UUID id, Principal principal) {
|
||||
try{
|
||||
this.dataManagementPlanManager.delete(this.getApiContext(), id);
|
||||
this.dataManagementPlanManager.delete(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DMP>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Successfully Deleted Datamanagement Plan"));
|
||||
}catch (DMPWithDatasetsDeleteException exception){
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new ResponseItem<DMP>().status(ApiMessageCode.ERROR_MESSAGE).message(exception.getMessage()));
|
||||
|
@ -157,8 +159,8 @@ public class DMPs extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id, @RequestHeader("Content-Type") String contentType) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||
System.out.println(contentType);
|
||||
File file = this.dataManagementPlanManager.getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File pdffile = new DatasetManager().convertToPDF(file, environment, file.getName());
|
||||
File file = this.dataManagementPlanManager.getWordDocument(id);
|
||||
File pdffile = datasetManager.convertToPDF(file, environment, file.getName());
|
||||
InputStream resource = new FileInputStream(pdffile);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(file));
|
||||
|
|
|
@ -20,36 +20,34 @@ import java.util.List;
|
|||
@RequestMapping(value = {"/api"})
|
||||
public class DashBoardController extends BaseController {
|
||||
|
||||
private DashBoardManager dashBoardManager;
|
||||
@Autowired
|
||||
public DashBoardController(ApiContext apiContext) {
|
||||
public DashBoardController(ApiContext apiContext, DashBoardManager dashBoardManager) {
|
||||
super(apiContext);
|
||||
this.dashBoardManager = dashBoardManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/getStatistics"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics() {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao());
|
||||
DashBoardStatistics statistics = dashBoardManager.getStatistics();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/me/getStatistics"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<DashBoardStatistics>> getStatistics(Principal principal) {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getMeStatistics(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), principal);
|
||||
DashBoardStatistics statistics = dashBoardManager.getMeStatistics(principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DashBoardStatistics>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/user/recentActivity"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<RecentActivity>> getRecentActivity(@RequestParam(name = "numOfActivities", required = false, defaultValue = "5") Integer numberOfActivities, Principal principal) {
|
||||
RecentActivity statistics = new DashBoardManager().getRecentActivity(this.getApiContext(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), principal, numberOfActivities);
|
||||
RecentActivity statistics = dashBoardManager.getRecentActivity(principal, numberOfActivities);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<RecentActivity>().status(ApiMessageCode.NO_MESSAGE).payload(statistics));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/dashboard/search"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<List<SearchBarItem>>> search(@RequestParam(name = "like") String like, Principal principal) {
|
||||
List<SearchBarItem> searchBarItemList = new DashBoardManager().searchUserData(like, this.getApiContext(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||
, this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), principal);
|
||||
List<SearchBarItem> searchBarItemList = dashBoardManager.searchUserData(like, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<SearchBarItem>>().status(ApiMessageCode.NO_MESSAGE).payload(searchBarItemList));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class DataRepositories extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataRepository>> create(@RequestBody eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel, Principal principal) throws Exception {
|
||||
DataRepository dataRepository = this.dataRepositoryManager.create(this.getApiContext(), dataRepositoryModel);
|
||||
DataRepository dataRepository = this.dataRepositoryManager.create(dataRepositoryModel);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataRepository>().payload(dataRepository).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ public class DatasetProfileController extends BaseController {
|
|||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/datasetprofile/clone/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>> clone(@PathVariable String id, @ClaimedAuthorities(claims = {ADMIN})Principal principal) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(this.getApiContext(), id);
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.datasetProfileManager.clone(id);
|
||||
eu.eudat.models.data.admin.composite.DatasetProfile datasetprofile = AdminManager.generateDatasetProfileModel(profile);
|
||||
datasetprofile.setLabel(profile.getLabel() + " new ");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.admin.composite.DatasetProfile>().payload(datasetprofile));
|
||||
|
|
|
@ -33,14 +33,14 @@ public class DatasetProfiles extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/dmps/datasetprofiles/get"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileAutocompleteItem>>> get(@RequestBody DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws InstantiationException, IllegalAccessException {
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = this.datasetProfileManager.getWithCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao(), datasetProfileAutocompleteRequest);
|
||||
List<DatasetProfileAutocompleteItem> datasetProfileAutocompleteItems = this.datasetProfileManager.getWithCriteria(datasetProfileAutocompleteRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileAutocompleteItems));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/datasetprofiles/getAll"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<DatasetProfileListingModel>>> getAll() throws InstantiationException, IllegalAccessException {
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao());
|
||||
List<DatasetProfileListingModel> datasetProfileTableData = this.datasetProfileManager.getAll();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<DatasetProfileListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(datasetProfileTableData));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,12 +47,14 @@ public class DatasetWizardController extends BaseController {
|
|||
|
||||
private Environment environment;
|
||||
private DatasetManager datasetManager;
|
||||
private UserManager userManager;
|
||||
|
||||
@Autowired
|
||||
public DatasetWizardController(ApiContext apiContext, Environment environment, DatasetManager datasetManager) {
|
||||
public DatasetWizardController(ApiContext apiContext, Environment environment, DatasetManager datasetManager, UserManager userManager) {
|
||||
super(apiContext);
|
||||
this.environment = environment;
|
||||
this.datasetManager = datasetManager;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/userDmps"}, produces = "application/json")
|
||||
|
@ -76,10 +78,10 @@ public class DatasetWizardController extends BaseController {
|
|||
DatasetDao datasetDao = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao();
|
||||
VisibilityRuleService visibilityRuleService = this.getApiContext().getUtilitiesService().getVisibilityRuleService();
|
||||
|
||||
return this.datasetManager.getDocument(datasetDao, id, visibilityRuleService, contentType);
|
||||
return this.datasetManager.getDocument(id, visibilityRuleService, contentType);
|
||||
}
|
||||
else {
|
||||
DatasetWizardModel dataset = this.datasetManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), this.getApiContext().getOperationsContext().getDatasetRepository(), id);
|
||||
DatasetWizardModel dataset = this.datasetManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetWizardModel>().status(ApiMessageCode.NO_MESSAGE).payload(dataset));
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +98,15 @@ public class DatasetWizardController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Dataset>> createOrUpdate(@RequestBody DatasetWizardModel profile, Principal principal) throws Exception {
|
||||
this.datasetManager.createOrUpdate(this.getApiContext(), profile, principal);
|
||||
this.datasetManager.createOrUpdate(profile, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Dataset>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created").payload(null));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/getPDF/{id}"})
|
||||
public @ResponseBody
|
||||
ResponseEntity<byte[]> getPDFDocument(@PathVariable String id) throws IllegalAccessException, IOException, InstantiationException, InterruptedException {
|
||||
File file = new DatasetManager().getWordDocument(this.environment, this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetDao(), id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File pdffile = new DatasetManager().convertToPDF(file, environment, file.getName());
|
||||
File file = datasetManager.getWordDocument(this.environment, id, this.getApiContext().getUtilitiesService().getVisibilityRuleService());
|
||||
File pdffile = datasetManager.convertToPDF(file, environment, file.getName());
|
||||
InputStream resource = new FileInputStream(pdffile);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(file));
|
||||
|
@ -124,7 +126,7 @@ public class DatasetWizardController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/get/{id}"}, produces = "application/json")
|
||||
public ResponseEntity<ResponseItem<PagedDatasetProfile>> getSingle(@PathVariable String id) {
|
||||
eu.eudat.data.entities.DatasetProfile profile = this.getApiContext().getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(profile);
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(profile);
|
||||
PagedDatasetProfile pagedDatasetProfile = new PagedDatasetProfile();
|
||||
pagedDatasetProfile.buildPagedDatasetProfile(datasetprofile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<PagedDatasetProfile>().status(ApiMessageCode.NO_MESSAGE).payload(pagedDatasetProfile));
|
||||
|
|
|
@ -38,14 +38,14 @@ public class Datasets extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(this.getApiContext(), datasetTableRequest, principal);
|
||||
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/public/paged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<DatasetListingModel>>> getPublicPaged(@RequestBody DatasetPublicTableRequest datasetTableRequest, @ClaimedAuthorities(claims = {Authorities.ANONYMOUS}) Principal principal) throws Exception {
|
||||
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(this.getApiContext(), datasetTableRequest, principal);
|
||||
DataTableData<DatasetListingModel> dataTable = this.datasetManager.getPaged(datasetTableRequest, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<DatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ExternalDatasets extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ExternalDatasetListingModel>>> getPaged(@RequestBody ExternalDatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DataTableData<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getPaged(this.getApiContext(), datasetTableRequest);
|
||||
DataTableData<ExternalDatasetListingModel> dataTable = externalDatasetManager.getPaged(datasetTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<ExternalDatasetListingModel>>().status(ApiMessageCode.NO_MESSAGE).payload(dataTable));
|
||||
}
|
||||
|
||||
|
@ -48,14 +48,14 @@ public class ExternalDatasets extends BaseController {
|
|||
ResponseEntity<ResponseItem<List<ExternalDatasetListingModel>>> getWithExternal(
|
||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type, Principal principal
|
||||
) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<ExternalDatasetListingModel> dataTable = new ExternalDatasetManager().getWithExternal(this.getApiContext(), query, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
||||
List<ExternalDatasetListingModel> dataTable = externalDatasetManager.getWithExternal(query);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<ExternalDatasetListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets/getSingle/{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseItem<ExternalDatasetListingModel> getWithExternal(@PathVariable UUID id, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetManager().getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getExternalDatasetDao(), id);
|
||||
ExternalDatasetListingModel externalDatasetModel = externalDatasetManager.getSingle(id);
|
||||
return new ResponseItem<ExternalDatasetListingModel>().payload(externalDatasetModel).status(ApiMessageCode.NO_MESSAGE);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class ExternalDatasets extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/externaldatasets"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<ExternalDataset>> create(@RequestBody eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel, Principal principal) throws Exception {
|
||||
ExternalDataset externalDataset = this.externalDatasetManager.create(this.getApiContext(), externalDatasetModel);
|
||||
ExternalDataset externalDataset = this.externalDatasetManager.create(externalDatasetModel);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ExternalDataset>().payload(externalDataset).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,22 +25,24 @@ import java.util.List;
|
|||
@RequestMapping(value = {"/api/files"})
|
||||
public class FileController extends BaseController {
|
||||
|
||||
private FileManager fileManager;
|
||||
@Autowired
|
||||
public FileController(ApiContext apiContext) {
|
||||
public FileController(ApiContext apiContext, FileManager fileManager) {
|
||||
super(apiContext);
|
||||
this.fileManager = fileManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/upload"})
|
||||
public ResponseEntity<ResponseItem<List<ContentFile>>> handleFileUpload(@RequestParam("file") MultipartFile[] files) throws IOException {
|
||||
return ResponseEntity.status(HttpStatus.OK).body(
|
||||
new ResponseItem<List<ContentFile>>().status(ApiMessageCode.NO_MESSAGE).payload(FileManager.saveTempFile(files, getApiContext().getOperationsContext().getFileStorageService())));
|
||||
new ResponseItem<List<ContentFile>>().status(ApiMessageCode.NO_MESSAGE).payload(fileManager.saveTempFile(files)));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/{id}"})
|
||||
public ResponseEntity<Resource> handleFileUpload(@PathVariable(name = "id") String id,
|
||||
@RequestParam(name = "type") String type,
|
||||
@RequestParam(name = "location", required = false, defaultValue = "final") String location) throws IOException {
|
||||
Resource resource = FileManager.getFile(id, type, getApiContext().getOperationsContext().getFileStorageService(), location);
|
||||
Resource resource = fileManager.getFile(id, type, location);
|
||||
if (!resource.exists())
|
||||
resource = new UrlResource(FileController.class.getClassLoader().getResource("images/default.png"));
|
||||
return ResponseEntity.ok()
|
||||
|
|
|
@ -38,14 +38,17 @@ public class Login {
|
|||
|
||||
private Logger logger;
|
||||
|
||||
private UserManager userManager;
|
||||
@Autowired
|
||||
public Login(CustomAuthenticationProvider customAuthenticationProvider, AuthenticationServiceImpl authenticationServiceImpl,
|
||||
TwitterTokenValidator twitterTokenValidator, B2AccessTokenValidator b2AccessTokenValidator, Logger logger) {
|
||||
TwitterTokenValidator twitterTokenValidator, B2AccessTokenValidator b2AccessTokenValidator,
|
||||
UserManager userManager ,Logger logger) {
|
||||
this.customAuthenticationProvider = customAuthenticationProvider;
|
||||
this.authenticationServiceImpl = authenticationServiceImpl;
|
||||
this.twitterTokenValidator = twitterTokenValidator;
|
||||
this.b2AccessTokenValidator = b2AccessTokenValidator;
|
||||
this.logger = logger;
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -61,7 +64,7 @@ public class Login {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Principal>> nativelogin(@RequestBody Credentials credentials) {
|
||||
this.logger.info(credentials.getUsername(), "Trying To Login");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(UserManager.authenticate(this.authenticationServiceImpl, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Principal>().payload(userManager.authenticate(this.authenticationServiceImpl, credentials)).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/twitterRequestToken"}, produces = "application/json")
|
||||
|
|
|
@ -47,14 +47,14 @@ public class Projects extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<ProjectListingModel>>> getPaged(@Valid @RequestBody ProjectTableRequest projectTableRequest, @RequestParam String fieldsGroup, Principal principal) throws Exception {
|
||||
System.out.println(fieldsGroup);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPaged(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectTableRequest, principal, fieldsGroup);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = this.projectManager.getPaged(projectTableRequest, principal, fieldsGroup);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<eu.eudat.models.data.project.ProjectListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"{id}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<eu.eudat.models.data.project.Project>> getSingle(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
eu.eudat.models.data.project.Project project = this.projectManager.getSingle(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id);
|
||||
eu.eudat.models.data.project.Project project = this.projectManager.getSingle(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.models.data.project.Project>().payload(project).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class Projects extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Project>> addProject(@Valid @RequestBody eu.eudat.models.data.project.Project project, Principal principal) throws IOException, ParseException {
|
||||
this.projectManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(), this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(), this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(), project, principal);
|
||||
this.projectManager.createOrUpdate(project, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Created"));
|
||||
}
|
||||
|
||||
|
@ -70,21 +70,21 @@ public class Projects extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.DELETE, value = {"{id}"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Project>> inactivate(@PathVariable String id, Principal principal) throws IllegalAccessException, InstantiationException {
|
||||
this.projectManager.inactivate(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), id);
|
||||
this.projectManager.inactivate(id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<eu.eudat.data.entities.Project>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/external"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria, Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteriaWithExternal(this.getApiContext(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher(), principal);
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteriaWithExternal(projectCriteria, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"get"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.project.Project>>> get(@RequestBody ProjectCriteriaRequest projectCriteria, @ClaimedAuthorities(claims = {ANONYMOUS}) Principal principal) throws NoURLFound, InstantiationException, HugeResultSet, IllegalAccessException {
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteria(this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(), projectCriteria, this.getApiContext().getOperationsContext().getRemoteFetcher());
|
||||
List<eu.eudat.models.data.project.Project> dataTable = this.projectManager.getCriteria(projectCriteria);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.project.Project>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
|
|
@ -44,19 +44,13 @@ public class QuickWizardController extends BaseController {
|
|||
eu.eudat.data.entities.Project projectEntity;
|
||||
//Create Project
|
||||
if (quickWizard.getProject().getExistProject() == null) {
|
||||
projectEntity = this.quickWizardManager.createOrUpdate(this.getApiContext().getOperationsContext().getFileStorageService(),
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getProjectDao(),
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getContentDao(),
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
|
||||
quickWizard.getProject().toDataProject(), principal);
|
||||
projectEntity = this.quickWizardManager.createOrUpdate(quickWizard.getProject().toDataProject(), principal);
|
||||
} else {
|
||||
projectEntity = quickWizard.getProject().getExistProject().toDataModel();
|
||||
}
|
||||
//Create Dmp
|
||||
eu.eudat.data.entities.DMP dmpEntity = this.quickWizardManager.createOrUpdate(
|
||||
this.getApiContext(),
|
||||
quickWizard.getDmp().toDataDmp(
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
|
||||
projectEntity,
|
||||
principal),
|
||||
principal);
|
||||
|
@ -64,8 +58,7 @@ public class QuickWizardController extends BaseController {
|
|||
//Create Datasets
|
||||
quickWizard.getDmp().setId(dmpEntity.getId());
|
||||
for (DatasetDescriptionQuickWizardModel dataset : quickWizard.getDatasets().getDatasetsList()) {
|
||||
this.datasetManager.createOrUpdate(this.getApiContext(), dataset.toDataModel(quickWizard.getDmp().toDataDmp(
|
||||
this.getApiContext().getOperationsContext().getDatabaseRepository().getUserInfoDao(),
|
||||
this.datasetManager.createOrUpdate(dataset.toDataModel(quickWizard.getDmp().toDataDmp(
|
||||
projectEntity,
|
||||
principal),
|
||||
quickWizard.getDmp().getDatasetProfile().getId()),
|
||||
|
@ -82,7 +75,7 @@ public class QuickWizardController extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DatasetCreateWizardModel>> addDatasetWizard(@RequestBody DatasetCreateWizardModel datasetCreateWizardModel, Principal principal) throws Exception{
|
||||
for(DatasetDescriptionQuickWizardModel dataset : datasetCreateWizardModel.getDatasets().getDatasetsList()){
|
||||
this.datasetManager.createOrUpdate(this.getApiContext(), dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId()), principal);
|
||||
this.datasetManager.createOrUpdate(dataset.toDataModel(datasetCreateWizardModel.getDmpMeta().getDmp(), datasetCreateWizardModel.getDmpMeta().getDatasetProfile().getId()), principal);
|
||||
}
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DatasetCreateWizardModel>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Dataset added!"));
|
||||
|
|
|
@ -45,7 +45,7 @@ public class Registries extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/registries"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Registry>> create(@RequestBody RegistryModel registryModel, Principal principal) throws Exception {
|
||||
Registry registry = this.registryManager.create(this.getApiContext(), registryModel);
|
||||
Registry registry = this.registryManager.create(registryModel);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Registry>().payload(registry).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
|
||||
|
|
|
@ -33,19 +33,10 @@ public class Researchers extends BaseController {
|
|||
this.researcherManager = researcherManager;
|
||||
}
|
||||
|
||||
/*@RequestMapping(method = RequestMethod.GET, value = {"/external/researchers"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<ResearchersExternalSourcesModel>> listExternalResearchers(
|
||||
@RequestParam(value = "query", required = false) String query, @RequestParam(value = "type", required = false) String type) throws HugeResultSet, NoURLFound {
|
||||
List<Map<String, String>> remoteRepos = this.getApiContext().getOperationsContext().getRemoteFetcher().getResearchers(query, type);
|
||||
ResearchersExternalSourcesModel researchersExternalSourcesModel = new ResearchersExternalSourcesModel().fromExternalItem(remoteRepos);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<ResearchersExternalSourcesModel>().payload(researchersExternalSourcesModel).status(ApiMessageCode.NO_MESSAGE));
|
||||
}*/
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getWithExternal"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>> getWithExternal(@RequestBody ResearcherCriteriaRequest researcherCriteriaRequest, Principal principal) throws HugeResultSet, NoURLFound {
|
||||
List<eu.eudat.models.data.dmp.Researcher> dataTable = this.researcherManager.getCriteriaWithExternal(this.getApiContext(), this.getApiContext().getOperationsContext().getRemoteFetcher(), researcherCriteriaRequest);
|
||||
List<eu.eudat.models.data.dmp.Researcher> dataTable = this.researcherManager.getCriteriaWithExternal(researcherCriteriaRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<eu.eudat.models.data.dmp.Researcher>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -53,7 +44,7 @@ public class Researchers extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Researcher>> create(@RequestBody eu.eudat.models.data.researcher.Researcher researcher, Principal principal) throws Exception {
|
||||
this.researcherManager.create(this.getApiContext(), researcher);
|
||||
this.researcherManager.create(researcher);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Researcher>().status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.data.entities.Service;
|
||||
import eu.eudat.logic.managers.RegistryManager;
|
||||
import eu.eudat.logic.managers.ServiceManager;
|
||||
import eu.eudat.logic.proxy.config.exceptions.HugeResultSet;
|
||||
import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
||||
|
@ -25,9 +24,12 @@ import java.util.Map;
|
|||
@RequestMapping(value = {"/api"})
|
||||
public class Services extends BaseController {
|
||||
|
||||
private ServiceManager serviceManager;
|
||||
|
||||
@Autowired
|
||||
public Services(ApiContext apiContext) {
|
||||
public Services(ApiContext apiContext, ServiceManager serviceManager) {
|
||||
super(apiContext);
|
||||
this.serviceManager = serviceManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/services"}, produces = "application/json")
|
||||
|
@ -43,7 +45,7 @@ public class Services extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/services"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Service>> create(@RequestBody ServiceModel serviceModel, Principal principal) throws Exception {
|
||||
Service service = ServiceManager.create(this.getApiContext(), serviceModel);
|
||||
Service service = serviceManager.create(serviceModel);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Service>().payload(service).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,14 +35,6 @@ public class TagController extends BaseController {
|
|||
this.datasetRepository = tagRepository;
|
||||
}
|
||||
|
||||
/*@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/tag/create"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Dataset>> create(@RequestBody Dataset dataset) throws IOException {
|
||||
Dataset tagEntity = this.datasetRepository.createOrUpdate(dataset);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Dataset>().payload(dataset).status(ApiMessageCode.SUCCESS_MESSAGE));
|
||||
}*/
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = {"/external/tags"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<TagExternalSourcesModel>> listExternalTagModel(
|
||||
|
|
|
@ -23,16 +23,18 @@ import java.util.UUID;
|
|||
@CrossOrigin
|
||||
public class UserInvitationController extends BaseController {
|
||||
|
||||
private InvitationsManager invitationsManager;
|
||||
@Autowired
|
||||
public UserInvitationController(ApiContext apiContext) {
|
||||
public UserInvitationController(ApiContext apiContext, InvitationsManager invitationsManager) {
|
||||
super(apiContext);
|
||||
this.invitationsManager = invitationsManager;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/users"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<Invitation>> users(@RequestBody Invitation invitation, Principal principal) throws Exception {
|
||||
InvitationsManager.inviteUsers(this.getApiContext(), invitation, principal);
|
||||
this.invitationsManager.inviteUsers(invitation, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<Invitation>().status(ApiMessageCode.SUCCESS_MESSAGE).message("Users have beeen invited"));
|
||||
}
|
||||
|
||||
|
@ -40,14 +42,14 @@ public class UserInvitationController extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.GET, value = {"/exchange/{invitationID}"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<UUID>> exchange(@PathVariable UUID invitationID, Principal principal) {
|
||||
UUID dmpId = InvitationsManager.assignUserAcceptedInvitation(this.getApiContext(), invitationID, principal);
|
||||
UUID dmpId = invitationsManager.assignUserAcceptedInvitation(invitationID, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UUID>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(dmpId));
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getUsers"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<List<UserInfoInvitationModel>>> getUsers(@RequestBody UserInfoRequestItem userInfoRequestItem) throws IllegalAccessException, InstantiationException {
|
||||
List<UserInfoInvitationModel> users = InvitationsManager.getUsers(this.getApiContext(), userInfoRequestItem);
|
||||
List<UserInfoInvitationModel> users = invitationsManager.getUsers(userInfoRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<List<UserInfoInvitationModel>>().status(ApiMessageCode.SUCCESS_MESSAGE).payload(users));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,15 +29,17 @@ import static eu.eudat.types.Authorities.ADMIN;
|
|||
@RequestMapping(value = "api/user")
|
||||
public class Users extends BaseController {
|
||||
|
||||
private UserManager userManager;
|
||||
@Autowired
|
||||
public Users(ApiContext apiContext) {
|
||||
public Users(ApiContext apiContext, UserManager userManager) {
|
||||
super(apiContext);
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = {"/getPaged"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<DataTableData<UserListingModel>>> getPaged(@Valid @RequestBody UserInfoTableRequestItem userInfoTableRequestItem, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) throws Exception {
|
||||
DataTableData<UserListingModel> dataTable = UserManager.getPaged(this.getApiContext(), userInfoTableRequestItem);
|
||||
DataTableData<UserListingModel> dataTable = userManager.getPaged(userInfoTableRequestItem);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<DataTableData<UserListingModel>>().payload(dataTable).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -45,7 +47,7 @@ public class Users extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/updateRoles"}, consumes = "application/json", produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<UserListingModel>> updateRoles(@Valid @RequestBody UserListingModel userListingModel, @ClaimedAuthorities(claims = {ADMIN}) Principal principal) {
|
||||
UserManager.editRoles(this.getApiContext(), userListingModel);
|
||||
userManager.editRoles(userListingModel);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserListingModel>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -53,7 +55,7 @@ public class Users extends BaseController {
|
|||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<UserProfile>> get(@PathVariable String id, Principal principal) throws Exception {
|
||||
UUID userId = id.equals("me") ? principal.getId() : UUID.fromString(id);
|
||||
UserProfile user = UserManager.getSingle(this.getApiContext(), userId);
|
||||
UserProfile user = userManager.getSingle(userId);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().payload(user).status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
|
||||
|
@ -61,7 +63,7 @@ public class Users extends BaseController {
|
|||
@RequestMapping(method = RequestMethod.POST, value = {"/settings"}, produces = "application/json")
|
||||
public @ResponseBody
|
||||
ResponseEntity<ResponseItem<UserProfile>> saveSettings(@RequestBody Map<String, Object> settings, Principal principal) throws IOException {
|
||||
UserManager.updateSettings(this.getApiContext(), settings, principal);
|
||||
userManager.updateSettings(settings, principal);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(new ResponseItem<UserProfile>().status(ApiMessageCode.NO_MESSAGE));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,39 +8,55 @@ import eu.eudat.data.dao.entities.ProjectDao;
|
|||
import eu.eudat.data.entities.UserInfo;
|
||||
import eu.eudat.logic.builders.model.models.RecentActivityDataBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.dashboard.recent.RecentActivity;
|
||||
import eu.eudat.models.data.dashboard.recent.RecentActivityData;
|
||||
import eu.eudat.models.data.dashboard.searchbar.SearchBarItem;
|
||||
import eu.eudat.models.data.dashboard.statistics.DashBoardStatistics;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.types.searchbar.SearchBarItemType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@Component
|
||||
public class DashBoardManager {
|
||||
|
||||
public DashBoardStatistics getStatistics(DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository) {
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
|
||||
@Autowired
|
||||
public DashBoardManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public DashBoardStatistics getStatistics() {
|
||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setAllVersions(false);
|
||||
DataManagementPlanCriteria dataManagementPlanCriteria = new DataManagementPlanCriteria();
|
||||
dataManagementPlanCriteria.setAllVersions(false);
|
||||
|
||||
CompletableFuture dmpFuture = dataManagementPlanRepository.getWithCriteria(dataManagementPlanCriteria).countAsync()
|
||||
CompletableFuture dmpFuture = databaseRepository.getDmpDao().getWithCriteria(dataManagementPlanCriteria).countAsync()
|
||||
.whenComplete((dmpsStats, throwable) -> statistics.setTotalDataManagementPlanCount(dmpsStats));
|
||||
CompletableFuture datasetFuture = datasetRepository.getWithCriteria(datasetCriteria).countAsync()
|
||||
CompletableFuture datasetFuture = databaseRepository.getDatasetDao().getWithCriteria(datasetCriteria).countAsync()
|
||||
.whenComplete((datasetsStats, throwable) -> statistics.setTotalDataSetCount(datasetsStats));
|
||||
CompletableFuture projectFuture = projectRepository.asQueryable().countAsync()
|
||||
CompletableFuture projectFuture = databaseRepository.getProjectDao().asQueryable().countAsync()
|
||||
.whenComplete((projectsStats, throwable) -> statistics.setTotalProjectCount(projectsStats));
|
||||
|
||||
CompletableFuture.allOf(dmpFuture, datasetFuture, projectFuture).join();
|
||||
return statistics;
|
||||
}
|
||||
|
||||
public DashBoardStatistics getMeStatistics(DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository, Principal principal) {
|
||||
public DashBoardStatistics getMeStatistics(Principal principal) {
|
||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
|
@ -58,8 +74,11 @@ public class DashBoardManager {
|
|||
return statistics;
|
||||
}
|
||||
|
||||
public RecentActivity getRecentActivity(ApiContext apiContext, DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository, Principal principal, Integer numberofactivities) {
|
||||
public RecentActivity getRecentActivity(Principal principal, Integer numberofactivities) {
|
||||
RecentActivity activity = new RecentActivity();
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
|
@ -94,10 +113,13 @@ public class DashBoardManager {
|
|||
return activity;
|
||||
}
|
||||
|
||||
public List<SearchBarItem> searchUserData(String like, ApiContext apiContext, DatasetDao datasetRepository, DMPDao dataManagementPlanRepository, ProjectDao projectRepository, Principal principal) {
|
||||
public List<SearchBarItem> searchUserData(String like, Principal principal) {
|
||||
RecentActivity activity = new RecentActivity();
|
||||
UserInfo user = new UserInfo();
|
||||
user.setId(principal.getId());
|
||||
DMPDao dataManagementPlanRepository = databaseRepository.getDmpDao();
|
||||
DatasetDao datasetRepository = databaseRepository.getDatasetDao();
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
|
||||
List<SearchBarItem> searchBarItems = new LinkedList<>();
|
||||
CompletableFuture<List<SearchBarItem>> dmps = dataManagementPlanRepository.getAuthenticated(dataManagementPlanRepository.asQueryable(), user)
|
||||
|
|
|
@ -14,6 +14,8 @@ import eu.eudat.exceptions.security.UnauthorisedException;
|
|||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.logic.services.utilities.UtilitiesService;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.types.ParagraphStyle;
|
||||
|
@ -32,6 +34,7 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
|||
import eu.eudat.queryable.QueryableList;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -58,7 +61,22 @@ import java.util.stream.Collectors;
|
|||
@Component
|
||||
public class DataManagementPlanManager {
|
||||
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(ApiContext apiContext, DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private DatasetManager datasetManager;
|
||||
private UtilitiesService utilitiesService;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private Environment environment;
|
||||
|
||||
@Autowired
|
||||
public DataManagementPlanManager(ApiContext apiContext, DatasetManager datasetManager, Environment environment) {
|
||||
this.apiContext = apiContext;
|
||||
this.datasetManager = datasetManager;
|
||||
this.utilitiesService = apiContext.getUtilitiesService();
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.environment = environment;
|
||||
}
|
||||
|
||||
public DataTableData<DataManagementPlanListingModel> getPaged(DataManagementPlanTableRequest dataManagementPlanTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
UserInfo userInfo = new UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<DMP> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getWithCriteria(dataManagementPlanTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DataManagementPlanListingModel.class));
|
||||
|
@ -95,21 +113,22 @@ public class DataManagementPlanManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public void unlock(ApiContext apiContext, UUID uuid) throws Exception {
|
||||
public void unlock(UUID uuid) throws Exception {
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpDao()
|
||||
.asQueryable().where((builder, root) -> builder.equal(root.get("id"), uuid))
|
||||
.update(root -> root.get("status"), DMP.DMPStatus.ACTIVE.getValue());
|
||||
return;
|
||||
}
|
||||
|
||||
public File getWordDocument(Environment environment, DMPDao dmpRepository, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
public File getWordDocument(String id) throws InstantiationException, IllegalAccessException, IOException {
|
||||
WordBuilder wordBuilder = new WordBuilder();
|
||||
VisibilityRuleService visibilityRuleService = this.utilitiesService.getVisibilityRuleService();
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
String fileUrl = environment.getProperty("configuration.h2020template");
|
||||
InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
|
||||
XWPFDocument document = new XWPFDocument(is);
|
||||
|
||||
eu.eudat.data.entities.DMP dmpEntity = dmpRepository.find(UUID.fromString(id));
|
||||
eu.eudat.data.entities.DMP dmpEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
wordBuilder.addParagraphContent(dmpEntity.getLabel(), document, ParagraphStyle.TITLE, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent(dmpEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
|
||||
|
@ -140,7 +159,7 @@ public class DataManagementPlanManager {
|
|||
wordBuilder.addParagraphContent("Title: " + datasetEntity.getLabel(), document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent(datasetEntity.getDescription(), document, ParagraphStyle.TEXT, BigInteger.ZERO);
|
||||
wordBuilder.addParagraphContent("Dataset Description", document, ParagraphStyle.HEADER1, BigInteger.ZERO);
|
||||
PagedDatasetProfile pagedDatasetProfile = new DatasetManager().getPagedProfile(dataset, datasetEntity);
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
try {
|
||||
|
@ -158,8 +177,8 @@ public class DataManagementPlanManager {
|
|||
return exportFile;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
DMP dataManagementPlanEntity = dmpsRepository.find(UUID.fromString(id));
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan getSingle(String id, Principal principal, DynamicProjectConfiguration dynamicProjectConfiguration) throws InstantiationException, IllegalAccessException {
|
||||
DMP dataManagementPlanEntity = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
if (dataManagementPlanEntity.getCreator().getId() != principal.getId() && dataManagementPlanEntity.getUsers().stream().filter(userInfo -> userInfo.getId() == principal.getId()).collect(Collectors.toList()).size() == 0)
|
||||
throw new UnauthorisedException();
|
||||
eu.eudat.models.data.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
|
@ -262,7 +281,7 @@ public class DataManagementPlanManager {
|
|||
apiContext.getOperationsContext().getDatabaseRepository().getUserDmpDao().createOrUpdate(userDMP);
|
||||
}
|
||||
|
||||
public void newVersion(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
public void newVersion(UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP oldDmp = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().find(uuid);
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
|
@ -277,7 +296,7 @@ public class DataManagementPlanManager {
|
|||
copyDatasets(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao());
|
||||
}
|
||||
|
||||
public void clone(ApiContext apiContext, UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
public void clone(UUID uuid, DataManagementPlanNewVersionModel dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
createOrganisationsIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getOrganisationDao());
|
||||
createResearchersIfTheyDontExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao());
|
||||
|
@ -291,7 +310,7 @@ public class DataManagementPlanManager {
|
|||
copyDatasets(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao());
|
||||
}
|
||||
|
||||
public void delete(ApiContext apiContext, UUID uuid) throws DMPWithDatasetsDeleteException {
|
||||
public void delete(UUID uuid) throws DMPWithDatasetsDeleteException {
|
||||
DatasetCriteria criteria = new DatasetCriteria();
|
||||
List<UUID> dmpIds = Collections.singletonList(uuid);
|
||||
criteria.setDmpIds(dmpIds);
|
||||
|
@ -400,9 +419,10 @@ public class DataManagementPlanManager {
|
|||
}
|
||||
}
|
||||
|
||||
public FileEnvelope getXmlDocument(DMPDao dmpRepository, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
public FileEnvelope getXmlDocument(String id) throws InstantiationException, IllegalAccessException, IOException {
|
||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||
eu.eudat.data.entities.DMP dmp = dmpRepository.find(UUID.fromString(id));
|
||||
VisibilityRuleService visibilityRuleService = utilitiesService.getVisibilityRuleService();
|
||||
eu.eudat.data.entities.DMP dmp = databaseRepository.getDmpDao().find(UUID.fromString(id));
|
||||
List<Dataset> datasets = dmp.getDataset().stream().collect(Collectors.toList());
|
||||
String fileName = dmp.getLabel();
|
||||
fileName = fileName.replaceAll("[^a-zA-Z0-9+ ]", "");
|
||||
|
@ -473,7 +493,7 @@ public class DataManagementPlanManager {
|
|||
JSONObject jobject = new JSONObject(dataset.getProperties());
|
||||
properties = jobject.toMap();
|
||||
}
|
||||
PagedDatasetProfile pagedDatasetProfile = new DatasetManager().getPagedProfile(datasetWizardModel, dataset);
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(datasetWizardModel, dataset);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
datasetElement.appendChild(xmlBuilder.createPages(pagedDatasetProfile.getPages(), visibilityRuleService, xmlDoc));
|
||||
|
@ -516,17 +536,19 @@ public class DataManagementPlanManager {
|
|||
return fileEnvelope;
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getDocument(Environment environment, DMPDao dmpDao, String id, VisibilityRuleService visibilityRuleService, String contentType) throws InstantiationException, IllegalAccessException, IOException{
|
||||
public ResponseEntity<byte[]> getDocument(String id, String contentType) throws InstantiationException, IllegalAccessException, IOException{
|
||||
File file;
|
||||
VisibilityRuleService visibilityRuleService = this.utilitiesService.getVisibilityRuleService();
|
||||
DMPDao dmpDao = databaseRepository.getDmpDao();
|
||||
switch (contentType){
|
||||
case "application/xml":
|
||||
file = getXmlDocument(dmpDao, id, visibilityRuleService).getFile();
|
||||
file = getXmlDocument(id).getFile();
|
||||
break;
|
||||
case "application/msword":
|
||||
file = getWordDocument(environment, dmpDao, id, visibilityRuleService);
|
||||
file = getWordDocument(id);
|
||||
break;
|
||||
default:
|
||||
file = getXmlDocument(dmpDao, id, visibilityRuleService).getFile();
|
||||
file = getXmlDocument(id).getFile();
|
||||
}
|
||||
InputStream resource = new FileInputStream(file);
|
||||
System.out.println("Mime Type of " + file.getName() + " is " +
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.data.dao.entities.DMPProfileDao;
|
|||
import eu.eudat.data.entities.DMPProfile;
|
||||
import eu.eudat.data.query.items.item.dmpprofile.DataManagementPlanProfileCriteriaRequest;
|
||||
import eu.eudat.data.query.items.table.dmpprofile.DataManagementPlanProfileTableRequest;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.ExportXmlBuilderDmpProfile;
|
||||
import eu.eudat.logic.utilities.documents.xml.dmpXml.ImportXmlBuilderDmpProfile;
|
||||
|
@ -12,6 +13,7 @@ import eu.eudat.models.data.listingmodels.DataManagementPlanProfileListingModel;
|
|||
import eu.eudat.models.data.security.Principal;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -31,7 +33,16 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
@Component
|
||||
public class DataManagementProfileManager {
|
||||
|
||||
public DataTableData<DataManagementPlanProfileListingModel> getPaged(ApiContext apiContext, DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
|
||||
@Autowired
|
||||
public DataManagementProfileManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public DataTableData<DataManagementPlanProfileListingModel> getPaged(DataManagementPlanProfileTableRequest dataManagementPlanProfileTableRequest, Principal principal) throws Exception {
|
||||
|
||||
QueryableList<DMPProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().getWithCriteria(dataManagementPlanProfileTableRequest.getCriteria());
|
||||
QueryableList<DMPProfile> pagedItems = PaginationManager.applyPaging(items, dataManagementPlanProfileTableRequest);
|
||||
|
@ -50,20 +61,20 @@ public class DataManagementProfileManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public DataManagementPlanProfileListingModel getSingle(DMPProfileDao dmpProfileDao, String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
DMPProfile dmpProfile = dmpProfileDao.find(UUID.fromString(id));
|
||||
public DataManagementPlanProfileListingModel getSingle(String id, Principal principal) throws InstantiationException, IllegalAccessException {
|
||||
DMPProfile dmpProfile = databaseRepository.getDmpProfileDao().find(UUID.fromString(id));
|
||||
DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel = new DataManagementPlanProfileListingModel();
|
||||
dataManagementPlanProfileListingModel.fromDataModel(dmpProfile);
|
||||
return dataManagementPlanProfileListingModel;
|
||||
}
|
||||
|
||||
public List<DataManagementPlanProfileListingModel> getWithCriteria(DMPProfileDao dmpProfileDao, DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DMPProfile> items = dmpProfileDao.getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
|
||||
public List<DataManagementPlanProfileListingModel> getWithCriteria(DataManagementPlanProfileCriteriaRequest dataManagementPlanProfileCriteriaRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DMPProfile> items = databaseRepository.getDmpProfileDao().getWithCriteria(dataManagementPlanProfileCriteriaRequest.getCriteria());
|
||||
List<DataManagementPlanProfileListingModel> datamanagementPlans = items.select(item -> new DataManagementPlanProfileListingModel().fromDataModel(item));
|
||||
return datamanagementPlans;
|
||||
}
|
||||
|
||||
public void createOrUpdate(ApiContext apiContext, DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel, Principal principal) throws Exception {
|
||||
public void createOrUpdate(DataManagementPlanProfileListingModel dataManagementPlanProfileListingModel, Principal principal) throws Exception {
|
||||
DMPProfile dmpProfile = dataManagementPlanProfileListingModel.toDataModel();
|
||||
apiContext.getOperationsContext().getDatabaseRepository().getDmpProfileDao().createOrUpdate(dmpProfile);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import eu.eudat.data.entities.DataRepository;
|
|||
import eu.eudat.data.entities.Researcher;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +12,14 @@ import org.springframework.stereotype.Component;
|
|||
*/
|
||||
@Component
|
||||
public class DataRepositoryManager {
|
||||
public DataRepository create(ApiContext apiContext, eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
|
||||
@Autowired
|
||||
public DataRepositoryManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
public DataRepository create(eu.eudat.models.data.datarepository.DataRepositoryModel dataRepositoryModel) throws Exception {
|
||||
DataRepository dataRepository = dataRepositoryModel.toDataModel();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao().createOrUpdate(dataRepository);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,11 @@ import eu.eudat.data.query.items.table.dataset.DatasetPublicTableRequest;
|
|||
import eu.eudat.data.query.items.table.dataset.DatasetTableRequest;
|
||||
import eu.eudat.elastic.criteria.DatasetCriteria;
|
||||
import eu.eudat.elastic.repository.DatasetRepository;
|
||||
import eu.eudat.logic.builders.BuilderFactory;
|
||||
import eu.eudat.logic.builders.entity.UserInfoBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
||||
import eu.eudat.logic.utilities.documents.xml.ExportXmlBuilder;
|
||||
|
@ -26,6 +28,7 @@ import eu.eudat.queryable.QueryableList;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
|
@ -48,20 +51,35 @@ import java.util.zip.ZipInputStream;
|
|||
@Component
|
||||
public class DatasetManager {
|
||||
|
||||
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private DatasetRepository datasetRepository;
|
||||
private BuilderFactory builderFactory;
|
||||
private UserManager userManager;
|
||||
|
||||
@Autowired
|
||||
public DatasetManager(ApiContext apiContext, UserManager userManager) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.datasetRepository = apiContext.getOperationsContext().getDatasetRepository();
|
||||
this.builderFactory = apiContext.getOperationsContext().getBuilderFactory();
|
||||
this.userManager = userManager;
|
||||
}
|
||||
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
|
||||
List<eu.eudat.elastic.entities.Dataset> datasets;
|
||||
try {
|
||||
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && apiContext.getOperationsContext().getDatasetRepository().exists() ?
|
||||
apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>();
|
||||
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && datasetRepository.exists() ?
|
||||
datasetRepository.query(datasetCriteria) : new LinkedList<>();
|
||||
}
|
||||
catch (Exception ex){
|
||||
datasets = null;
|
||||
}
|
||||
|
||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
QueryableList<eu.eudat.data.entities.Dataset> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||
UserInfo userInfo = builderFactory.getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
QueryableList<eu.eudat.data.entities.Dataset> items = databaseRepository.getDatasetDao().getWithCriteria(datasetTableRequest.getCriteria()).withHint(HintedModelFactory.getHint(DatasetListingModel.class));
|
||||
if (datasets != null && datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) {
|
||||
if (!datasets.isEmpty()){
|
||||
List<eu.eudat.elastic.entities.Dataset> finalDatasets = datasets;
|
||||
|
@ -70,7 +88,7 @@ public class DatasetManager {
|
|||
else
|
||||
items.where((builder, root) -> root.get("id").in(new UUID[]{UUID.randomUUID()}));
|
||||
}
|
||||
QueryableList<eu.eudat.data.entities.Dataset> authItems = apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.data.entities.Dataset> authItems = databaseRepository.getDatasetDao().getAuthenticated(items, userInfo);
|
||||
QueryableList<eu.eudat.data.entities.Dataset> pagedItems = PaginationManager.applyPaging(authItems, datasetTableRequest);
|
||||
DataTableData<DatasetListingModel> dataTable = new DataTableData<DatasetListingModel>();
|
||||
|
||||
|
@ -88,18 +106,18 @@ public class DatasetManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public DataTableData<DatasetListingModel> getPaged(ApiContext apiContext, DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
public DataTableData<DatasetListingModel> getPaged(DatasetPublicTableRequest datasetTableRequest, Principal principal) throws Exception {
|
||||
DatasetCriteria datasetCriteria = new DatasetCriteria();
|
||||
datasetCriteria.setTags(datasetTableRequest.getCriteria().getTags());
|
||||
List<eu.eudat.elastic.entities.Dataset> datasets;
|
||||
try{
|
||||
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && apiContext.getOperationsContext().getDatasetRepository().exists() ?
|
||||
apiContext.getOperationsContext().getDatasetRepository().query(datasetCriteria) : new LinkedList<>();
|
||||
datasets = datasetCriteria.getTags() != null && datasetCriteria.getTags().size() > 0 && datasetRepository.exists() ?
|
||||
datasetRepository.query(datasetCriteria) : new LinkedList<>();
|
||||
}
|
||||
catch (Exception ex){
|
||||
datasets = null;
|
||||
}
|
||||
datasetTableRequest.setQuery(apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||
datasetTableRequest.setQuery(databaseRepository.getDatasetDao().asQueryable().withHint(HintedModelFactory.getHint(DatasetListingModel.class)));
|
||||
QueryableList<Dataset> items = datasetTableRequest.applyCriteria();
|
||||
if (datasets != null && datasetTableRequest.getCriteria().getTags() != null && !datasetTableRequest.getCriteria().getTags().isEmpty()) {
|
||||
if (!datasets.isEmpty()) {
|
||||
|
@ -125,13 +143,13 @@ public class DatasetManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, DatasetRepository elasticDatasetRepository, String id) throws InstantiationException, IllegalAccessException, IOException {
|
||||
public DatasetWizardModel getSingle(String id) throws InstantiationException, IllegalAccessException, IOException {
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
eu.eudat.elastic.entities.Dataset datasetElastic;
|
||||
try{
|
||||
datasetElastic = elasticDatasetRepository.exists() ?
|
||||
elasticDatasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
||||
datasetElastic = datasetRepository.exists() ?
|
||||
datasetRepository.findDocument(id) : new eu.eudat.elastic.entities.Dataset();
|
||||
}
|
||||
catch (Exception ex){
|
||||
datasetElastic = new eu.eudat.elastic.entities.Dataset();
|
||||
|
@ -143,7 +161,7 @@ public class DatasetManager {
|
|||
}
|
||||
|
||||
public PagedDatasetProfile getPagedProfile(DatasetWizardModel dataset, eu.eudat.data.entities.Dataset datasetEntity) {
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
eu.eudat.models.data.user.composite.DatasetProfile datasetprofile = userManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
if (datasetEntity.getProperties() != null) {
|
||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
|
@ -155,13 +173,13 @@ public class DatasetManager {
|
|||
return pagedDatasetProfile;
|
||||
}
|
||||
|
||||
public File getWordDocument(Environment environment, DatasetDao datatasetRepository, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
public File getWordDocument(Environment environment, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
WordBuilder wordBuilder = new WordBuilder();
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
String fileUrl = environment.getProperty("configuration.h2020template");
|
||||
InputStream is = new URL(Paths.get(fileUrl).toUri().toURL().toString()).openStream();
|
||||
XWPFDocument document = new XWPFDocument(is);
|
||||
eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
if (datasetEntity.getProperties() != null) {
|
||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
|
@ -178,10 +196,10 @@ public class DatasetManager {
|
|||
return exportFile;
|
||||
}
|
||||
|
||||
public FileEnvelope getXmlDocument(DatasetDao datatasetRepository, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
public FileEnvelope getXmlDocument(String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
ExportXmlBuilder xmlBuilder = new ExportXmlBuilder();
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
eu.eudat.data.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
eu.eudat.data.entities.Dataset datasetEntity = databaseRepository.getDatasetDao().find(UUID.fromString(id), HintedModelFactory.getHint(DatasetWizardModel.class));
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
if (datasetEntity.getProperties() != null) {
|
||||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
|
@ -263,7 +281,7 @@ public class DatasetManager {
|
|||
return newFile;
|
||||
}
|
||||
|
||||
public eu.eudat.data.entities.Dataset createOrUpdate(ApiContext apiContext, DatasetWizardModel datasetWizardModel, Principal principal) throws Exception {
|
||||
public eu.eudat.data.entities.Dataset createOrUpdate(DatasetWizardModel datasetWizardModel, Principal principal) throws Exception {
|
||||
eu.eudat.data.entities.Dataset dataset = datasetWizardModel.toDataModel();
|
||||
propertiesModelToString(datasetWizardModel, dataset);
|
||||
UserInfo userInfo = apiContext.getOperationsContext().getBuilderFactory().getBuilder(UserInfoBuilder.class).id(principal.getId()).build();
|
||||
|
@ -271,8 +289,8 @@ public class DatasetManager {
|
|||
updateTags(apiContext.getOperationsContext().getDatasetRepository(), datasetWizardModel);
|
||||
createRegistriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao(), dataset);
|
||||
createDataRepositoriesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDataRepositoryDao(), dataset);
|
||||
createServicesIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDatasetServiceDao(), apiContext.getOperationsContext().getDatabaseRepository().getServiceDao(), dataset);
|
||||
createExternalDatasetsIfTheyDontExist(apiContext.getOperationsContext().getDatabaseRepository().getDatasetExternalDatasetDao(), apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao(), dataset);
|
||||
createServicesIfTheyDontExist(dataset);
|
||||
createExternalDatasetsIfTheyDontExist(dataset);
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getDatasetDao().createOrUpdate(dataset);
|
||||
}
|
||||
|
||||
|
@ -328,20 +346,20 @@ public class DatasetManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void createServicesIfTheyDontExist(DatasetServiceDao datasetServiceDao, ServiceDao serviceDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
private void createServicesIfTheyDontExist(eu.eudat.data.entities.Dataset dataset) {
|
||||
Set<DatasetService> services = dataset.getServices();
|
||||
dataset.setServices(new HashSet<>());
|
||||
if (services != null && !services.isEmpty()) {
|
||||
for (eu.eudat.data.entities.DatasetService datasetService : services) {
|
||||
ServiceCriteria criteria = new ServiceCriteria();
|
||||
criteria.setLike(datasetService.getService().getLabel());
|
||||
List<eu.eudat.data.entities.Service> entries = serviceDao.getWithCriteria(criteria).toList();
|
||||
List<eu.eudat.data.entities.Service> entries = databaseRepository.getServiceDao().getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
datasetService.getService().setId(entries.get(0).getId());
|
||||
datasetService.setDataset(dataset);
|
||||
dataset.getServices().add(datasetService);
|
||||
} else {
|
||||
Service service = serviceDao.createOrUpdate(datasetService.getService());
|
||||
Service service = databaseRepository.getServiceDao().createOrUpdate(datasetService.getService());
|
||||
datasetService.setService(service);
|
||||
dataset.getServices().add(datasetService);
|
||||
}
|
||||
|
@ -349,20 +367,20 @@ public class DatasetManager {
|
|||
}
|
||||
}
|
||||
|
||||
private void createExternalDatasetsIfTheyDontExist(DatasetExternalDatasetDao datasetExternalDatasetDao, ExternalDatasetDao externalDatasetDao, eu.eudat.data.entities.Dataset dataset) {
|
||||
private void createExternalDatasetsIfTheyDontExist(eu.eudat.data.entities.Dataset dataset) {
|
||||
Set<DatasetExternalDataset> externalDatasets = dataset.getDatasetExternalDatasets();
|
||||
dataset.setDatasetExternalDatasets(new HashSet<>());
|
||||
if (externalDatasets != null && !externalDatasets.isEmpty()) {
|
||||
for (eu.eudat.data.entities.DatasetExternalDataset datasetExternalDataset : externalDatasets) {
|
||||
ExternalDatasetCriteria criteria = new ExternalDatasetCriteria();
|
||||
criteria.setLike(datasetExternalDataset.getExternalDataset().getLabel());
|
||||
List<eu.eudat.data.entities.ExternalDataset> entries = externalDatasetDao.getWithCriteria(criteria).toList();
|
||||
List<eu.eudat.data.entities.ExternalDataset> entries = databaseRepository.getExternalDatasetDao().getWithCriteria(criteria).toList();
|
||||
if (entries != null && !entries.isEmpty()) {
|
||||
datasetExternalDataset.getExternalDataset().setId(entries.get(0).getId());
|
||||
datasetExternalDataset.setDataset(dataset);
|
||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||
} else {
|
||||
ExternalDataset externalDataset = externalDatasetDao.createOrUpdate(datasetExternalDataset.getExternalDataset());
|
||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().createOrUpdate(datasetExternalDataset.getExternalDataset());
|
||||
datasetExternalDataset.setExternalDataset(externalDataset);
|
||||
dataset.getDatasetExternalDatasets().add(datasetExternalDataset);
|
||||
}
|
||||
|
@ -377,8 +395,8 @@ public class DatasetManager {
|
|||
datasetDao.createOrUpdate(dataset);
|
||||
}
|
||||
|
||||
public ResponseEntity<byte[]> getDocument(DatasetDao datasetDao, String id, VisibilityRuleService visibilityRuleService, String contentType) throws IllegalAccessException, IOException, InstantiationException {
|
||||
FileEnvelope envelope = getXmlDocument(datasetDao, id, visibilityRuleService);
|
||||
public ResponseEntity<byte[]> getDocument(String id, VisibilityRuleService visibilityRuleService, String contentType) throws IllegalAccessException, IOException, InstantiationException {
|
||||
FileEnvelope envelope = getXmlDocument(id, visibilityRuleService);
|
||||
InputStream resource = new FileInputStream(envelope.getFile());
|
||||
System.out.println("Mime Type of " + envelope.getFilename() + " is " +
|
||||
new MimetypesFileTypeMap().getContentType(envelope.getFile()));
|
||||
|
|
|
@ -9,6 +9,7 @@ import eu.eudat.data.query.items.item.datasetprofile.DatasetProfileAutocompleteR
|
|||
import eu.eudat.data.query.items.table.datasetprofile.DatasetProfileTableRequestItem;
|
||||
import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.logic.utilities.builders.XmlBuilder;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.xml.datasetProfileXml.ExportXmlBuilderDatasetProfile;
|
||||
|
@ -20,6 +21,7 @@ import eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.Field;
|
|||
import eu.eudat.models.data.helpermodels.Tuple;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
@ -39,29 +41,37 @@ import java.io.*;
|
|||
@Component
|
||||
public class DatasetProfileManager {
|
||||
|
||||
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileDao datasetProfileRepository, DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
@Autowired
|
||||
public DatasetProfileManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public List<DatasetProfileAutocompleteItem> getWithCriteria(DatasetProfileAutocompleteRequest datasetProfileAutocompleteRequest) throws IllegalAccessException, InstantiationException {
|
||||
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(datasetProfileAutocompleteRequest.getCriteria());
|
||||
List<DatasetProfileAutocompleteItem> datasetProfiles = items.select(item -> new DatasetProfileAutocompleteItem().fromDataModel(item));
|
||||
return datasetProfiles;
|
||||
}
|
||||
|
||||
public DatasetProfile clone(ApiContext apiContext, String id) {
|
||||
public DatasetProfile clone(String id) {
|
||||
DatasetProfile profile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(UUID.fromString(id));
|
||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(profile);
|
||||
profile.setId(null);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public DataTableData<DatasetProfileListingModel> getPaged(ApiContext apiContext, DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
||||
public DataTableData<DatasetProfileListingModel> getPaged(DatasetProfileTableRequestItem datasetProfileTableRequestItem) throws Exception {
|
||||
QueryableList<DatasetProfile> items = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().getWithCriteria(datasetProfileTableRequestItem.getCriteria());
|
||||
QueryableList<DatasetProfile> pagedItems = PaginationManager.applyPaging(items, datasetProfileTableRequestItem);
|
||||
List<DatasetProfileListingModel> datasetProfiles = pagedItems.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(datasetProfiles).totalCount(items.count()).build();
|
||||
}
|
||||
|
||||
public List<DatasetProfileListingModel> getAll(DatasetProfileDao datasetProfileRepository) throws IllegalAccessException, InstantiationException {
|
||||
public List<DatasetProfileListingModel> getAll() throws IllegalAccessException, InstantiationException {
|
||||
DatasetProfileCriteria criteria = new DatasetProfileCriteria();
|
||||
QueryableList<DatasetProfile> items = datasetProfileRepository.getWithCriteria(criteria);
|
||||
QueryableList<DatasetProfile> items = databaseRepository.getDatasetProfileDao().getWithCriteria(criteria);
|
||||
List<DatasetProfileListingModel> datasetProfiles = items.select(item -> new DatasetProfileListingModel().fromDataModel(item));
|
||||
return datasetProfiles;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package eu.eudat.logic.managers;
|
||||
|
||||
import eu.eudat.data.dao.entities.DatasetDao;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.forms.VisibilityRuleService;
|
||||
import eu.eudat.logic.utilities.documents.helpers.FileEnvelope;
|
||||
import eu.eudat.logic.utilities.documents.word.WordBuilder;
|
||||
|
@ -11,10 +12,12 @@ import eu.eudat.models.data.user.composite.PagedDatasetProfile;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.poi.xwpf.usermodel.XWPFDocument;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
|
@ -31,7 +34,16 @@ import java.util.zip.ZipInputStream;
|
|||
/**
|
||||
* Created by ikalyvas on 10/16/2018.
|
||||
*/
|
||||
@Service
|
||||
public class DocumentManager {
|
||||
|
||||
private ApiContext context;
|
||||
private DatasetManager datasetManager;
|
||||
public DocumentManager(ApiContext context, DatasetManager datasetManager) {
|
||||
this.context = context;
|
||||
this.datasetManager = datasetManager;
|
||||
}
|
||||
|
||||
public File getWordDocument(Environment environment, DatasetDao datatasetRepository, String id, VisibilityRuleService visibilityRuleService) throws InstantiationException, IllegalAccessException, IOException {
|
||||
WordBuilder wordBuilder = new WordBuilder();
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
|
@ -44,7 +56,7 @@ public class DocumentManager {
|
|||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
properties = jobject.toMap();
|
||||
}
|
||||
PagedDatasetProfile pagedDatasetProfile = new DatasetManager().getPagedProfile(dataset, datasetEntity);
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
wordBuilder.build(document, pagedDatasetProfile, visibilityRuleService);
|
||||
|
@ -63,7 +75,7 @@ public class DocumentManager {
|
|||
JSONObject jobject = new JSONObject(datasetEntity.getProperties());
|
||||
properties = jobject.toMap();
|
||||
}
|
||||
PagedDatasetProfile pagedDatasetProfile = new DatasetManager().getPagedProfile(dataset, datasetEntity);
|
||||
PagedDatasetProfile pagedDatasetProfile = datasetManager.getPagedProfile(dataset, datasetEntity);
|
||||
visibilityRuleService.setProperties(properties);
|
||||
visibilityRuleService.buildVisibilityContext(pagedDatasetProfile.getRules());
|
||||
File file = xmlBuilder.build(pagedDatasetProfile, visibilityRuleService);
|
||||
|
|
|
@ -5,6 +5,7 @@ import eu.eudat.logic.builders.model.models.DataTableDataBuilder;
|
|||
import eu.eudat.data.dao.entities.ExternalDatasetDao;
|
||||
import eu.eudat.data.entities.ExternalDataset;
|
||||
import eu.eudat.data.dao.criteria.ExternalDatasetCriteria;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.externaldataset.ExternalDatasetListingModel;
|
||||
import eu.eudat.data.query.items.table.externaldataset.ExternalDatasetTableRequest;
|
||||
import eu.eudat.models.data.helpers.common.DataTableData;
|
||||
|
@ -13,6 +14,7 @@ import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -21,28 +23,38 @@ import java.util.UUID;
|
|||
@Component
|
||||
public class ExternalDatasetManager {
|
||||
|
||||
public DataTableData<ExternalDatasetListingModel> getPaged(ApiContext apiContext, ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
@Autowired
|
||||
public ExternalDatasetManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public DataTableData<ExternalDatasetListingModel> getPaged(ExternalDatasetTableRequest externalDatasetTableRequest) throws Exception {
|
||||
QueryableList<ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(externalDatasetTableRequest.getCriteria());
|
||||
QueryableList<ExternalDataset> pagedItems = PaginationManager.applyPaging(items, externalDatasetTableRequest);
|
||||
List<ExternalDatasetListingModel> externalDatasetListingmodels = pagedItems.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
||||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).data(externalDatasetListingmodels).totalCount(items.count()).build();
|
||||
}
|
||||
|
||||
public List<ExternalDatasetListingModel> getWithExternal(ApiContext apiContext, String query, RemoteFetcher remoteFetcher) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
public List<ExternalDatasetListingModel> getWithExternal(String query) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDatasetCriteria criteria = apiContext.getOperationsContext().getBuilderFactory().getBuilder(ExternalDatasetCriteriaBuilder.class).like(query).build();
|
||||
QueryableList<eu.eudat.data.entities.ExternalDataset> items = apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().getWithCriteria(criteria);
|
||||
List<ExternalDatasetListingModel> externalDatasets = items.select(item -> new ExternalDatasetListingModel().fromDataModel(item));
|
||||
return externalDatasets;
|
||||
}
|
||||
|
||||
public ExternalDatasetListingModel getSingle(ExternalDatasetDao externalDatasetDao, UUID id) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDataset externalDataset = externalDatasetDao.find(id);
|
||||
public ExternalDatasetListingModel getSingle(UUID id) throws HugeResultSet, NoURLFound, InstantiationException, IllegalAccessException {
|
||||
ExternalDataset externalDataset = databaseRepository.getExternalDatasetDao().find(id);
|
||||
ExternalDatasetListingModel externalDatasetModel = new ExternalDatasetListingModel();
|
||||
externalDatasetModel.fromDataModel(externalDataset);
|
||||
return externalDatasetModel;
|
||||
}
|
||||
|
||||
public ExternalDataset create(ApiContext apiContext, eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception {
|
||||
public ExternalDataset create(eu.eudat.models.data.externaldataset.ExternalDatasetModel externalDatasetModel) throws Exception {
|
||||
ExternalDataset externalDataset = externalDatasetModel.toDataModel();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getExternalDatasetDao().createOrUpdate(externalDataset);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,9 @@ package eu.eudat.logic.managers;
|
|||
|
||||
import eu.eudat.models.data.files.ContentFile;
|
||||
import eu.eudat.logic.services.helpers.FileStorageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.io.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -11,13 +13,21 @@ import java.util.List;
|
|||
/**
|
||||
* Created by ikalyvas on 3/15/2018.
|
||||
*/
|
||||
@Component
|
||||
public class FileManager {
|
||||
|
||||
public static List<ContentFile> saveTempFile(MultipartFile file[], FileStorageService fileStorageService) throws IOException {
|
||||
private FileStorageService fileStorageService;
|
||||
|
||||
@Autowired
|
||||
public FileManager(FileStorageService fileStorageService) {
|
||||
this.fileStorageService = fileStorageService;
|
||||
}
|
||||
|
||||
public List<ContentFile> saveTempFile(MultipartFile file[]) throws IOException {
|
||||
return fileStorageService.writeToTempFileSystem(file);
|
||||
}
|
||||
|
||||
public static Resource getFile(String filename, String type, FileStorageService fileStorageService, String location) throws IOException {
|
||||
public Resource getFile(String filename, String type, String location) throws IOException {
|
||||
return fileStorageService.readFromFilesystem(filename, type, location);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,15 +9,24 @@ import eu.eudat.models.data.userinfo.UserInfoInvitationModel;
|
|||
import eu.eudat.data.query.items.item.userinfo.UserInfoRequestItem;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@Component
|
||||
public class InvitationsManager {
|
||||
|
||||
public static void inviteUsers(ApiContext apiContext, Invitation invitation, Principal principal) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
|
||||
@Autowired
|
||||
public InvitationsManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
public void inviteUsers(Invitation invitation, Principal principal) throws Exception {
|
||||
UserInfo principalUser = new UserInfo();
|
||||
principalUser.setId(principal.getId());
|
||||
List<UserInfoInvitationModel> alreadySignedInUsers = invitation.getUsers().stream().filter(item -> item.getId() != null).collect(Collectors.toList());
|
||||
|
@ -27,13 +36,13 @@ public class InvitationsManager {
|
|||
apiContext.getUtilitiesService().getInvitationService().assignToDmp(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao(), alreadySignedInUsersEntities, dataManagementPlan);
|
||||
}
|
||||
|
||||
public static List<UserInfoInvitationModel> getUsers(ApiContext apiContext, UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||
public List<UserInfoInvitationModel> getUsers(UserInfoRequestItem userInfoRequestItem) throws InstantiationException, IllegalAccessException {
|
||||
QueryableList<UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoRequestItem.getCriteria());
|
||||
List<UserInfoInvitationModel> userModels = users.select(item -> new UserInfoInvitationModel().fromDataModel(item));
|
||||
return userModels;
|
||||
}
|
||||
|
||||
public static UUID assignUserAcceptedInvitation(ApiContext apiContext, UUID invitationID, Principal principal) throws UnauthorisedException {
|
||||
public UUID assignUserAcceptedInvitation(UUID invitationID, Principal principal) throws UnauthorisedException {
|
||||
eu.eudat.data.entities.Invitation invitation = apiContext.getOperationsContext().getDatabaseRepository().getInvitationDao().find(invitationID);
|
||||
if (invitation == null)
|
||||
throw new UnauthorisedException("There is no Data Management Plan assigned to this Link");
|
||||
|
|
|
@ -9,6 +9,7 @@ import eu.eudat.data.dao.entities.UserInfoDao;
|
|||
import eu.eudat.data.entities.Content;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
import eu.eudat.exceptions.files.TempFileNotFoundException;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.HintedModelFactory;
|
||||
import eu.eudat.models.data.external.ExternalSourcesItemModel;
|
||||
import eu.eudat.models.data.external.ProjectsExternalSourcesModel;
|
||||
|
@ -39,12 +40,24 @@ import java.util.stream.Collectors;
|
|||
@Component
|
||||
public class ProjectManager {
|
||||
|
||||
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
private FileStorageService fileStorageService;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
|
||||
public ProjectManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
this.fileStorageService = apiContext.getOperationsContext().getFileStorageService();
|
||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public DataTableData<eu.eudat.models.data.project.ProjectListingModel> getPaged(ProjectTableRequest projectTableRequest, Principal principal, String fieldsGroup) throws Exception {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||
QueryableList<eu.eudat.data.entities.Project> authItems = projectRepository.getAuthenticated(items, userInfo);
|
||||
|
||||
QueryableList<eu.eudat.data.entities.Project> pagedItems = PaginationManager.applyPaging(authItems, projectTableRequest);
|
||||
DataTableData<eu.eudat.models.data.project.ProjectListingModel> dataTable = new DataTableData<>();
|
||||
CompletableFuture projectsFuture;
|
||||
|
@ -75,20 +88,21 @@ public class ProjectManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.project.Project getSingle(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException {
|
||||
public eu.eudat.models.data.project.Project getSingle(String id) throws InstantiationException, IllegalAccessException {
|
||||
eu.eudat.models.data.project.Project project = new eu.eudat.models.data.project.Project();
|
||||
project.fromDataModel(projectRepository.find(UUID.fromString(id)));
|
||||
project.fromDataModel(databaseRepository.getProjectDao().find(UUID.fromString(id)));
|
||||
return project;
|
||||
}
|
||||
|
||||
public eu.eudat.data.entities.Project inactivate(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException {
|
||||
public eu.eudat.data.entities.Project inactivate(String id) throws InstantiationException, IllegalAccessException {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
eu.eudat.data.entities.Project project = projectRepository.find(UUID.fromString(id));
|
||||
project.setStatus(eu.eudat.data.entities.Project.Status.DELETED.getValue());
|
||||
project = projectRepository.createOrUpdate(project);
|
||||
return project;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.project.Project> getCriteriaWithExternal(ApiContext apiContext, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher, Principal principal) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
public List<eu.eudat.models.data.project.Project> getCriteriaWithExternal(ProjectCriteriaRequest projectCriteria, Principal principal) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
eu.eudat.data.entities.UserInfo userInfo = new eu.eudat.data.entities.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
QueryableList<eu.eudat.data.entities.Project> items = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().getWithCriteria(projectCriteria.getCriteria());
|
||||
|
@ -109,14 +123,15 @@ public class ProjectManager {
|
|||
return projects;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria, RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
public List<eu.eudat.models.data.project.Project> getCriteria(ProjectCriteriaRequest projectCriteria) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
ProjectDao projectRepository = databaseRepository.getProjectDao();
|
||||
QueryableList<eu.eudat.data.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
if (projectCriteria.getLength() != null) items.take(projectCriteria.getLength());
|
||||
List<eu.eudat.models.data.project.Project> projects = items.select(item -> new Project().fromDataModel(item));
|
||||
return projects;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(FileStorageService fileStorageService, ProjectDao projectRepository, ContentDao contentRepository, UserInfoDao userInfoRepository, eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
public void createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
||||
if (project.getFiles() != null) {
|
||||
for (ContentFile file : project.getFiles()) {
|
||||
|
@ -128,18 +143,18 @@ public class ProjectManager {
|
|||
.parentType(Content.ParentType.PROJECT.getValue())
|
||||
.uri("LOCAL:" + storedFile.getId())
|
||||
.build();
|
||||
projectEntity.setContent(contentRepository.createOrUpdate(content));
|
||||
projectEntity.setContent(databaseRepository.getContentDao().createOrUpdate(content));
|
||||
} catch (TempFileNotFoundException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||
projectEntity.setCreationUser(userInfoRepository.find(principal.getId()));
|
||||
projectRepository.createOrUpdate(projectEntity);
|
||||
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||
}
|
||||
|
||||
public void delete(ApiContext apiContext, UUID uuid) {
|
||||
public void delete(UUID uuid) {
|
||||
eu.eudat.data.entities.Project oldProject = apiContext.getOperationsContext().getDatabaseRepository().getProjectDao().find(uuid);
|
||||
if (oldProject.getDmps().size() > 0)
|
||||
throw new ProjectWithDMPsDeleteException("You cannot Remove Projects with DMPs");
|
||||
|
|
|
@ -7,10 +7,13 @@ import eu.eudat.data.dao.entities.UserInfoDao;
|
|||
import eu.eudat.data.entities.*;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.logic.services.helpers.FileStorageService;
|
||||
import eu.eudat.logic.services.operations.DatabaseRepository;
|
||||
import eu.eudat.models.data.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.data.quickwizard.DatasetDescriptionQuickWizardModel;
|
||||
import eu.eudat.models.data.quickwizard.QuickWizardModel;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import eu.eudat.data.entities.DMP;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
@ -18,35 +21,43 @@ import java.text.ParseException;
|
|||
@Component
|
||||
public class QuickWizardManager {
|
||||
|
||||
private ApiContext apiContext;
|
||||
private DatabaseRepository databaseRepository;
|
||||
|
||||
public static Project createOrUpdate(FileStorageService fileStorageService, ProjectDao projectRepository, ContentDao contentRepository, UserInfoDao userInfoRepository, eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
@Autowired
|
||||
public QuickWizardManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.databaseRepository = apiContext.getOperationsContext().getDatabaseRepository();
|
||||
}
|
||||
|
||||
public Project createOrUpdate(eu.eudat.models.data.project.Project project, Principal principal) throws ParseException, IOException {
|
||||
eu.eudat.data.entities.Project projectEntity = project.toDataModel();
|
||||
projectEntity.setType(eu.eudat.data.entities.Project.ProjectType.INTERNAL.getValue());
|
||||
projectEntity.setCreationUser(userInfoRepository.find(principal.getId()));
|
||||
Project projectEntityRet = projectRepository.createOrUpdate(projectEntity);
|
||||
projectEntity.setCreationUser(databaseRepository.getUserInfoDao().find(principal.getId()));
|
||||
Project projectEntityRet = databaseRepository.getProjectDao().createOrUpdate(projectEntity);
|
||||
return projectEntityRet;
|
||||
}
|
||||
|
||||
public DMP createOrUpdate(ApiContext apiContext, DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
public DMP createOrUpdate(DataManagementPlan dataManagementPlan, Principal principal) throws Exception {
|
||||
DMP newDmp = dataManagementPlan.toDataModel();
|
||||
UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
createProjectIfItDoesntExist(newDmp, apiContext.getOperationsContext().getDatabaseRepository().getProjectDao(), user);
|
||||
createProjectIfItDoesntExist(newDmp, user);
|
||||
newDmp.setCreator(user);
|
||||
DMP dmpret = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().createOrUpdate(newDmp);
|
||||
return dmpret;
|
||||
}
|
||||
|
||||
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, ProjectDao projectDao, UserInfo userInfo) {
|
||||
private void createProjectIfItDoesntExist(DMP newDmp, UserInfo userInfo) {
|
||||
if (newDmp.getProject() != null) {
|
||||
Project project = newDmp.getProject();
|
||||
ProjectCriteria criteria = new ProjectCriteria();
|
||||
criteria.setReference(project.getReference());
|
||||
eu.eudat.data.entities.Project projectEntity = projectDao.getWithCriteria(criteria).getSingleOrDefault();
|
||||
eu.eudat.data.entities.Project projectEntity = databaseRepository.getProjectDao().getWithCriteria(criteria).getSingleOrDefault();
|
||||
if (projectEntity != null) project.setId(projectEntity.getId());
|
||||
else {
|
||||
project.setType(Project.ProjectType.EXTERNAL.getValue());
|
||||
projectDao.createOrUpdate(project);
|
||||
databaseRepository.getProjectDao().createOrUpdate(project);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,20 @@ import eu.eudat.data.entities.Registry;
|
|||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.datarepository.DataRepositoryModel;
|
||||
import eu.eudat.models.data.registries.RegistryModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 9/3/2018.
|
||||
*/
|
||||
@Component
|
||||
public class RegistryManager {
|
||||
public Registry create(ApiContext apiContext, RegistryModel registryModel) throws Exception {
|
||||
|
||||
private ApiContext apiContext;
|
||||
|
||||
@Autowired
|
||||
public RegistryManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
public Registry create(RegistryModel registryModel) throws Exception {
|
||||
Registry registry = registryModel.toDataModel();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getRegistryDao().createOrUpdate(registry);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import eu.eudat.logic.proxy.config.exceptions.NoURLFound;
|
|||
import eu.eudat.logic.proxy.fetching.RemoteFetcher;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.logic.services.ApiContext;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -22,12 +23,21 @@ import java.util.stream.Collectors;
|
|||
@Component
|
||||
public class ResearcherManager {
|
||||
|
||||
public Researcher create(ApiContext apiContext, eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
|
||||
private ApiContext apiContext;
|
||||
private RemoteFetcher remoteFetcher;
|
||||
|
||||
@Autowired
|
||||
public ResearcherManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
this.remoteFetcher = apiContext.getOperationsContext().getRemoteFetcher();
|
||||
}
|
||||
|
||||
public Researcher create(eu.eudat.models.data.researcher.Researcher researcher) throws Exception {
|
||||
Researcher researcherEntity = researcher.toDataModel();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().createOrUpdate(researcherEntity);
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.data.dmp.Researcher> getCriteriaWithExternal(ApiContext apiContext, RemoteFetcher remoteFetcher, ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound {
|
||||
public List<eu.eudat.models.data.dmp.Researcher> getCriteriaWithExternal(ResearcherCriteriaRequest researcherCriteriaRequest) throws HugeResultSet, NoURLFound {
|
||||
|
||||
QueryableList<eu.eudat.data.entities.Researcher> items = apiContext.getOperationsContext().getDatabaseRepository().getResearcherDao().getWithCriteria(researcherCriteriaRequest.getCriteria());
|
||||
List<eu.eudat.models.data.dmp.Researcher> researchers = items.select(item -> new eu.eudat.models.data.dmp.Researcher().fromDataModel(item));
|
||||
|
|
|
@ -5,12 +5,23 @@ import eu.eudat.data.entities.Service;
|
|||
import eu.eudat.logic.services.ApiContext;
|
||||
import eu.eudat.models.data.registries.RegistryModel;
|
||||
import eu.eudat.models.data.services.ServiceModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 9/3/2018.
|
||||
*/
|
||||
@Component
|
||||
public class ServiceManager {
|
||||
public static Service create(ApiContext apiContext, ServiceModel serviceModel) throws Exception {
|
||||
|
||||
private ApiContext apiContext;
|
||||
|
||||
@Autowired
|
||||
public ServiceManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
public Service create(ServiceModel serviceModel) throws Exception {
|
||||
Service service = serviceModel.toDataModel();
|
||||
return apiContext.getOperationsContext().getDatabaseRepository().getServiceDao().createOrUpdate(service);
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@ import eu.eudat.models.data.userinfo.UserListingModel;
|
|||
import eu.eudat.models.data.userinfo.UserProfile;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
|
@ -29,8 +31,17 @@ import java.util.Map;
|
|||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class UserManager {
|
||||
public static eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
|
||||
|
||||
private ApiContext apiContext;
|
||||
|
||||
@Autowired
|
||||
public UserManager(ApiContext apiContext) {
|
||||
this.apiContext = apiContext;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.user.composite.DatasetProfile generateDatasetProfileModel(eu.eudat.data.entities.DatasetProfile profile) {
|
||||
Document viewStyleDoc = XmlBuilder.fromXml(profile.getDefinition());
|
||||
Element root = (Element) viewStyleDoc.getDocumentElement();
|
||||
eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel viewstyle = new eu.eudat.models.data.entities.xmlmodels.datasetprofiledefinition.ViewStyleModel().fromXml(root);
|
||||
|
@ -41,7 +52,7 @@ public class UserManager {
|
|||
return datasetprofile;
|
||||
}
|
||||
|
||||
public static DataTableData<UserListingModel> getPaged(ApiContext apiContext, UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
|
||||
public DataTableData<UserListingModel> getPaged(UserInfoTableRequestItem userInfoTableRequestItem) throws Exception {
|
||||
QueryableList<eu.eudat.data.entities.UserInfo> users = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().getWithCriteria(userInfoTableRequestItem.getCriteria()).withHint(HintedModelFactory.getHint(UserListingModel.class));
|
||||
QueryableList<eu.eudat.data.entities.UserInfo> pagedUsers = PaginationManager.applyPaging(users, userInfoTableRequestItem);
|
||||
|
||||
|
@ -49,7 +60,7 @@ public class UserManager {
|
|||
return apiContext.getOperationsContext().getBuilderFactory().getBuilder(DataTableDataBuilder.class).totalCount(users.count()).data(modelUsers).build();
|
||||
}
|
||||
|
||||
public static UserProfile getSingle(ApiContext apiContext, UUID userId) throws Exception {
|
||||
public UserProfile getSingle(UUID userId) throws Exception {
|
||||
eu.eudat.data.entities.UserInfo user = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(userId);
|
||||
UserProfile profile = new UserProfile().fromDataModel(user);
|
||||
List<DMP> dmps = apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().getAuthenticated(apiContext.getOperationsContext().getDatabaseRepository().getDmpDao().asQueryable(), user).take(5).toList();
|
||||
|
@ -57,7 +68,7 @@ public class UserManager {
|
|||
return profile;
|
||||
}
|
||||
|
||||
public static void editRoles(ApiContext apiContext, UserListingModel user) {
|
||||
public void editRoles(UserListingModel user) {
|
||||
eu.eudat.data.entities.UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(user.getId());
|
||||
userInfo.getUserRoles().stream().forEach(item -> apiContext.getOperationsContext().getDatabaseRepository().getUserRoleDao().delete(item));
|
||||
for (Integer role : user.getAppRoles()) {
|
||||
|
@ -66,7 +77,7 @@ public class UserManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void updateSettings(ApiContext apiContext, Map<String, Object> settings, Principal principal) throws IOException {
|
||||
public void updateSettings(Map<String, Object> settings, Principal principal) throws IOException {
|
||||
eu.eudat.data.entities.UserInfo userInfo = apiContext.getOperationsContext().getDatabaseRepository().getUserInfoDao().find(principal.getId());
|
||||
apiContext.getOperationsContext().getDatabaseRepository().detachEntity(userInfo);
|
||||
HashMap<String, Object> result =
|
||||
|
@ -77,7 +88,7 @@ public class UserManager {
|
|||
.createOrUpdate(userInfo);
|
||||
}
|
||||
|
||||
public static Principal authenticate(AuthenticationServiceImpl authenticationServiceImpl, Credentials credentials) {
|
||||
public Principal authenticate(AuthenticationServiceImpl authenticationServiceImpl, Credentials credentials) {
|
||||
Principal principal = authenticationServiceImpl.Touch(credentials);
|
||||
if (principal == null) throw new UnauthorisedException("Could not Sign In User");
|
||||
return principal;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package eu.eudat.models.data.quickwizard;
|
||||
|
||||
import eu.eudat.data.dao.entities.UserInfoDao;
|
||||
import eu.eudat.data.entities.Project;
|
||||
import eu.eudat.models.data.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.data.security.Principal;
|
||||
|
@ -16,7 +15,7 @@ public class DmpQuickWizardModel {
|
|||
private UUID id;
|
||||
private String label;
|
||||
private int status;
|
||||
private AssociatedProfile profile;
|
||||
private AssociatedProfile datasetProfile;
|
||||
private String description;
|
||||
private eu.eudat.models.data.project.Project project;
|
||||
|
||||
|
@ -45,12 +44,8 @@ public class DmpQuickWizardModel {
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
public AssociatedProfile getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(AssociatedProfile profile) {
|
||||
this.profile = profile;
|
||||
public void setDatasetProfile(AssociatedProfile datasetProfile) {
|
||||
this.datasetProfile = datasetProfile;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
|
@ -69,7 +64,7 @@ public class DmpQuickWizardModel {
|
|||
this.project = project;
|
||||
}
|
||||
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(UserInfoDao userInfoRepository ,Project project, Principal principal) {
|
||||
public eu.eudat.models.data.dmp.DataManagementPlan toDataDmp(Project project, Principal principal) {
|
||||
eu.eudat.models.data.dmp.DataManagementPlan dataManagementPlanEntity = new eu.eudat.models.data.dmp.DataManagementPlan();
|
||||
|
||||
dataManagementPlanEntity.setId(this.id);
|
||||
|
@ -80,9 +75,9 @@ public class DmpQuickWizardModel {
|
|||
eu.eudat.models.data.project.Project importProject = new eu.eudat.models.data.project.Project();
|
||||
dataManagementPlanEntity.setProject(importProject.fromDataModel(project));
|
||||
}
|
||||
if(this.profile!=null) {
|
||||
if (this.datasetProfile != null) {
|
||||
List<AssociatedProfile> assProfile = new LinkedList<>();
|
||||
assProfile.add(this.profile);
|
||||
assProfile.add(this.datasetProfile);
|
||||
dataManagementPlanEntity.setProfiles(assProfile);
|
||||
}
|
||||
dataManagementPlanEntity.setStatus((short) this.status);
|
||||
|
@ -90,19 +85,18 @@ public class DmpQuickWizardModel {
|
|||
dataManagementPlanEntity.setProperties(null);
|
||||
dataManagementPlanEntity.setCreated(new Date());
|
||||
List<UserInfo> user = new LinkedList<UserInfo>();
|
||||
eu.eudat.models.data.userinfo.UserInfo usetInfo = new eu.eudat.models.data.userinfo.UserInfo();
|
||||
usetInfo.fromDataModel(userInfoRepository.find(principal.getId()));
|
||||
user.add(usetInfo);
|
||||
eu.eudat.models.data.userinfo.UserInfo userInfo = new eu.eudat.models.data.userinfo.UserInfo();
|
||||
userInfo.setId(principal.getId());
|
||||
dataManagementPlanEntity.setAssociatedUsers(user);
|
||||
return dataManagementPlanEntity;
|
||||
}
|
||||
|
||||
|
||||
public eu.eudat.data.entities.DatasetProfile getDatasetProfile(){
|
||||
public eu.eudat.data.entities.DatasetProfile getDatasetProfile() {
|
||||
eu.eudat.data.entities.DatasetProfile datasetProfile = new eu.eudat.data.entities.DatasetProfile();
|
||||
datasetProfile.setDefinition(this.profile.getLabel());
|
||||
datasetProfile.setLabel(this.profile.getLabel());
|
||||
datasetProfile.setId(this.profile.getId());
|
||||
datasetProfile.setDefinition(this.datasetProfile.getLabel());
|
||||
datasetProfile.setLabel(this.datasetProfile.getLabel());
|
||||
datasetProfile.setId(this.datasetProfile.getId());
|
||||
return datasetProfile;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue