Merge branch 'Development' of https://gitlab.eudat.eu/dmp/OpenAIRE-EUDAT-DMP-service-pilot into Development
This commit is contained in:
commit
fa8881946e
|
@ -1,13 +1,19 @@
|
||||||
package eu.eudat;
|
package eu.eudat;
|
||||||
|
|
||||||
|
import eu.eudat.handlers.PrincipalArgumentResolver;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 12/15/2017.
|
* Created by ikalyvas on 12/15/2017.
|
||||||
*/
|
*/
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class EuDatApplication {
|
public class EuDatApplication {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.setProperty("spring.devtools.restart.enabled", "true");
|
System.setProperty("spring.devtools.restart.enabled", "true");
|
||||||
SpringApplication.run(EuDatApplication.class, args);
|
SpringApplication.run(EuDatApplication.class, args);
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
package eu.eudat.configurations;
|
||||||
|
|
||||||
|
import eu.eudat.handlers.PrincipalArgumentResolver;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class WebMVCConfiguration extends WebMvcConfigurerAdapter {
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
|
||||||
|
argumentResolvers.add(new PrincipalArgumentResolver());
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import eu.eudat.models.criteria.ResearcherCriteria;
|
||||||
import eu.eudat.models.dmp.DataManagementPlan;
|
import eu.eudat.models.dmp.DataManagementPlan;
|
||||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
|
import eu.eudat.models.helpers.responses.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -68,392 +68,392 @@ public class DMPs {
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DataTableData<eu.eudat.models.dmp.DataManagementPlan>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
public @ResponseBody ResponseItem<DataTableData<DataManagementPlan>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||||
try {
|
try {
|
||||||
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataTable);
|
return new ResponseItem<DataTableData<DataManagementPlan>>().status(HttpStatus.OK).payload(dataTable);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<DataTableData<DataManagementPlan>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.models.dmp.DataManagementPlan> getPaged(@PathVariable String id) {
|
public @ResponseBody ResponseItem<DataManagementPlan> getPaged(@PathVariable String id) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(dMPDao, id);
|
eu.eudat.models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(dMPDao, id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(project);
|
return new ResponseItem<DataManagementPlan>().status(HttpStatus.OK).payload(project);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<DataManagementPlan>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/add" }, consumes = "application/json", produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/add" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.entities.DMP> addDmp(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan) {
|
public @ResponseBody ResponseEntity<eu.eudat.entities.DMP> addDmp(@RequestBody eu.eudat.models.dmp.DataManagementPlan dataManagementPlan) {
|
||||||
eu.eudat.entities.DMP createdProject = dMPDao.update(dataManagementPlan.toDataModel());
|
eu.eudat.entities.DMP createdProject = dMPDao.createOrUpdate(dataManagementPlan.toDataModel());
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dmps" }, produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<List<UUID>> listDMPs(){
|
// public @ResponseBody ResponseEntity<List<UUID>> listDMPs(){
|
||||||
try {
|
// try {
|
||||||
List<UUID> allIDs = dMPDao.listAllIDs();
|
// List<UUID> allIDs = dMPDao.listAllIDs();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/{id}" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dmps/{id}" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DataManagementPlan> getDMP(@PathVariable("id") String id){
|
// public @ResponseBody ResponseEntity<DataManagementPlan> getDMP(@PathVariable("id") String id){
|
||||||
try {
|
// try {
|
||||||
DMP dmp = dMPDao.read(UUID.fromString(id));
|
// DMP dmp = dMPDao.read(UUID.fromString(id));
|
||||||
DataManagementPlan dataManagementPlan = new DataManagementPlan();
|
// DataManagementPlan dataManagementPlan = new DataManagementPlan();
|
||||||
dataManagementPlan.fromDataModel(dmp);
|
// dataManagementPlan.fromDataModel(dmp);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataManagementPlan);
|
// return ResponseEntity.status(HttpStatus.OK).body(dataManagementPlan);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmp/listDMPLabelID" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/listDMPLabelID" }, produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<List<IDLabelPair>> listDmpLabelID(){
|
// public @ResponseBody ResponseEntity<List<IDLabelPair>> listDmpLabelID(){
|
||||||
try {
|
// try {
|
||||||
List<IDLabelPair> allIDLabels = dMPDao.listAllIDsLabels();
|
// List<IDLabelPair> allIDLabels = dMPDao.listAllIDsLabels();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDLabels);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDLabels);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* This should be called on extreme cases. It's computationally intensive
|
// * This should be called on extreme cases. It's computationally intensive
|
||||||
*/
|
// */
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmp/getAll" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> getAllDMPs(){
|
// public @ResponseBody ResponseEntity<Object> getAllDMPs(){
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
List<DMP> allDMPs = dMPDao.getAll();
|
// List<DMP> allDMPs = dMPDao.getAll();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allDMPs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allDMPs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null );
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/create" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/create" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DMP> createDMP(@RequestBody DMP dmp) {
|
// public @ResponseBody ResponseEntity<DMP> createDMP(@RequestBody DMP dmp) {
|
||||||
try {
|
// try {
|
||||||
DMP createdDmp = dMPDao.update(dmp);
|
// DMP createdDmp = dMPDao.update(dmp);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdDmp);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(createdDmp);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/update" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/update" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DMP> updateDMP(@RequestBody DataManagementPlan dataManagementPlan) {
|
// public @ResponseBody ResponseEntity<DMP> updateDMP(@RequestBody DataManagementPlan dataManagementPlan) {
|
||||||
|
//
|
||||||
DMP newDmp = dataManagementPlan.toDataModel();
|
// DMP newDmp = dataManagementPlan.toDataModel();
|
||||||
if(newDmp.getOrganisations()!=null&&!newDmp.getOrganisations().isEmpty()){
|
// if(newDmp.getOrganisations()!=null&&!newDmp.getOrganisations().isEmpty()){
|
||||||
for(eu.eudat.entities.Organisation organisation: newDmp.getOrganisations()){
|
// for(eu.eudat.entities.Organisation organisation: newDmp.getOrganisations()){
|
||||||
OrganisationCriteria criteria = new OrganisationCriteria();
|
// OrganisationCriteria criteria = new OrganisationCriteria();
|
||||||
criteria.setLike(organisation.getReference());
|
// criteria.setLike(organisation.getReference());
|
||||||
List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
// List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
||||||
else organisation = this.organisationDao.create(organisation);
|
// else organisation = this.organisationDao.create(organisation);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(newDmp.getResearchers()!=null&&!newDmp.getResearchers().isEmpty()){
|
// if(newDmp.getResearchers()!=null&&!newDmp.getResearchers().isEmpty()){
|
||||||
for(eu.eudat.entities.Researcher researcher : newDmp.getResearchers()){
|
// for(eu.eudat.entities.Researcher researcher : newDmp.getResearchers()){
|
||||||
ResearcherCriteria criteria = new ResearcherCriteria();
|
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||||
criteria.setLike(researcher.getReference());
|
// criteria.setLike(researcher.getReference());
|
||||||
List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
// List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
||||||
else researcher = this.researcherDao.create(researcher);
|
// else researcher = this.researcherDao.create(researcher);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
DMP previousDmp = dMPDao.read(dataManagementPlan.getId());
|
// DMP previousDmp = dMPDao.read(dataManagementPlan.getId());
|
||||||
previousDmp.setResearchers(newDmp.getResearchers());
|
// previousDmp.setResearchers(newDmp.getResearchers());
|
||||||
previousDmp.setOrganisations(newDmp.getOrganisations());
|
// previousDmp.setOrganisations(newDmp.getOrganisations());
|
||||||
previousDmp.setLabel(dataManagementPlan.getLabel());
|
// previousDmp.setLabel(dataManagementPlan.getLabel());
|
||||||
previousDmp.setVersion(dataManagementPlan.getVersion());
|
// previousDmp.setVersion(dataManagementPlan.getVersion());
|
||||||
previousDmp.setStatus((short)dataManagementPlan.getStatus());
|
// previousDmp.setStatus((short)dataManagementPlan.getStatus());
|
||||||
//if(!previousDmp.getProject().getId().equals(newDmp.getProject().getId()))previousDmp.setProject(projectDao.read(newDmp.getProject().getId()));
|
// //if(!previousDmp.getProject().getId().equals(newDmp.getProject().getId()))previousDmp.setProject(projectDao.read(newDmp.getProject().getId()));
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
DMP updatedDMP = dMPDao.update(previousDmp);
|
// DMP updatedDMP = dMPDao.update(previousDmp);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(updatedDMP);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(updatedDMP);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/getdatasets" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/getdatasets" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<List<Dataset>> getDatasetsOfDMP(@RequestBody DMP dmp) {
|
// public @ResponseBody ResponseEntity<List<Dataset>> getDatasetsOfDMP(@RequestBody DMP dmp) {
|
||||||
try {
|
// try {
|
||||||
List<Dataset> datasets = datasetDao.getDatasetsOfDmp(dmp.getId());
|
// List<Dataset> datasets = datasetDao.getDatasetsOfDmp(dmp.getId());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(datasets);
|
// return ResponseEntity.status(HttpStatus.OK).body(datasets);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/delete" }, consumes = "application/json", produces="text/plain")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/delete" }, consumes = "application/json", produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody DMP dmp) {
|
// public @ResponseBody ResponseEntity<Object> delete(@RequestBody DMP dmp) {
|
||||||
|
//
|
||||||
DMP d = new DMP();
|
// DMP d = new DMP();
|
||||||
d.setId(dmp.getId());
|
// d.setId(dmp.getId());
|
||||||
try {
|
// try {
|
||||||
dMPDao.delete(d);
|
// dMPDao.delete(d);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
// return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not Delete DMP!\"");
|
// 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")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody DMP dmp) {
|
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody DMP dmp) {
|
||||||
|
//
|
||||||
try{
|
// try{
|
||||||
DMP d = dMPDao.read(dmp.getId());
|
// DMP d = dMPDao.read(dmp.getId());
|
||||||
d.setStatus(new Short("-1"));
|
// d.setStatus(new Short("-1"));
|
||||||
dMPDao.update(d);
|
// dMPDao.update(d);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"deleted DMP!\"");
|
// return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"deleted DMP!\"");
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\"");
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete DMP!\"");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
////////////////////////////////
|
// ////////////////////////////////
|
||||||
//// USER - RELATED ACTIONS ////
|
// //// USER - RELATED ACTIONS ////
|
||||||
////////////////////////////////
|
// ////////////////////////////////
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmp/getofuser" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dmp/getofuser" }, produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<List<DMP>> getDmpsOfUser(){
|
// public @ResponseBody ResponseEntity<List<DMP>> getDmpsOfUser(){
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
//List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
|
// //List<DMP> nonDeleted = userInfoDao.getDmpsOfUser(userID);
|
||||||
List<DMP> nonDeleted = dMPDao.getDMPsOfUser(userID);
|
// List<DMP> nonDeleted = dMPDao.getDMPsOfUser(userID);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(nonDeleted);
|
// return ResponseEntity.status(HttpStatus.OK).body(nonDeleted);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain", consumes = "application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/createofuser" }, produces="text/plain", consumes = "application/json")
|
||||||
public @ResponseBody ResponseEntity<DMP> createDmpOfUser(@RequestBody DataManagementPlan dataManagementPlan){
|
// public @ResponseBody ResponseEntity<DMP> createDmpOfUser(@RequestBody DataManagementPlan dataManagementPlan){
|
||||||
|
//
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happer
|
// if(userInfo==null) //this should normally never happer
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
DMP dmp = dataManagementPlan.toDataModel();
|
// DMP dmp = dataManagementPlan.toDataModel();
|
||||||
|
//
|
||||||
if(dmp.getOrganisations()!=null&&!dmp.getOrganisations().isEmpty()){
|
// if(dmp.getOrganisations()!=null&&!dmp.getOrganisations().isEmpty()){
|
||||||
for(eu.eudat.entities.Organisation organisation: dmp.getOrganisations()){
|
// for(eu.eudat.entities.Organisation organisation: dmp.getOrganisations()){
|
||||||
OrganisationCriteria criteria = new OrganisationCriteria();
|
// OrganisationCriteria criteria = new OrganisationCriteria();
|
||||||
criteria.setLike(organisation.getReference());
|
// criteria.setLike(organisation.getReference());
|
||||||
List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
// List<eu.eudat.entities.Organisation> entries = this.organisationDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())organisation.setId(entries.get(0).getId());
|
||||||
else organisation = this.organisationDao.create(organisation);
|
// else organisation = this.organisationDao.create(organisation);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(dmp.getResearchers()!=null&&!dmp.getResearchers().isEmpty()){
|
// if(dmp.getResearchers()!=null&&!dmp.getResearchers().isEmpty()){
|
||||||
for(eu.eudat.entities.Researcher researcher : dmp.getResearchers()){
|
// for(eu.eudat.entities.Researcher researcher : dmp.getResearchers()){
|
||||||
ResearcherCriteria criteria = new ResearcherCriteria();
|
// ResearcherCriteria criteria = new ResearcherCriteria();
|
||||||
criteria.setLike(researcher.getReference());
|
// criteria.setLike(researcher.getReference());
|
||||||
List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
// List<eu.eudat.entities.Researcher> entries = this.researcherDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())researcher.setId(entries.get(0).getId());
|
||||||
else researcher = this.researcherDao.create(researcher);
|
// else researcher = this.researcherDao.create(researcher);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
dmp.setId(null);
|
// dmp.setId(null);
|
||||||
|
//
|
||||||
dmp.setCreator(userInfo);
|
// dmp.setCreator(userInfo);
|
||||||
dmp.setProject(this.projectDao.read(dataManagementPlan.getProject().getId()));
|
// dmp.setProject(this.projectDao.read(dataManagementPlan.getProject().getId()));
|
||||||
Set<UserInfo> users = new HashSet<UserInfo>();
|
// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||||
users.add(userInfo);
|
// users.add(userInfo);
|
||||||
dmp.setUsers(users);
|
// dmp.setUsers(users);
|
||||||
|
//
|
||||||
dmp.setCreated(new Date());
|
// dmp.setCreated(new Date());
|
||||||
dmp.setModified(new Date());
|
// dmp.setModified(new Date());
|
||||||
dmp.setStatus(new Short("0"));
|
// dmp.setStatus(new Short("0"));
|
||||||
|
//
|
||||||
DMP newdmp = dMPDao.create(dmp);
|
// DMP newdmp = dMPDao.create(dmp);
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(newdmp);
|
// return ResponseEntity.status(HttpStatus.OK).body(newdmp);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/cloneforuser" }, produces="text/plain", consumes = "application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/cloneforuser" }, produces="text/plain", consumes = "application/json")
|
||||||
public @ResponseBody ResponseEntity<DMP> cloneDmpOfUser(@RequestBody DMP dmp){
|
// public @ResponseBody ResponseEntity<DMP> cloneDmpOfUser(@RequestBody DMP dmp){
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happer
|
// if(userInfo==null) //this should normally never happer
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
//
|
||||||
DMP clone = dMPDao.read(dmp.getId());
|
// DMP clone = dMPDao.read(dmp.getId());
|
||||||
|
//
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
Set<UserInfo> users = new HashSet<UserInfo>();
|
// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||||
users.add(userInfo);
|
// users.add(userInfo);
|
||||||
clone.setUsers(users);
|
// clone.setUsers(users);
|
||||||
|
//
|
||||||
clone.setCreated(new Date());
|
// clone.setCreated(new Date());
|
||||||
clone.setModified(new Date());
|
// clone.setModified(new Date());
|
||||||
clone.setStatus(new Short("0"));
|
// clone.setStatus(new Short("0"));
|
||||||
|
//
|
||||||
String cloneLabel = dmp.getLabel();
|
// String cloneLabel = dmp.getLabel();
|
||||||
if(cloneLabel==null || cloneLabel.isEmpty()) //if the provided label is null or empty, use parent's label + "_clone"
|
// if(cloneLabel==null || cloneLabel.isEmpty()) //if the provided label is null or empty, use parent's label + "_clone"
|
||||||
cloneLabel = clone.getLabel()+"_clone";
|
// cloneLabel = clone.getLabel()+"_clone";
|
||||||
clone.setVersion(clone.getVersion()+1);
|
// clone.setVersion(clone.getVersion()+1);
|
||||||
clone.setLabel(cloneLabel);
|
// clone.setLabel(cloneLabel);
|
||||||
clone.setPrevious(clone.getId());
|
// clone.setPrevious(clone.getId());
|
||||||
|
//
|
||||||
|
//
|
||||||
clone.setId(null);
|
// clone.setId(null);
|
||||||
|
//
|
||||||
clone = dMPDao.create(clone);
|
// clone = dMPDao.create(clone);
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(clone);
|
// return ResponseEntity.status(HttpStatus.OK).body(clone);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/adduser" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dmp/adduser" }, produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<DMP> addUserToDmp(@RequestBody DMP dmp){
|
// public @ResponseBody ResponseEntity<DMP> addUserToDmp(@RequestBody DMP dmp){
|
||||||
|
//
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
final UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// final UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happer
|
// if(userInfo==null) //this should normally never happer
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
//
|
||||||
if(dmp==null || dmp.getId()==null)
|
// if(dmp==null || dmp.getId()==null)
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
DMP existingDMP = dMPDao.read(dmp.getId());
|
// DMP existingDMP = dMPDao.read(dmp.getId());
|
||||||
|
//
|
||||||
Set<UserInfo> users = existingDMP.getUsers().parallelStream().filter(user -> user.getId().toString() != userInfo.getId().toString()).collect(Collectors.toSet());
|
// Set<UserInfo> users = existingDMP.getUsers().parallelStream().filter(user -> user.getId().toString() != userInfo.getId().toString()).collect(Collectors.toSet());
|
||||||
|
//
|
||||||
users.add(userInfo);
|
// users.add(userInfo);
|
||||||
dmp.setUsers(users);
|
// dmp.setUsers(users);
|
||||||
|
//
|
||||||
DMP updateddmp = dMPDao.update(dmp);
|
// DMP updateddmp = dMPDao.update(dmp);
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(updateddmp);
|
// return ResponseEntity.status(HttpStatus.OK).body(updateddmp);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
private static void addNullAndForeignElems(DMP existing, DMP newone) {
|
// private static void addNullAndForeignElems(DMP existing, DMP newone) {
|
||||||
|
//
|
||||||
newone.setModified(new Date());
|
// newone.setModified(new Date());
|
||||||
if(newone.getStatus()==null)
|
// if(newone.getStatus()==null)
|
||||||
newone.setStatus(existing.getStatus());
|
// newone.setStatus(existing.getStatus());
|
||||||
if(newone.getCreated()==null)
|
// if(newone.getCreated()==null)
|
||||||
newone.setCreated(existing.getCreated());
|
// newone.setCreated(existing.getCreated());
|
||||||
|
//
|
||||||
newone.setDataset(existing.getDataset());
|
// newone.setDataset(existing.getDataset());
|
||||||
newone.setOrganisations(existing.getOrganisations());
|
// newone.setOrganisations(existing.getOrganisations());
|
||||||
newone.setResearchers(existing.getResearchers());
|
// newone.setResearchers(existing.getResearchers());
|
||||||
newone.setUsers(existing.getUsers());
|
// newone.setUsers(existing.getUsers());
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +1,18 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import java.util.Map;
|
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||||
import java.util.UUID;
|
import eu.eudat.models.security.Principal;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import eu.eudat.dao.entities.DMPDao;
|
import eu.eudat.dao.entities.DMPDao;
|
||||||
import eu.eudat.dao.entities.DMPProfileDao;
|
|
||||||
import eu.eudat.dao.entities.DataRepositoryDao;
|
|
||||||
import eu.eudat.dao.entities.DatasetDao;
|
import eu.eudat.dao.entities.DatasetDao;
|
||||||
import eu.eudat.dao.entities.DatasetProfileDao;
|
|
||||||
import eu.eudat.dao.entities.DatasetProfileRulesetDao;
|
|
||||||
import eu.eudat.dao.entities.DatasetProfileViewstyleDao;
|
|
||||||
import eu.eudat.dao.entities.OrganisationDao;
|
|
||||||
import eu.eudat.dao.entities.ProjectDao;
|
import eu.eudat.dao.entities.ProjectDao;
|
||||||
import eu.eudat.dao.entities.RegistryDao;
|
|
||||||
import eu.eudat.dao.entities.ResearcherDao;
|
|
||||||
import eu.eudat.dao.entities.ServiceDao;
|
|
||||||
import eu.eudat.managers.DashBoardManager;
|
import eu.eudat.managers.DashBoardManager;
|
||||||
import eu.eudat.managers.UserManager;
|
|
||||||
import eu.eudat.models.dashboard.DashBoardStatistics;
|
import eu.eudat.models.dashboard.DashBoardStatistics;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -38,14 +24,14 @@ public class DashBoardController {
|
||||||
@Autowired private ProjectDao projectDao;
|
@Autowired private ProjectDao projectDao;
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||||
public ResponseEntity<DashBoardStatistics> getStatistics(){
|
public ResponseItem<DashBoardStatistics> getStatistics(Principal principal){
|
||||||
try {
|
try {
|
||||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(datasetDao, dMPDao, projectDao);
|
DashBoardStatistics statistics = new DashBoardManager().getStatistics(datasetDao, dMPDao, projectDao);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(statistics);
|
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.OK).payload(statistics);
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
return new ResponseItem<DashBoardStatistics>().status(HttpStatus.INTERNAL_SERVER_ERROR).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,73 +76,73 @@ public class DataRepositories {
|
||||||
|
|
||||||
// MANAGE DATAREPOSITORy(IES)
|
// MANAGE DATAREPOSITORy(IES)
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datarepos" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/datarepos" })
|
||||||
public @ResponseBody ResponseEntity<List<UUID>> listDataRepositories(){
|
// public @ResponseBody ResponseEntity<List<UUID>> listDataRepositories(){
|
||||||
try {
|
// try {
|
||||||
List<UUID> allIDs = dataRepositoryDao.listAllIDs();
|
// List<UUID> allIDs = dataRepositoryDao.listAllIDs();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datarepos/{id}" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/datarepos/{id}" })
|
||||||
public @ResponseBody ResponseEntity<DataRepository> getDataRepository(@PathVariable("id") String id) {
|
// public @ResponseBody ResponseEntity<DataRepository> getDataRepository(@PathVariable("id") String id) {
|
||||||
try {
|
// try {
|
||||||
DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
|
// DataRepository dataRepository = dataRepositoryDao.read(UUID.fromString(id));
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataRepository);
|
// return ResponseEntity.status(HttpStatus.OK).body(dataRepository);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datarepo/getAll" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/datarepo/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<List<DataRepository>> getAllDataRepositories(){
|
// public @ResponseBody ResponseEntity<List<DataRepository>> getAllDataRepositories(){
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
List<DataRepository> allDataRepositories = dataRepositoryDao.getAll();
|
// List<DataRepository> allDataRepositories = dataRepositoryDao.getAll();
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allDataRepositories);
|
// return ResponseEntity.status(HttpStatus.OK).body(allDataRepositories);
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/datarepo/create" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/datarepo/create" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DataRepository> setOrganisation(@RequestBody DataRepository dataRepository) {
|
// public @ResponseBody ResponseEntity<DataRepository> setOrganisation(@RequestBody DataRepository dataRepository) {
|
||||||
try {
|
// try {
|
||||||
DataRepository createdDataRepository = dataRepositoryDao.update(dataRepository);
|
// DataRepository createdDataRepository = dataRepositoryDao.update(dataRepository);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdDataRepository);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(createdDataRepository);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/datarepo/delete" }, consumes = "application/json", produces="text/plain")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/datarepo/delete" }, consumes = "application/json", produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<Object> delete(@RequestBody DataRepository dataRepository) {
|
// public @ResponseBody ResponseEntity<Object> delete(@RequestBody DataRepository dataRepository) {
|
||||||
|
//
|
||||||
DataRepository dr = new DataRepository();
|
// DataRepository dr = new DataRepository();
|
||||||
dr.setId(dataRepository.getId());
|
// dr.setId(dataRepository.getId());
|
||||||
try {
|
// try {
|
||||||
dataRepositoryDao.delete(dr);
|
// dataRepositoryDao.delete(dr);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted data repository!\"}");
|
// return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted data repository!\"}");
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete data repository!\"}");
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete data repository!\"}");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public class DatasetProfileController {
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/datasetprofile/get/{id}" }, produces="application/json")
|
||||||
public ResponseEntity<Object> getSingle(@PathVariable String id){
|
public ResponseEntity<Object> getSingle(@PathVariable String id){
|
||||||
try {
|
try {
|
||||||
eu.eudat.entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
|
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(id));
|
||||||
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
eu.eudat.models.user.composite.DatasetProfile datasetprofile = UserManager.generateDatasetProfileModel(dataset.getProfile());
|
||||||
datasetprofile.setStatus(dataset.getStatus());
|
datasetprofile.setStatus(dataset.getStatus());
|
||||||
if(dataset.getProperties()!=null){
|
if(dataset.getProperties()!=null){
|
||||||
|
@ -62,13 +62,13 @@ public class DatasetProfileController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/save/{id}" }, consumes="application/json",produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/save/{id}" }, consumes="application/json",produces="application/json")
|
||||||
public ResponseEntity<Object> updateDataset(@PathVariable String id,@RequestBody PropertiesModel properties){
|
public ResponseEntity<Object> updateDataset(@PathVariable String id,@RequestBody PropertiesModel properties){
|
||||||
try {
|
try {
|
||||||
eu.eudat.entities.Dataset dataset = datasetDao.read(UUID.fromString(id));
|
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(id));
|
||||||
Map<String,Object> values = new HashMap();
|
Map<String,Object> values = new HashMap();
|
||||||
properties.toMap(values);
|
properties.toMap(values);
|
||||||
JSONObject jobject = new JSONObject(values);
|
JSONObject jobject = new JSONObject(values);
|
||||||
dataset.setProperties(jobject.toString());
|
dataset.setProperties(jobject.toString());
|
||||||
dataset.setStatus((short)properties.getStatus());
|
dataset.setStatus((short)properties.getStatus());
|
||||||
datasetDao.update(dataset);
|
datasetDao.createOrUpdate(dataset); //TODO
|
||||||
|
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(properties);
|
return ResponseEntity.status(HttpStatus.OK).body(properties);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ public class DatasetProfileController {
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/search/autocomplete" }, consumes="application/json",produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/search/autocomplete" }, consumes="application/json",produces="application/json")
|
||||||
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody AutoCompleteLookupItem lookupItem){
|
public ResponseEntity<Object> getDataForAutocomplete(@RequestBody AutoCompleteLookupItem lookupItem){
|
||||||
try {
|
try {
|
||||||
eu.eudat.entities.Dataset dataset = datasetDao.read(UUID.fromString(lookupItem.getProfileID()));
|
eu.eudat.entities.Dataset dataset = datasetDao.find(UUID.fromString(lookupItem.getProfileID()));
|
||||||
Document viewStyleDoc = XmlBuilder.fromXml(dataset.getProfile().getViewstyle().getDefinition());
|
Document viewStyleDoc = XmlBuilder.fromXml(dataset.getProfile().getViewstyle().getDefinition());
|
||||||
Element field = viewStyleDoc.getElementById(lookupItem.getFieldID());
|
Element field = viewStyleDoc.getElementById(lookupItem.getFieldID());
|
||||||
eu.eudat.entities.xmlmodels.viewstyledefinition.Field modelfield = new eu.eudat.entities.xmlmodels.viewstyledefinition.Field();
|
eu.eudat.entities.xmlmodels.viewstyledefinition.Field modelfield = new eu.eudat.entities.xmlmodels.viewstyledefinition.Field();
|
||||||
|
|
|
@ -9,11 +9,9 @@ import eu.eudat.entities.Dataset;
|
||||||
import eu.eudat.entities.DatasetProfile;
|
import eu.eudat.entities.DatasetProfile;
|
||||||
import eu.eudat.entities.UserInfo;
|
import eu.eudat.entities.UserInfo;
|
||||||
import eu.eudat.managers.DatasetManager;
|
import eu.eudat.managers.DatasetManager;
|
||||||
import eu.eudat.managers.ProjectManager;
|
|
||||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
import eu.eudat.models.project.Project;
|
import eu.eudat.models.helpers.responses.*;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
|
@ -68,25 +66,25 @@ public class Datasets {
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/datasets/getPaged" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DataTableData<eu.eudat.models.dataset.Dataset>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>> getPaged(@RequestBody DatasetTableRequest datasetTableRequest) {
|
||||||
try {
|
try {
|
||||||
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest);
|
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DatasetManager().getPaged(datasetDao, datasetTableRequest);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataTable);
|
return new ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>>().status(HttpStatus.OK).payload(dataTable);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<DataTableData<eu.eudat.models.dataset.Dataset>>().status(HttpStatus.OK).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasets/getSingle/{id}" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/datasets/getSingle/{id}" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.models.dataset.Dataset> getPaged(@PathVariable String id) {
|
public @ResponseBody ResponseItem<eu.eudat.models.dataset.Dataset> getPaged(@PathVariable String id) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.models.dataset.Dataset dataset = new DatasetManager().getSingle(datasetDao, id);
|
eu.eudat.models.dataset.Dataset dataset = new DatasetManager().getSingle(datasetDao, id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataset);
|
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.OK).payload(dataset);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<eu.eudat.models.dataset.Dataset>().status(HttpStatus.OK).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,256 +95,256 @@ public class Datasets {
|
||||||
// FETCH BY DATASET(S)
|
// FETCH BY DATASET(S)
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasets" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/datasets" })
|
||||||
public @ResponseBody ResponseEntity<List<UUID>> listDatasets(){
|
// public @ResponseBody ResponseEntity<List<UUID>> listDatasets(){
|
||||||
try {
|
// try {
|
||||||
List<UUID> allIDs = datasetDao.listAllIDs();
|
// List<UUID> allIDs = datasetDao.listAllIDs();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/datasets/{id}" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/datasets/{id}" })
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.models.dataset.Dataset> getDataset(@PathVariable("id") String id) {
|
// public @ResponseBody ResponseEntity<eu.eudat.models.dataset.Dataset> getDataset(@PathVariable("id") String id) {
|
||||||
try {
|
// try {
|
||||||
Dataset ds = datasetDao.read(UUID.fromString(id));
|
// Dataset ds = datasetDao.read(UUID.fromString(id));
|
||||||
eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset();
|
// eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset();
|
||||||
dataset.fromDataModel(ds);
|
// dataset.fromDataModel(ds);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataset);
|
// return ResponseEntity.status(HttpStatus.OK).body(dataset);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/**
|
// /**
|
||||||
* This should be called on extreme cases. It's computationally intensive
|
// * This should be called on extreme cases. It's computationally intensive
|
||||||
*/
|
// */
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/getAll" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/getAll" })
|
||||||
public @ResponseBody ResponseEntity<List<Dataset>> getAllDatasets(){
|
// public @ResponseBody ResponseEntity<List<Dataset>> getAllDatasets(){
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
List<Dataset> allDatasets = datasetDao.getAll();
|
// List<Dataset> allDatasets = datasetDao.getAll();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allDatasets);
|
// return ResponseEntity.status(HttpStatus.OK).body(allDatasets);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/create" }, consumes = "application/json", produces="application/json")
|
// @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) {
|
// public @ResponseBody ResponseEntity<Dataset> createDataset(@RequestBody eu.eudat.models.dataset.Dataset modeldataset) {
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happer
|
// if(userInfo==null) //this should normally never happer
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
//
|
||||||
|
//
|
||||||
Dataset dataset = modeldataset.toDataModel();
|
// Dataset dataset = modeldataset.toDataModel();
|
||||||
if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
// if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
||||||
for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
// for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
criteria.setLike(dataRepo.getReference());
|
// criteria.setLike(dataRepo.getReference());
|
||||||
List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
// List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
||||||
else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
// else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
// if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
||||||
for(eu.eudat.entities.Service service : dataset.getServices()){
|
// for(eu.eudat.entities.Service service : dataset.getServices()){
|
||||||
ServiceCriteria criteria = new ServiceCriteria();
|
// ServiceCriteria criteria = new ServiceCriteria();
|
||||||
criteria.setLike(service.getReference());
|
// criteria.setLike(service.getReference());
|
||||||
List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
// List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
||||||
else service = this.serviceDao.create(service);
|
// else service = this.serviceDao.create(service);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
// if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
||||||
for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
// for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
||||||
RegistryCriteria criteria = new RegistryCriteria();
|
// RegistryCriteria criteria = new RegistryCriteria();
|
||||||
criteria.setLike(registry.getReference());
|
// criteria.setLike(registry.getReference());
|
||||||
List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
// List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
||||||
else registry = this.registryDao.create(registry);
|
// else registry = this.registryDao.create(registry);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
dataset.setId(null);
|
// dataset.setId(null);
|
||||||
dataset.setCreated(new Date());
|
// dataset.setCreated(new Date());
|
||||||
dataset.setModified(new Date());
|
// dataset.setModified(new Date());
|
||||||
dataset.setStatus(new Short("0"));
|
// dataset.setStatus(new Short("0"));
|
||||||
dataset.setCreator(userInfo);
|
// dataset.setCreator(userInfo);
|
||||||
if("".equals(dataset.getReference())) dataset.setReference(null);
|
// if("".equals(dataset.getReference())) dataset.setReference(null);
|
||||||
if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
// if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
dataset = datasetDao.create(dataset);
|
// dataset = datasetDao.create(dataset);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
||||||
}
|
// }
|
||||||
catch(Exception e) {
|
// catch(Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/dataset/update" }, consumes = "application/json", produces="application/json")
|
// @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) {
|
// public @ResponseBody ResponseEntity<Object> updateDataset(@RequestBody eu.eudat.models.dataset.Dataset modeldataset) {
|
||||||
|
//
|
||||||
Dataset dataset = modeldataset.toDataModel();
|
// Dataset dataset = modeldataset.toDataModel();
|
||||||
|
//
|
||||||
if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
// if(dataset.getDataRepositories()!=null&&!dataset.getDataRepositories().isEmpty()){
|
||||||
for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
// for(eu.eudat.entities.DataRepository dataRepo : dataset.getDataRepositories()){
|
||||||
DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
// DataRepositoryCriteria criteria = new DataRepositoryCriteria();
|
||||||
criteria.setLike(dataRepo.getReference());
|
// criteria.setLike(dataRepo.getReference());
|
||||||
List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
// List<eu.eudat.entities.DataRepository> entries = this.dataRepositoryDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())dataRepo.setId(entries.get(0).getId());
|
||||||
else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
// else dataRepo = this.dataRepositoryDao.create(dataRepo);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
// if(dataset.getServices()!=null&&!dataset.getServices().isEmpty()){
|
||||||
for(eu.eudat.entities.Service service : dataset.getServices()){
|
// for(eu.eudat.entities.Service service : dataset.getServices()){
|
||||||
ServiceCriteria criteria = new ServiceCriteria();
|
// ServiceCriteria criteria = new ServiceCriteria();
|
||||||
criteria.setLike(service.getReference());
|
// criteria.setLike(service.getReference());
|
||||||
List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
// List<eu.eudat.entities.Service> entries = this.serviceDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())service.setId(entries.get(0).getId());
|
||||||
else service = this.serviceDao.create(service);
|
// else service = this.serviceDao.create(service);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
// if(dataset.getRegistries()!=null&&!dataset.getRegistries().isEmpty()){
|
||||||
for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
// for(eu.eudat.entities.Registry registry : dataset.getRegistries()){
|
||||||
RegistryCriteria criteria = new RegistryCriteria();
|
// RegistryCriteria criteria = new RegistryCriteria();
|
||||||
criteria.setLike(registry.getReference());
|
// criteria.setLike(registry.getReference());
|
||||||
List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
// List<eu.eudat.entities.Registry> entries = this.registryDao.listBy(criteria);
|
||||||
if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
// if(entries!=null&&!entries.isEmpty())registry.setId( entries.get(0).getId());
|
||||||
else registry = this.registryDao.create(registry);
|
// else registry = this.registryDao.create(registry);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
Dataset olddataset = datasetDao.read(modeldataset.getId());
|
// Dataset olddataset = datasetDao.read(modeldataset.getId());
|
||||||
|
//
|
||||||
olddataset.getServices().clear();
|
// olddataset.getServices().clear();
|
||||||
olddataset.setServices(dataset.getServices());
|
// olddataset.setServices(dataset.getServices());
|
||||||
|
//
|
||||||
olddataset.getDataRepositories().clear();
|
// olddataset.getDataRepositories().clear();
|
||||||
olddataset.setDataRepositories(dataset.getDataRepositories());
|
// olddataset.setDataRepositories(dataset.getDataRepositories());
|
||||||
olddataset.getRegistries().clear();
|
// olddataset.getRegistries().clear();
|
||||||
olddataset.setRegistries(dataset.getRegistries());
|
// olddataset.setRegistries(dataset.getRegistries());
|
||||||
|
//
|
||||||
olddataset.setLabel(modeldataset.getLabel());
|
// olddataset.setLabel(modeldataset.getLabel());
|
||||||
olddataset.setDescription(modeldataset.getDescription());
|
// olddataset.setDescription(modeldataset.getDescription());
|
||||||
//SafeCleanAttribs.clean(dataset);
|
// //SafeCleanAttribs.clean(dataset);
|
||||||
|
//
|
||||||
if("".equals(dataset.getReference())) dataset.setReference(null);
|
// if("".equals(dataset.getReference())) dataset.setReference(null);
|
||||||
if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
// if("".equals(dataset.getProperties())) dataset.setProperties(null);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
dataset = datasetDao.update(olddataset);
|
// dataset = datasetDao.update(olddataset);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(dataset);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not create or update Dataset! Reason: " + ex.getMessage());
|
// 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")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/delete" }, consumes = "application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> deleteDataset(@RequestBody Dataset dataset) {
|
// 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
|
// //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)
|
// // e.g: DMP dmp = new DMP() and then dataset.setDMP(dmp)
|
||||||
try {
|
// try {
|
||||||
datasetDao.delete(dataset);
|
// datasetDao.delete(dataset);
|
||||||
RestResponse rr = new RestResponse("Deleted dataset with id: "+dataset.getId().toString(), dataset.getId().toString());
|
// RestResponse rr = new RestResponse("Deleted dataset with id: "+dataset.getId().toString(), dataset.getId().toString());
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(rr.toString());
|
// return ResponseEntity.status(HttpStatus.OK).body(rr.toString());
|
||||||
}
|
// }
|
||||||
catch(Exception e) {
|
// catch(Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Could not delete Dataset! Reason: " + e.getMessage());
|
// 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")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/dataset/softdelete" }, consumes = "application/json", produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Dataset dataset) {
|
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Dataset dataset) {
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
Dataset d = datasetDao.read(dataset.getId());
|
// Dataset d = datasetDao.read(dataset.getId());
|
||||||
d.setStatus(new Short("-1"));
|
// d.setStatus(new Short("-1"));
|
||||||
dataset = datasetDao.update(d);
|
// dataset = datasetDao.update(d);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"Deleted dataset!\"");
|
// return ResponseEntity.status(HttpStatus.OK).body("{\"msg\":\"Deleted dataset!\"");
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete dataset!\"");
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not soft delete dataset!\"");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignDMPToDataset" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignDMPToDataset" })
|
||||||
public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {
|
// public @ResponseBody ResponseEntity<Object> assignDMPToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("dmpID") String dmpID) {
|
||||||
|
//
|
||||||
Dataset dataset = null;
|
// Dataset dataset = null;
|
||||||
try {
|
// try {
|
||||||
dataset = datasetDao.read(UUID.fromString(datasetID));
|
// dataset = datasetDao.read(UUID.fromString(datasetID));
|
||||||
if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
// if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
||||||
DMP dmp = new DMP();
|
// DMP dmp = new DMP();
|
||||||
dmp.setId(UUID.fromString(dmpID));
|
// dmp.setId(UUID.fromString(dmpID));
|
||||||
dataset.setDmp(dmp);
|
// dataset.setDmp(dmp);
|
||||||
datasetDao.update(dataset);
|
// datasetDao.update(dataset);
|
||||||
return ResponseEntity.status(HttpStatus.OK).build();
|
// return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignProfileToDataset" })
|
// @RequestMapping(method = RequestMethod.GET, value = { "/dataset/assignProfileToDataset" })
|
||||||
public @ResponseBody ResponseEntity<Object> assignProfileToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("profileID") String profileID) {
|
// public @ResponseBody ResponseEntity<Object> assignProfileToDataset(@RequestParam("datasetID") String datasetID, @RequestParam("profileID") String profileID) {
|
||||||
|
//
|
||||||
Dataset dataset = null;
|
// Dataset dataset = null;
|
||||||
try {
|
// try {
|
||||||
dataset = datasetDao.read(UUID.fromString(datasetID));
|
// dataset = datasetDao.read(UUID.fromString(datasetID));
|
||||||
if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
// if(dataset==null || dataset.getId()==null) throw new Exception("Could not find a Dataset by this id");
|
||||||
DatasetProfile profile = new DatasetProfile();
|
// DatasetProfile profile = new DatasetProfile();
|
||||||
profile.setId(UUID.fromString(profileID));
|
// profile.setId(UUID.fromString(profileID));
|
||||||
dataset.setProfile(profile);
|
// dataset.setProfile(profile);
|
||||||
datasetDao.update(dataset);
|
// datasetDao.update(dataset);
|
||||||
return ResponseEntity.status(HttpStatus.OK).build();
|
// return ResponseEntity.status(HttpStatus.OK).build();
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
|
import eu.eudat.models.login.Credentials;
|
||||||
|
import eu.eudat.models.helpers.responses.ResponseItem;
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
|
import eu.eudat.security.CustomAuthenticationProvider;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping(value = "/login")
|
||||||
|
public class Login {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CustomAuthenticationProvider customAuthenticationProvider;
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/googlelogin" }, consumes = "application/json", produces="application/json")
|
||||||
|
public @ResponseBody ResponseItem<Principal> googleLogin(@RequestBody Credentials credentials) {
|
||||||
|
try {
|
||||||
|
return new ResponseItem<Principal>().payload(customAuthenticationProvider.authenticate(credentials)).status(HttpStatus.OK);
|
||||||
|
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return new ResponseItem<Principal>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,23 +1,18 @@
|
||||||
package eu.eudat.controllers;
|
package eu.eudat.controllers;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.transaction.Transactional;
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import eu.eudat.models.helpers.responses.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.MediaType;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
import org.springframework.util.MultiValueMap;
|
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
@ -27,11 +22,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import eu.eudat.dao.entities.DMPDao;
|
import eu.eudat.dao.entities.DMPDao;
|
||||||
import eu.eudat.dao.entities.DMPProfileDao;
|
import eu.eudat.dao.entities.DMPProfileDao;
|
||||||
import eu.eudat.dao.entities.DataRepositoryDao;
|
import eu.eudat.dao.entities.DataRepositoryDao;
|
||||||
|
@ -46,27 +36,16 @@ import eu.eudat.dao.entities.ResearcherDao;
|
||||||
import eu.eudat.dao.entities.ServiceDao;
|
import eu.eudat.dao.entities.ServiceDao;
|
||||||
import eu.eudat.dao.entities.UserInfoDao;
|
import eu.eudat.dao.entities.UserInfoDao;
|
||||||
import eu.eudat.entities.DMP;
|
import eu.eudat.entities.DMP;
|
||||||
import eu.eudat.entities.DMPProfile;
|
|
||||||
import eu.eudat.entities.DataRepository;
|
|
||||||
import eu.eudat.entities.Dataset;
|
|
||||||
import eu.eudat.entities.DatasetProfile;
|
|
||||||
import eu.eudat.entities.DatasetProfileRuleset;
|
|
||||||
import eu.eudat.entities.Organisation;
|
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
import eu.eudat.entities.Registry;
|
|
||||||
import eu.eudat.entities.Researcher;
|
|
||||||
import eu.eudat.entities.Service;
|
|
||||||
import eu.eudat.entities.UserInfo;
|
import eu.eudat.entities.UserInfo;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
|
|
||||||
import eu.eudat.helpers.Transformers;
|
|
||||||
import eu.eudat.managers.ProjectManager;
|
import eu.eudat.managers.ProjectManager;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
import eu.eudat.proxy.config.exceptions.HugeResultSet;
|
||||||
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
import eu.eudat.proxy.config.exceptions.NoURLFound;
|
||||||
import eu.eudat.proxy.fetching.RemoteFetcher;
|
import eu.eudat.proxy.fetching.RemoteFetcher;
|
||||||
import eu.eudat.responses.RestResponse;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -94,34 +73,34 @@ public class Projects {
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getPaged" }, consumes = "application/json", produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getPaged" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<DataTableData<eu.eudat.models.project.Project>> getPaged(@RequestBody ProjectTableRequest projectTableRequest) {
|
public @ResponseBody ResponseItem<DataTableData<eu.eudat.models.project.Project>> getPaged(@RequestBody ProjectTableRequest projectTableRequest) {
|
||||||
try {
|
try {
|
||||||
DataTableData<eu.eudat.models.project.Project> dataTable = new ProjectManager().getPaged(projectDao, projectTableRequest);
|
DataTableData<eu.eudat.models.project.Project> dataTable = new ProjectManager().getPaged(projectDao, projectTableRequest);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(dataTable);
|
return new ResponseItem<DataTableData<eu.eudat.models.project.Project>>().payload(dataTable).status(HttpStatus.OK);
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<DataTableData<eu.eudat.models.project.Project>>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/projects/getSingle/{id}" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/projects/getSingle/{id}" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.models.project.Project> getPaged(@PathVariable String id) {
|
public @ResponseBody ResponseItem<eu.eudat.models.project.Project> getPaged(@PathVariable String id) {
|
||||||
try {
|
try {
|
||||||
eu.eudat.models.project.Project project = new ProjectManager().getSingle(projectDao, id);
|
eu.eudat.models.project.Project project = new ProjectManager().getSingle(projectDao, id);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(project);
|
return new ResponseItem<eu.eudat.models.project.Project>().payload(project).status(HttpStatus.OK);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
return new ResponseItem<eu.eudat.models.project.Project>().status(HttpStatus.BAD_REQUEST).message(ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/add" }, consumes = "application/json", produces="application/json")
|
@RequestMapping(method = RequestMethod.POST, value = { "/projects/add" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project) {
|
public @ResponseBody ResponseItem<eu.eudat.entities.Project> addProject(@RequestBody eu.eudat.models.project.Project project) {
|
||||||
Project createdProject = projectDao.update(project.toDataModel());
|
Project createdProject = projectDao.createOrUpdate(project.toDataModel());
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
return new ResponseItem<eu.eudat.entities.Project>().payload(createdProject).status(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,219 +123,219 @@ public class Projects {
|
||||||
|
|
||||||
// MANAGE PROJECT(S)
|
// MANAGE PROJECT(S)
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/projects" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/projects" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<List<UUID>> listProjects(){
|
// public @ResponseBody ResponseEntity<List<UUID>> listProjects(){
|
||||||
try {
|
// try {
|
||||||
List<UUID> allIDs = projectDao.listAllIDs();
|
// List<UUID> allIDs = projectDao.listAllIDs();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/projects/{id}" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/projects/{id}" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Project> getProject(@PathVariable("id") String id) {
|
// public @ResponseBody ResponseEntity<Project> getProject(@PathVariable("id") String id) {
|
||||||
try {
|
// try {
|
||||||
Project project = projectDao.read(UUID.fromString(id));
|
// Project project = projectDao.read(UUID.fromString(id));
|
||||||
|
//
|
||||||
System.out.println(project.getId().toString());
|
// System.out.println(project.getId().toString());
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(project);
|
// return ResponseEntity.status(HttpStatus.OK).body(project);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/project/listAllLabelIDs" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/project/listAllLabelIDs" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
// public @ResponseBody ResponseEntity<List<IDLabelPair>> listLabelIds(){
|
||||||
try {
|
// try {
|
||||||
List<IDLabelPair> allIDs = projectDao.listAllIDsLabels();
|
// List<IDLabelPair> allIDs = projectDao.listAllIDsLabels();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
// return ResponseEntity.status(HttpStatus.OK).body(allIDs);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/project/getAll" }, produces="application/json")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/project/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> getAllProjects(){
|
// public @ResponseBody ResponseEntity<Object> getAllProjects(){
|
||||||
try {
|
// try {
|
||||||
List<Project> allProjects = projectDao.getAll();
|
// List<Project> allProjects = projectDao.getAll();
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(allProjects);
|
// return ResponseEntity.status(HttpStatus.OK).body(allProjects);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
// return new ResponseEntity<>(null, HttpStatus.INTERNAL_SERVER_ERROR);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Project> createProject(@RequestBody Project project) {
|
// public @ResponseBody ResponseEntity<Project> createProject(@RequestBody Project project) {
|
||||||
Project createdProject = projectDao.update(project);
|
// Project createdProject = projectDao.update(project);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/update" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/update" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Project> updateProject(@RequestBody Project project) {
|
// public @ResponseBody ResponseEntity<Project> updateProject(@RequestBody Project project) {
|
||||||
Project updatedProject = projectDao.update(project);
|
// Project updatedProject = projectDao.update(project);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(updatedProject);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(updatedProject);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/delete" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/delete" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Project> delete(@RequestBody Project project) {
|
// public @ResponseBody ResponseEntity<Project> delete(@RequestBody Project project) {
|
||||||
|
//
|
||||||
Project p = new Project();
|
// Project p = new Project();
|
||||||
p.setId(project.getId());
|
// p.setId(project.getId());
|
||||||
try {
|
// try {
|
||||||
projectDao.delete(p);
|
// projectDao.delete(p);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/softdelete" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/softdelete" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Project project) {
|
// public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Project project) {
|
||||||
|
//
|
||||||
project.setStatus(new Short("-1"));
|
// project.setStatus(new Short("-1"));
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
projectDao.update(project);
|
// projectDao.update(project);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(null);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/getdmps" }, consumes = "application/json", produces="application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/getdmps" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> getProjectDmps(@RequestBody Project project) {
|
// public @ResponseBody ResponseEntity<Object> getProjectDmps(@RequestBody Project project) {
|
||||||
try {
|
// try {
|
||||||
Set<DMP> dmps = projectDao.read(project.getId()).getDmps();
|
// Set<DMP> dmps = projectDao.read(project.getId()).getDmps();
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(dmps);
|
// return ResponseEntity.status(HttpStatus.CREATED).body(dmps);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
////////////////////////////////
|
// ////////////////////////////////
|
||||||
//// USER - RELATED ACTIONS ////
|
// //// USER - RELATED ACTIONS ////
|
||||||
////////////////////////////////
|
// ////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/project/getofuser" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.GET, value = { "/project/getofuser" }, produces="text/plain")
|
||||||
public @ResponseBody ResponseEntity<Object> getProjectsOfUser(){
|
// public @ResponseBody ResponseEntity<Object> getProjectsOfUser(){
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here");
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happen
|
// if(userInfo==null) //this should normally never happen
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
|
||||||
|
//
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
List<Project> userProjects = projectDao.getProjectsOfUser(userID);
|
// List<Project> userProjects = projectDao.getProjectsOfUser(userID);
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(userProjects);
|
// return ResponseEntity.status(HttpStatus.OK).body(userProjects);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
/*
|
// /*
|
||||||
* OLD ONE
|
// * OLD ONE
|
||||||
Map<UUID, Researcher> userProjects = new HashMap<UUID, Researcher>();
|
// Map<UUID, Researcher> userProjects = new HashMap<UUID, Researcher>();
|
||||||
|
//
|
||||||
userInfo.getDmps().forEach( dmp -> {
|
// userInfo.getDmps().forEach( dmp -> {
|
||||||
Researcher proj = dmp.getProject();
|
// Researcher proj = dmp.getProject();
|
||||||
userProjects.put(proj.getId(), proj);
|
// userProjects.put(proj.getId(), proj);
|
||||||
});
|
// });
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(userProjects.values()));
|
// return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(userProjects.values()));
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||||
}
|
// }
|
||||||
*/
|
// */
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
@Transactional
|
// @Transactional
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/project/createofuser" }, produces="text/plain", consumes = "application/json")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/createofuser" }, produces="text/plain", consumes = "application/json")
|
||||||
public @ResponseBody ResponseEntity<Project> createProjectOfUser(@RequestBody Project project){
|
// public @ResponseBody ResponseEntity<Project> createProjectOfUser(@RequestBody Project project){
|
||||||
|
//
|
||||||
|
//
|
||||||
String userID = null;
|
// String userID = null;
|
||||||
try {
|
// try {
|
||||||
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
// userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
|
||||||
} catch(NullPointerException ex) {
|
// } catch(NullPointerException ex) {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
// UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
|
||||||
|
//
|
||||||
|
//
|
||||||
if(userInfo==null) //this should normally never happer
|
// if(userInfo==null) //this should normally never happer
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
project.setId(null);
|
// project.setId(null);
|
||||||
project.setStatus(new Short("0"));
|
// project.setStatus(new Short("0"));
|
||||||
project.setCreationUser(userInfo);
|
// project.setCreationUser(userInfo);
|
||||||
project.setCreated(new Date());
|
// project.setCreated(new Date());
|
||||||
project.setModified(new Date());
|
// project.setModified(new Date());
|
||||||
|
//
|
||||||
Project newproj = projectDao.create(project);
|
// Project newproj = projectDao.create(project);
|
||||||
|
//
|
||||||
// DMP newdmp = new DMP();
|
//// DMP newdmp = new DMP();
|
||||||
// newdmp.setId(null);
|
//// newdmp.setId(null);
|
||||||
// newdmp.setLabel("Auto-Generated");
|
//// newdmp.setLabel("Auto-Generated");
|
||||||
// newdmp.setCreated(new Date());
|
//// newdmp.setCreated(new Date());
|
||||||
// newdmp.setVersion(1);
|
//// newdmp.setVersion(1);
|
||||||
// newdmp.setStatus(new Short("0"));
|
//// newdmp.setStatus(new Short("0"));
|
||||||
// newdmp.setProject(newproj);
|
//// newdmp.setProject(newproj);
|
||||||
//
|
////
|
||||||
// Set<UserInfo> users = new HashSet<UserInfo>();
|
//// Set<UserInfo> users = new HashSet<UserInfo>();
|
||||||
// users.add(userInfo);
|
//// users.add(userInfo);
|
||||||
// newdmp.setUsers(users);
|
//// newdmp.setUsers(users);
|
||||||
//
|
////
|
||||||
// newdmp = dMPDao.create(newdmp);
|
//// newdmp = dMPDao.create(newdmp);
|
||||||
|
//
|
||||||
return ResponseEntity.status(HttpStatus.OK).body(newproj);
|
// return ResponseEntity.status(HttpStatus.OK).body(newproj);
|
||||||
}
|
// }
|
||||||
catch(Exception ex) {
|
// catch(Exception ex) {
|
||||||
ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// @Transactional
|
// @Transactional
|
||||||
// @RequestMapping(method = RequestMethod.POST, value = { "/project/updateofuser" }, produces="text/plain")
|
// @RequestMapping(method = RequestMethod.POST, value = { "/project/updateofuser" }, produces="text/plain")
|
||||||
// public @ResponseBody ResponseEntity<Object> updateProjectOfUser(@RequestBody Researcher project){
|
// public @ResponseBody ResponseEntity<Object> updateProjectOfUser(@RequestBody Researcher project){
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package eu.eudat.dao.databaselayer.context;
|
||||||
|
|
||||||
|
import eu.eudat.entities.DataEntity;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import eu.eudat.queryable.hibernatequeryablelist.QueryableHibernateList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by giannis on 7/16/2017.
|
||||||
|
*/
|
||||||
|
@Repository("databaseCtx")
|
||||||
|
public class DatabaseContext<T extends DataEntity<T>> {
|
||||||
|
@Autowired
|
||||||
|
private EntityManager entityManager;
|
||||||
|
|
||||||
|
public QueryableList<T> getQueryable(Class<T> type) {
|
||||||
|
return new QueryableHibernateList<>(this.entityManager, type).setEntity(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T createOrUpdate(T item, Class<T> type) {
|
||||||
|
if (item.getKeys()[0] != null) {
|
||||||
|
T oldItem = entityManager.find(type, item.getKeys()[0]);
|
||||||
|
oldItem.update(item);
|
||||||
|
entityManager.merge(oldItem);
|
||||||
|
return oldItem;
|
||||||
|
} else entityManager.persist(item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long count(Class<T> entityClass) {
|
||||||
|
return ((Number) entityManager.createQuery("select count(e) from " + entityClass.getSimpleName() + " e").getSingleResult()).longValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package eu.eudat.dao.databaselayer.service;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.dao.databaselayer.context.DatabaseContext;
|
||||||
|
import eu.eudat.entities.DataEntity;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by giannis on 7/17/2017.
|
||||||
|
*/
|
||||||
|
@Service("databaseService")
|
||||||
|
public class DatabaseService<T extends DataEntity<T>> {
|
||||||
|
@Autowired
|
||||||
|
private DatabaseContext<T> databaseCtx;
|
||||||
|
|
||||||
|
public QueryableList<T> getQueryable(Class<T> tClass) {
|
||||||
|
return this.databaseCtx.getQueryable(tClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T createOrUpdate(T item, Class<T> tClass) {
|
||||||
|
return this.databaseCtx.createOrUpdate(item, tClass);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long count(Class<T> tClass){return this.databaseCtx.count(tClass);}
|
||||||
|
}
|
|
@ -6,17 +6,19 @@ import java.util.UUID;
|
||||||
import eu.eudat.dao.Dao;
|
import eu.eudat.dao.Dao;
|
||||||
import eu.eudat.entities.DMP;
|
import eu.eudat.entities.DMP;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
|
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface DMPDao extends Dao<DMP, UUID> {
|
public interface DMPDao {
|
||||||
|
|
||||||
public List<UUID> listAllIDs();
|
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria);
|
||||||
|
|
||||||
List<IDLabelPair> listAllIDsLabels();
|
DMP createOrUpdate(DMP item);
|
||||||
|
|
||||||
List<DMP> getDMPsOfUser(String userID);
|
DMP find(UUID id);
|
||||||
|
|
||||||
public List<DMP> getWithCriteria(DataManagementPlanTableRequest dataManagementPlanTableRequest);
|
Long count();
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,65 +10,46 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.entities.Project;
|
||||||
|
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import eu.eudat.dao.JpaDao;
|
import eu.eudat.dao.JpaDao;
|
||||||
import eu.eudat.entities.DMP;
|
import eu.eudat.entities.DMP;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component("dMPDao")
|
@Component("dMPDao")
|
||||||
public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
public class DMPDaoImpl implements DMPDao {
|
||||||
|
|
||||||
public DMP loadDetails(DMP t) {
|
|
||||||
// TODO Auto-generated method stub
|
@Autowired
|
||||||
return null;
|
DatabaseService<DMP> databaseService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<DMP> getWithCriteria(DataManagementPlanCriteria criteria) {
|
||||||
|
QueryableList<DMP> query = databaseService.getQueryable(DMP.class);
|
||||||
|
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||||
|
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("created"),criteria.getPeriodEnd()));
|
||||||
|
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> listAllIDs() {
|
public DMP createOrUpdate(DMP item) {
|
||||||
String queryString = "SELECT dmp.id FROM DMP dmp where dmp.status>=0";
|
return this.databaseService.createOrUpdate(item,DMP.class);
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
|
||||||
String queryString = "SELECT dmp.id, dmp.label FROM DMP dmp where dmp.status>=0";
|
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
|
||||||
List<Object[]> rows = query.list();
|
|
||||||
return rows.stream().map(row -> {
|
|
||||||
return new IDLabelPair(row[0].toString(), row[1].toString());
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DMP> getDMPsOfUser(String userID) {
|
public DMP find(UUID id) {
|
||||||
|
return databaseService.getQueryable(DMP.class).where((builder, root) -> builder.equal((root.get("id")),id)).toList().get(0);
|
||||||
String queryString = "select dmp from DMP dmp where dmp.creator.id=:userid and dmp.status >= 0";
|
|
||||||
TypedQuery<DMP> typedQuery = entityManager.createQuery(queryString, DMP.class);
|
|
||||||
typedQuery.setParameter("userid", UUID.fromString(userID));
|
|
||||||
try {
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
catch(Exception ex) { //no need to distinguish between eu.eudat.exceptions for the moment
|
|
||||||
ex.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Long count(){
|
||||||
public List<DMP> getWithCriteria(DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
return this.databaseService.count(DMP.class);
|
||||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
}
|
||||||
CriteriaQuery<DMP> criteriaQuery = criteriaBuilder .createQuery(DMP.class);
|
|
||||||
Root<DMP> root = criteriaQuery.from(DMP.class);
|
|
||||||
TypedQuery<DMP> typedQuery = entityManager.createQuery(criteriaQuery);
|
|
||||||
typedQuery.setFirstResult(dataManagementPlanTableRequest.getOffset());
|
|
||||||
typedQuery.setMaxResults(dataManagementPlanTableRequest.getLength());
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,7 @@ import eu.eudat.entities.responses.IDLabelPair;
|
||||||
import eu.eudat.models.criteria.Criteria;
|
import eu.eudat.models.criteria.Criteria;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface DataRepositoryDao extends Dao<DataRepository, UUID> {
|
public interface DataRepositoryDao {
|
||||||
|
|
||||||
List<UUID> listAllIDs();
|
|
||||||
|
|
||||||
List<IDLabelPair> listAllIDsLabels();
|
|
||||||
|
|
||||||
List<DataRepository> listBy(Criteria<DataRepository> criteria);
|
List<DataRepository> listBy(Criteria<DataRepository> criteria);
|
||||||
|
DataRepository createOrUpdate(DataRepository item);
|
||||||
}
|
}
|
|
@ -9,52 +9,33 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import eu.eudat.dao.JpaDao;
|
import eu.eudat.dao.JpaDao;
|
||||||
import eu.eudat.entities.DataRepository;
|
import eu.eudat.entities.DataRepository;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
import eu.eudat.models.criteria.Criteria;
|
import eu.eudat.models.criteria.Criteria;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Component("dataRepositoryDao")
|
@Component("dataRepositoryDao")
|
||||||
public class DataRepositoryDaoImpl extends JpaDao<DataRepository, UUID> implements DataRepositoryDao {
|
public class DataRepositoryDaoImpl implements DataRepositoryDao{
|
||||||
|
|
||||||
public DataRepository loadDetails(DataRepository t) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<UUID> listAllIDs() {
|
|
||||||
String queryString = "SELECT dataRepository.id FROM DataRepository dataRepository";
|
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
|
||||||
String queryString = "SELECT dataRepository.id, dataRepository.label FROM DataRepository dataRepository";
|
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
|
||||||
List<Object[]> rows = query.list();
|
|
||||||
return rows.stream().map(row -> {
|
|
||||||
return new IDLabelPair(row[0].toString(), row[1].toString());
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DatabaseService<DataRepository> databaseService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DataRepository> listBy(Criteria<DataRepository> criteria) {
|
public List<DataRepository> listBy(Criteria<DataRepository> criteria) {
|
||||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
QueryableList<DataRepository> query = databaseService.getQueryable(DataRepository.class);
|
||||||
CriteriaQuery<DataRepository> criteriaQuery = criteriaBuilder .createQuery(DataRepository.class);
|
if(criteria.getLike()!=null)query.where((builder, root) -> builder.equal(root.get("reference"),criteria.getLike()));
|
||||||
Root<DataRepository> root = criteriaQuery.from(DataRepository.class);
|
return query.toList();
|
||||||
criteriaQuery.where(criteriaBuilder.equal(root.get("reference"), criteria.getLike()));
|
|
||||||
TypedQuery<DataRepository> typedQuery = entityManager.createQuery(criteriaQuery);
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DataRepository createOrUpdate(DataRepository item) {
|
||||||
|
return databaseService.createOrUpdate(item,DataRepository.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,19 +7,23 @@ import eu.eudat.dao.Dao;
|
||||||
import eu.eudat.entities.Dataset;
|
import eu.eudat.entities.Dataset;
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
|
import eu.eudat.models.criteria.DatasetCriteria;
|
||||||
|
import eu.eudat.models.criteria.ProjectCriteria;
|
||||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface DatasetDao extends Dao<Dataset, UUID> {
|
public interface DatasetDao {
|
||||||
|
|
||||||
|
|
||||||
public List<UUID> listAllIDs();
|
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria);
|
||||||
|
|
||||||
List<IDLabelPair> listAllIDsLabels();
|
Dataset createOrUpdate(Dataset item);
|
||||||
|
|
||||||
List<Dataset> getDatasetsOfDmp(UUID dmpID);
|
Dataset find(UUID id);
|
||||||
|
|
||||||
|
Long count();
|
||||||
|
|
||||||
public List<Dataset> getWithCriteria(DatasetTableRequest datasetTableRequest);
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,56 +12,40 @@ import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
import eu.eudat.dao.JpaDao;
|
import eu.eudat.dao.JpaDao;
|
||||||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
import eu.eudat.entities.Dataset;
|
import eu.eudat.entities.Dataset;
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
|
import eu.eudat.models.criteria.DatasetCriteria;
|
||||||
import eu.eudat.models.dataset.DatasetTableRequest;
|
import eu.eudat.models.dataset.DatasetTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component("datasetDao")
|
@Component("datasetDao")
|
||||||
public class DatasetDaoImpl extends JpaDao<Dataset, UUID> implements DatasetDao {
|
public class DatasetDaoImpl implements DatasetDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DatabaseService<Dataset> databaseService;
|
||||||
|
|
||||||
public Dataset loadDetails(Dataset t) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> listAllIDs() {
|
public QueryableList<Dataset> getWithCriteria(DatasetCriteria criteria) {
|
||||||
String queryString = "SELECT dataset.id FROM Dataset dataset where dataset.status>=0";
|
QueryableList<Dataset> query = databaseService.getQueryable(Dataset.class);
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||||
return typedQuery.getResultList();
|
return query;
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
|
||||||
String queryString = "SELECT dataset.id, dataset.label FROM Dataset dataset where dataset.status>=0";
|
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
|
||||||
List<Object[]> rows = query.getResultList();
|
|
||||||
return rows.stream().map(row -> {
|
|
||||||
return new IDLabelPair(row[0].toString(), row[1].toString());
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Dataset> getDatasetsOfDmp(UUID dmpID) {
|
public Dataset createOrUpdate(Dataset item) {
|
||||||
String queryString = "FROM Dataset dataset where dataset.dmp.id=:dmpID and dataset.status>=0";
|
return databaseService.createOrUpdate(item,Dataset.class);
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
|
||||||
query.setParameter("dmpID", dmpID);
|
|
||||||
List<Dataset> datasets = (List<Dataset>) query.getResultList();
|
|
||||||
return datasets;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Dataset> getWithCriteria(DatasetTableRequest datasetTableRequest) {
|
public Dataset find(UUID id) {
|
||||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
return databaseService.getQueryable(Dataset.class).where((builder, root) -> builder.equal((root.get("id")),id)).toList().get(0);
|
||||||
CriteriaQuery<Dataset> criteriaQuery = criteriaBuilder .createQuery(Dataset.class);
|
}
|
||||||
Root<Dataset> root = criteriaQuery.from(Dataset.class);
|
|
||||||
TypedQuery<Dataset> typedQuery = entityManager.createQuery(criteriaQuery);
|
public Long count(){
|
||||||
typedQuery.setFirstResult(datasetTableRequest.getOffset());
|
return this.databaseService.count(Dataset.class);
|
||||||
typedQuery.setMaxResults(datasetTableRequest.getLength());
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@ import eu.eudat.dao.Dao;
|
||||||
import eu.eudat.entities.DatasetService;
|
import eu.eudat.entities.DatasetService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface DatasetServiceDao extends Dao<DatasetService, UUID> {
|
public interface DatasetServiceDao {
|
||||||
|
|
||||||
}
|
}
|
|
@ -6,17 +6,18 @@ import java.util.UUID;
|
||||||
import eu.eudat.dao.Dao;
|
import eu.eudat.dao.Dao;
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
|
import eu.eudat.models.criteria.ProjectCriteria;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
public interface ProjectDao extends Dao<Project, UUID> {
|
public interface ProjectDao {
|
||||||
|
|
||||||
public List<UUID> listAllIDs();
|
QueryableList<Project> getWithCriteria(ProjectCriteria criteria);
|
||||||
|
|
||||||
public List<IDLabelPair> listAllIDsLabels();
|
Project createOrUpdate(Project item);
|
||||||
|
|
||||||
public List<Project> getProjectsOfUser(String userID);
|
Project find(UUID id);
|
||||||
|
|
||||||
public List<Project> getWithCriteria(ProjectTableRequest projectTableRequest);
|
Long count();
|
||||||
|
|
||||||
}
|
}
|
|
@ -9,70 +9,44 @@ import javax.persistence.criteria.CriteriaBuilder;
|
||||||
import javax.persistence.criteria.CriteriaQuery;
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
import javax.persistence.criteria.Root;
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
import eu.eudat.dao.databaselayer.service.DatabaseService;
|
||||||
|
import eu.eudat.models.criteria.ProjectCriteria;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import org.hibernate.query.Query;
|
import org.hibernate.query.Query;
|
||||||
|
|
||||||
import eu.eudat.dao.JpaDao;
|
import eu.eudat.dao.JpaDao;
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
import eu.eudat.entities.responses.IDLabelPair;
|
import eu.eudat.entities.responses.IDLabelPair;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component("projectDao")
|
@Component("projectDao")
|
||||||
public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao {
|
public class ProjectDaoImpl implements ProjectDao {
|
||||||
|
|
||||||
public Project loadDetails(Project t) {
|
@Autowired
|
||||||
// TODO Auto-generated method stub
|
DatabaseService<Project> databaseService;
|
||||||
return null;
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<Project> getWithCriteria(ProjectCriteria criteria) {
|
||||||
|
QueryableList<Project> query = databaseService.getQueryable(Project.class);
|
||||||
|
if(criteria.getLike()!=null&&!criteria.getLike().isEmpty())query.where((builder, root) -> builder.like(root.get("label"),"%"+criteria.getLike()+"%"));
|
||||||
|
if(criteria.getPeriodEnd()!=null)query.where((builder, root) -> builder.lessThan(root.get("created"),criteria.getPeriodEnd()));
|
||||||
|
if(criteria.getPeriodStart()!=null)query.where((builder, root) -> builder.greaterThan(root.get("created"),criteria.getPeriodStart()));
|
||||||
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<UUID> listAllIDs() {
|
public Project createOrUpdate(Project item) {
|
||||||
String queryString = "SELECT project.id FROM Project project";
|
return databaseService.createOrUpdate(item,Project.class);
|
||||||
TypedQuery<UUID> typedQuery = entityManager.createQuery(queryString, UUID.class);
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<IDLabelPair> listAllIDsLabels() {
|
|
||||||
String queryString = "SELECT project.id, project.label FROM Project project";
|
|
||||||
Query query = (Query) entityManager.createQuery(queryString);
|
|
||||||
List<Object[]> rows = query.list();
|
|
||||||
return rows.stream().map(row -> {
|
|
||||||
return new IDLabelPair(row[0].toString(), row[1].toString());
|
|
||||||
})
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public List<Project> getProjectsOfUser(String userID){
|
|
||||||
|
|
||||||
String queryString = "select p from Project p where p.creationUser.id=:userid and project.status >= 0";
|
|
||||||
TypedQuery<Project> typedQuery = entityManager.createQuery(queryString, Project.class);
|
|
||||||
typedQuery.setParameter("userid", UUID.fromString(userID));
|
|
||||||
try {
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
|
||||||
catch(Exception ex) { //no need to distinguish between eu.eudat.exceptions for the moment
|
|
||||||
ex.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Project> getWithCriteria(ProjectTableRequest projectTableRequest) {
|
public Project find(UUID id) {
|
||||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
return databaseService.getQueryable(Project.class).where((builder, root) -> builder.equal((root.get("id")),id)).toList().get(0);
|
||||||
CriteriaQuery<Project> criteriaQuery = criteriaBuilder .createQuery(Project.class);
|
|
||||||
Root<Project> root = criteriaQuery.from(Project.class);
|
|
||||||
TypedQuery<Project> typedQuery = entityManager.createQuery(criteriaQuery);
|
|
||||||
typedQuery.setFirstResult(projectTableRequest.getOffset());
|
|
||||||
typedQuery.setMaxResults(projectTableRequest.getLength());
|
|
||||||
return typedQuery.getResultList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long count(){
|
||||||
|
return this.databaseService.count(Project.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,7 @@ public interface UserInfoDao extends Dao<UserInfo, UUID> {
|
||||||
public UserInfo getByIdAndMail(String id, String email);
|
public UserInfo getByIdAndMail(String id, String email);
|
||||||
|
|
||||||
public UserInfo getByMail(String email);
|
public UserInfo getByMail(String email);
|
||||||
|
|
||||||
public UserInfo getByAuthenticationId(String authentication);
|
|
||||||
|
|
||||||
public UserInfo getByUsername(String username);
|
public UserInfo getByUsername(String username);
|
||||||
|
|
||||||
public List<DMP> getDmpsOfUser(String userID);
|
public List<DMP> getDmpsOfUser(String userID);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package eu.eudat.dao.entities;
|
package eu.eudat.dao.entities;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.persistence.NoResultException;
|
import javax.persistence.NoResultException;
|
||||||
|
@ -10,7 +9,6 @@ import javax.persistence.TypedQuery;
|
||||||
import eu.eudat.dao.JpaDao;
|
import eu.eudat.dao.JpaDao;
|
||||||
import eu.eudat.entities.DMP;
|
import eu.eudat.entities.DMP;
|
||||||
import eu.eudat.entities.UserInfo;
|
import eu.eudat.entities.UserInfo;
|
||||||
import eu.eudat.entities.security.UserAuth;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component("userInfoDao")
|
@Component("userInfoDao")
|
||||||
|
@ -51,22 +49,6 @@ public class UserInfoDaoImpl extends JpaDao<UserInfo, UUID> implements UserInfoD
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserInfo getByAuthenticationId(String authenticationID) {
|
|
||||||
UserAuth userauth = new UserAuth();
|
|
||||||
userauth.setId(UUID.fromString(authenticationID));
|
|
||||||
String queryString = "FROM UserInfo userInfo where userInfo.authentication = :auth";
|
|
||||||
TypedQuery<UserInfo> typedQuery = entityManager.createQuery(queryString, UserInfo.class);
|
|
||||||
typedQuery.setParameter("auth", userauth);
|
|
||||||
try {
|
|
||||||
return typedQuery.getSingleResult();
|
|
||||||
}
|
|
||||||
catch(NoResultException ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.dao.entities.security;
|
||||||
|
|
||||||
|
import eu.eudat.dao.Dao;
|
||||||
|
import eu.eudat.entities.Credential;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public interface CredentialDao extends Dao<Credential, UUID> {
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package eu.eudat.dao.entities.security;
|
||||||
|
|
||||||
|
import eu.eudat.dao.JpaDao;
|
||||||
|
import eu.eudat.entities.Credential;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Component("credentialDao")
|
||||||
|
public class CredentialDaoImpl extends JpaDao<Credential, UUID> implements CredentialDao {
|
||||||
|
@Override
|
||||||
|
public Credential loadDetails(Credential credential) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,15 +0,0 @@
|
||||||
package eu.eudat.dao.entities.security;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import eu.eudat.dao.Dao;
|
|
||||||
import eu.eudat.entities.security.UserAuth;
|
|
||||||
|
|
||||||
public interface UserAuthDao extends Dao<UserAuth, UUID> {
|
|
||||||
|
|
||||||
|
|
||||||
public String getPasswordHashOfUser(String username);
|
|
||||||
|
|
||||||
public UserAuth getUserAuthBy(String username);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,51 +0,0 @@
|
||||||
package eu.eudat.dao.entities.security;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.TypedQuery;
|
|
||||||
|
|
||||||
import eu.eudat.dao.JpaDao;
|
|
||||||
import eu.eudat.entities.security.UserAuth;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component("userAuthDaoImpl")
|
|
||||||
public class UserAuthDaoImpl extends JpaDao<UserAuth, UUID> implements UserAuthDao {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserAuth loadDetails(UserAuth t) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPasswordHashOfUser(String username) {
|
|
||||||
|
|
||||||
String queryString = "SELECT userAuth.password FROM UserAuth userAuth where userAuth.username = :username";
|
|
||||||
TypedQuery<String> typedQuery = entityManager.createQuery(queryString, String.class);
|
|
||||||
typedQuery.setParameter("username", username);
|
|
||||||
try {
|
|
||||||
return typedQuery.getSingleResult();
|
|
||||||
}
|
|
||||||
catch(Exception ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public UserAuth getUserAuthBy(String username) {
|
|
||||||
|
|
||||||
String queryString = "FROM UserAuth userAuth where userAuth.username = :username";
|
|
||||||
TypedQuery<UserAuth> typedQuery = entityManager.createQuery(queryString, UserAuth.class);
|
|
||||||
typedQuery.setParameter("username", username);
|
|
||||||
try {
|
|
||||||
return typedQuery.getSingleResult();
|
|
||||||
}
|
|
||||||
catch(Exception ex) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.dao.entities.security;
|
||||||
|
|
||||||
|
import eu.eudat.dao.Dao;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public interface UserTokenDao extends Dao<UserToken, UUID> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package eu.eudat.dao.entities.security;
|
||||||
|
|
||||||
|
import eu.eudat.dao.JpaDao;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Component("userTokenDao")
|
||||||
|
public class UserTokenDaoImpl extends JpaDao<UserToken, UUID> implements UserTokenDao {
|
||||||
|
@Override
|
||||||
|
public UserToken loadDetails(UserToken userToken) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,116 @@
|
||||||
|
package eu.eudat.entities;
|
||||||
|
|
||||||
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name="\"Credential\"")
|
||||||
|
public class Credential {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "\"ID\"", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
private UUID id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn(name="userid", nullable=false)
|
||||||
|
private UserInfo userInfo;
|
||||||
|
|
||||||
|
@Column(name = "status", nullable = false)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Column(name = "provider", nullable = false)
|
||||||
|
private Integer provider;
|
||||||
|
@Column(name = "publicValue", nullable = false)
|
||||||
|
private String publicValue;
|
||||||
|
@Column(name = "secret", nullable = false)
|
||||||
|
private String secret;
|
||||||
|
@Column(name = "creationtime", nullable = false)
|
||||||
|
private Date creationTime;
|
||||||
|
@Column(name = "lastupdatetime", nullable = false)
|
||||||
|
private Date lastUpdateTime;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserInfo getUserInfo() {
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserInfo(UserInfo userInfo) {
|
||||||
|
this.userInfo = userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(Integer status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getProvider() {
|
||||||
|
return provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProvider(Integer provider) {
|
||||||
|
this.provider = provider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublicValue() {
|
||||||
|
return publicValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublicValue(String publicValue) {
|
||||||
|
this.publicValue = publicValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecret() {
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecret(String secret) {
|
||||||
|
this.secret = secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreationTime() {
|
||||||
|
return creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreationTime(Date creationTime) {
|
||||||
|
this.creationTime = creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLastUpdateTime() {
|
||||||
|
return lastUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLastUpdateTime(Date lastUpdateTime) {
|
||||||
|
this.lastUpdateTime = lastUpdateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
|
||||||
|
Credential that = (Credential) o;
|
||||||
|
|
||||||
|
return provider.intValue() == that.provider.intValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return provider.intValue();
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,7 +27,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"DMP\"")
|
@Table(name="\"DMP\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope = DMP.class)
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id", scope = DMP.class)
|
||||||
public class DMP implements Serializable,DataEntity {
|
public class DMP implements Serializable,DataEntity<DMP> {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -8263056535208547615L;
|
private static final long serialVersionUID = -8263056535208547615L;
|
||||||
|
@ -250,6 +250,16 @@ public class DMP implements Serializable,DataEntity {
|
||||||
public void setResearchers(Set<Researcher> researchers) {
|
public void setResearchers(Set<Researcher> researchers) {
|
||||||
this.researchers = researchers;
|
this.researchers = researchers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DMP entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
package eu.eudat.entities;
|
package eu.eudat.entities;
|
||||||
|
|
||||||
public interface DataEntity {
|
public interface DataEntity<T> {
|
||||||
|
void update(T entity);
|
||||||
|
|
||||||
|
Object[] getKeys();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"DataRepository\"")
|
@Table(name="\"DataRepository\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class DataRepository implements Serializable,DataEntity {
|
public class DataRepository implements Serializable,DataEntity<DataRepository> {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 4162323701450468639L;
|
private static final long serialVersionUID = 4162323701450468639L;
|
||||||
|
@ -162,5 +162,13 @@ public class DataRepository implements Serializable,DataEntity {
|
||||||
this.datasets = datasets;
|
this.datasets = datasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DataRepository entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Dataset\"")
|
@Table(name="\"Dataset\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Dataset implements Serializable,DataEntity {
|
public class Dataset implements DataEntity<Dataset> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3575723814399553259L;
|
private static final long serialVersionUID = 3575723814399553259L;
|
||||||
|
|
||||||
|
@ -253,9 +253,15 @@ public class Dataset implements Serializable,DataEntity {
|
||||||
public void setReference(String reference) {
|
public void setReference(String reference) {
|
||||||
this.reference = reference;
|
this.reference = reference;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Dataset entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"DatasetProfile\"")
|
@Table(name="\"DatasetProfile\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class DatasetProfile implements Serializable,DataEntity {
|
public class DatasetProfile implements Serializable,DataEntity<DatasetProfile> {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 8203086344232867334L;
|
private static final long serialVersionUID = 8203086344232867334L;
|
||||||
|
@ -177,6 +177,14 @@ public class DatasetProfile implements Serializable,DataEntity {
|
||||||
+ ", viewstyle=" + viewstyle + ", definition=" + definition + "]";
|
+ ", viewstyle=" + viewstyle + ", definition=" + definition + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(DatasetProfile entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Organisation\"")
|
@Table(name="\"Organisation\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Organisation implements Serializable,DataEntity {
|
public class Organisation implements Serializable,DataEntity<Organisation> {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3614146195740867782L;
|
private static final long serialVersionUID = 3614146195740867782L;
|
||||||
|
@ -164,6 +164,14 @@ public class Organisation implements Serializable,DataEntity {
|
||||||
this.dMPs = dMPs;
|
this.dMPs = dMPs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Organisation entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Project\"")
|
@Table(name="\"Project\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Project implements Serializable,DataEntity {
|
public class Project implements Serializable,DataEntity<Project> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -767048645098311154L;
|
private static final long serialVersionUID = -767048645098311154L;
|
||||||
|
|
||||||
|
@ -226,7 +226,14 @@ public class Project implements Serializable,DataEntity {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Project entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Registry\"")
|
@Table(name="\"Registry\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Registry implements Serializable,DataEntity {
|
public class Registry implements Serializable,DataEntity<Registry> {
|
||||||
|
|
||||||
private static final long serialVersionUID = -277572262583178090L;
|
private static final long serialVersionUID = -277572262583178090L;
|
||||||
|
|
||||||
|
@ -161,6 +161,14 @@ public class Registry implements Serializable,DataEntity {
|
||||||
this.datasets = datasets;
|
this.datasets = datasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Registry entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Researcher\"")
|
@Table(name="\"Researcher\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Researcher implements Serializable,DataEntity {
|
public class Researcher implements Serializable,DataEntity<Researcher> {
|
||||||
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -2513186824704729896L;
|
private static final long serialVersionUID = -2513186824704729896L;
|
||||||
|
@ -163,6 +163,14 @@ public class Researcher implements Serializable,DataEntity {
|
||||||
this.dMPs = dMPs;
|
this.dMPs = dMPs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Researcher entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"Service\"")
|
@Table(name="\"Service\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class Service implements Serializable,DataEntity {
|
public class Service implements Serializable,DataEntity<Service> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 163279108676904730L;
|
private static final long serialVersionUID = 163279108676904730L;
|
||||||
|
|
||||||
|
@ -160,6 +160,14 @@ public class Service implements Serializable,DataEntity {
|
||||||
this.datasets = datasets;
|
this.datasets = datasets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Service entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.id == null ? null : this.id};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,20 +2,11 @@ package eu.eudat.entities;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
import javax.persistence.*;
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.FetchType;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.JoinColumn;
|
|
||||||
import javax.persistence.JoinTable;
|
|
||||||
import javax.persistence.OneToMany;
|
|
||||||
import javax.persistence.OneToOne;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
import org.hibernate.annotations.GenericGenerator;
|
||||||
import org.hibernate.annotations.Type;
|
import org.hibernate.annotations.Type;
|
||||||
|
@ -23,13 +14,11 @@ import org.hibernate.annotations.Type;
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||||
|
|
||||||
import eu.eudat.entities.security.UserAuth;
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name="\"UserInfo\"")
|
@Table(name="\"UserInfo\"")
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
||||||
public class UserInfo implements Serializable,DataEntity{
|
public class UserInfo implements Serializable,DataEntity<UserInfo>{
|
||||||
|
|
||||||
private static final long serialVersionUID = 1225151430484658395L;
|
private static final long serialVersionUID = 1225151430484658395L;
|
||||||
|
|
||||||
|
@ -49,10 +38,6 @@ public class UserInfo implements Serializable,DataEntity{
|
||||||
@Column(name = "usertype", nullable = false)
|
@Column(name = "usertype", nullable = false)
|
||||||
private Short usertype; // 0 internal, 1 external
|
private Short usertype; // 0 internal, 1 external
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.LAZY)
|
|
||||||
@JoinColumn(name = "authentication", nullable = true)
|
|
||||||
private UserAuth authentication;
|
|
||||||
|
|
||||||
@Column(name = "verified_email", nullable = true)
|
@Column(name = "verified_email", nullable = true)
|
||||||
private Boolean verified_email = null;
|
private Boolean verified_email = null;
|
||||||
|
|
||||||
|
@ -78,13 +63,9 @@ public class UserInfo implements Serializable,DataEntity{
|
||||||
inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
inverseJoinColumns={@JoinColumn(name="dmp", referencedColumnName="\"ID\"")}
|
||||||
)
|
)
|
||||||
private Set<DMP> dmps;
|
private Set<DMP> dmps;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy="userInfo",fetch = FetchType.LAZY)
|
||||||
/*
|
Set<Credential> credentials = new HashSet<>();
|
||||||
public Set<DMP> getDmpsNonDeleted(){
|
|
||||||
return getDmps().parallelStream().filter(dmp -> dmp.getStatus()>=0).collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public Set<DMP> getDmps() {
|
public Set<DMP> getDmps() {
|
||||||
return dmps;
|
return dmps;
|
||||||
|
@ -142,14 +123,6 @@ public class UserInfo implements Serializable,DataEntity{
|
||||||
this.usertype = usertype;
|
this.usertype = usertype;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAuth getAuthentication() {
|
|
||||||
return authentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAuthentication(UserAuth authentication) {
|
|
||||||
this.authentication = authentication;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getVerified_email() {
|
public Boolean getVerified_email() {
|
||||||
return verified_email;
|
return verified_email;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +146,22 @@ public class UserInfo implements Serializable,DataEntity{
|
||||||
public void setAdditionalinfo(String additionalinfo) {
|
public void setAdditionalinfo(String additionalinfo) {
|
||||||
this.additionalinfo = additionalinfo;
|
this.additionalinfo = additionalinfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Credential> getCredentials() {
|
||||||
|
return credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCredentials(Set<Credential> credentials) {
|
||||||
|
this.credentials = credentials;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(UserInfo entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new Object[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
package eu.eudat.entities;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name="\"UserToken\"")
|
||||||
|
public class UserToken implements DataEntity<UserToken>{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1225151430484658395L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@Column(name = "token", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
||||||
|
private UUID token;
|
||||||
|
|
||||||
|
@OneToOne(fetch = FetchType.EAGER)
|
||||||
|
@JoinColumn(name = "userid", nullable = false)
|
||||||
|
private UserInfo user;
|
||||||
|
|
||||||
|
@Column(name = "issuedat", nullable = false)
|
||||||
|
private Date issuedAt = null;
|
||||||
|
|
||||||
|
|
||||||
|
@Column(name = "expiresat", nullable = false)
|
||||||
|
private Date expiresAt = null;
|
||||||
|
|
||||||
|
public UUID getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(UUID token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserInfo getUser() {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUser(UserInfo user) {
|
||||||
|
this.user = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getIssuedAt() {
|
||||||
|
return issuedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssuedAt(Date issuedAt) {
|
||||||
|
this.issuedAt = issuedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpiresAt() {
|
||||||
|
return expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiresAt(Date expiresAt) {
|
||||||
|
this.expiresAt = expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(UserToken entity) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object[] getKeys() {
|
||||||
|
return new UUID[]{this.token == null ? null : this.token};
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,61 +0,0 @@
|
||||||
package eu.eudat.entities.security;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.GeneratedValue;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
|
|
||||||
import org.hibernate.annotations.GenericGenerator;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
|
||||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|
||||||
|
|
||||||
@Entity
|
|
||||||
@Table(name="\"UserAuth\"")
|
|
||||||
@JsonIdentityInfo(generator=ObjectIdGenerators.PropertyGenerator.class, property="id")
|
|
||||||
public class UserAuth {
|
|
||||||
|
|
||||||
@Id
|
|
||||||
@GeneratedValue
|
|
||||||
@GenericGenerator(name = "uuid2", strategy = "uuid2")
|
|
||||||
@Column(name = "id", updatable = false, nullable = false, columnDefinition = "BINARY(16)")
|
|
||||||
private UUID id;
|
|
||||||
|
|
||||||
@Column(name = "username", nullable = false)
|
|
||||||
private String username;
|
|
||||||
|
|
||||||
@Column(name = "password", nullable = false)
|
|
||||||
private String password; //hash-encoded password
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public UUID getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(UUID id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package eu.eudat.handlers;
|
||||||
|
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
|
import org.springframework.core.MethodParameter;
|
||||||
|
import org.springframework.web.bind.support.WebDataBinderFactory;
|
||||||
|
import org.springframework.web.context.request.NativeWebRequest;
|
||||||
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
|
import org.springframework.web.method.support.ModelAndViewContainer;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public final class PrincipalArgumentResolver implements HandlerMethodArgumentResolver {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsParameter(MethodParameter methodParameter) {
|
||||||
|
return methodParameter.getParameterType().equals(Principal.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object resolveArgument(MethodParameter methodParameter,ModelAndViewContainer modelAndViewContainer,NativeWebRequest nativeWebRequest,WebDataBinderFactory webDataBinderFactory) throws Exception {
|
||||||
|
Principal principal = new Principal();
|
||||||
|
principal.setName("Giannis");
|
||||||
|
principal.setId(UUID.randomUUID());
|
||||||
|
principal.setExpiresAt(new Date());
|
||||||
|
principal.setToken(UUID.randomUUID());
|
||||||
|
return principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,170 +0,0 @@
|
||||||
package eu.eudat.login;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.security.MessageDigest;
|
|
||||||
import java.security.NoSuchAlgorithmException;
|
|
||||||
import java.security.SecureRandom;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
||||||
|
|
||||||
import eu.eudat.dao.entities.UserInfoDao;
|
|
||||||
import eu.eudat.dao.entities.security.UserAuthDao;
|
|
||||||
import eu.eudat.entities.UserInfo;
|
|
||||||
import eu.eudat.entities.security.UserAuth;
|
|
||||||
import eu.eudat.security.TokenSessionManager;
|
|
||||||
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@CrossOrigin
|
|
||||||
public class Login {
|
|
||||||
|
|
||||||
|
|
||||||
@Autowired private UserInfoDao userInfoDao;
|
|
||||||
@Autowired private UserAuthDao userAuthDao;
|
|
||||||
|
|
||||||
@Autowired private TokenSessionManager tokenSessionManager;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/nativeLogin" }, consumes = "application/json", produces = "application/json")
|
|
||||||
public @ResponseBody ResponseEntity<String> nativeLogin(@RequestBody Credentials credentials) {
|
|
||||||
|
|
||||||
String token = null;
|
|
||||||
|
|
||||||
if(credentials == null || credentials.getPassword() == null || credentials.getUsername() ==null ||
|
|
||||||
credentials.getPassword().isEmpty() || credentials.getUsername().isEmpty()) {
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Username and/or password cannot be empty.");
|
|
||||||
}
|
|
||||||
|
|
||||||
UserAuth userAuth = userAuthDao.getUserAuthBy(credentials.getUsername());
|
|
||||||
|
|
||||||
if(userAuth == null) userAuth = new UserAuth();
|
|
||||||
|
|
||||||
String userHash = userAuth.getPassword();
|
|
||||||
|
|
||||||
String providedHash = "";
|
|
||||||
try {
|
|
||||||
providedHash = tokenSessionManager.hashPassword(credentials.getPassword());
|
|
||||||
}
|
|
||||||
catch(NoSuchAlgorithmException ex) {
|
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Internal error. Cannot authenticate.");
|
|
||||||
}
|
|
||||||
|
|
||||||
if(userHash == null || "".equals(userHash) || !userHash.equals(providedHash)) {
|
|
||||||
return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("Wrong username or password");
|
|
||||||
}
|
|
||||||
else if(userHash.equals(providedHash)) {
|
|
||||||
// create a token
|
|
||||||
token = tokenSessionManager.generateRandomAlphanumeric(512);
|
|
||||||
// add it to the eu.eudat.cache
|
|
||||||
tokenSessionManager.set(token, credentials.getUsername());
|
|
||||||
}
|
|
||||||
|
|
||||||
//get also the additional info of the user (if he has)
|
|
||||||
UserInfo userInfo = userInfoDao.getByAuthenticationId((userAuth.getId() == null) ? "" : userAuth.getId().toString());
|
|
||||||
if(userInfo == null) userInfo = new UserInfo();
|
|
||||||
|
|
||||||
Response response = new Response();
|
|
||||||
response.setToken(token);
|
|
||||||
response.setEmail(userInfo.getEmail());
|
|
||||||
response.setName(userInfo.getName());
|
|
||||||
response.setUsername(credentials.getUsername());
|
|
||||||
|
|
||||||
return new ResponseEntity<String>(response.toJson(), HttpStatus.OK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Credentials implements Serializable{
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 3519634756673886633L;
|
|
||||||
|
|
||||||
private String username;
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
class Response implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = -3855159530298902864L;
|
|
||||||
|
|
||||||
private String token;
|
|
||||||
private String username;
|
|
||||||
private String email;
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
|
|
||||||
public String getToken() {
|
|
||||||
return token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToken(String token) {
|
|
||||||
this.token = token;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEmail() {
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmail(String email) {
|
|
||||||
this.email = email;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String toJson() {
|
|
||||||
ObjectMapper objMapper = new ObjectMapper();
|
|
||||||
try {
|
|
||||||
return objMapper.writeValueAsString(this);
|
|
||||||
}
|
|
||||||
catch(JsonProcessingException ex) {
|
|
||||||
return "{}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,14 +4,18 @@ import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import eu.eudat.dao.entities.DMPDao;
|
import eu.eudat.dao.entities.DMPDao;
|
||||||
|
import eu.eudat.entities.DMP;
|
||||||
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
import eu.eudat.models.dmp.DataManagementPlanTableRequest;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||||
|
|
||||||
public class DataManagementPlanManager {
|
public class DataManagementPlanManager {
|
||||||
|
|
||||||
public DataTableData<eu.eudat.models.dmp.DataManagementPlan> getPaged(DMPDao dmpsRepository, DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
|
public DataTableData<eu.eudat.models.dmp.DataManagementPlan> getPaged(DMPDao dmpsRepository, DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
|
||||||
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, eu.eudat.models.dmp.DataManagementPlan>().fromDataModel( dmpsRepository.getWithCriteria(dataManagementPlanTableRequest), eu.eudat.models.dmp.DataManagementPlan.class);
|
QueryableList<DMP> items = dmpsRepository.getWithCriteria(dataManagementPlanTableRequest.getCriteria());
|
||||||
|
QueryableList<DMP> pagedItems = PaginationManager.applyPaging(items,dataManagementPlanTableRequest);
|
||||||
|
List<eu.eudat.models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<eu.eudat.entities.DMP, eu.eudat.models.dmp.DataManagementPlan>().fromDataModel( pagedItems.toList(), eu.eudat.models.dmp.DataManagementPlan.class);
|
||||||
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataTableData<eu.eudat.models.dmp.DataManagementPlan>();
|
DataTableData<eu.eudat.models.dmp.DataManagementPlan> dataTable = new DataTableData<eu.eudat.models.dmp.DataManagementPlan>();
|
||||||
dataTable.setData(datamanagementPlans);
|
dataTable.setData(datamanagementPlans);
|
||||||
dataTable.setTotalCount(dmpsRepository.count());
|
dataTable.setTotalCount(dmpsRepository.count());
|
||||||
|
@ -20,7 +24,7 @@ public class DataManagementPlanManager {
|
||||||
|
|
||||||
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id) throws InstantiationException, IllegalAccessException{
|
public eu.eudat.models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository, String id) throws InstantiationException, IllegalAccessException{
|
||||||
eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan();
|
eu.eudat.models.dmp.DataManagementPlan datamanagementPlan = new eu.eudat.models.dmp.DataManagementPlan();
|
||||||
datamanagementPlan.fromDataModel(dmpsRepository.read(UUID.fromString(id)));
|
datamanagementPlan.fromDataModel(dmpsRepository.find(UUID.fromString(id)));
|
||||||
return datamanagementPlan;
|
return datamanagementPlan;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import eu.eudat.models.dataset.DatasetTableRequest;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
import eu.eudat.models.project.Project;
|
import eu.eudat.models.project.Project;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -18,7 +19,9 @@ import java.util.UUID;
|
||||||
public class DatasetManager {
|
public class DatasetManager {
|
||||||
|
|
||||||
public DataTableData<Dataset> getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{
|
public DataTableData<Dataset> getPaged(DatasetDao datatasetRepository, DatasetTableRequest datasetTableRequest) throws IllegalAccessException, InstantiationException{
|
||||||
List<Dataset> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, Dataset>().fromDataModel( datatasetRepository.getWithCriteria(datasetTableRequest), eu.eudat.models.dataset.Dataset.class);
|
QueryableList<eu.eudat.entities.Dataset> items = datatasetRepository.getWithCriteria(datasetTableRequest.getCriteria());
|
||||||
|
QueryableList<eu.eudat.entities.Dataset> pagedItems = PaginationManager.applyPaging( items ,datasetTableRequest);
|
||||||
|
List<Dataset> datasets = new DomainModelConverter<eu.eudat.entities.Dataset, Dataset>().fromDataModel( pagedItems.toList(), eu.eudat.models.dataset.Dataset.class);
|
||||||
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DataTableData<eu.eudat.models.dataset.Dataset>();
|
DataTableData<eu.eudat.models.dataset.Dataset> dataTable = new DataTableData<eu.eudat.models.dataset.Dataset>();
|
||||||
dataTable.setData(datasets);
|
dataTable.setData(datasets);
|
||||||
dataTable.setTotalCount(datatasetRepository.count());
|
dataTable.setTotalCount(datatasetRepository.count());
|
||||||
|
@ -27,7 +30,7 @@ public class DatasetManager {
|
||||||
|
|
||||||
public eu.eudat.models.dataset.Dataset getSingle(DatasetDao datatasetRepository, String id) throws InstantiationException, IllegalAccessException{
|
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();
|
eu.eudat.models.dataset.Dataset dataset = new eu.eudat.models.dataset.Dataset();
|
||||||
dataset.fromDataModel(datatasetRepository.read(UUID.fromString(id)));
|
dataset.fromDataModel(datatasetRepository.find(UUID.fromString(id)));
|
||||||
return dataset;
|
return dataset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.managers;
|
||||||
|
|
||||||
|
import eu.eudat.models.helpers.requests.TableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
|
||||||
|
public class PaginationManager {
|
||||||
|
|
||||||
|
public static <T> QueryableList<T> applyPaging(QueryableList<T> items, TableRequest tableRequest){
|
||||||
|
if(tableRequest.getLength()!=null)items.take(tableRequest.getLength());
|
||||||
|
if(tableRequest.getOffset()!=null)items.skip(tableRequest.getOffset());
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,12 +7,15 @@ import eu.eudat.dao.entities.ProjectDao;
|
||||||
import eu.eudat.models.helpers.DataTableData;
|
import eu.eudat.models.helpers.DataTableData;
|
||||||
import eu.eudat.models.project.Project;
|
import eu.eudat.models.project.Project;
|
||||||
import eu.eudat.models.project.ProjectTableRequest;
|
import eu.eudat.models.project.ProjectTableRequest;
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
import eu.eudat.utilities.builders.DomainModelConverter;
|
import eu.eudat.utilities.builders.DomainModelConverter;
|
||||||
|
|
||||||
public class ProjectManager {
|
public class ProjectManager {
|
||||||
|
|
||||||
public DataTableData<eu.eudat.models.project.Project> getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest) throws IllegalAccessException, InstantiationException{
|
public DataTableData<eu.eudat.models.project.Project> getPaged(ProjectDao projectRepository, ProjectTableRequest projectTableRequest) throws IllegalAccessException, InstantiationException{
|
||||||
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel( projectRepository.getWithCriteria(projectTableRequest), eu.eudat.models.project.Project.class);
|
QueryableList<eu.eudat.entities.Project> items = projectRepository.getWithCriteria(projectTableRequest.getCriteria());
|
||||||
|
QueryableList<eu.eudat.entities.Project> pagedItems = PaginationManager.applyPaging(items,projectTableRequest);
|
||||||
|
List<eu.eudat.models.project.Project> projects = new DomainModelConverter<eu.eudat.entities.Project, Project>().fromDataModel(pagedItems.toList(), eu.eudat.models.project.Project.class);
|
||||||
DataTableData<eu.eudat.models.project.Project> dataTable = new DataTableData<eu.eudat.models.project.Project>();
|
DataTableData<eu.eudat.models.project.Project> dataTable = new DataTableData<eu.eudat.models.project.Project>();
|
||||||
dataTable.setData(projects);
|
dataTable.setData(projects);
|
||||||
dataTable.setTotalCount(projectRepository.count());
|
dataTable.setTotalCount(projectRepository.count());
|
||||||
|
@ -21,7 +24,7 @@ public class ProjectManager {
|
||||||
|
|
||||||
public eu.eudat.models.project.Project getSingle(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException{
|
public eu.eudat.models.project.Project getSingle(ProjectDao projectRepository, String id) throws InstantiationException, IllegalAccessException{
|
||||||
eu.eudat.models.project.Project project = new eu.eudat.models.project.Project();
|
eu.eudat.models.project.Project project = new eu.eudat.models.project.Project();
|
||||||
project.fromDataModel(projectRepository.read(UUID.fromString(id)));
|
project.fromDataModel(projectRepository.find(UUID.fromString(id)));
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,25 @@ package eu.eudat.models.criteria;
|
||||||
|
|
||||||
import eu.eudat.entities.DMP;
|
import eu.eudat.entities.DMP;
|
||||||
|
|
||||||
public class DataManagementPlanCriteria extends Criteria<DMP>{
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class DataManagementPlanCriteria extends Criteria<DMP>{
|
||||||
|
private Date periodStart;
|
||||||
|
private Date periodEnd;
|
||||||
|
|
||||||
|
public Date getPeriodStart() {
|
||||||
|
return periodStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodStart(Date periodStart) {
|
||||||
|
this.periodStart = periodStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getPeriodEnd() {
|
||||||
|
return periodEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodEnd(Date periodEnd) {
|
||||||
|
this.periodEnd = periodEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,25 @@ package eu.eudat.models.criteria;
|
||||||
|
|
||||||
import eu.eudat.entities.Project;
|
import eu.eudat.entities.Project;
|
||||||
|
|
||||||
public class ProjectCriteria extends Criteria<Project>{
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class ProjectCriteria extends Criteria<Project>{
|
||||||
|
private Date periodStart;
|
||||||
|
private Date periodEnd;
|
||||||
|
|
||||||
|
public Date getPeriodStart() {
|
||||||
|
return periodStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodStart(Date periodStart) {
|
||||||
|
this.periodStart = periodStart;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getPeriodEnd() {
|
||||||
|
return periodEnd;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodEnd(Date periodEnd) {
|
||||||
|
this.periodEnd = periodEnd;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,37 +2,11 @@ package eu.eudat.models.dataset;
|
||||||
|
|
||||||
import eu.eudat.models.criteria.DatasetCriteria;
|
import eu.eudat.models.criteria.DatasetCriteria;
|
||||||
import eu.eudat.models.criteria.ProjectCriteria;
|
import eu.eudat.models.criteria.ProjectCriteria;
|
||||||
|
import eu.eudat.models.helpers.requests.RequestItem;
|
||||||
|
import eu.eudat.models.helpers.requests.TableRequest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by ikalyvas on 12/15/2017.
|
* Created by ikalyvas on 12/15/2017.
|
||||||
*/
|
*/
|
||||||
public class DatasetTableRequest {
|
public class DatasetTableRequest extends TableRequest<DatasetCriteria> {
|
||||||
private int length;
|
|
||||||
private int offset;
|
|
||||||
|
|
||||||
private DatasetCriteria criteria;
|
|
||||||
|
|
||||||
public int getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(int length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOffset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOffset(int offset) {
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DatasetCriteria getCriteria() {
|
|
||||||
return criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCriteria(DatasetCriteria criteria) {
|
|
||||||
this.criteria = criteria;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,36 +1,8 @@
|
||||||
package eu.eudat.models.dmp;
|
package eu.eudat.models.dmp;
|
||||||
|
|
||||||
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
import eu.eudat.models.criteria.DataManagementPlanCriteria;
|
||||||
|
import eu.eudat.models.helpers.requests.RequestItem;
|
||||||
|
import eu.eudat.models.helpers.requests.TableRequest;
|
||||||
|
|
||||||
public class DataManagementPlanTableRequest {
|
public class DataManagementPlanTableRequest extends TableRequest<DataManagementPlanCriteria> {
|
||||||
private Integer length;
|
|
||||||
private Integer offset;
|
|
||||||
|
|
||||||
private DataManagementPlanCriteria criteria;
|
|
||||||
|
|
||||||
public Integer getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(Integer length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getOffset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOffset(Integer offset) {
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DataManagementPlanCriteria getCriteria() {
|
|
||||||
return criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCriteria(DataManagementPlanCriteria criteria) {
|
|
||||||
this.criteria = criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package eu.eudat.models.helpers.requests;
|
||||||
|
|
||||||
|
public abstract class RequestItem<T>{
|
||||||
|
private T criteria;
|
||||||
|
|
||||||
|
public T getCriteria() {
|
||||||
|
return criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCriteria(T criteria) {
|
||||||
|
this.criteria = criteria;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.eudat.models.helpers.requests;
|
||||||
|
|
||||||
|
public abstract class TableRequest<T> extends RequestItem<T> {
|
||||||
|
private Integer length;
|
||||||
|
private Integer offset;
|
||||||
|
|
||||||
|
public Integer getLength() {
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLength(Integer length) {
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOffset() {
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOffset(Integer offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,52 @@
|
||||||
|
package eu.eudat.models.helpers.responses;
|
||||||
|
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public class ResponseItem<T> {
|
||||||
|
private HttpStatus statusCode;
|
||||||
|
private String message;
|
||||||
|
private T payload;
|
||||||
|
|
||||||
|
public HttpStatus getStatusCode() {
|
||||||
|
return statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatusCode(HttpStatus statusCode) {
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getPayload() {
|
||||||
|
return payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setpayload(T payload) {
|
||||||
|
this.payload = payload;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseItem<T> status(HttpStatus statusCode){
|
||||||
|
this.statusCode = statusCode;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseItem<T> message(String message){
|
||||||
|
this.message = message;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResponseItem<T> payload(T payload){
|
||||||
|
this.payload = payload;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package eu.eudat.models.login;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public class Credentials {
|
||||||
|
private String username;
|
||||||
|
private String secret;
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSecret() {
|
||||||
|
return secret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSecret(String secret) {
|
||||||
|
this.secret = secret;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +1,8 @@
|
||||||
package eu.eudat.models.project;
|
package eu.eudat.models.project;
|
||||||
|
|
||||||
import eu.eudat.models.criteria.ProjectCriteria;
|
import eu.eudat.models.criteria.ProjectCriteria;
|
||||||
|
import eu.eudat.models.helpers.requests.RequestItem;
|
||||||
|
import eu.eudat.models.helpers.requests.TableRequest;
|
||||||
|
|
||||||
public class ProjectTableRequest {
|
public class ProjectTableRequest extends TableRequest<ProjectCriteria> {
|
||||||
private int length;
|
|
||||||
private int offset;
|
|
||||||
|
|
||||||
private ProjectCriteria criteria;
|
|
||||||
|
|
||||||
public int getLength() {
|
|
||||||
return length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLength(int length) {
|
|
||||||
this.length = length;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getOffset() {
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOffset(int offset) {
|
|
||||||
this.offset = offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ProjectCriteria getCriteria() {
|
|
||||||
return criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCriteria(ProjectCriteria criteria) {
|
|
||||||
this.criteria = criteria;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
package eu.eudat.models.security;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
public class Principal {
|
||||||
|
private UUID id;
|
||||||
|
private UUID token;
|
||||||
|
private String name;
|
||||||
|
private Date expiresAt;
|
||||||
|
private Set<Integer> roles;
|
||||||
|
|
||||||
|
public UUID getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(UUID id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setToken(UUID token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpiresAt() {
|
||||||
|
return expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiresAt(Date expiresAt) {
|
||||||
|
this.expiresAt = expiresAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Integer> getRoles() {
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRoles(Set<Integer> roles) {
|
||||||
|
this.roles = roles;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package eu.eudat.queryable;
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||||
|
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||||
|
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface QueryableList<T> {
|
||||||
|
QueryableList<T> where(SinglePredicate<T> predicate);
|
||||||
|
|
||||||
|
<R> List<R> select(SelectPredicate<T, R> predicate);
|
||||||
|
|
||||||
|
List<T> toList();
|
||||||
|
|
||||||
|
QueryableList<T> skip(Integer offset);
|
||||||
|
|
||||||
|
QueryableList<T> take(Integer length);
|
||||||
|
|
||||||
|
QueryableList<T> distinct();
|
||||||
|
|
||||||
|
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package eu.eudat.queryable.hibernatequeryablelist;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import eu.eudat.queryable.QueryableList;
|
||||||
|
import eu.eudat.queryable.predicates.OrderByPredicate;
|
||||||
|
import eu.eudat.queryable.predicates.SelectPredicate;
|
||||||
|
import eu.eudat.queryable.predicates.SinglePredicate;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class QueryableHibernateList<T> implements QueryableList<T> {
|
||||||
|
|
||||||
|
private EntityManager manager;
|
||||||
|
private CriteriaQuery<T> query;
|
||||||
|
private Class<T> tClass;
|
||||||
|
private Root<T> root;
|
||||||
|
private LinkedList<Predicate> predicates = new LinkedList<Predicate>();
|
||||||
|
private Integer length;
|
||||||
|
private Integer offset;
|
||||||
|
public QueryableHibernateList(EntityManager manager, Class<T> tClass) {
|
||||||
|
this.manager = manager;
|
||||||
|
this.tClass = tClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryableHibernateList<T> setManager(EntityManager manager) {
|
||||||
|
this.manager = manager;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryableHibernateList<T> setEntity(Class<T> type) {
|
||||||
|
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
||||||
|
this.query = builder.createQuery(type);
|
||||||
|
this.root = this.query.from(this.tClass);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initiateQueryableList(Class<T> type) {
|
||||||
|
CriteriaBuilder builder = this.manager.getCriteriaBuilder();
|
||||||
|
this.query = builder.createQuery(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<T> skip(Integer offset) {
|
||||||
|
this.offset = offset;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryableList<T> take(Integer length) {
|
||||||
|
this.length = length;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryableList<T> where(SinglePredicate<T> predicate) {
|
||||||
|
this.predicates.add(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <R> List<R> select(SelectPredicate<T, R> predicate) {
|
||||||
|
List<T> list = this.toList();
|
||||||
|
List<R> newlist = new LinkedList<R>();
|
||||||
|
for (T item : list) {
|
||||||
|
newlist.add(predicate.applySelection(item));
|
||||||
|
}
|
||||||
|
return newlist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryableList<T> distinct() {
|
||||||
|
this.query.distinct(true);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QueryableList<T> orderBy(OrderByPredicate<T> predicate) {
|
||||||
|
this.query.orderBy(predicate.applyPredicate(this.manager.getCriteriaBuilder(), this.root));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> toList() {
|
||||||
|
Predicate[] array = new Predicate[this.predicates.size()];
|
||||||
|
this.predicates.toArray(array);
|
||||||
|
this.query.where(array);
|
||||||
|
|
||||||
|
TypedQuery<T> typedQuery = this.manager.createQuery(this.query);
|
||||||
|
if(this.offset!=null)typedQuery.setFirstResult(this.offset);
|
||||||
|
if(this.length!=null)typedQuery.setMaxResults(this.length);
|
||||||
|
return typedQuery.getResultList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package eu.eudat.queryable.predicates;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.Order;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
public interface OrderByPredicate<T> {
|
||||||
|
Order applyPredicate(CriteriaBuilder builder, Root<T> root);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
package eu.eudat.queryable.predicates;
|
||||||
|
|
||||||
|
public interface SelectPredicate<T, R> {
|
||||||
|
R applySelection(T item);
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
package eu.eudat.queryable.predicates;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
|
|
||||||
|
public interface SinglePredicate<T> {
|
||||||
|
Predicate applyPredicate(CriteriaBuilder builder, Root<T> root);
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.naming.NameAlreadyBoundException;
|
import javax.naming.NameAlreadyBoundException;
|
||||||
|
|
||||||
|
import eu.eudat.models.login.Credentials;
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.authentication.AuthenticationProvider;
|
import org.springframework.security.authentication.AuthenticationProvider;
|
||||||
import org.springframework.security.authentication.AuthenticationServiceException;
|
import org.springframework.security.authentication.AuthenticationServiceException;
|
||||||
|
@ -20,7 +22,7 @@ import eu.eudat.security.validators.NativeTokenValidator;
|
||||||
import eu.eudat.security.validators.TokenValidator;
|
import eu.eudat.security.validators.TokenValidator;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CustomAuthenticationProvider implements AuthenticationProvider {
|
public class CustomAuthenticationProvider {
|
||||||
|
|
||||||
|
|
||||||
@Autowired private UserInfoDao userInfoDao;
|
@Autowired private UserInfoDao userInfoDao;
|
||||||
|
@ -28,43 +30,14 @@ public class CustomAuthenticationProvider implements AuthenticationProvider {
|
||||||
@Autowired private GoogleTokenValidator googleTokenValidator;
|
@Autowired private GoogleTokenValidator googleTokenValidator;
|
||||||
@Autowired private NativeTokenValidator nativeTokenValidator;
|
@Autowired private NativeTokenValidator nativeTokenValidator;
|
||||||
|
|
||||||
|
public Principal authenticate(Credentials credentials) throws AuthenticationException {
|
||||||
@Override
|
String token = credentials.getSecret();
|
||||||
public Authentication authenticate(Authentication authentication) throws AuthenticationException {
|
|
||||||
|
|
||||||
if (authentication != null) {
|
|
||||||
|
|
||||||
String token = (String)authentication.getCredentials();
|
|
||||||
TokenValidator tokenValidator = null;
|
|
||||||
|
|
||||||
if(TokenAuthenticationFilter.HEADER_GOOGLE_TOKEN_FIELD.equals(authentication.getPrincipal()))
|
|
||||||
tokenValidator = googleTokenValidator;
|
|
||||||
else if(TokenAuthenticationFilter.HEADER_NATIVE_TOKEN_FIELD.equals(authentication.getPrincipal()))
|
|
||||||
tokenValidator = nativeTokenValidator;
|
|
||||||
else
|
|
||||||
throw new AuthenticationServiceException("The appropriate http headers have not been set. Please check!");
|
|
||||||
|
|
||||||
UserInfo userInfo;
|
|
||||||
try {
|
try {
|
||||||
userInfo = tokenValidator.validateToken(token);
|
Principal principal = googleTokenValidator.validateToken(token);
|
||||||
|
return principal;
|
||||||
} catch (NonValidTokenException e) {
|
} catch (NonValidTokenException e) {
|
||||||
System.out.println("Could not validate a user by his token! Reason: "+e.getMessage());
|
System.out.println("Could not validate a user by his token! Reason: " + e.getMessage());
|
||||||
throw new AuthenticationServiceException("Token validation failed - Not a valid token");
|
throw new AuthenticationServiceException("Token validation failed - Not a valid token");
|
||||||
}
|
}
|
||||||
|
|
||||||
// if reached this point, authentication is ok, so return just an instance where the principal is the UserInfo ID
|
|
||||||
//(to have it at the webservices calls - it's ESSENTIAL) while the password can be whatever...
|
|
||||||
return new UsernamePasswordAuthenticationToken(userInfo.getId(), authentication.getCredentials(), new ArrayList<>());
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
throw new AuthenticationServiceException("Authentication failed");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(Class<?> authentication) {
|
|
||||||
return authentication.equals(UsernamePasswordAuthenticationToken.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,10 +2,13 @@ package eu.eudat.security.validators;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.security.GeneralSecurityException;
|
import java.security.GeneralSecurityException;
|
||||||
import java.util.Arrays;
|
import java.security.Principal;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
import eu.eudat.dao.entities.security.CredentialDao;
|
||||||
|
import eu.eudat.entities.Credential;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
import eu.eudat.services.AuthenticationService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
|
import com.google.api.client.googleapis.auth.oauth2.GoogleIdToken;
|
||||||
|
@ -28,8 +31,8 @@ public class GoogleTokenValidator implements TokenValidator {
|
||||||
private static final HttpTransport transport = new NetHttpTransport();
|
private static final HttpTransport transport = new NetHttpTransport();
|
||||||
|
|
||||||
@Autowired private UserInfoDao userInfoDao;
|
@Autowired private UserInfoDao userInfoDao;
|
||||||
|
@Autowired private CredentialDao credentialDao;
|
||||||
|
@Autowired private AuthenticationService authenticationService;
|
||||||
private static final List<String> clientIDs = Arrays.asList(
|
private static final List<String> clientIDs = Arrays.asList(
|
||||||
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com",
|
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com",
|
||||||
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com"
|
"1010962018903-glegmqudqtl1lub0150vacopbu06lgsg.apps.googleusercontent.com"
|
||||||
|
@ -48,7 +51,7 @@ public class GoogleTokenValidator implements TokenValidator {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfo validateToken(String token) throws NonValidTokenException {
|
public eu.eudat.models.security.Principal validateToken(String token) throws NonValidTokenException {
|
||||||
|
|
||||||
GoogleIdToken idToken = null;
|
GoogleIdToken idToken = null;
|
||||||
try {
|
try {
|
||||||
|
@ -72,6 +75,15 @@ public class GoogleTokenValidator implements TokenValidator {
|
||||||
|
|
||||||
UserInfo userInfo = userInfoDao.getByMail(payload.getEmail());
|
UserInfo userInfo = userInfoDao.getByMail(payload.getEmail());
|
||||||
|
|
||||||
|
Credential credential = new Credential();
|
||||||
|
credential.setCreationTime(new Date());
|
||||||
|
credential.setId(UUID.randomUUID());
|
||||||
|
credential.setLastUpdateTime(new Date());
|
||||||
|
credential.setProvider(1);
|
||||||
|
credential.setSecret(token);
|
||||||
|
credential.setPublicValue(userInfo.getName());
|
||||||
|
credential.setUserInfo(userInfo);
|
||||||
|
|
||||||
if(userInfo == null) { //means not existing in db, so create one
|
if(userInfo == null) { //means not existing in db, so create one
|
||||||
userInfo = new UserInfo();
|
userInfo = new UserInfo();
|
||||||
userInfo.setName((String)payload.get("name"));
|
userInfo.setName((String)payload.get("name"));
|
||||||
|
@ -82,13 +94,22 @@ public class GoogleTokenValidator implements TokenValidator {
|
||||||
userInfo.setAuthorization_level(new Short("1"));
|
userInfo.setAuthorization_level(new Short("1"));
|
||||||
userInfo.setUsertype(new Short("1"));
|
userInfo.setUsertype(new Short("1"));
|
||||||
userInfo = userInfoDao.create(userInfo);
|
userInfo = userInfoDao.create(userInfo);
|
||||||
|
credential = credentialDao.create(credential);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
userInfo.setLastloggedin(new Date());
|
userInfo.setLastloggedin(new Date());
|
||||||
|
Set<Credential> credentials = userInfo.getCredentials();
|
||||||
|
credentials.add(credential);
|
||||||
userInfo = userInfoDao.update(userInfo);
|
userInfo = userInfoDao.update(userInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserToken userToken = new UserToken();
|
||||||
|
userToken.setUser(userInfo);
|
||||||
|
userToken.setIssuedAt(new Date());
|
||||||
|
userToken.setToken(UUID.randomUUID());
|
||||||
|
userToken.setExpiresAt(new Date());
|
||||||
|
|
||||||
return userInfo;
|
return authenticationService.Touch(userToken.getToken());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package eu.eudat.security.validators;
|
package eu.eudat.security.validators;
|
||||||
|
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import eu.eudat.dao.entities.UserInfoDao;
|
import eu.eudat.dao.entities.UserInfoDao;
|
||||||
|
@ -15,11 +16,11 @@ public class NativeTokenValidator implements TokenValidator {
|
||||||
@Autowired private UserInfoDao userInfoDao;
|
@Autowired private UserInfoDao userInfoDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserInfo validateToken(String token) throws NonValidTokenException {
|
public Principal validateToken(String token) throws NonValidTokenException {
|
||||||
String tokenUser = tokenSessionManager.getUser(token);
|
String tokenUser = tokenSessionManager.getUser(token);
|
||||||
if(tokenUser==null || tokenUser.isEmpty())
|
if(tokenUser==null || tokenUser.isEmpty())
|
||||||
throw new NonValidTokenException("Login session has expired! Need to eu.eudat.login again!");
|
throw new NonValidTokenException("Login session has expired! Need to eu.eudat.login again!");
|
||||||
return userInfoDao.getByUsername(tokenUser);
|
return new Principal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,10 @@ package eu.eudat.security.validators;
|
||||||
|
|
||||||
import eu.eudat.entities.UserInfo;
|
import eu.eudat.entities.UserInfo;
|
||||||
import eu.eudat.exceptions.NonValidTokenException;
|
import eu.eudat.exceptions.NonValidTokenException;
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
|
|
||||||
public interface TokenValidator {
|
public interface TokenValidator {
|
||||||
|
|
||||||
public UserInfo validateToken(String token) throws NonValidTokenException;
|
public Principal validateToken(String token) throws NonValidTokenException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
package eu.eudat.services;
|
||||||
|
|
||||||
|
import eu.eudat.dao.entities.UserInfoDao;
|
||||||
|
import eu.eudat.dao.entities.security.UserTokenDao;
|
||||||
|
import eu.eudat.entities.UserInfo;
|
||||||
|
import eu.eudat.entities.UserToken;
|
||||||
|
import eu.eudat.models.security.Principal;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.xml.ws.ServiceMode;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by ikalyvas on 12/15/2017.
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AuthenticationService {
|
||||||
|
@Autowired
|
||||||
|
UserTokenDao userTokenDao;
|
||||||
|
@Autowired
|
||||||
|
UserInfoDao userInfoDao;
|
||||||
|
|
||||||
|
public Principal Touch(UUID token)
|
||||||
|
{
|
||||||
|
UserToken tokenEntry = userTokenDao.read(token);
|
||||||
|
if (tokenEntry == null || tokenEntry.getExpiresAt().before(new Date())) return null;
|
||||||
|
|
||||||
|
Principal principal = this.Touch(tokenEntry);
|
||||||
|
|
||||||
|
return principal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Logout(UUID token)
|
||||||
|
{
|
||||||
|
UserToken tokenEntry = userTokenDao.read(token);
|
||||||
|
userTokenDao.delete(tokenEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Principal Touch(UserToken token)
|
||||||
|
{
|
||||||
|
if (token == null || token.getExpiresAt().before(new Date())) return null;
|
||||||
|
|
||||||
|
UserInfo user = this.userInfoDao.read(token.getUser().getId());
|
||||||
|
if (user == null /*|| user.Status != ActivityStatus.Active*/) return null;
|
||||||
|
|
||||||
|
//List<UserRole> appRoles = this._unitOfWork.UserRoles.GetAll().Where(x => x.UserId == token.UserId /*&& x.Status == ActivityStatus.Active*/).ToList();
|
||||||
|
|
||||||
|
Principal principal = new Principal();
|
||||||
|
principal.setId(user.getId());
|
||||||
|
principal.setToken(token.getToken());
|
||||||
|
principal.setExpiresAt(token.getExpiresAt());
|
||||||
|
principal.setName(user.getName());
|
||||||
|
|
||||||
|
/*foreach (UserRole item in appRoles)
|
||||||
|
{
|
||||||
|
if (principal.AppRoles == null) principal.AppRoles = new HashSet<AppRole>();
|
||||||
|
principal.AppRoles.Add(item.Role);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this._config.Refresh) token.ExpiresAt = DateTime.UtcNow.AddMinutes(this._config.Lifetime);
|
||||||
|
*/
|
||||||
|
return principal;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,15 +19,13 @@
|
||||||
"testTsconfig": "tsconfig.spec.json",
|
"testTsconfig": "tsconfig.spec.json",
|
||||||
"prefix": "app",
|
"prefix": "app",
|
||||||
"styles": [
|
"styles": [
|
||||||
"../node_modules/primeng/resources/themes/omega/theme.css" ,
|
|
||||||
"../node_modules/primeng/resources/primeng.css",
|
|
||||||
"./../node_modules/bootstrap/dist/css/bootstrap.min.css",
|
"./../node_modules/bootstrap/dist/css/bootstrap.min.css",
|
||||||
"styles.css"
|
"styles.scss"
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"./../node_modules/bootstrap/dist/js/bootstrap.min.js",
|
"./../node_modules/bootstrap/dist/js/bootstrap.min.js",
|
||||||
"./assets/xml2json.min.js"
|
"./assets/xml2json.min.js"
|
||||||
],
|
],
|
||||||
"environmentSource": "environments/environment.ts",
|
"environmentSource": "environments/environment.ts",
|
||||||
"environments": {
|
"environments": {
|
||||||
"dev": "environments/environment.ts",
|
"dev": "environments/environment.ts",
|
||||||
|
@ -63,4 +61,4 @@
|
||||||
"styleExt": "css",
|
"styleExt": "css",
|
||||||
"component": {}
|
"component": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -277,6 +277,14 @@
|
||||||
"tslib": "1.7.1"
|
"tslib": "1.7.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@covalent/core": {
|
||||||
|
"version": "1.0.0-rc.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@covalent/core/-/core-1.0.0-rc.1.tgz",
|
||||||
|
"integrity": "sha1-majfr1PoModZlV7EBM4KwMjmDSU=",
|
||||||
|
"requires": {
|
||||||
|
"tslib": "1.7.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@ng-bootstrap/ng-bootstrap": {
|
"@ng-bootstrap/ng-bootstrap": {
|
||||||
"version": "1.0.0-beta.7",
|
"version": "1.0.0-beta.7",
|
||||||
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-1.0.0-beta.7.tgz",
|
"resolved": "https://registry.npmjs.org/@ng-bootstrap/ng-bootstrap/-/ng-bootstrap-1.0.0-beta.7.tgz",
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"@angular/platform-browser": "5.1.1",
|
"@angular/platform-browser": "5.1.1",
|
||||||
"@angular/platform-browser-dynamic": "5.1.1",
|
"@angular/platform-browser-dynamic": "5.1.1",
|
||||||
"@angular/router": "5.1.1",
|
"@angular/router": "5.1.1",
|
||||||
|
"@covalent/core": "^1.0.0-rc.1",
|
||||||
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.7",
|
"@ng-bootstrap/ng-bootstrap": "1.0.0-beta.7",
|
||||||
"@ngui/auto-complete": "^0.16.0",
|
"@ngui/auto-complete": "^0.16.0",
|
||||||
"@ngx-translate/core": "^9.0.1",
|
"@ngx-translate/core": "^9.0.1",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export const HostConfiguration = {
|
export const HostConfiguration = {
|
||||||
Server: 'http://192.168.32.103:8080/',
|
Server: 'http://192.168.32.171:8080/',
|
||||||
//CASHost: 'https://login-devel.uoa.gr/login',
|
//CASHost: 'https://login-devel.uoa.gr/login',
|
||||||
//Service: 'http://elkefinman/login'
|
//Service: 'http://elkefinman/login'
|
||||||
}
|
}
|
|
@ -97,7 +97,7 @@ export class DatasetDataSource extends DataSource<DatasetListingModel> {
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
||||||
request.projectCriteria = this._criteria.getFormData();
|
request.criteria = this._criteria.getFormData();
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
|
|
@ -115,7 +115,7 @@ export class DataManagementPlanDataSource extends DataSource<DataManagementPlanL
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
||||||
request.projectCriteria = this._criteria.getFormData();
|
request.criteria = this._criteria.getFormData();
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
|
|
@ -1,20 +0,0 @@
|
||||||
.mat-card {
|
|
||||||
overflow: auto;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-table {
|
|
||||||
margin: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-progress-bar {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-fab-bottom-right {
|
|
||||||
top: auto !important;
|
|
||||||
right: 20px !important;
|
|
||||||
bottom: 10px !important;
|
|
||||||
left: auto !important;
|
|
||||||
position: fixed !important;
|
|
||||||
}
|
|
|
@ -1,190 +1,97 @@
|
||||||
<div class="container-fluid">
|
<div class="project-editor">
|
||||||
<h3>{{'PROJECT-LISTING.TITLE' | translate}}</h3>
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||||
|
<mat-card>
|
||||||
|
<mat-card-title *ngIf="isNew">{{'DMP-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
||||||
|
<mat-card-title *ngIf="!isNew">{{'DMP-EDITOR.TITLE.EDIT' | translate}} {{project.label}}</mat-card-title>
|
||||||
|
<mat-card-content>
|
||||||
|
|
||||||
<app-projects-criteria-component></app-projects-criteria-component>
|
<mat-form-field>
|
||||||
<mat-card class="mat-card">
|
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.NAME' | translate}}" type="text" name="label" formControlName="label" required>
|
||||||
<mat-progress-bar *ngIf="dataSource?.isLoadingResults" mode="query"></mat-progress-bar>
|
<mat-error *ngIf="formGroup.get('label').errors?.backendError">{{baseErrorModel.label}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('label').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-table [dataSource]="dataSource" matSort>
|
<!-- <mat-form-field>
|
||||||
|
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.ABBREVIATION' | translate}}" type="text" name="abbreviation" formControlName="abbreviation"
|
||||||
|
required>
|
||||||
|
<mat-error *ngIf="formGroup.get('abbreviation').errors?.backendError">{{baseErrorModel.abbreviation}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('abbreviation').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<!-- Column Definition: Name -->
|
<mat-form-field>
|
||||||
<ng-container cdkColumnDef="name">
|
<input matInput placeholder="{{'DMP-EDITOR.FIELDS.URI' | translate}}" type="text" name="uri" formControlName="uri" required>
|
||||||
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.NAME' | translate}}</mat-header-cell>
|
<mat-error *ngIf="formGroup.get('uri').errors?.backendError">{{baseErrorModel.uri}}</mat-error>
|
||||||
<mat-cell *matCellDef="let row">{{row.name}}</mat-cell>
|
<mat-error *ngIf="formGroup.get('uri').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</ng-container>
|
</mat-form-field> -->
|
||||||
|
|
||||||
<!-- Column Definition: Αbbreviation -->
|
<!-- <table class="input-table full-width">
|
||||||
<ng-container cdkColumnDef="abbreviation">
|
<tr>
|
||||||
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.ABBREVIATION' | translate}}</mat-header-cell>
|
<td>
|
||||||
<mat-cell *matCellDef="let row"> {{row.abbreviation}} </mat-cell>
|
<mat-form-field>
|
||||||
</ng-container>
|
<input matInput (focus)="startDate.open()" (click)="startDate.open()" placeholder="{{'DMP-EDITOR.FIELDS.START' | translate}}"
|
||||||
|
class="table-input" [matDatepicker]="startDate" formControlName="startDate" required>
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="startDate"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #startDate></mat-datepicker>
|
||||||
|
<mat-error *ngIf="formGroup.get('startDate').errors?.backendError">{{baseErrorModel.startDate}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('startDate').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<mat-form-field>
|
||||||
|
<input matInput (focus)="endDate.open()" (click)="endDate.open()" placeholder="{{'DMP-EDITOR.FIELDS.END' | translate}}"
|
||||||
|
class="table-input" [matDatepicker]="endDate" formControlName="endDate" required>
|
||||||
|
<mat-datepicker-toggle matSuffix [for]="endDate"></mat-datepicker-toggle>
|
||||||
|
<mat-datepicker #endDate></mat-datepicker>
|
||||||
|
<mat-error *ngIf="formGroup.get('endDate').errors?.backendError">{{baseErrorModel.endDate}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('endDate').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table> -->
|
||||||
|
|
||||||
<!-- Column Definition: Start -->
|
<mat-form-field class="full-width">
|
||||||
<ng-container cdkColumnDef="start">
|
<textarea matInput class="description-area" placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description"
|
||||||
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.START' | translate}}</mat-header-cell>
|
required></textarea>
|
||||||
<mat-cell *matCellDef="let row"> {{row.start}} </mat-cell>
|
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
|
||||||
</ng-container>
|
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<!-- Column Definition: End -->
|
<td-chips color="accent" [items]="filteredOrganisations" formControlName="organisations" placeholder="{{'DMP-EDITOR.FIELDS.ORGANISATIONS' | translate}}"
|
||||||
<ng-container cdkColumnDef="end">
|
(inputChange)="filterOrganisations($event)" requireMatch>
|
||||||
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.END' | translate}}</mat-header-cell>
|
<ng-template td-chip let-chip="chip">
|
||||||
<mat-cell *matCellDef="let row"> {{row.end}} </mat-cell>
|
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||||
</ng-container>
|
{{chip.name}}
|
||||||
|
</ng-template>
|
||||||
<!-- Column Definition: Submission Time -->
|
<ng-template td-autocomplete-option let-option="option">
|
||||||
<ng-container cdkColumnDef="actions">
|
<div layout="row" layout-align="start center">
|
||||||
<mat-header-cell *matHeaderCellDef>{{'PROJECT-LISTING.COLUMNS.ACTIONS' | translate}}</mat-header-cell>
|
{{option.name}}
|
||||||
<mat-cell *matCellDef="let row"></mat-cell>
|
|
||||||
</ng-container>
|
|
||||||
|
|
||||||
<mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
|
|
||||||
<mat-row *matRowDef="let row; columns: displayedColumns" (click)="rowClick(row.id)"></mat-row>
|
|
||||||
|
|
||||||
</mat-table>
|
|
||||||
<mat-paginator #paginator
|
|
||||||
[length]="dataSource?.totalCount"
|
|
||||||
[pageSizeOptions]="[10, 25, 100]">
|
|
||||||
</mat-paginator>
|
|
||||||
</mat-card>
|
|
||||||
|
|
||||||
<button mat-fab class="mat-fab-bottom-right" color="primary" [routerLink]=" ['./new'] ">
|
|
||||||
<mat-icon class="mat-24">add</mat-icon>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<!-- <meta name="google-signin-client_id" content="524432312250-vhgidft856v8qftsc81kls4c74v87d8o.apps.googleusercontent.com">
|
|
||||||
|
|
||||||
<table class="table table-striped" [mfData]="tableData | projectTableFilter : filterQuery : whoami?.id : onlyMyProjects"
|
|
||||||
#mf="mfDataTable" [mfRowsOnPage]="rowsOnPage" [(mfSortBy)]="sortBy" [(mfSortOrder)]="sortOrder">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th colspan="1">
|
|
||||||
<input class="form-control" [(ngModel)]="filterQuery" placeholder='Filter' />
|
|
||||||
</th>
|
|
||||||
<th style="width:50px;">
|
|
||||||
<button class="btn btn-default" (click)="getProjects('false')">
|
|
||||||
<span class="glyphicon glyphicon-refresh"></span>
|
|
||||||
</button>
|
|
||||||
</th>
|
|
||||||
<th colspan="1">
|
|
||||||
<div class="checkbox">
|
|
||||||
<label><input type="checkbox" [(ngModel)]="onlyMyProjects" >Show only my projects</label>
|
|
||||||
</div>
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<th [ngClass]="{true:'visible', false:'invisible'}[showIDs]">
|
|
||||||
<mfDefaultSorter by="id">ID</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="label">Label</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="abbreviation">Αbbreviation</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="startdate">Start Date</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="enddate">End Date</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="status">Status</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter by="description">Description</mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
<mfDefaultSorter>Actions </mfDefaultSorter>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr class="grayout-empty-table" *ngIf="!mf.data[0]">
|
|
||||||
<td colspan="7">No elements</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr *ngFor="let project of mf.data" class="hover">
|
|
||||||
<td [ngClass]="{true:'visible', false:'invisible'}[showIDs]">{{project?.id}}</td>
|
|
||||||
<td>{{(project?.label?.length > 40) ? (project?.label | slice:0:40)+'...':(project?.label) }}</td>
|
|
||||||
<td>{{project?.abbreviation}}</td>
|
|
||||||
<td>{{project?.startdate | date:'medium' }}</td>
|
|
||||||
<td>{{project?.enddate | date:'medium'}}</td>
|
|
||||||
<td>{{project?.status | statusToString}}</td>
|
|
||||||
<td>{{(project?.description?.length > 40) ? (project?.description | slice:0:40)+'...':(project?.description) }}</td>
|
|
||||||
<td>
|
|
||||||
<a [ngClass]="{'not-active': whoami?.id!=project?.creationUser?.id }" class="editGridColumn" (click)="editRow(project, $event)">
|
|
||||||
<i class="fa fa-pencil fa-fw" data-toggle="tooltip" title="edit properties" id="editDMP" ></i>
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
<tfoot>
|
|
||||||
<tr>
|
|
||||||
<td colspan="1">
|
|
||||||
<button type="button" class="btn btn-info btncustom" (click)="newProject(item)">New Project</button>
|
|
||||||
</td>
|
|
||||||
<td colspan="5">
|
|
||||||
|
|
||||||
<mfBootstrapPaginator [rowsOnPageSet]="[5,10,20]"></mfBootstrapPaginator>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tfoot>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="modal fade" id="newEditProjectModal" tabindex="-1" role="dialog" aria-labelledby="newProjectModalLabel" aria-hidden="true">
|
|
||||||
<div class="modal-dialog" role="document">
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="exampleModalLabel">Project</h5>
|
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
||||||
<span aria-hidden="true">×</span>
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div class="modal-body">
|
|
||||||
<form #newProjectForm="ngForm" (ngSubmit)="SaveProject()" novalidate>
|
|
||||||
|
|
||||||
<label for="label-name" class="form-control-label">Label:</label>
|
|
||||||
<input type="text" class="form-control" id="label-name" [(ngModel)]= "project.label" name = "label" required>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="abbreviation-text" class="form-control-label">Abbreviation:</label>
|
|
||||||
<input class="form-control" id="abbreviation-text" [(ngModel)]= "project.abbreviation" name = "abbreviation">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="reference-text" class="form-control-label">Reference:</label>
|
|
||||||
<input class="form-control" id="reference-text" [(ngModel)]= "project.reference" name = "reference">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="uri-text" class="form-control-label">Uri:</label>
|
|
||||||
<input class="form-control" id="uri-text" [(ngModel)]= "project.uri" name = "uri">
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="start-date" class="form-control-label">Start Date:</label>
|
|
||||||
<input class="form-control" type='date' class="form-control" [(ngModel)]= "project.startdate" id='start-date' name = "startdate" required/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="end-date" class="form-control-label">End Date:</label>
|
|
||||||
<input class="form-control" type='date' class="form-control" [(ngModel)]= "project.enddate" id='end-date' name = "enddate" required/>
|
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="status-name" class="col-form-label">Status:</label>
|
|
||||||
<select class="form-control" id="statusid" [(ngModel)]="project.status" name="statusDropDown">
|
|
||||||
<option *ngFor="let opt of statusDropDown.options" [value]="opt.key">{{opt.value}}</option>
|
|
||||||
</select>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</ng-template>
|
||||||
<label for="code-name" class="form-control-label">Description:</label>
|
<mat-progress-bar [style.height.px]="2" *ngIf="filteringOrganisationsAsync" mode="indeterminate"></mat-progress-bar>
|
||||||
<textarea rows="3" class="form-control" name="desc" id="description" [(ngModel)]= "project.description"> </textarea>
|
</td-chips>
|
||||||
</div>
|
|
||||||
</form>
|
<td-chips color="accent" [items]="filteredResearchers" formControlName="researchers" placeholder="{{'DMP-EDITOR.FIELDS.RESEARCHERS' | translate}}"
|
||||||
</div>
|
(inputChange)="filterResearchers($event)" requireMatch>
|
||||||
<div class="modal-footer">
|
<ng-template td-chip let-chip="chip">
|
||||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
<div class="tc-grey-100 bgc-teal-700" td-chip-avatar>{{chip.name.substring(0, 1).toUpperCase()}}</div>
|
||||||
<button type="submit" class="btn btn-primary" [disabled]="!newProjectForm.form.valid" (click)="SaveProject();">Save project</button>
|
{{chip.name}}
|
||||||
</div>
|
</ng-template>
|
||||||
</div>
|
<ng-template td-autocomplete-option let-option="option">
|
||||||
</div>
|
<div layout="row" layout-align="start center">
|
||||||
</div>
|
{{option.name}}
|
||||||
-->
|
</div>
|
||||||
|
</ng-template>
|
||||||
|
<mat-progress-bar [style.height.px]="2" *ngIf="filteringResearchersAsync" mode="indeterminate"></mat-progress-bar>
|
||||||
|
</td-chips>
|
||||||
|
|
||||||
|
<div layout="row" class="full-width text-right" align="end">
|
||||||
|
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'DMP-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||||
|
<button mat-raised-button color="primary" type="submit">{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
||||||
|
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</mat-card-content>
|
||||||
|
</mat-card>
|
||||||
|
</form>
|
||||||
|
<div *ngIf="formGroup"> {{ formGroup.value | json }}</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,35 @@
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-table {
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-card .mat-grid-tile {
|
||||||
|
background: rgba(0, 0, 0, 0.32);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-editor {
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-card {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-button {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description-area {
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,34 +1,144 @@
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||||
import { Router } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
import { DataSource } from "@angular/cdk/table";
|
import { DataSource } from "@angular/cdk/table";
|
||||||
import { Observable } from "rxjs/Observable";
|
import { Observable } from "rxjs/Observable";
|
||||||
|
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||||
|
import { FormGroup } from "@angular/forms";
|
||||||
|
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||||
|
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
||||||
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
import { DataManagementPlanService } from "../../services/data-management-plan/data-management-plan.service";
|
||||||
|
import { DataManagementPlanModel } from "../../models/data-managemnt-plans/DataManagementPlanModel";
|
||||||
|
import { ServerService } from "../../services/server.service";
|
||||||
|
import { ExternalSourcesService } from "../../services/external-sources/external-sources.service";
|
||||||
|
import { ExternalSourcesItemModel } from "../../models/external-sources/ExternalSourcesItemModel";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-dmp-editor-component',
|
selector: 'app-dmp-editor-component',
|
||||||
templateUrl: 'dmp-editor.component.html',
|
templateUrl: 'dmp-editor.component.html',
|
||||||
styleUrls: ['./dmp-editor.component.css'],
|
styleUrls: ['./dmp-editor.component.scss'],
|
||||||
|
providers: [DataManagementPlanService, ExternalSourcesService],
|
||||||
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class DataManagementPlanEditorComponent implements OnInit, AfterViewInit {
|
export class DataManagementPlanEditorComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
isNew = true;
|
||||||
|
dataManagementPlan: DataManagementPlanModel;
|
||||||
|
formGroup: FormGroup = null;
|
||||||
|
|
||||||
|
filteringOrganisationsAsync: boolean = false;
|
||||||
|
filteringResearchersAsync: boolean = false;
|
||||||
|
filteredOrganisations: ExternalSourcesItemModel[];
|
||||||
|
filteredResearchers: ExternalSourcesItemModel[];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private projectService: DataManagementPlanService,
|
private dataManagementPlanService: DataManagementPlanService,
|
||||||
private router: Router,
|
private externalSourcesService: ExternalSourcesService,
|
||||||
private languageService: TranslateService,
|
private route: ActivatedRoute,
|
||||||
public snackBar: MatSnackBar
|
public snackBar: MatSnackBar,
|
||||||
|
public router: Router,
|
||||||
|
public language: TranslateService,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngAfterViewInit() {
|
||||||
|
this.route.params.subscribe((params: Params) => {
|
||||||
|
const itemId = params['id'];
|
||||||
|
|
||||||
|
if (itemId != null) {
|
||||||
|
this.isNew = false;
|
||||||
|
this.dataManagementPlanService.getSingle(itemId).map(data => data as DataManagementPlanModel)
|
||||||
|
.subscribe(data => {
|
||||||
|
this.dataManagementPlan = new JsonSerializer<DataManagementPlanModel>().fromJSONObject(data, DataManagementPlanModel);
|
||||||
|
this.formGroup = this.dataManagementPlan.buildForm();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.dataManagementPlan = new DataManagementPlanModel();
|
||||||
|
setTimeout(() => {
|
||||||
|
this.formGroup = this.dataManagementPlan.buildForm();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit() {
|
formSubmit(): void {
|
||||||
|
//this.touchAllFormFields(this.formGroup);
|
||||||
|
if (!this.isFormValid()) { return; }
|
||||||
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public isFormValid() {
|
||||||
|
return this.formGroup.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(): void {
|
||||||
|
this.dataManagementPlanService.createDataManagementPlan(this.formGroup.value).subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackSuccess(): void {
|
||||||
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
|
duration: 3000,
|
||||||
|
extraClasses: ['snackbar-success']
|
||||||
|
})
|
||||||
|
this.router.navigate(['/dataManagementPlans']);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackError(error: any) {
|
||||||
|
this.setErrorModel(error.error);
|
||||||
|
//this.validateAllFormFields(this.formGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
|
Object.keys(errorModel).forEach(item => {
|
||||||
|
(<any>this.dataManagementPlan.errorModel)[item] = (<any>errorModel)[item];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public cancel(): void {
|
||||||
|
this.router.navigate(['/dataManagementPlans']);
|
||||||
|
}
|
||||||
|
|
||||||
|
filterOrganisations(value: string): void {
|
||||||
|
|
||||||
|
this.filteredOrganisations = undefined;
|
||||||
|
if (value) {
|
||||||
|
this.filteringOrganisationsAsync = true;
|
||||||
|
|
||||||
|
this.externalSourcesService.searchDMPOrganizations(value).subscribe(items => {
|
||||||
|
this.filteredOrganisations = items;
|
||||||
|
this.filteringOrganisationsAsync = false;
|
||||||
|
|
||||||
|
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||||
|
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||||
|
// });
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filterResearchers(value: string): void {
|
||||||
|
|
||||||
|
this.filteredResearchers = undefined;
|
||||||
|
if (value) {
|
||||||
|
this.filteringResearchersAsync = true;
|
||||||
|
|
||||||
|
this.externalSourcesService.searchDMPResearchers(value).subscribe(items => {
|
||||||
|
this.filteredResearchers = items;
|
||||||
|
this.filteringResearchersAsync = false;
|
||||||
|
|
||||||
|
// this.filteredOrganisations = items.filter((filteredObj: any) => {
|
||||||
|
// return this.objectsModel ? this.objectsModel.indexOf(filteredObj) < 0 : true;
|
||||||
|
// });
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,27 +1,61 @@
|
||||||
import { Serializable } from "../Serializable";
|
import { Serializable } from "../Serializable";
|
||||||
|
import { ValidationContext } from "../../utilities/validators/ValidationContext";
|
||||||
|
import { FormGroup, FormBuilder, FormControl, Validators } from "@angular/forms";
|
||||||
|
import { BackendErrorValidator } from "../../utilities/validators/BackendErrorValidator";
|
||||||
|
import { BaseErrorModel } from "../error/BaseErrorModel";
|
||||||
|
import { AutoCompleteItem } from "../../shared/components/autocomplete/AutoCompleteItem";
|
||||||
|
import { ExternalSourcesItemModel } from "../external-sources/ExternalSourcesItemModel";
|
||||||
|
|
||||||
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
export class DataManagementPlanModel implements Serializable<DataManagementPlanModel> {
|
||||||
public id: String;
|
public id: String;
|
||||||
public label: String;
|
public label: String;
|
||||||
public abbreviation: String;
|
public previous: String;
|
||||||
public reference: String;
|
public version: number;
|
||||||
public uri: String;
|
|
||||||
public status: String;
|
public status: String;
|
||||||
public startDate: Date;
|
|
||||||
public endDate: Date;
|
|
||||||
public description: String;
|
public description: String;
|
||||||
|
public selectedProject: AutoCompleteItem;
|
||||||
|
public organisations: ExternalSourcesItemModel[] = [];
|
||||||
|
public researchers: ExternalSourcesItemModel[] = [];
|
||||||
|
|
||||||
|
public errorModel: BaseErrorModel = new BaseErrorModel();
|
||||||
|
|
||||||
fromJSONObject(item: any): DataManagementPlanModel {
|
fromJSONObject(item: any): DataManagementPlanModel {
|
||||||
this.id = item.id;
|
this.id = item.id;
|
||||||
this.label = item.label;
|
this.label = item.label;
|
||||||
this.abbreviation = item.abbreviation;
|
this.previous = item.previous;
|
||||||
this.reference = item.reference;
|
this.version = item.version;
|
||||||
this.uri = item.uri;
|
this.status = item.status;
|
||||||
this.status = item.status;
|
this.description = item.description;
|
||||||
this.startDate = item.startDate;
|
|
||||||
this.endDate = item.endDate;
|
|
||||||
this.description = item.description;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext = null, disabled: boolean = false): FormGroup {
|
||||||
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
|
||||||
|
const formGroup = new FormBuilder().group({
|
||||||
|
label: [{ value: this.label, disabled: disabled }, context.getValidation('label').validators],
|
||||||
|
previous: [{ value: this.previous, disabled: disabled }, context.getValidation('previous').validators],
|
||||||
|
version: [{ value: this.version, disabled: disabled }, context.getValidation('version').validators],
|
||||||
|
status: [{ value: this.status, disabled: disabled }, context.getValidation('status').validators],
|
||||||
|
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators],
|
||||||
|
organisations: [{ value: this.organisations, disabled: disabled }, context.getValidation('description').validators],
|
||||||
|
researchers: [{ value: this.researchers, disabled: disabled }, context.getValidation('researchers').validators],
|
||||||
|
});
|
||||||
|
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
createValidationContext(): ValidationContext {
|
||||||
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
|
baseContext.validation.push({ key: 'label', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'label')] });
|
||||||
|
baseContext.validation.push({ key: 'previous', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'previous')] });
|
||||||
|
baseContext.validation.push({ key: 'version', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'version')] });
|
||||||
|
baseContext.validation.push({ key: 'status', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'status')] });
|
||||||
|
baseContext.validation.push({ key: 'description', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'description')] });
|
||||||
|
baseContext.validation.push({ key: 'organisations', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'organisations')] });
|
||||||
|
baseContext.validation.push({ key: 'researchers', validators: [Validators.required, BackendErrorValidator(this.errorModel, 'researchers')] });
|
||||||
|
|
||||||
|
return baseContext;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,11 +1,9 @@
|
||||||
import { DataManagementPlanCriteria } from "../criteria/data-management-plan/DataManagementPlanCriteria";
|
import { BaseCriteria } from "../criteria/BaseCriteria";
|
||||||
import { ProjectCriteria } from "../criteria/project/ProjectCriteria";
|
|
||||||
|
|
||||||
export class DataTableRequest {
|
export class DataTableRequest {
|
||||||
offset = 0;
|
offset = 0;
|
||||||
length = 0;
|
length = 0;
|
||||||
projectCriteria: ProjectCriteria;
|
criteria: BaseCriteria;
|
||||||
dmpCriteria: DataManagementPlanCriteria;
|
|
||||||
|
|
||||||
constructor(offset: number, length: number) {
|
constructor(offset: number, length: number) {
|
||||||
this.length = length;
|
this.length = length;
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface ExternalSourcesItemModel {
|
||||||
|
id: String;
|
||||||
|
name: String;
|
||||||
|
description: String;
|
||||||
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
.mat-card {
|
|
||||||
overflow: auto;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-table {
|
|
||||||
margin: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-progress-bar {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-fab-bottom-right {
|
|
||||||
top: auto !important;
|
|
||||||
right: 20px !important;
|
|
||||||
bottom: 10px !important;
|
|
||||||
left: auto !important;
|
|
||||||
position: fixed !important;
|
|
||||||
}
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div>
|
<div class="project-editor">
|
||||||
<form *ngIf="formGroup" class="expense-list" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
<form *ngIf="formGroup" (ngSubmit)="formSubmit()" [formGroup]="formGroup">
|
||||||
<mat-card>
|
<mat-card>
|
||||||
<mat-card-title *ngIf="isNew">{{'PROJECT-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
<mat-card-title *ngIf="isNew">{{'PROJECT-EDITOR.TITLE.NEW' | translate}}</mat-card-title>
|
||||||
<mat-card-title *ngIf="!isNew">{{'PROJECT-EDITOR.TITLE.EDIT' | translate}} {{project.label}}</mat-card-title>
|
<mat-card-title *ngIf="!isNew">{{'PROJECT-EDITOR.TITLE.EDIT' | translate}} {{project.label}}</mat-card-title>
|
||||||
|
@ -49,17 +49,19 @@
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</mat-card-content>
|
|
||||||
</mat-card>
|
|
||||||
|
|
||||||
<mat-card>
|
<mat-form-field class="full-width">
|
||||||
<mat-card-content>
|
<textarea matInput class="description-area" placeholder="{{'PROJECT-EDITOR.FIELDS.DESCRIPTION' | translate}}" formControlName="description" required></textarea>
|
||||||
|
<mat-error *ngIf="formGroup.get('description').errors?.backendError">{{errorModel.description}}</mat-error>
|
||||||
|
<mat-error *ngIf="formGroup.get('description').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
|
||||||
<div layout="row" class="full-width text-right" align="end">
|
<div layout="row" class="full-width text-right" align="end">
|
||||||
<!-- <button mat-raised-button color="primary" (click)="cancel()" type="button">{{'FORM-EXPENSE-LIST.EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
<button mat-raised-button color="primary" (click)="cancel()" type="button">{{'PROJECT-EDITOR.ACTIONS.CANCEL' | translate}}</button>
|
||||||
<button *ngIf="this.item.status == 0" mat-raised-button color="primary" type="submit" (click)="save()">{{'FORM-EXPENSE-LIST.EDITOR.ACTIONS.SAVE' | translate}}</button>
|
<button mat-raised-button color="primary" type="submit">{{'PROJECT-EDITOR.ACTIONS.SAVE' | translate}}</button>
|
||||||
<button *ngIf="this.item.status == 0" mat-raised-button color="primary" type="submit" (click)="submit()">{{'FORM-EXPENSE-LIST.EDITOR.ACTIONS.SUBMIT' | translate}}</button>
|
<button *ngIf="!isNew" mat-raised-button color="primary" type="submit" (click)="delete()">{{'PROJECT-EDITOR.ACTIONS.DELETE' | translate}}</button>
|
||||||
<button *ngIf="!isNew && this.item.status == 0" mat-raised-button color="primary" type="submit" (click)="delete()">{{'FORM-EXPENSE-LIST.EDITOR.ACTIONS.DELETE' | translate}}</button> -->
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</mat-card-content>
|
</mat-card-content>
|
||||||
</mat-card>
|
</mat-card>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-table {
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-card .mat-grid-tile {
|
||||||
|
background: rgba(0, 0, 0, 0.32);
|
||||||
|
}
|
||||||
|
|
||||||
|
.project-editor {
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-card {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-button {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.description-area {
|
||||||
|
height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||||
import { Router, ActivatedRoute, Params } from "@angular/router";
|
import { Router, ActivatedRoute, Params } from "@angular/router";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
@ -9,14 +9,17 @@ import { ProjectModel } from "../../models/projects/ProjectModel";
|
||||||
import { ProjectService } from "../../services/project/project.service";
|
import { ProjectService } from "../../services/project/project.service";
|
||||||
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
import { JsonSerializer } from "../../utilities/JsonSerializer";
|
||||||
import { FormGroup } from "@angular/forms";
|
import { FormGroup } from "@angular/forms";
|
||||||
|
import { SnackBarNotificationComponent } from "../../shared/components/notificaiton/snack-bar-notification.component";
|
||||||
|
import { BaseErrorModel } from "../../models/error/BaseErrorModel";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-project-editor-component',
|
selector: 'app-project-editor-component',
|
||||||
templateUrl: 'project-editor.component.html',
|
templateUrl: 'project-editor.component.html',
|
||||||
styleUrls: ['./project-editor.component.css'],
|
styleUrls: ['./project-editor.component.scss'],
|
||||||
providers: [ProjectService]
|
providers: [ProjectService],
|
||||||
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ProjectEditorComponent implements AfterViewInit {
|
export class ProjectEditorComponent implements AfterViewInit {
|
||||||
|
|
||||||
|
@ -27,6 +30,9 @@ export class ProjectEditorComponent implements AfterViewInit {
|
||||||
constructor(
|
constructor(
|
||||||
private projectService: ProjectService,
|
private projectService: ProjectService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
|
public snackBar: MatSnackBar,
|
||||||
|
public router: Router,
|
||||||
|
public language: TranslateService
|
||||||
) {
|
) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,8 +50,51 @@ export class ProjectEditorComponent implements AfterViewInit {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.project = new ProjectModel();
|
this.project = new ProjectModel();
|
||||||
this.formGroup = this.project.buildForm();
|
setTimeout(() => {
|
||||||
|
this.formGroup = this.project.buildForm();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formSubmit(): void {
|
||||||
|
//this.touchAllFormFields(this.formGroup);
|
||||||
|
if (!this.isFormValid()) { return; }
|
||||||
|
this.onSubmit();
|
||||||
|
}
|
||||||
|
|
||||||
|
public isFormValid() {
|
||||||
|
return this.formGroup.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
onSubmit(): void {
|
||||||
|
this.projectService.createProject(this.formGroup.value).subscribe(
|
||||||
|
complete => this.onCallbackSuccess(),
|
||||||
|
error => this.onCallbackError(error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackSuccess(): void {
|
||||||
|
this.snackBar.openFromComponent(SnackBarNotificationComponent, {
|
||||||
|
data: { message: this.isNew ? 'GENERAL.SNACK-BAR.SUCCESSFUL-CREATION' : 'GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE', language: this.language },
|
||||||
|
duration: 3000,
|
||||||
|
extraClasses: ['snackbar-success']
|
||||||
|
})
|
||||||
|
this.router.navigate(['/projects']);
|
||||||
|
}
|
||||||
|
|
||||||
|
onCallbackError(error: any) {
|
||||||
|
this.setErrorModel(error.error);
|
||||||
|
//this.validateAllFormFields(this.formGroup);
|
||||||
|
}
|
||||||
|
|
||||||
|
public setErrorModel(errorModel: BaseErrorModel) {
|
||||||
|
Object.keys(errorModel).forEach(item => {
|
||||||
|
(<any>this.project.errorModel)[item] = (<any>errorModel)[item];
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
public cancel(): void {
|
||||||
|
this.router.navigate(['/projects']);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,20 +0,0 @@
|
||||||
.mat-card {
|
|
||||||
overflow: auto;
|
|
||||||
padding: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-table {
|
|
||||||
margin: 24px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-progress-bar {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mat-fab-bottom-right {
|
|
||||||
top: auto !important;
|
|
||||||
right: 20px !important;
|
|
||||||
bottom: 10px !important;
|
|
||||||
left: auto !important;
|
|
||||||
position: fixed !important;
|
|
||||||
}
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
.mat-table {
|
||||||
|
margin: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-progress-bar {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-fab-bottom-right {
|
||||||
|
top: auto !important;
|
||||||
|
right: 20px !important;
|
||||||
|
bottom: 10px !important;
|
||||||
|
left: auto !important;
|
||||||
|
position: fixed !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-card {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
import { Component, ViewChild, OnInit, AfterViewInit } from "@angular/core";
|
import { Component, ViewChild, OnInit, AfterViewInit, ViewEncapsulation } from "@angular/core";
|
||||||
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
import { MatPaginator, MatSort, MatSnackBar } from "@angular/material";
|
||||||
import { Router } from "@angular/router";
|
import { Router } from "@angular/router";
|
||||||
import { TranslateService } from "@ngx-translate/core";
|
import { TranslateService } from "@ngx-translate/core";
|
||||||
|
@ -16,8 +16,9 @@ import { SnackBarNotificationComponent } from "../shared/components/notificaiton
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-project-listing-component',
|
selector: 'app-project-listing-component',
|
||||||
templateUrl: 'project-listing.component.html',
|
templateUrl: 'project-listing.component.html',
|
||||||
styleUrls: ['./project-listing.component.css'],
|
styleUrls: ['./project-listing.component.scss'],
|
||||||
providers: [ProjectService]
|
providers: [ProjectService],
|
||||||
|
encapsulation: ViewEncapsulation.None
|
||||||
})
|
})
|
||||||
export class ProjectListingComponent implements OnInit, AfterViewInit {
|
export class ProjectListingComponent implements OnInit, AfterViewInit {
|
||||||
|
|
||||||
|
@ -115,7 +116,7 @@ export class ProjectDataSource extends DataSource<ProjectListingModel> {
|
||||||
});
|
});
|
||||||
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
const startIndex = this._paginator.pageIndex * this._paginator.pageSize;
|
||||||
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
const request = new DataTableRequest(startIndex, this._paginator.pageSize);
|
||||||
request.projectCriteria = this._criteria.getFormData();
|
request.criteria = this._criteria.getFormData();
|
||||||
return this._service.getPaged(request);
|
return this._service.getPaged(request);
|
||||||
})
|
})
|
||||||
.catch((error: any) => {
|
.catch((error: any) => {
|
||||||
|
@ -136,7 +137,7 @@ export class ProjectDataSource extends DataSource<ProjectListingModel> {
|
||||||
.map(result => {
|
.map(result => {
|
||||||
if (!result) { return []; }
|
if (!result) { return []; }
|
||||||
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
if (this._paginator.pageIndex === 0) { this.totalCount = result.totalCount; }
|
||||||
return result.data;
|
return result.payload.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export class DataManagementPlanService {
|
||||||
|
|
||||||
constructor(private http: BaseHttpService) {
|
constructor(private http: BaseHttpService) {
|
||||||
|
|
||||||
this.actionUrl = HostConfiguration.Server + 'api/dmps/';
|
this.actionUrl = HostConfiguration.Server + 'dmps/';
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||||
|
@ -32,4 +32,8 @@ export class DataManagementPlanService {
|
||||||
getSingle(id: string): Observable<DataManagementPlanModel> {
|
getSingle(id: string): Observable<DataManagementPlanModel> {
|
||||||
return this.http.get<DataManagementPlanModel>(this.actionUrl + id, { headers: this.headers });
|
return this.http.get<DataManagementPlanModel>(this.actionUrl + id, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createDataManagementPlan(dataManagementPlanModel: DataManagementPlanModel): Observable<DataManagementPlanModel> {
|
||||||
|
return this.http.post<DataManagementPlanModel>(this.actionUrl + 'add', dataManagementPlanModel, { headers: this.headers });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { HostConfiguration } from './../../app.constants';
|
||||||
|
import { BaseHttpService } from '../../utilities/cite-http-service-module/base-http.service';
|
||||||
|
import { Observable } from 'rxjs/Observable';
|
||||||
|
import { ExternalSourcesItemModel } from '../../models/external-sources/ExternalSourcesItemModel';
|
||||||
|
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ExternalSourcesService {
|
||||||
|
|
||||||
|
private actionUrl: string;
|
||||||
|
private headers: HttpHeaders;
|
||||||
|
|
||||||
|
constructor(private http: BaseHttpService) {
|
||||||
|
|
||||||
|
this.actionUrl = HostConfiguration.Server + 'external/';
|
||||||
|
|
||||||
|
this.headers = new HttpHeaders();
|
||||||
|
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||||
|
this.headers = this.headers.set('Accept', 'application/json');
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchDatasetRegistry(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "registries" + "?query=" + like, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchDatasetRepository(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "datarepos" + "?query=" + like, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchDatasetService(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "services" + "?query=" + like, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchDMPResearchers(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "researchers" + "?query=" + like, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
|
public searchDMPOrganizations(like: string): Observable<ExternalSourcesItemModel[]> {
|
||||||
|
return this.http.get<ExternalSourcesItemModel[]>(this.actionUrl + "organisations" + "?query=" + like, { headers: this.headers });
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,7 +18,7 @@ export class ProjectService {
|
||||||
|
|
||||||
constructor(private http: BaseHttpService) {
|
constructor(private http: BaseHttpService) {
|
||||||
|
|
||||||
this.actionUrl = HostConfiguration.Server + 'dmp-backend/rest/projects/';
|
this.actionUrl = HostConfiguration.Server + 'projects/';
|
||||||
|
|
||||||
this.headers = new HttpHeaders();
|
this.headers = new HttpHeaders();
|
||||||
this.headers = this.headers.set('Content-Type', 'application/json');
|
this.headers = this.headers.set('Content-Type', 'application/json');
|
||||||
|
@ -32,4 +32,9 @@ export class ProjectService {
|
||||||
getSingle(id: string): Observable<ProjectModel> {
|
getSingle(id: string): Observable<ProjectModel> {
|
||||||
return this.http.get<ProjectModel>(this.actionUrl + id, { headers: this.headers });
|
return this.http.get<ProjectModel>(this.actionUrl + id, { headers: this.headers });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
createProject(projectModel: ProjectModel): Observable<ProjectModel> {
|
||||||
|
return this.http.post<ProjectModel>(this.actionUrl + 'add', projectModel, { headers: this.headers });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { BaseCriteria } from "../../../models/criteria/BaseCriteria";
|
||||||
|
|
||||||
|
export class AutoCompleteConfiguration {
|
||||||
|
public callback: Function;
|
||||||
|
public criteria: BaseCriteria;
|
||||||
|
constructor(callback: Function, criteria: BaseCriteria) {
|
||||||
|
this.callback = callback;
|
||||||
|
this.criteria = criteria;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { FormGenerator } from "../../../utilities/forms/FormGenerator";
|
||||||
|
import { ValidationContext } from "../../../utilities/validators/ValidationContext";
|
||||||
|
import { FormBuilder, FormGroup } from "@angular/forms";
|
||||||
|
|
||||||
|
export class AutoCompleteItem implements FormGenerator {
|
||||||
|
|
||||||
|
public value: string;
|
||||||
|
public text: string;
|
||||||
|
public description: string;
|
||||||
|
constructor(value: string, text: string, description: string) {
|
||||||
|
this.value = value;
|
||||||
|
this.text = text;
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(context: ValidationContext, disabled: boolean = false): FormGroup {
|
||||||
|
return new FormBuilder().group({
|
||||||
|
value: [{ value: this.value, disabled: disabled }, context.getValidation('value').validators],
|
||||||
|
text: [{ value: this.text, disabled: disabled }, context.getValidation('text').validators],
|
||||||
|
description: [{ value: this.description, disabled: disabled }, context.getValidation('description').validators]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
<div [formGroup]="form" class="autocomplete">
|
||||||
|
<table class="full-width">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<mat-form-field class="autocomplete-input">
|
||||||
|
<input matInput type="text" placeholder="{{placeholder}}" [matAutocomplete]="auto" formControlName="text" [required]="required"
|
||||||
|
[errorStateMatcher]="errorStateMatcher">
|
||||||
|
<mat-error *ngIf="form.get('value').errors?.required">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
<mat-error *ngIf="validationErrorString">{{errorString}}</mat-error>
|
||||||
|
<mat-progress-spinner matSuffix mode="indeterminate" *ngIf="loading" [diameter]="22"></mat-progress-spinner>
|
||||||
|
<input matInput type="text" [matAutocomplete]="auto" hidden="hidden">
|
||||||
|
</mat-form-field>
|
||||||
|
</td>
|
||||||
|
<td *ngIf="createNew">
|
||||||
|
<button mat-raised-button type="button" color="primary" (click)="this.ClickFunctionCall()" tabindex="2">{{'GENERAL.AUTOCOMPLETE.CREATE-NEW' | translate}}</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<mat-autocomplete #auto="matAutocomplete" (optionSelected)="this.optionSelected($event)">
|
||||||
|
<mat-option *ngFor="let option of options" [value]="option">
|
||||||
|
{{ option.text }} {{option.description?'['+option.description+']':''}}
|
||||||
|
</mat-option>
|
||||||
|
</mat-autocomplete>
|
||||||
|
</div>
|
|
@ -0,0 +1,30 @@
|
||||||
|
.autocomplete-input {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete-progress {
|
||||||
|
overflow: initial !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.autocomplete {
|
||||||
|
mat-form-field {
|
||||||
|
width: 100%;
|
||||||
|
padding: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mat-card {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.left-button {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-table {
|
||||||
|
table-layout: fixed;
|
||||||
|
}
|
||||||
|
|
||||||
|
.full-width {
|
||||||
|
width: 100%;
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
import { FormControl, FormGroupDirective, NgForm, FormGroup } from '@angular/forms';
|
||||||
|
import { Observable } from 'rxjs/Rx';
|
||||||
|
import { setTimeout } from 'timers';
|
||||||
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
|
import 'rxjs/add/operator/debounceTime';
|
||||||
|
import 'rxjs/add/operator/map';
|
||||||
|
import { AutoCompleteConfiguration } from './AutoCompleteConfiguration';
|
||||||
|
import { AutoCompleteItem } from './AutoCompleteItem';
|
||||||
|
import { ErrorStateMatcher } from '@angular/material';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'auto-complete',
|
||||||
|
templateUrl: './autocomplete.component.html',
|
||||||
|
styleUrls: ['./autocomplete.component.scss']
|
||||||
|
})
|
||||||
|
export class AutocompleteComponent implements OnInit {
|
||||||
|
@Input()
|
||||||
|
configuration: AutoCompleteConfiguration;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
mapper: Function;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
typeaheadMS: number;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
placeholder: String;
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
validationErrorString: String;
|
||||||
|
|
||||||
|
public errorStateMatcher: AutoCompleteErrorStateMatcher = new AutoCompleteErrorStateMatcher();
|
||||||
|
|
||||||
|
@Input()
|
||||||
|
required: boolean;
|
||||||
|
|
||||||
|
@Input() selectedDropdownItem: AutoCompleteItem;
|
||||||
|
@Output() selectedDropdownItemChange = new EventEmitter<AutoCompleteItem>();
|
||||||
|
|
||||||
|
@Output()
|
||||||
|
output: EventEmitter<AutoCompleteItem> = new EventEmitter<AutoCompleteItem>();
|
||||||
|
|
||||||
|
@Input() form: FormGroup;
|
||||||
|
|
||||||
|
@Input() createNew = false;
|
||||||
|
//term = new FormControl();
|
||||||
|
@Input()
|
||||||
|
ClickFunctionCall: Function;
|
||||||
|
|
||||||
|
loading = false;
|
||||||
|
|
||||||
|
options: AutoCompleteItem[];
|
||||||
|
constructor() {
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
const valueChanges = this.form.controls['text'].valueChanges.share();
|
||||||
|
valueChanges.subscribe(searchTerm => {
|
||||||
|
this.loading = true;
|
||||||
|
if (this.form.controls['value'].value) {
|
||||||
|
this.resetFormGroupValue();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
valueChanges
|
||||||
|
.debounceTime(this.typeaheadMS)
|
||||||
|
.subscribe(searchTerm => {
|
||||||
|
if (typeof searchTerm === 'string') {
|
||||||
|
this.inputOnChange(searchTerm)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
resetFormGroupValue() {
|
||||||
|
this.form.patchValue({ value: null }, { emitEvent: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
// listingItemToDropDown(item: DropdownListingItem): AutoCompleteItem {
|
||||||
|
// return (item as DropdownListingItem).toDropdownList();
|
||||||
|
// }
|
||||||
|
|
||||||
|
optionSelected(event: any) {
|
||||||
|
this.form.patchValue(event.option.value, { emitEvent: false });
|
||||||
|
this.selectedDropdownItemChange.emit(event.option.value);
|
||||||
|
//this.form.updateValueAndValidity();
|
||||||
|
this.options = [event.option.value];
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inputOnChange(term: string) {
|
||||||
|
//this.form.patchValue({ value: null, description: '', text: '' });
|
||||||
|
//this.form.updateValueAndValidity();
|
||||||
|
this.configuration.criteria.Like = term;
|
||||||
|
this.configuration.callback(this.configuration.criteria)
|
||||||
|
.map((res: any) => this.mapper(res))
|
||||||
|
.subscribe(
|
||||||
|
(res: AutoCompleteItem[]) => {
|
||||||
|
this.options = res;
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
() => { this.loading = false });
|
||||||
|
}
|
||||||
|
|
||||||
|
displayFn(item: AutoCompleteItem): string {
|
||||||
|
return item.text ? item.text : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
//fieldHasErrors(control: FormControl, form: FormGroupDirective | NgForm): boolean {
|
||||||
|
// return this.errorStateMatcher(control, form);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
export class AutoCompleteErrorStateMatcher implements ErrorStateMatcher {
|
||||||
|
isErrorState(control: FormControl | null, form: FormGroupDirective | NgForm | null): boolean {
|
||||||
|
const isFormSubmitted = form && form.submitted;
|
||||||
|
const isControlInvalid = control && control.invalid && (control.dirty || control.touched || isFormSubmitted);
|
||||||
|
const isFormInvalid = form && form.enabled && form.invalid && (form.dirty || form.touched || isFormSubmitted)
|
||||||
|
return !!(isControlInvalid || isFormInvalid);
|
||||||
|
}
|
||||||
|
}
|
|
@ -27,6 +27,7 @@ import {
|
||||||
} from '@angular/material';
|
} from '@angular/material';
|
||||||
import { CdkTableModule } from '@angular/cdk/table';
|
import { CdkTableModule } from '@angular/cdk/table';
|
||||||
import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component';
|
import { SnackBarNotificationComponent } from '../components/notificaiton/snack-bar-notification.component';
|
||||||
|
import { CovalentLayoutModule, CovalentChipsModule } from '@covalent/core';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
|
@ -56,7 +57,9 @@ import { SnackBarNotificationComponent } from '../components/notificaiton/snack-
|
||||||
MatProgressSpinnerModule,
|
MatProgressSpinnerModule,
|
||||||
MatTooltipModule,
|
MatTooltipModule,
|
||||||
MatCheckboxModule,
|
MatCheckboxModule,
|
||||||
MatTabsModule
|
MatTabsModule,
|
||||||
|
CovalentLayoutModule,
|
||||||
|
CovalentChipsModule
|
||||||
],
|
],
|
||||||
|
|
||||||
providers: [
|
providers: [
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
{
|
{
|
||||||
|
"GENERAL": {
|
||||||
|
"VALIDATION": {
|
||||||
|
"REQUIRED": "Required"
|
||||||
|
}
|
||||||
|
},
|
||||||
"NAV-BAR": {
|
"NAV-BAR": {
|
||||||
"TITLE": "DMPS"
|
"TITLE": "DMPS"
|
||||||
},
|
},
|
||||||
|
@ -38,6 +43,36 @@
|
||||||
"TITLE": {
|
"TITLE": {
|
||||||
"NEW": "New Project",
|
"NEW": "New Project",
|
||||||
"EDIT": "Edit"
|
"EDIT": "Edit"
|
||||||
|
},
|
||||||
|
"FIELDS": {
|
||||||
|
"NAME": "Name",
|
||||||
|
"ABBREVIATION": "Abbreviation",
|
||||||
|
"URI": "URI",
|
||||||
|
"START": "Start",
|
||||||
|
"END": "End",
|
||||||
|
"DESCRIPTION": "Description"
|
||||||
|
},
|
||||||
|
"ACTIONS": {
|
||||||
|
"SAVE": "Save",
|
||||||
|
"CANCEL": "Cancel",
|
||||||
|
"DELETE": "Delete"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"DMP-EDITOR": {
|
||||||
|
"TITLE": {
|
||||||
|
"NEW": "New Data Management Plan",
|
||||||
|
"EDIT": "Edit"
|
||||||
|
},
|
||||||
|
"FIELDS": {
|
||||||
|
"NAME": "Name",
|
||||||
|
"DESCRIPTION": "Description",
|
||||||
|
"ORGANISATIONS": "Organisations",
|
||||||
|
"RESEARCHERS": "Researchers"
|
||||||
|
},
|
||||||
|
"ACTIONS": {
|
||||||
|
"SAVE": "Save",
|
||||||
|
"CANCEL": "Cancel",
|
||||||
|
"DELETE": "Delete"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"CRITERIA": {
|
"CRITERIA": {
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
@import "~@angular/material/prebuilt-themes/indigo-pink.css";
|
|
||||||
|
|
||||||
/* You can add global styles to this file, and also import other style files */
|
|
||||||
/*
|
|
||||||
body {
|
|
||||||
padding-top: 40px;
|
|
||||||
padding-bottom: 40px;
|
|
||||||
background-color: #eee;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
.form-signin {
|
|
||||||
max-width: 330px;
|
|
||||||
padding: 15px;
|
|
||||||
margin: 0 auto;
|
|
||||||
box-shadow: 0px 0px 0px 1px #d8d4d4;
|
|
||||||
}
|
|
||||||
.form-signin .form-signin-heading,
|
|
||||||
.form-signin .checkbox {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
.form-signin .checkbox {
|
|
||||||
font-weight: normal;
|
|
||||||
}
|
|
||||||
.form-signin .form-control {
|
|
||||||
position: relative;
|
|
||||||
height: auto;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
padding: 10px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
.form-signin .form-control:focus {
|
|
||||||
z-index: 2;
|
|
||||||
}
|
|
||||||
.form-signin input[type="email"] {
|
|
||||||
margin-bottom: -1px;
|
|
||||||
border-bottom-right-radius: 0;
|
|
||||||
border-bottom-left-radius: 0;
|
|
||||||
}
|
|
||||||
.form-signin input[type="password"] {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
border-top-left-radius: 0;
|
|
||||||
border-top-right-radius: 0;
|
|
||||||
}
|
|
||||||
.errorMessage{
|
|
||||||
color:red;
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control.is-invalid{
|
|
||||||
border-color: #dc3545
|
|
||||||
}
|
|
||||||
|
|
||||||
.invalid-feedbackCustom {
|
|
||||||
margin-top: .25rem;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
color: #dc3545;
|
|
||||||
}
|
|
||||||
|
|
||||||
.ng-valid[required], .ng-valid.required {
|
|
||||||
border-left: 5px solid #42A948; /* green */
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-control.ng-invalid {
|
|
||||||
border-left: 5px solid #a94442; /* red */
|
|
||||||
}
|
|
||||||
|
|
||||||
.form-groupCustom {
|
|
||||||
border: 2px solid #A11515;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cursor-link{
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* dashboard */
|
|
||||||
|
|
||||||
.card{
|
|
||||||
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
|
|
||||||
border-radius: 6px;
|
|
||||||
color: rgba(0,0,0, 0.87);
|
|
||||||
background: #fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.card-raised{
|
|
||||||
box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.42), 0 4px 25px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 990px){
|
|
||||||
#sidebar, #nav-right, #nav-left-button{
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#menu{
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
#main-panel{
|
|
||||||
padding-left: 0;
|
|
||||||
-webkit-transition: all 400ms;
|
|
||||||
-moz-transition: all 400ms;
|
|
||||||
-ms-transition: all 400ms;
|
|
||||||
-o-transition: all 400ms;
|
|
||||||
transition: all 400ms;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
/* @import "~@angular/material/prebuilt-themes/indigo-pink.css"; */
|
||||||
|
@import '~@angular/material/theming';
|
||||||
|
@import '~@covalent/core/theming/all-theme';
|
||||||
|
|
||||||
|
@include mat-core();
|
||||||
|
|
||||||
|
// Define a theme.
|
||||||
|
$primary: mat-palette($mat-indigo);
|
||||||
|
$accent: mat-palette($mat-pink, A200, A100, A400);
|
||||||
|
|
||||||
|
$theme: mat-light-theme($primary, $accent);
|
||||||
|
|
||||||
|
// Include all theme styles for the components.
|
||||||
|
@include angular-material-theme($theme);
|
||||||
|
@include covalent-theme($theme);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* dashboard */
|
||||||
|
|
||||||
|
.card{
|
||||||
|
box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.14);
|
||||||
|
border-radius: 6px;
|
||||||
|
color: rgba(0,0,0, 0.87);
|
||||||
|
background: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-raised{
|
||||||
|
box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.42), 0 4px 25px 0px rgba(0, 0, 0, 0.12), 0 8px 10px -5px rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 990px){
|
||||||
|
#sidebar, #nav-right, #nav-left-button{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#menu{
|
||||||
|
display: inline;
|
||||||
|
}
|
||||||
|
#main-panel{
|
||||||
|
padding-left: 0;
|
||||||
|
-webkit-transition: all 400ms;
|
||||||
|
-moz-transition: all 400ms;
|
||||||
|
-ms-transition: all 400ms;
|
||||||
|
-o-transition: all 400ms;
|
||||||
|
transition: all 400ms;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue