project dmps pagination
This commit is contained in:
parent
878db46b0e
commit
7e9b995cca
|
@ -8,6 +8,8 @@ import entities.DMP;
|
|||
import entities.Organisation;
|
||||
import entities.Project;
|
||||
import entities.responses.IDLabelPair;
|
||||
import models.dmp.DataManagementPlanTableRequest;
|
||||
import models.project.ProjectTableRequest;
|
||||
|
||||
public interface DMPDao extends Dao<DMP, UUID> {
|
||||
|
||||
|
@ -17,4 +19,6 @@ public interface DMPDao extends Dao<DMP, UUID> {
|
|||
|
||||
List<DMP> getDMPsOfUser(String userID);
|
||||
|
||||
public List<DMP> getWithCriteria(DataManagementPlanTableRequest dataManagementPlanTableRequest);
|
||||
|
||||
}
|
|
@ -6,6 +6,9 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.query.Query;
|
||||
|
||||
|
@ -14,6 +17,8 @@ import entities.DMP;
|
|||
import entities.Project;
|
||||
import entities.UserInfo;
|
||||
import entities.responses.IDLabelPair;
|
||||
import models.dmp.DataManagementPlanTableRequest;
|
||||
import models.project.ProjectTableRequest;
|
||||
|
||||
public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
||||
|
||||
|
@ -54,11 +59,17 @@ public class DMPDaoImpl extends JpaDao<DMP, UUID> implements DMPDao {
|
|||
ex.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<DMP> getWithCriteria(DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.UUID;
|
|||
import dao.Dao;
|
||||
import entities.Project;
|
||||
import entities.responses.IDLabelPair;
|
||||
import models.project.ProjectTableRequest;
|
||||
|
||||
public interface ProjectDao extends Dao<Project, UUID> {
|
||||
|
||||
|
@ -15,4 +16,6 @@ public interface ProjectDao extends Dao<Project, UUID> {
|
|||
|
||||
public List<Project> getProjectsOfUser(String userID);
|
||||
|
||||
public List<Project> getWithCriteria(ProjectTableRequest projectTableRequest);
|
||||
|
||||
}
|
|
@ -5,13 +5,18 @@ import java.util.UUID;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.persistence.TypedQuery;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Root;
|
||||
|
||||
import org.hibernate.query.Query;
|
||||
|
||||
import dao.JpaDao;
|
||||
import entities.DMP;
|
||||
import entities.Project;
|
||||
import entities.Registry;
|
||||
import entities.responses.IDLabelPair;
|
||||
import models.project.ProjectTableRequest;
|
||||
|
||||
public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao {
|
||||
|
||||
|
@ -55,6 +60,17 @@ public class ProjectDaoImpl extends JpaDao<Project, UUID> implements ProjectDao
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Project> getWithCriteria(ProjectTableRequest projectTableRequest) {
|
||||
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package managers;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.DatasetDao;
|
||||
import dao.entities.ProjectDao;
|
||||
import models.dashboard.DashBoardStatistics;
|
||||
|
||||
public class DashBoardManager {
|
||||
|
||||
public DashBoardStatistics getStatistics(DatasetDao datasetRepository,DMPDao dataManagementPlanRepository,ProjectDao projectRepository){
|
||||
DashBoardStatistics statistics = new DashBoardStatistics();
|
||||
statistics.setTotalDataManagementPlanCount(dataManagementPlanRepository.count());
|
||||
statistics.setTotalDataSetCount(datasetRepository.count());
|
||||
statistics.setTotalProjectCount(projectRepository.count());
|
||||
return statistics;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package managers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.ProjectDao;
|
||||
import models.dmp.DataManagementPlanTableRequest;
|
||||
import models.helpers.DataTableData;
|
||||
import models.project.Project;
|
||||
import models.project.ProjectTableRequest;
|
||||
import utilities.builders.DomainModelConverter;
|
||||
|
||||
public class DataManagementPlanManager {
|
||||
|
||||
public DataTableData<models.dmp.DataManagementPlan> getPaged(DMPDao dmpsRepository,DataManagementPlanTableRequest dataManagementPlanTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
List<models.dmp.DataManagementPlan> datamanagementPlans = new DomainModelConverter<entities.DMP, models.dmp.DataManagementPlan>().fromDataModel( dmpsRepository.getWithCriteria(dataManagementPlanTableRequest),models.dmp.DataManagementPlan.class);
|
||||
DataTableData<models.dmp.DataManagementPlan> dataTable = new DataTableData<models.dmp.DataManagementPlan>();
|
||||
dataTable.setData(datamanagementPlans);
|
||||
dataTable.setTotalCount(dmpsRepository.count());
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public models.dmp.DataManagementPlan getSingle(DMPDao dmpsRepository,String id) throws InstantiationException, IllegalAccessException{
|
||||
models.dmp.DataManagementPlan datamanagementPlan = new models.dmp.DataManagementPlan();
|
||||
datamanagementPlan.fromDataModel(dmpsRepository.read(UUID.fromString(id)));
|
||||
return datamanagementPlan;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package managers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import dao.entities.ProjectDao;
|
||||
import models.helpers.DataTableData;
|
||||
import models.project.Project;
|
||||
import models.project.ProjectTableRequest;
|
||||
import utilities.builders.DomainModelConverter;
|
||||
|
||||
public class ProjectManager {
|
||||
|
||||
public DataTableData<models.project.Project> getPaged(ProjectDao projectRepository,ProjectTableRequest projectTableRequest) throws IllegalAccessException, InstantiationException{
|
||||
List<models.project.Project> projects = new DomainModelConverter<entities.Project, Project>().fromDataModel( projectRepository.getWithCriteria(projectTableRequest),models.project.Project.class);
|
||||
DataTableData<models.project.Project> dataTable = new DataTableData<models.project.Project>();
|
||||
dataTable.setData(projects);
|
||||
dataTable.setTotalCount(projectRepository.count());
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
public models.project.Project getSingle(ProjectDao projectRepository,String id) throws InstantiationException, IllegalAccessException{
|
||||
models.project.Project project = new models.project.Project();
|
||||
project.fromDataModel(projectRepository.read(UUID.fromString(id)));
|
||||
return project;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package models.criteria;
|
||||
|
||||
import entities.DMP;
|
||||
|
||||
public class DataManagementPlanCriteria extends Criteria<DMP>{
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package models.criteria;
|
||||
|
||||
import entities.Project;
|
||||
|
||||
public class ProjectCriteria extends Criteria<Project>{
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package models.dashboard;
|
||||
|
||||
public class DashBoardStatistics {
|
||||
private Long totalDataManagementPlanCount;
|
||||
private Long totalProjectCount;
|
||||
private Long totalDataSetCount;
|
||||
|
||||
|
||||
public Long getTotalDataManagementPlanCount() {
|
||||
return totalDataManagementPlanCount;
|
||||
}
|
||||
public void setTotalDataManagementPlanCount(Long totalDataManagementPlanCount) {
|
||||
this.totalDataManagementPlanCount = totalDataManagementPlanCount;
|
||||
}
|
||||
public Long getTotalProjectCount() {
|
||||
return totalProjectCount;
|
||||
}
|
||||
public void setTotalProjectCount(Long totalProjectCount) {
|
||||
this.totalProjectCount = totalProjectCount;
|
||||
}
|
||||
public Long getTotalDataSetCount() {
|
||||
return totalDataSetCount;
|
||||
}
|
||||
public void setTotalDataSetCount(Long totalDataSetCount) {
|
||||
this.totalDataSetCount = totalDataSetCount;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -103,7 +103,7 @@ public class DataManagementPlan implements DataModel<DMP>{
|
|||
this.project = new models.dmp.Project();
|
||||
this.project.fromDataModel(entity.getProject());
|
||||
this.creator = new models.dmp.UserInfo();
|
||||
this.creator.fromDataModel(entity.getCreator());
|
||||
if(entity.getCreator()!=null)this.creator.fromDataModel(entity.getCreator());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
package models.dmp;
|
||||
|
||||
import models.criteria.DataManagementPlanCriteria;
|
||||
|
||||
public class DataManagementPlanTableRequest {
|
||||
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,21 @@
|
|||
package models.helpers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DataTableData<T> {
|
||||
private Long totalCount;
|
||||
private List<T> data;
|
||||
|
||||
public Long getTotalCount() {
|
||||
return totalCount;
|
||||
}
|
||||
public void setTotalCount(Long totalCount) {
|
||||
this.totalCount = totalCount;
|
||||
}
|
||||
public List<T> getData() {
|
||||
return data;
|
||||
}
|
||||
public void setData(List<T> data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package models.project;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.FetchType;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.JoinColumn;
|
||||
import javax.persistence.ManyToOne;
|
||||
import javax.persistence.OneToMany;
|
||||
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.Type;
|
||||
|
||||
import entities.DMP;
|
||||
import entities.UserInfo;
|
||||
import models.DataModel;
|
||||
import models.dmp.DataManagementPlan;
|
||||
|
||||
public class Project implements DataModel<entities.Project>{
|
||||
|
||||
private UUID id;
|
||||
|
||||
private List<DataManagementPlan> dmps;
|
||||
|
||||
private String label;
|
||||
|
||||
private String abbreviation;
|
||||
|
||||
private String reference;
|
||||
|
||||
private String uri;
|
||||
|
||||
private String definition;
|
||||
|
||||
private Date startdate;
|
||||
|
||||
private Date enddate;
|
||||
|
||||
private Short status;
|
||||
|
||||
private UserInfo creationUser;
|
||||
|
||||
private Date created;
|
||||
|
||||
private Date modified;
|
||||
|
||||
private String description;
|
||||
|
||||
|
||||
public UUID getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(UUID id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<DataManagementPlan> getDmps() {
|
||||
return dmps;
|
||||
}
|
||||
|
||||
public void setDmps(List<DataManagementPlan> dmps) {
|
||||
this.dmps = dmps;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getAbbreviation() {
|
||||
return abbreviation;
|
||||
}
|
||||
|
||||
public void setAbbreviation(String abbreviation) {
|
||||
this.abbreviation = abbreviation;
|
||||
}
|
||||
|
||||
public String getReference() {
|
||||
return reference;
|
||||
}
|
||||
|
||||
public void setReference(String reference) {
|
||||
this.reference = reference;
|
||||
}
|
||||
|
||||
public String getUri() {
|
||||
return uri;
|
||||
}
|
||||
|
||||
public void setUri(String uri) {
|
||||
this.uri = uri;
|
||||
}
|
||||
|
||||
public String getDefinition() {
|
||||
return definition;
|
||||
}
|
||||
|
||||
public void setDefinition(String definition) {
|
||||
this.definition = definition;
|
||||
}
|
||||
|
||||
public Date getStartdate() {
|
||||
return startdate;
|
||||
}
|
||||
|
||||
public void setStartdate(Date startdate) {
|
||||
this.startdate = startdate;
|
||||
}
|
||||
|
||||
public Date getEnddate() {
|
||||
return enddate;
|
||||
}
|
||||
|
||||
public void setEnddate(Date enddate) {
|
||||
this.enddate = enddate;
|
||||
}
|
||||
|
||||
public Short getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Short status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public UserInfo getCreationUser() {
|
||||
return creationUser;
|
||||
}
|
||||
|
||||
public void setCreationUser(UserInfo creationUser) {
|
||||
this.creationUser = creationUser;
|
||||
}
|
||||
|
||||
public Date getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(Date created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public Date getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(Date modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromDataModel(entities.Project entity) throws InstantiationException, IllegalAccessException {
|
||||
this.id = entity.getId();
|
||||
this.label = entity.getLabel();
|
||||
this.abbreviation = entity.getAbbreviation();
|
||||
this.reference = entity.getReference();
|
||||
this.uri = entity.getUri();
|
||||
this.definition = entity.getDefinition();
|
||||
this.startdate = entity.getStartdate();
|
||||
this.enddate = entity.getEnddate();
|
||||
this.status = entity.getStatus();
|
||||
this.created = entity.getCreated();
|
||||
this.modified = entity.getModified();
|
||||
this.description = entity.getDescription();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public entities.Project toDataModel() {
|
||||
entities.Project entity = new entities.Project();
|
||||
entity.setId(this.id);
|
||||
entity.setAbbreviation(this.abbreviation);
|
||||
entity.setLabel(this.label);
|
||||
entity.setReference(this.reference);
|
||||
entity.setUri(this.uri);
|
||||
entity.setDefinition(this.definition);
|
||||
entity.setStartdate(this.startdate);
|
||||
entity.setCreated(this.created == null? new Date():this.created);
|
||||
entity.setEnddate(this.enddate);
|
||||
entity.setStatus(this.status);
|
||||
entity.setModified(new Date());
|
||||
entity.setDescription(this.description);
|
||||
return entity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package models.project;
|
||||
|
||||
import models.criteria.ProjectCriteria;
|
||||
|
||||
public class ProjectTableRequest {
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -11,6 +11,10 @@ import models.criteria.OrganisationCriteria;
|
|||
import models.criteria.ResearcherCriteria;
|
||||
import models.criteria.ServiceCriteria;
|
||||
import models.dmp.DataManagementPlan;
|
||||
import models.dmp.DataManagementPlanTableRequest;
|
||||
import models.helpers.DataTableData;
|
||||
import models.project.ProjectTableRequest;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
@ -38,9 +42,12 @@ import dao.entities.ServiceDao;
|
|||
import dao.entities.UserInfoDao;
|
||||
import entities.DMP;
|
||||
import entities.Dataset;
|
||||
import entities.Project;
|
||||
import entities.UserInfo;
|
||||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import managers.DataManagementPlanManager;
|
||||
import managers.ProjectManager;
|
||||
import utilities.builders.DomainModelConverter;
|
||||
|
||||
|
||||
|
@ -66,6 +73,42 @@ public class DMPs {
|
|||
|
||||
// FETCH BY DMP(S)
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DataTableData<models.dmp.DataManagementPlan>> getPaged(@RequestBody DataManagementPlanTableRequest dataManagementPlanTableRequest) {
|
||||
try {
|
||||
DataTableData<models.dmp.DataManagementPlan> dataTable = new DataManagementPlanManager().getPaged(dMPDao, dataManagementPlanTableRequest);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK).body(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<models.dmp.DataManagementPlan> getPaged(@PathVariable String id) {
|
||||
try {
|
||||
models.dmp.DataManagementPlan project = new DataManagementPlanManager().getSingle(dMPDao, id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(project);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/dmps/add" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<entities.DMP> addDmp(@RequestBody models.dmp.DataManagementPlan dataManagementPlan) {
|
||||
entities.DMP createdProject = dMPDao.update(dataManagementPlan.toDataModel());
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dmps" }, produces="text/plain")
|
||||
public @ResponseBody ResponseEntity<Object> listDMPs(){
|
||||
try {
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package rest.entities;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.json.JSONObject;
|
||||
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.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
import dao.entities.DMPProfileDao;
|
||||
import dao.entities.DataRepositoryDao;
|
||||
import dao.entities.DatasetDao;
|
||||
import dao.entities.DatasetProfileDao;
|
||||
import dao.entities.DatasetProfileRulesetDao;
|
||||
import dao.entities.DatasetProfileViewstyleDao;
|
||||
import dao.entities.OrganisationDao;
|
||||
import dao.entities.ProjectDao;
|
||||
import dao.entities.RegistryDao;
|
||||
import dao.entities.ResearcherDao;
|
||||
import dao.entities.ServiceDao;
|
||||
import managers.DashBoardManager;
|
||||
import managers.UserManager;
|
||||
import models.dashboard.DashBoardStatistics;
|
||||
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class DashBoardController {
|
||||
|
||||
@Autowired private DatasetDao datasetDao;
|
||||
@Autowired private DMPDao dMPDao;
|
||||
@Autowired private ProjectDao projectDao;
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/dashboard/getStatistics" }, produces="application/json")
|
||||
public ResponseEntity<Object> getStatistics(){
|
||||
try {
|
||||
DashBoardStatistics statistics = new DashBoardManager().getStatistics(datasetDao, dMPDao, projectDao);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(statistics);
|
||||
}
|
||||
catch(Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,9 @@ import entities.UserInfo;
|
|||
import entities.responses.IDLabelPair;
|
||||
import helpers.SerializerProvider;
|
||||
import helpers.Transformers;
|
||||
import managers.ProjectManager;
|
||||
import models.helpers.DataTableData;
|
||||
import models.project.ProjectTableRequest;
|
||||
import proxy.config.exceptions.HugeResultSet;
|
||||
import proxy.config.exceptions.NoURLFound;
|
||||
import proxy.fetching.RemoteFetcher;
|
||||
|
@ -88,6 +91,43 @@ public class Projects {
|
|||
@Autowired private RemoteFetcher remoteFetcher;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/getPaged" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<DataTableData<models.project.Project>> getPaged(@RequestBody ProjectTableRequest projectTableRequest) {
|
||||
try {
|
||||
DataTableData<models.project.Project> dataTable = new ProjectManager().getPaged(projectDao, projectTableRequest);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(dataTable);
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/projects/getSingle/{id}" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<models.project.Project> getPaged(@PathVariable String id) {
|
||||
try {
|
||||
models.project.Project project = new ProjectManager().getSingle(projectDao, id);
|
||||
return ResponseEntity.status(HttpStatus.OK).body(project);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Transactional
|
||||
@RequestMapping(method = RequestMethod.POST, value = { "/projects/add" }, consumes = "application/json", produces="application/json")
|
||||
public @ResponseBody ResponseEntity<entities.Project> addProject(@RequestBody models.project.Project project) {
|
||||
Project createdProject = projectDao.update(project.toDataModel());
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = { "/external/projects" }, produces="application/json")
|
||||
public @ResponseBody ResponseEntity<Object> listExternalProjects(@RequestParam(value="query", required=false) String query ){
|
||||
try {
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<csrf disabled="true"/>
|
||||
|
||||
<custom-filter after="BASIC_AUTH_FILTER" ref="tokenAuthenticationFilter" />
|
||||
<intercept-url pattern="/**" access="isAuthenticated()" />
|
||||
<intercept-url pattern="/**" access="true" />
|
||||
<http-basic/>
|
||||
</http>
|
||||
|
||||
|
|
Loading…
Reference in New Issue