Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
5a79779335
|
@ -39,7 +39,7 @@ public class Admin {
|
|||
modelDefinition.setViewstyle(viewStyleDefinition);
|
||||
datasetProfileDao.createOrUpdate(modelDefinition);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body("");
|
||||
return ResponseEntity.status(HttpStatus.OK).body(modelDefinition.getId());
|
||||
}catch(Exception ex){
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("{\"reason\":\""+ex.getMessage()+"\"}");
|
||||
|
|
|
@ -65,12 +65,8 @@ public class DMPs {
|
|||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
|
||||
|
||||
// FETCH BY DMP(S)
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<DataTableData<DataManagementPlanListingModel>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
try {
|
||||
|
@ -124,361 +120,5 @@ public class DMPs {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dmps" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<List<UUID>> listDMPs(){
|
||||
// try {
|
||||
// List<UUID> allIDs = dMPDao.listAllIDs();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dmps/{id}" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<DataManagementPlan> getDMP(@PathVariable("id") String id){
|
||||
// try {
|
||||
// DMP dmp = dMPDao.read(UUID.fromString(id));
|
||||
// DataManagementPlan dataManagementPlan = new DataManagementPlan();
|
||||
// dataManagementPlan.fromDataModel(dmp);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(dataManagementPlan);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/listDMPLabelID" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<List<IDLabelPair>> listDmpLabelID(){
|
||||
// try {
|
||||
// List<IDLabelPair> allIDLabels = dMPDao.listAllIDsLabels();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allIDLabels);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * This should be called on extreme cases. It's computationally intensive
|
||||
// */
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/getAll" }, produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> getAllDMPs(){
|
||||
//
|
||||
// try {
|
||||
// List<DMP> allDMPs = dMPDao.getAll();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allDMPs);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/create" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<DMP> createDMP(@RequestBody DMP dmp) {
|
||||
// try {
|
||||
// DMP createdDmp = dMPDao.update(dmp);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(createdDmp);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @Transactional
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/update" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<DMP> updateDMP(@RequestBody DataManagementPlan dataManagementPlan) {
|
||||
//
|
||||
// DMP newDmp = dataManagementPlan.toDataModel();
|
||||
// if(newDmp.getOrganisations()!=null&&!newDmp.getOrganisations().isEmpty()){
|
||||
// for(eu.eudat.entities.Organisation organisation: newDmp.getOrganisations()){
|
||||
// OrganisationCriteria criteria = new OrganisationCriteria();
|
||||
// criteria.setLike(organisation.getReference());
|
||||
// List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
||||
// else organisation = this.organisationDao.create(organisation);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(newDmp.getResearchers()!=null&&!newDmp.getResearchers().isEmpty()){
|
||||
// for(eu.eudat.entities.Researcher researcher : newDmp.getResearchers()){
|
||||
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||
// criteria.setLike(researcher.getReference());
|
||||
// List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
||||
// else researcher = this.researcherDao.create(researcher);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// DMP previousDmp = dMPDao.read(dataManagementPlan.getId());
|
||||
// previousDmp.setResearchers(newDmp.getResearchers());
|
||||
// previousDmp.setOrganisations(newDmp.getOrganisations());
|
||||
// previousDmp.setLabel(dataManagementPlan.getLabel());
|
||||
// previousDmp.setVersion(dataManagementPlan.getVersion());
|
||||
// previousDmp.setStatus((short)dataManagementPlan.getStatus());
|
||||
// //if(!previousDmp.getProject().getId().equals(newDmp.getProject().getId()))previousDmp.setProject(projectDao.read(newDmp.getProject().getId()));
|
||||
//
|
||||
// try {
|
||||
// DMP updatedDMP = dMPDao.update(previousDmp);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(updatedDMP);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/getdatasets" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<List<Dataset>> getDatasetsOfDMP(@RequestBody DMP dmp) {
|
||||
// try {
|
||||
// List<Dataset> datasets = datasetDao.getDatasetsOfDmp(dmp.getId());
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(datasets);
|
||||
// } catch (Exception e) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/delete" }, consumes = "application/json", produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<Object> delete(@RequestBody DMP dmp) {
|
||||
//
|
||||
// DMP d = new DMP();
|
||||
// d.setId(dmp.getId());
|
||||
// try {
|
||||
// dMPDao.delete(d);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP!\"");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody DMP dmp) {
|
||||
//
|
||||
// try{
|
||||
// DMP d = dMPDao.read(dmp.getId());
|
||||
// d.setStatus(new Short("-1"));
|
||||
// dMPDao.update(d);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"deleted DMP!\"");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\"");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ////////////////////////////////
|
||||
// //// USER - RELATED ACTIONS ////
|
||||
// ////////////////////////////////
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/getofuser" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<List<DMP>> getDmpsOfUser(){
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// //List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
|
||||
// List<DMP> nonDeleted = dMPDao.getDMPsOfUser(userID);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(nonDeleted);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain", consumes = "application/json")
|
||||
// public @ResponseBody ResponseEntity<DMP> createDmpOfUser(@RequestBody DataManagementPlan dataManagementPlan){
|
||||
//
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happer
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
//
|
||||
// try {
|
||||
// DMP dmp = dataManagementPlan.toDataModel();
|
||||
//
|
||||
// if(dmp.getOrganisations()!=null&&!dmp.getOrganisations().isEmpty()){
|
||||
// for(eu.eudat.entities.Organisation organisation: dmp.getOrganisations()){
|
||||
// OrganisationCriteria criteria = new OrganisationCriteria();
|
||||
// criteria.setLike(organisation.getReference());
|
||||
// List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
||||
// else organisation = this.organisationDao.create(organisation);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(dmp.getResearchers()!=null&&!dmp.getResearchers().isEmpty()){
|
||||
// for(eu.eudat.entities.Researcher researcher : dmp.getResearchers()){
|
||||
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||
// criteria.setLike(researcher.getReference());
|
||||
// List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
||||
// else researcher = this.researcherDao.create(researcher);
|
||||
// }
|
||||
// }
|
||||
// dmp.setId(null);
|
||||
//
|
||||
// dmp.setCreator(userInfo);
|
||||
// dmp.setProject(this.projectDao.read(dataManagementPlan.getProject().getId()));
|
||||
// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||
// users.add(userInfo);
|
||||
// dmp.setUsers(users);
|
||||
//
|
||||
// dmp.setCreated(new Date());
|
||||
// dmp.setModified(new Date());
|
||||
// dmp.setStatus(new Short("0"));
|
||||
//
|
||||
// DMP newdmp = dMPDao.create(dmp);
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(newdmp);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/cloneforuser" }, produces="text/plain", consumes = "application/json")
|
||||
// public @ResponseBody ResponseEntity<DMP> cloneDmpOfUser(@RequestBody DMP dmp){
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happer
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
//
|
||||
// DMP clone = dMPDao.read(dmp.getId());
|
||||
//
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||
// users.add(userInfo);
|
||||
// clone.setUsers(users);
|
||||
//
|
||||
// clone.setCreated(new Date());
|
||||
// clone.setModified(new Date());
|
||||
// clone.setStatus(new Short("0"));
|
||||
//
|
||||
// String cloneLabel = dmp.getLabel();
|
||||
// if(cloneLabel==null || cloneLabel.isEmpty()) //if the provided label is null or empty, use parent's label + "_clone"
|
||||
// cloneLabel = clone.getLabel()+"_clone";
|
||||
// clone.setVersion(clone.getVersion()+1);
|
||||
// clone.setLabel(cloneLabel);
|
||||
// clone.setPrevious(clone.getId());
|
||||
//
|
||||
//
|
||||
// clone.setId(null);
|
||||
//
|
||||
// clone = dMPDao.create(clone);
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(clone);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/adduser" }, produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<DMP> addUserToDmp(@RequestBody DMP dmp){
|
||||
//
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// final UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happer
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
//
|
||||
// if(dmp==null || dmp.getId()==null)
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
//
|
||||
// try {
|
||||
//
|
||||
// DMP existingDMP = dMPDao.read(dmp.getId());
|
||||
//
|
||||
// Set<UserInfo> users = existingDMP.getUsers().parallelStream().filter(user -> user.getId().toString() != userInfo.getId().toString()).collect(Collectors.toSet());
|
||||
//
|
||||
// users.add(userInfo);
|
||||
// dmp.setUsers(users);
|
||||
//
|
||||
// DMP updateddmp = dMPDao.update(dmp);
|
||||
//
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(updateddmp);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// private static void addNullAndForeignElems(DMP existing, DMP newone) {
|
||||
//
|
||||
// newone.setModified(new Date());
|
||||
// if(newone.getStatus()==null)
|
||||
// newone.setStatus(existing.getStatus());
|
||||
// if(newone.getCreated()==null)
|
||||
// newone.setCreated(existing.getCreated());
|
||||
//
|
||||
// newone.setDataset(existing.getDataset());
|
||||
// newone.setOrganisations(existing.getOrganisations());
|
||||
// newone.setResearchers(existing.getResearchers());
|
||||
// newone.setUsers(existing.getUsers());
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public class DatasetProfileController {
|
|||
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetwizard/get/{id}" }, produces="application/json")
|
||||
public ResponseEntity<Object> getSingle(@PathVariable String id){
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(id));
|
||||
|
|
|
@ -67,137 +67,5 @@ public class DatasetProfiles {
|
|||
return new ResponseItem<List<DatasetProfileAutocompleteItem>>().status(HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//FETCH BY DATASET PROFILE
|
||||
/*
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofiles" }, produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<List<UUID>> listDMPs(){
|
||||
try {
|
||||
List<UUID> allIDs = datasetProfileDao.listAllIDs();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofiles/{id}" })
|
||||
public @ResponseBody ResponseEntity<DatasetProfile> getDatasetProfile(@PathVariable("id") String id) {
|
||||
try {
|
||||
DatasetProfile profile = datasetProfileDao.read(UUID.fromString(id));
|
||||
return ResponseEntity.status(HttpStatus.OK).body(profile);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/getAll" })
|
||||
public @ResponseBody ResponseEntity<List<DatasetProfile>> getAllDatasetProfiles(){
|
||||
|
||||
try {
|
||||
List<DatasetProfile> allDatasetProfiles = datasetProfileDao.getAll();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body((allDatasetProfiles));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.OK).body(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/create" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DatasetProfile> createDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
|
||||
|
||||
datasetProfile.setCreated(new Date());
|
||||
datasetProfile.setModified(new Date());
|
||||
|
||||
DatasetProfileRuleset datasetprofileruleset = datasetProfile.getRuleset();
|
||||
DatasetProfileViewstyle datasetprofileviewstyle = datasetProfile.getViewstyle();
|
||||
|
||||
if(datasetprofileruleset != null) {
|
||||
if(datasetprofileruleset.getId()==null)
|
||||
datasetProfileRulesetDao.create(datasetprofileruleset);
|
||||
else
|
||||
datasetProfileRulesetDao.update(datasetprofileruleset);
|
||||
datasetProfile.setRuleset(datasetprofileruleset);
|
||||
}
|
||||
if(datasetprofileviewstyle != null) {
|
||||
if(datasetprofileviewstyle.getId()==null)
|
||||
datasetProfileViewstyleDao.create(datasetprofileviewstyle);
|
||||
else
|
||||
datasetProfileViewstyleDao.update(datasetprofileviewstyle);
|
||||
datasetProfile.setViewstyle(datasetprofileviewstyle);
|
||||
}
|
||||
|
||||
if(datasetProfile.getId()==null)
|
||||
datasetProfileDao.create(datasetProfile);
|
||||
else
|
||||
datasetProfileDao.update(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(datasetProfile);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/update" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DatasetProfile> updateDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
|
||||
|
||||
DatasetProfileRuleset datasetprofileruleset = datasetProfile.getRuleset();
|
||||
DatasetProfileViewstyle datasetprofileviewstyle = datasetProfile.getViewstyle();
|
||||
|
||||
if(datasetprofileruleset != null) {
|
||||
if(datasetprofileruleset.getId()==null)
|
||||
datasetProfileRulesetDao.create(datasetprofileruleset);
|
||||
else
|
||||
datasetProfileRulesetDao.update(datasetprofileruleset);
|
||||
}
|
||||
if(datasetprofileviewstyle != null) {
|
||||
if(datasetprofileviewstyle.getId()==null)
|
||||
datasetProfileViewstyleDao.create(datasetprofileviewstyle);
|
||||
else
|
||||
datasetProfileViewstyleDao.update(datasetprofileviewstyle);
|
||||
}
|
||||
|
||||
if(datasetProfile.getId()==null)
|
||||
datasetProfile = datasetProfileDao.create(datasetProfile);
|
||||
else
|
||||
datasetProfile = datasetProfileDao.update(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(datasetProfile);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/delete" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DatasetProfile> deleteDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
|
||||
|
||||
DatasetProfileRuleset datasetprofileruleset = datasetProfile.getRuleset();
|
||||
DatasetProfileViewstyle datasetprofileviewstyle = datasetProfile.getViewstyle();
|
||||
|
||||
try {
|
||||
if(datasetprofileruleset != null)
|
||||
datasetProfileRulesetDao.delete(datasetprofileruleset);
|
||||
if(datasetprofileviewstyle != null)
|
||||
datasetProfileViewstyleDao.delete(datasetprofileviewstyle);
|
||||
datasetProfileDao.delete(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(datasetProfile);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
|
@ -1,23 +1,28 @@
|
|||
package eu.eudat.controllers;
|
||||
|
||||
import eu.eudat.dao.entities.DMPDao;
|
||||
import eu.eudat.dao.entities.*;
|
||||
import eu.eudat.managers.DatasetManager;
|
||||
import eu.eudat.managers.DatasetWizardManager;
|
||||
import eu.eudat.managers.UserManager;
|
||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.datasetwizard.DataManagentPlanListingModel;
|
||||
import eu.eudat.models.datasetwizard.DatasetProfileWizardAutocompleteRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardAutocompleteRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.dmp.AssociatedProfile;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.security.Principal;
|
||||
import org.json.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/20/2017.
|
||||
|
@ -28,8 +33,20 @@ import java.util.List;
|
|||
@RequestMapping( value = { "/datasetwizard" })
|
||||
public class DatasetWizardController {
|
||||
|
||||
@Autowired
|
||||
private DMPDao dMPDao;
|
||||
@Autowired private DataRepositoryDao dataRepositoryDao;
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
@Autowired private DatasetProfileDao datasetProfileDao;
|
||||
@Autowired private DatasetProfileRulesetDao datasetProfileRulesetDao;
|
||||
@Autowired private DatasetProfileViewstyleDao datasetProfileViewstyleDao;
|
||||
@Autowired private DMPDao dMPDao;
|
||||
@Autowired private DMPProfileDao dMPProfileDao;
|
||||
@Autowired private OrganisationDao organisationDao;
|
||||
@Autowired private ProjectDao projectDao;
|
||||
@Autowired private RegistryDao registryDao;
|
||||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
@Autowired private UserInfoDao userInfoDao;
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/userDmps" }, produces="application/json")
|
||||
public @ResponseBody
|
||||
|
@ -55,4 +72,28 @@ public class DatasetWizardController {
|
|||
return new ResponseItem<List<AssociatedProfile>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<DatasetWizardModel> getPaged(@PathVariable String id) {
|
||||
try {
|
||||
DatasetWizardModel dataset = new DatasetManager().getSingle(datasetDao, id);
|
||||
|
||||
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).payload(dataset);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<DatasetWizardModel>().status(HttpStatus.OK).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/createOrUpdate" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.entities.Dataset> createOrUpdate(@RequestBody DatasetWizardModel profile) {
|
||||
try {
|
||||
eu.eudat.entities.Dataset dataset= DatasetManager.createOrUpdate(datasetDao, dataRepositoryDao,serviceDao,registryDao,profile);
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<eu.eudat.entities.Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,8 @@ import eu.eudat.models.criteria.DataRepositoryCriteria;
|
|||
import eu.eudat.models.criteria.RegistryCriteria;
|
||||
import eu.eudat.models.criteria.ServiceCriteria;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
|
@ -76,288 +78,6 @@ public class Datasets {
|
|||
return new ResponseItem<DataTableData<DatasetListingModel>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasets/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.models.dataset.Dataset> getPaged(@PathVariable String id) {
|
||||
try {
|
||||
eu.eudat.models.dataset.Dataset dataset = new DatasetManager().getSingle(datasetDao, id);
|
||||
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.OK).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasets/createOrUpdate" }, produces="application/json")
|
||||
public @ResponseBody ResponseItem<eu.eudat.models.dataset.Dataset> createOrUpdate(@PathVariable eu.eudat.models.dataset.Dataset profile) {
|
||||
try {
|
||||
DatasetManager.createOrUpdate(datasetDao, dataRepositoryDao,serviceDao,registryDao,profile);
|
||||
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
// FETCH BY DATASET(S)
|
||||
|
||||
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/datasets" })
|
||||
// public @ResponseBody ResponseEntity<List<UUID>> listDatasets(){
|
||||
// try {
|
||||
// List<UUID> allIDs = datasetDao.listAllIDs();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/datasets/{id}" })
|
||||
// public @ResponseBody ResponseEntity<eu.eudat.models.dataset.Dataset> getDataset(@PathVariable("id") String id) {
|
||||
// try {
|
||||
// Dataset ds = datasetDao.read(UUID.fromString(id));
|
||||
// eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset();
|
||||
// dataset.fromDataModel(ds);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(dataset);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * This should be called on extreme cases. It's computationally intensive
|
||||
// */
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/getAll" })
|
||||
// public @ResponseBody ResponseEntity<List<Dataset>> getAllDatasets(){
|
||||
//
|
||||
// try {
|
||||
// List<Dataset> allDatasets = datasetDao.getAll();
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(allDatasets);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Dataset> createDataset(@RequestBody eu.eudat.models.dataset.Dataset modeldataset) {
|
||||
//
|
||||
// String userID = null;
|
||||
// try {
|
||||
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||
// } catch(NullPointerException ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||
//
|
||||
// if(userInfo==null) //this should normally never happer
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
//
|
||||
//
|
||||
// Dataset dataset = modeldataset.toDataModel();
|
||||
// if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
||||
// for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
||||
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||
// criteria.setLike(dataRepo.getReference());
|
||||
// List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
||||
// else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
||||
// for(eu.eudat.entities.Service service : dataset.getServices()){
|
||||
// ServiceCriteria criteria = new ServiceCriteria();
|
||||
// criteria.setLike(service.getReference());
|
||||
// List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
||||
// else service = this.serviceDao.create(service);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
||||
// for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
||||
// RegistryCriteria criteria = new RegistryCriteria();
|
||||
// criteria.setLike(registry.getReference());
|
||||
// List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
||||
// else registry = this.registryDao.create(registry);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// dataset.setId(null);
|
||||
// dataset.setCreated(new Date());
|
||||
// dataset.setModified(new Date());
|
||||
// dataset.setStatus(new Short("0"));
|
||||
// dataset.setCreator(userInfo);
|
||||
// if("".equals(dataset.getReference())) dataset.setReference(null);
|
||||
// if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
||||
//
|
||||
// try {
|
||||
// dataset = datasetDao.create(dataset);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/update" }, consumes = "application/json", produces="application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> updateDataset(@RequestBody eu.eudat.models.dataset.Dataset modeldataset) {
|
||||
//
|
||||
// Dataset dataset = modeldataset.toDataModel();
|
||||
//
|
||||
// if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
||||
// for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
||||
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||
// criteria.setLike(dataRepo.getReference());
|
||||
// List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
||||
// else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
||||
// for(eu.eudat.entities.Service service : dataset.getServices()){
|
||||
// ServiceCriteria criteria = new ServiceCriteria();
|
||||
// criteria.setLike(service.getReference());
|
||||
// List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
||||
// else service = this.serviceDao.create(service);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
||||
// for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
||||
// RegistryCriteria criteria = new RegistryCriteria();
|
||||
// criteria.setLike(registry.getReference());
|
||||
// List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
||||
// if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
||||
// else registry = this.registryDao.create(registry);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Dataset olddataset = datasetDao.read(modeldataset.getId());
|
||||
//
|
||||
// olddataset.getServices().clear();
|
||||
// olddataset.setServices(dataset.getServices());
|
||||
//
|
||||
// olddataset.getDataRepositories().clear();
|
||||
// olddataset.setDataRepositories(dataset.getDataRepositories());
|
||||
// olddataset.getRegistries().clear();
|
||||
// olddataset.setRegistries(dataset.getRegistries());
|
||||
//
|
||||
// olddataset.setLabel(modeldataset.getLabel());
|
||||
// olddataset.setDescription(modeldataset.getDescription());
|
||||
// //SafeCleanAttribs.clean(dataset);
|
||||
//
|
||||
// if("".equals(dataset.getReference())) dataset.setReference(null);
|
||||
// if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
||||
//
|
||||
// try {
|
||||
// dataset = datasetDao.update(olddataset);
|
||||
// return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// ex.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + ex.getMessage());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/delete" }, consumes = "application/json")
|
||||
// public @ResponseBody ResponseEntity<Object> deleteDataset(@RequestBody Dataset dataset) {
|
||||
//
|
||||
// //if we want to make sure it won't cascade up to other (child) components, we can just unhook them by setting them = new ones
|
||||
// // e.g: DMP dmp = new DMP() and then dataset.setDMP(dmp)
|
||||
// try {
|
||||
// datasetDao.delete(dataset);
|
||||
// RestResponse rr = new RestResponse("Deleted dataset with id: "+dataset.getId().toString(), dataset.getId().toString());
|
||||
// return ResponseEntity.status(HttpStatus.OK).body(rr.toString());
|
||||
// }
|
||||
// catch(Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not delete Dataset! Reason: " + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Dataset dataset) {
|
||||
// try {
|
||||
//
|
||||
// Dataset d = datasetDao.read(dataset.getId());
|
||||
// d.setStatus(new Short("-1"));
|
||||
// dataset = datasetDao.update(d);
|
||||
// return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"Deleted dataset!\"");
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete dataset!\"");
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignDMPToDataset" })
|
||||
// public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {
|
||||
//
|
||||
// Dataset dataset = null;
|
||||
// try {
|
||||
// dataset = datasetDao.read(UUID.fromString(datasetID));
|
||||
// if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
||||
// DMP dmp = new DMP();
|
||||
// dmp.setId(UUID.fromString(dmpID));
|
||||
// dataset.setDmp(dmp);
|
||||
// datasetDao.update(dataset);
|
||||
// return ResponseEntity.status(HttpStatus.OK).build();
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignProfileToDataset" })
|
||||
// public @ResponseBody ResponseEntity<Object> assignProfileToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("profileID") String profileID) {
|
||||
//
|
||||
// Dataset dataset = null;
|
||||
// try {
|
||||
// dataset = datasetDao.read(UUID.fromString(datasetID));
|
||||
// if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
||||
// DatasetProfile profile = new DatasetProfile();
|
||||
// profile.setId(UUID.fromString(profileID));
|
||||
// dataset.setProfile(profile);
|
||||
// datasetDao.update(dataset);
|
||||
// return ResponseEntity.status(HttpStatus.OK).build();
|
||||
// }
|
||||
// catch(Exception ex) {
|
||||
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -126,8 +126,19 @@ public class Projects {
|
|||
}
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getWithExternal" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getWithExternal(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteriaWithExternal(projectDao, projectCriteria,remoteFetcher);
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/get" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> getPaged(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
public @ResponseBody ResponseItem<List<eu.eudat.models.project.Project>> get(@RequestBody ProjectCriteriaRequest projectCriteria) {
|
||||
try {
|
||||
List<eu.eudat.models.project.Project> dataTable = new ProjectManager().getCriteria(projectDao, projectCriteria,remoteFetcher);
|
||||
return new ResponseItem<List<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||
|
|
|
@ -6,14 +6,17 @@ import eu.eudat.models.criteria.RegistryCriteria;
|
|||
import eu.eudat.models.criteria.ServiceCriteria;
|
||||
import eu.eudat.models.dataset.Dataset;
|
||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||
import eu.eudat.models.datasetwizard.DatasetWizardModel;
|
||||
import eu.eudat.models.helpers.DataTableData;
|
||||
import eu.eudat.models.listingmodels.DatasetListingModel;
|
||||
import eu.eudat.models.project.Project;
|
||||
import eu.eudat.models.project.ProjectTableRequest;
|
||||
import eu.eudat.queryable.QueryableList;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -31,18 +34,27 @@ public class DatasetManager {
|
|||
return dataTable;
|
||||
}
|
||||
|
||||
public eu.eudat.models.dataset.Dataset getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException{
|
||||
eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset();
|
||||
dataset.fromDataModel(datatasetRepository.find(UUID.fromString(id)));
|
||||
public DatasetWizardModel getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException{
|
||||
DatasetWizardModel dataset = new DatasetWizardModel();
|
||||
eu.eudat.entities.Dataset datasetEntity = datatasetRepository.find(UUID.fromString(id));
|
||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(datasetEntity.getProfile());
|
||||
datasetprofile.setStatus(dataset.getStatus());
|
||||
if(dataset.getProperties()!=null){
|
||||
JSONObject jobject = new JSONObject(dataset.getProperties());
|
||||
Map<String,Object> properties = (Map<String, Object>)jobject.toMap();
|
||||
datasetprofile.fromJsonObject(properties);
|
||||
}
|
||||
dataset.setDatasetProfileDefinition(datasetprofile);
|
||||
dataset.fromDataModel(datasetEntity);
|
||||
return dataset;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(DatasetDao datatasetRepository, DataRepositoryDao dataRepositoryDao, ServiceDao serviceDao, RegistryDao registryDao, Dataset profile) throws InstantiationException, IllegalAccessException{
|
||||
public static eu.eudat.entities.Dataset createOrUpdate(DatasetDao datatasetRepository, DataRepositoryDao dataRepositoryDao, ServiceDao serviceDao, RegistryDao registryDao, DatasetWizardModel profile) throws InstantiationException, IllegalAccessException{
|
||||
eu.eudat.entities.Dataset dataset = profile.toDataModel();
|
||||
createRegistriesIfTheyDontExist(registryDao,dataset);
|
||||
createDataRepositoriesIfTheyDontExist(dataRepositoryDao,dataset);
|
||||
createServicesIfTheyDontExist(serviceDao,dataset);
|
||||
datatasetRepository.createOrUpdate(dataset);
|
||||
return datatasetRepository.createOrUpdate(dataset);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ProjectManager {
|
|||
return project;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria,RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
public List<eu.eudat.models.project.Project> getCriteriaWithExternal(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria,RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(items.toList(), eu.eudat.models.project.Project.class);
|
||||
List<Map<String,String>> remoteRepos = remoteFetcher.getProjects(projectCriteria.getCriteria().getLike());
|
||||
|
@ -64,6 +64,12 @@ public class ProjectManager {
|
|||
return projects;
|
||||
}
|
||||
|
||||
public List<eu.eudat.models.project.Project> getCriteria(ProjectDao projectRepository, ProjectCriteriaRequest projectCriteria,RemoteFetcher remoteFetcher) throws IllegalAccessException, InstantiationException, HugeResultSet, NoURLFound {
|
||||
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectCriteria.getCriteria());
|
||||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(items.toList(), eu.eudat.models.project.Project.class);
|
||||
return projects;
|
||||
}
|
||||
|
||||
public static void createOrUpdate(ProjectDao projectRepository, UserInfoDao userInfoRepository, eu.eudat.models.project.Project project, Principal principal){
|
||||
eu.eudat.entities.Project projectEntity = project.toDataModel();
|
||||
projectEntity.setCreationUser(userInfoRepository.read(principal.getId()));
|
||||
|
|
|
@ -90,6 +90,8 @@ public class DatasetProfileListingModel implements DataModel<DatasetProfile> {
|
|||
|
||||
@Override
|
||||
public DatasetProfile toDataModel() {
|
||||
return null;
|
||||
DatasetProfile profile = new DatasetProfile();
|
||||
profile.setId(this.id);
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,202 @@
|
|||
package eu.eudat.models.datasetwizard;
|
||||
|
||||
import eu.eudat.entities.Dataset;
|
||||
import eu.eudat.models.DataModel;
|
||||
import eu.eudat.models.dataset.DataRepository;
|
||||
import eu.eudat.models.dataset.Registry;
|
||||
import eu.eudat.models.dataset.Service;
|
||||
import eu.eudat.models.datasetprofile.DatasetProfileListingModel;
|
||||
import eu.eudat.models.dmp.DataManagementPlan;
|
||||
import eu.eudat.models.user.composite.DatasetProfile;
|
||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by ikalyvas on 12/22/2017.
|
||||
*/
|
||||
public class DatasetWizardModel implements DataModel<Dataset> {
|
||||
|
||||
private UUID id;
|
||||
private String label;
|
||||
private String reference;
|
||||
private String uri;
|
||||
private String description;
|
||||
private short status;
|
||||
private String properties;
|
||||
private Date created;
|
||||
private DataManagementPlan dmp;
|
||||
private eu.eudat.models.user.composite.DatasetProfile datasetProfileDefinition;
|
||||
private List<Registry> registries;
|
||||
private List<Service> services;
|
||||
private List<DataRepository> dataRepositories;
|
||||
private DatasetProfileListingModel profile;
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getProperties() {
|
||||
return properties;
|
||||
}
|
||||
|
||||
public void setProperties(String properties) {
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public DataManagementPlan getDmp() {
|
||||
return dmp;
|
||||
}
|
||||
|
||||
public void setDmp(DataManagementPlan dmp) {
|
||||
this.dmp = dmp;
|
||||
}
|
||||
|
||||
public DatasetProfile getDatasetProfileDefinition() {
|
||||
return datasetProfileDefinition;
|
||||
}
|
||||
|
||||
public void setDatasetProfileDefinition(DatasetProfile datasetProfileDefinition) {
|
||||
this.datasetProfileDefinition = datasetProfileDefinition;
|
||||
}
|
||||
|
||||
public List<Registry> getRegistries() {
|
||||
return registries;
|
||||
}
|
||||
|
||||
public void setRegistries(List<Registry> registries) {
|
||||
this.registries = registries;
|
||||
}
|
||||
|
||||
public List<Service> getServices() {
|
||||
return services;
|
||||
}
|
||||
|
||||
public void setServices(List<Service> services) {
|
||||
this.services = services;
|
||||
}
|
||||
|
||||
public List<DataRepository> getDataRepositories() {
|
||||
return dataRepositories;
|
||||
}
|
||||
|
||||
public void setDataRepositories(List<DataRepository> dataRepositories) {
|
||||
this.dataRepositories = dataRepositories;
|
||||
}
|
||||
|
||||
public DatasetProfileListingModel getProfile() {
|
||||
return profile;
|
||||
}
|
||||
|
||||
public void setProfile(DatasetProfileListingModel profile) {
|
||||
this.profile = profile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(Dataset entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.properties = entity.getProperties();
|
||||
this.reference = entity.getReference();
|
||||
this.description = entity.getDescription();
|
||||
this.profile = new DatasetProfileListingModel();
|
||||
this.profile.fromDataModel(entity.getProfile());
|
||||
this.registries = new DomainModelConverter<eu.eudat.entities.Registry,Registry>().fromDataModel(entity.getRegistries().stream().collect(Collectors.toList()), Registry.class);
|
||||
this.dataRepositories = new DomainModelConverter<eu.eudat.entities.DataRepository,DataRepository>().fromDataModel(entity.getDataRepositories().stream().collect(Collectors.toList()), DataRepository.class);
|
||||
this.services = new DomainModelConverter<eu.eudat.entities.Service,Service>().fromDataModel(entity.getServices().stream().collect(Collectors.toList()), Service.class);
|
||||
this.created = entity.getCreated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dataset toDataModel() {
|
||||
eu.eudat.entities.Dataset entity = new eu.eudat.entities.Dataset();
|
||||
entity.setId(this.id);
|
||||
entity.setLabel(this.label);
|
||||
entity.setReference(this.reference);
|
||||
entity.setUri(this.uri);
|
||||
entity.setProperties(this.properties);
|
||||
entity.setStatus(this.status);
|
||||
entity.setDmp(dmp.toDataModel());
|
||||
entity.setDescription(this.description);
|
||||
entity.setCreated(this.created!=null?this.created:new Date());
|
||||
entity.setModified(new Date());
|
||||
entity.setProfile(profile.toDataModel()); ///TODO
|
||||
if(!this.registries.isEmpty()){
|
||||
entity.setRegistries(new HashSet<eu.eudat.entities.Registry>());
|
||||
for(Registry registry:this.registries){
|
||||
entity.getRegistries().add(registry.toDataModel());
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.dataRepositories.isEmpty()){
|
||||
entity.setDataRepositories(new HashSet<eu.eudat.entities.DataRepository>());
|
||||
for(DataRepository dataRepository:this.dataRepositories){
|
||||
entity.getDataRepositories().add(dataRepository.toDataModel());
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.services.isEmpty()){
|
||||
entity.setServices(new HashSet<eu.eudat.entities.Service>());
|
||||
for(Service service:this.services){
|
||||
entity.getServices().add(service.toDataModel());
|
||||
}
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
}
|
|
@ -159,12 +159,12 @@ public class DataManagementPlan implements DataModel<DMP>{
|
|||
public DMP toDataModel() {
|
||||
DMP dataManagementPlanEntity = new DMP();
|
||||
dataManagementPlanEntity.setId(this.id);
|
||||
dataManagementPlanEntity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().toDataModel(this.organisations)));
|
||||
dataManagementPlanEntity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().toDataModel(this.researchers)));
|
||||
if(this.organisations!=null&&!this.organisations.isEmpty())dataManagementPlanEntity.setOrganisations(new HashSet<eu.eudat.entities.Organisation>(new DomainModelConverter<eu.eudat.entities.Organisation,Organisation>().toDataModel(this.organisations)));
|
||||
if(this.researchers!=null&&!this.researchers.isEmpty())dataManagementPlanEntity.setResearchers(new HashSet<eu.eudat.entities.Researcher>(new DomainModelConverter<eu.eudat.entities.Researcher,Researcher>().toDataModel(this.researchers)));
|
||||
dataManagementPlanEntity.setVersion(this.version);
|
||||
dataManagementPlanEntity.setPrevious(this.previous);
|
||||
dataManagementPlanEntity.setLabel(this.label);
|
||||
dataManagementPlanEntity.setProject(this.project.toDataModel());
|
||||
if(this.project!=null)dataManagementPlanEntity.setProject(this.project.toDataModel());
|
||||
dataManagementPlanEntity.setStatus((short)this.status);
|
||||
dataManagementPlanEntity.setDescription(this.description);
|
||||
if(this.profiles!=null) {
|
||||
|
|
|
@ -20,13 +20,13 @@
|
|||
<app-dataset-editor-component [formGroup]="formGroup"></app-dataset-editor-component>
|
||||
<div>
|
||||
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
||||
<button matStepperNext mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.NEXT' | translate}}</button>
|
||||
<button matStepperNext mat-raised-button color="primary" (click)="formSubmit()">{{'DATASET-WIZARD.ACTIONS.NEXT' | translate}}</button>
|
||||
</div>
|
||||
</form>
|
||||
</mat-step>
|
||||
<mat-step>
|
||||
<ng-template matStepLabel>{{'DATASET-WIZARD.THIRD-STEP.TITLE' | translate}}</ng-template>
|
||||
|
||||
<dynamic-form *ngIf="datasetWizardModel" [dataModel]="datasetWizardModel"></dynamic-form>
|
||||
<div>
|
||||
<button matStepperPrevious mat-raised-button color="primary">{{'DATASET-WIZARD.ACTIONS.BACK' | translate}}</button>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { DatasetProfileDefinitionModel } from '../models/DatasetProfileDefinitionModel';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BaseErrorModel } from '../models/error/BaseErrorModel';
|
||||
import { ActivatedRoute, Router, Params} from '@angular/router';
|
||||
import { DatasetService } from '../services/dataset/dataset.service';
|
||||
import { DatasetWizardModel } from '../models/datasets/DatasetWizardModel';
|
||||
import { DatasetModel } from '../models/datasets/DatasetModel';
|
||||
import { DatasetProfileCriteria } from '../models/criteria/dataset-profile/DatasetProfileCriteria';
|
||||
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
||||
|
@ -29,7 +29,7 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
|
||||
dmpAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
datasetProfileAutoCompleteConfiguration: AutoCompleteConfiguration;
|
||||
datasetModel:DatasetWizardModel;
|
||||
datasetWizardModel:DatasetWizardModel;
|
||||
isNew = true;
|
||||
formGroup:FormGroup;
|
||||
constructor(
|
||||
|
@ -59,10 +59,10 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
const itemId = params['id'];
|
||||
if (itemId != null) {
|
||||
this.isNew = false;
|
||||
this.datasetService.getSingle(itemId).map(data => data as DatasetModel)
|
||||
this.datasetWizardService.getSingle(itemId).map(data => data as DatasetWizardModel)
|
||||
.subscribe(data => {
|
||||
this.datasetModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(data, DatasetWizardModel);
|
||||
this.formGroup = this.datasetModel.buildForm();
|
||||
this.datasetWizardModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(data, DatasetWizardModel);
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.datasetProfileAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.getAvailableProfiles.bind(this.datasetWizardService), datasetProfileRequestItem);
|
||||
this.formGroup.get("dmp").valueChanges.subscribe(change=>{
|
||||
this.datasetProfileAutoCompleteConfiguration.requestItem.criteria.id=change.id
|
||||
|
@ -70,9 +70,9 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
);
|
||||
});
|
||||
} else {
|
||||
this.datasetModel = new DatasetWizardModel();
|
||||
this.datasetWizardModel = new DatasetWizardModel();
|
||||
setTimeout(() => {
|
||||
this.formGroup = this.datasetModel.buildForm();
|
||||
this.formGroup = this.datasetWizardModel.buildForm();
|
||||
this.datasetProfileAutoCompleteConfiguration = new AutoCompleteConfiguration(this.datasetWizardService.getAvailableProfiles.bind(this.datasetWizardService), datasetProfileRequestItem);
|
||||
this.formGroup.get("dmp").valueChanges.subscribe(change=>{
|
||||
this.datasetProfileAutoCompleteConfiguration.requestItem.criteria.id=change.id
|
||||
|
@ -112,6 +112,7 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
|
||||
formSubmit(): void {
|
||||
//this.touchAllFormFields(this.formGroup);
|
||||
if(this.isNew)return;
|
||||
if (!this.isFormValid()) { return; }
|
||||
this.onSubmit();
|
||||
}
|
||||
|
@ -121,8 +122,15 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
}
|
||||
|
||||
onSubmit(): void {
|
||||
this.datasetService.createDataset(this.formGroup.value).subscribe(
|
||||
complete => this.onCallbackSuccess(),
|
||||
this.datasetWizardService.createDataset(this.formGroup.value).subscribe(
|
||||
complete => {
|
||||
this.datasetWizardService.getSingle(complete.id).subscribe(
|
||||
result=>{
|
||||
this.datasetWizardModel = new JsonSerializer<DatasetWizardModel>().fromJSONObject(result,DatasetWizardModel);
|
||||
}
|
||||
)
|
||||
this.onCallbackSuccess()
|
||||
},
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
|
@ -133,7 +141,6 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
duration: 3000,
|
||||
extraClasses: ['snackbar-success']
|
||||
})
|
||||
this.router.navigate(['/datasets']);
|
||||
}
|
||||
|
||||
onCallbackError(error: any) {
|
||||
|
@ -143,7 +150,7 @@ export class DatasetWizardComponent implements AfterViewInit {
|
|||
|
||||
public setErrorModel(errorModel: BaseErrorModel) {
|
||||
Object.keys(errorModel).forEach(item => {
|
||||
(<any>this.datasetModel.errorModel)[item] = (<any>errorModel)[item];
|
||||
(<any>this.datasetWizardModel.errorModel)[item] = (<any>errorModel)[item];
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import { Router } from "@angular/router";
|
|||
import { TranslateService } from "@ngx-translate/core";
|
||||
import { DataSource } from "@angular/cdk/table";
|
||||
import { Observable } from "rxjs/Observable";
|
||||
import { DataTableRequest } from "../models/data-table/DataTableRequest";
|
||||
import { DataTableRequest } from "@app/models/data-table/DataTableRequest";
|
||||
import { SnackBarNotificationComponent } from "../shared/components/notificaiton/snack-bar-notification.component";
|
||||
import { DataManagementPlanService } from "../services/data-management-plan/data-management-plan.service";
|
||||
import { DataManagementPlanCriteriaComponent } from "../shared/components/criteria/data-management-plan/dmp-criteria.component";
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service';
|
||||
import { DatasetModel } from '../models/DatasetModel';
|
||||
import { DatasetWizardModel } from '../models/datasets/DatasetWizardModel';
|
||||
import { DatasetWizardComponent } from '../dataset-wizard/dataset-wizard.component';
|
||||
import { DatasetProfileDefinitionModel } from '../models/DatasetProfileDefinitionModel';
|
||||
import { VisibilityRulesService } from '../visibility-rules/visibility-rules.service';
|
||||
import { Rule } from '../models/Rule';
|
||||
import { Section } from '../models/Section';
|
||||
|
||||
|
@ -26,7 +28,7 @@ declare function simple_notifier(type: string, title: string, message: string):
|
|||
})
|
||||
export class DynamicFormComponent implements OnInit {
|
||||
|
||||
@Input() dataModel: DatasetModel = new DatasetModel();
|
||||
@Input() dataModel: DatasetWizardModel = new DatasetWizardModel();
|
||||
@Input() path: string;
|
||||
form: FormGroup;
|
||||
id: string;
|
||||
|
@ -54,33 +56,25 @@ export class DynamicFormComponent implements OnInit {
|
|||
|
||||
|
||||
ngOnInit() {
|
||||
let datasetProfileDefinitionModel: DatasetProfileDefinitionModel = this.dataModel.datasetProfileDefinition
|
||||
this.pages = this.getPages(datasetProfileDefinitionModel);
|
||||
this.createPagination();
|
||||
this.form = datasetProfileDefinitionModel.buildForm();
|
||||
this.visibilityRulesService.formGroup = this.form;
|
||||
//let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule);
|
||||
//this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
this.progressbar = true;
|
||||
|
||||
// this.serverService.getSingleDataset(this.datasetId).subscribe(
|
||||
// (response: any) => {
|
||||
// this.dataModel = new JsonSerializer<DatasetModel>().fromJSONObject(response, DatasetModel);
|
||||
// this.pages = this.getPages(this.dataModel);
|
||||
// this.createPagination();
|
||||
// this.form = this.dataModel.buildForm();
|
||||
// this.visibilityRulesService.formGroup = this.form;
|
||||
// let rules: Rule[] = new JsonSerializer<Rule>().fromJSONArray(response.rules, Rule);
|
||||
// this.visibilityRulesService.buildVisibilityRules(rules)
|
||||
// this.progressbar = true;
|
||||
|
||||
// this.route.fragment.subscribe((fragment: string) => {
|
||||
// var self = this;
|
||||
// setTimeout(function () { self.scrollTo(fragment) });
|
||||
// });
|
||||
|
||||
// this.route.queryParams.subscribe((params) => {
|
||||
// if (params && "page" in params)
|
||||
// this.changeCurrentPage(params["page"]);
|
||||
// });
|
||||
// },
|
||||
// error => {
|
||||
// console.log("Could not load dmp");
|
||||
// }
|
||||
// )
|
||||
this.route.fragment.subscribe((fragment: string) => {
|
||||
var self = this;
|
||||
setTimeout(function () { self.scrollTo(fragment) });
|
||||
});
|
||||
|
||||
this.route.queryParams.subscribe((params) => {
|
||||
if (params && "page" in params)
|
||||
this.changeCurrentPage(params["page"]);
|
||||
});
|
||||
|
||||
/* else{
|
||||
|
||||
this.addSection();
|
||||
|
@ -100,7 +94,7 @@ export class DynamicFormComponent implements OnInit {
|
|||
this.visibleSidebar = !this.visibleSidebar;
|
||||
}
|
||||
|
||||
getPages(model: DatasetModel): Array<number> {
|
||||
getPages(model: DatasetProfileDefinitionModel): Array<number> {
|
||||
let pageSet = new Set<number>();
|
||||
|
||||
model.sections.forEach(section => {
|
||||
|
@ -115,11 +109,11 @@ export class DynamicFormComponent implements OnInit {
|
|||
}
|
||||
|
||||
createPagination() {
|
||||
this.pages.forEach(item => {
|
||||
// this.stepperItems.push({
|
||||
// label: '',
|
||||
// })
|
||||
});
|
||||
/*this.pages.forEach(item => {
|
||||
this.stepperItems.push({
|
||||
label: '',
|
||||
})
|
||||
});*/
|
||||
}
|
||||
|
||||
changePageIndex(index: any) {
|
||||
|
@ -131,8 +125,8 @@ export class DynamicFormComponent implements OnInit {
|
|||
var element = document.querySelector('#' + sectionID);
|
||||
if (!element) return;
|
||||
element.scrollIntoView();
|
||||
// this.visibleSidebar = true;
|
||||
//var scrollElement = document.querySelector('.scrollableContent');
|
||||
this.visibleSidebar = true;
|
||||
var scrollElement = document.querySelector('.scrollableContent');
|
||||
//scrollElement.scrollTop = topElement.offsetTop;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { DatasetModel } from '../../models/DatasetModel';
|
||||
import { DatasetProfileDefinitionModel } from '../../models/DatasetProfileDefinitionModel';
|
||||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
||||
|
||||
//import * as $ from '../../../../node_modules/jquery/dist/jquery'
|
||||
|
@ -13,7 +13,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
|
|||
})
|
||||
export class TableOfContentsComponent implements OnInit{
|
||||
|
||||
@Input() model:DatasetModel;
|
||||
@Input() model:DatasetProfileDefinitionModel;
|
||||
public path:string="";
|
||||
/* @Output()
|
||||
setPage:EventEmitter<number> = new EventEmitter<number>();
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
import { Rule } from './Rule';
|
||||
import { BaseModel } from './BaseModel';
|
||||
import { FormBuilder, FormGroup } from '@angular/forms';
|
||||
import { FormGenerator } from './interfaces/FormGenerator';
|
||||
import { JsonSerializer } from '../utilities/JsonSerializer';
|
||||
import { Section } from './Section';
|
||||
import { Serializable } from './interfaces/Serializable';
|
||||
export class DatasetModel extends BaseModel implements Serializable<DatasetModel>,FormGenerator<FormGroup>{
|
||||
export class DatasetProfileDefinitionModel extends BaseModel implements Serializable<DatasetProfileDefinitionModel>,FormGenerator<FormGroup>{
|
||||
public status:number
|
||||
public rules:Rule[];
|
||||
public sections:Array<Section>
|
||||
fromJSONObject(item:any):DatasetModel{
|
||||
fromJSONObject(item:any):DatasetProfileDefinitionModel{
|
||||
this.status = item.status;
|
||||
this.sections = new JsonSerializer<Section>().fromJSONArray(item.sections,Section);
|
||||
this.rules = new JsonSerializer<Rule>().fromJSONArray(item.rules,Rule);
|
||||
return this;
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
import { DatasetProfileDefinitionModel } from '../DatasetProfileDefinitionModel';
|
||||
import { DatasetProfileModel } from '../datasetprofile/DatasetProfileModel';
|
||||
import { DataManagementPlanModel } from '../data-managemnt-plans/DataManagementPlanModel';
|
||||
import { Serializable } from "../Serializable";
|
||||
|
@ -22,7 +23,7 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
|||
public registries: RegisterModel[] = [];
|
||||
public dataRepositories: DataRepositoryModel[] = [];
|
||||
public dmp:DataManagementPlanModel = new DataManagementPlanModel();
|
||||
|
||||
public datasetProfileDefinition = new DatasetProfileDefinitionModel();
|
||||
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||
|
||||
fromJSONObject(item: any): DatasetWizardModel {
|
||||
|
@ -36,7 +37,8 @@ export class DatasetWizardModel implements Serializable<DatasetWizardModel> {
|
|||
this.registries = new JsonSerializer<RegisterModel>().fromJSONArray(item.registries, RegisterModel);
|
||||
this.dataRepositories = new JsonSerializer<DataRepositoryModel>().fromJSONArray(item.dataRepositories, DataRepositoryModel);
|
||||
this.dmp = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(item.dmp, DataManagementPlanModel);
|
||||
this.profile = new JsonSerializer<DatasetWizardModel>().fromJSONObject(item.profile, DatasetWizardModel);
|
||||
this.profile = new JsonSerializer<DatasetWizardModel>().fromJSONObject(item.profile, DatasetWizardModel);
|
||||
this.datasetProfileDefinition = new JsonSerializer<DatasetProfileDefinitionModel>().fromJSONObject(item.datasetProfileDefinition, DatasetProfileDefinitionModel);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { DatasetWizardModel } from '../../models/datasets/DatasetWizardModel';
|
||||
import { DatasetProfileCriteria } from '../../models/criteria/dataset-profile/DatasetProfileCriteria';
|
||||
import 'rxjs/add/operator/map';
|
||||
import { HttpHeaders } from '@angular/common/http';
|
||||
|
@ -32,4 +33,12 @@ export class DatasetWizardService {
|
|||
public getAvailableProfiles(criteria: RequestItem<DatasetProfileCriteria>): Observable<DataManagementPlanModel[]> {
|
||||
return this.http.post<DataManagementPlanModel[]>(this.actionUrl + 'getAvailableProfiles/', criteria, { headers: this.headers });
|
||||
}
|
||||
|
||||
public getSingle(id:String): Observable<DatasetWizardModel> {
|
||||
return this.http.get<DatasetWizardModel>(this.actionUrl + 'getSingle/'+id,{ headers: this.headers });
|
||||
}
|
||||
|
||||
createDataset(datasetModel: DatasetWizardModel): Observable<DatasetWizardModel> {
|
||||
return this.http.post<DatasetWizardModel>(this.actionUrl + 'createOrUpdate', datasetModel, { headers: this.headers });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,5 @@ export class DatasetService {
|
|||
getPaged(dataTableRequest: DataTableRequest<DatasetCriteria>): Observable<DataTableData<DatasetListingModel>> {
|
||||
return this.http.post<DataTableData<DatasetListingModel>>(this.actionUrl + 'getPaged', dataTableRequest, { headers: this.headers });
|
||||
}
|
||||
|
||||
getSingle(id: string): Observable<DatasetModel> {
|
||||
return this.http.get<DatasetModel>(this.actionUrl +'getSingle/' + id, { headers: this.headers });
|
||||
}
|
||||
|
||||
createDataset(datasetModel: DatasetModel): Observable<DatasetModel> {
|
||||
return this.http.post<DatasetModel>(this.actionUrl + 'createOrUpdate', datasetModel, { headers: this.headers });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
"lib": [
|
||||
"es2017",
|
||||
"dom"
|
||||
]
|
||||
],
|
||||
"baseUrl": "./src/",
|
||||
"paths": {
|
||||
"@app/*": ["app/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue