Added "description" on tables {Dataset, DMP, DatasetProfile, Project}

This commit is contained in:
Nikolaos Laskaris 2017-11-07 14:20:13 +02:00
parent ce7e1c739b
commit a7b251ed04
14 changed files with 232 additions and 34 deletions

View File

@ -104,12 +104,28 @@ public class DMP implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;

View File

@ -57,11 +57,12 @@ public class DMPProfile implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -72,11 +72,11 @@ public class DataRepository implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -99,11 +99,25 @@ public class Dataset implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {

View File

@ -67,13 +67,27 @@ public class DatasetProfile implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;
}

View File

@ -74,11 +74,12 @@ public class Organisation implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -80,12 +80,26 @@ public class Project implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
@Column(name = "\"Description\"")
private String description;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Short getStatus() {
return status;

View File

@ -73,11 +73,12 @@ public class Registry implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -73,11 +73,12 @@ public class Researcher implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -73,11 +73,12 @@ public class Service implements Serializable {
@Column(name = "\"Status\"", nullable = false)
private Short status;
@Column(name = "\"Created\"", nullable = false)
@Column(name = "\"Created\"")
private Date created = null;
@Column(name = "\"Modified\"", nullable = false)
private Date modified = null;
@Column(name = "\"Modified\"")
private Date modified = new Date();
public Short getStatus() {

View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.util.Date;
import java.util.Set;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.persistence.Column;
import javax.persistence.Entity;
@ -84,6 +85,11 @@ public class UserInfo implements Serializable{
private Set<DMP> dmps;
public Set<DMP> getDmpsNonDeleted(){
return getDmps().parallelStream().filter(dmp -> dmp.getStatus()>=0).collect(Collectors.toSet());
}
public Set<DMP> getDmps() {
return dmps;
}

View File

@ -203,7 +203,7 @@ public class DMPs {
d.setStatus(new Short("-1"));
try {
int code = updateDMP(dmp).getStatusCodeValue();
int code = updateDMP(d).getStatusCodeValue();
if(code>199 && code<300)
return ResponseEntity.status(HttpStatus.CREATED).body("DELETED!");
else
@ -238,7 +238,8 @@ public class DMPs {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
try {
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(userInfo.getDmps()));
Set<DMP> nonDeleted = userInfo.getDmpsNonDeleted();
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(nonDeleted));
}
catch(Exception ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
@ -285,6 +286,51 @@ public class DMPs {
}
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/cloneforuser" }, produces="text/plain", consumes = "application/json")
public @ResponseBody ResponseEntity<Object> cloneDmpOfUser(@RequestBody DMP dmp){
String userID = null;
try {
userID = SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString();
} catch(NullPointerException ex) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("You have not logged in. You shouldn't be here");
}
UserInfo userInfo = userInfoDao.read(UUID.fromString(userID));
if(userInfo==null) //this should normally never happer
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("There's no such a user on the system. You shouldn't be here");
DMP clone = dMPDao.read(dmp.getId());
try {
Set<UserInfo> users = new HashSet<UserInfo>();
users.add(userInfo);
clone.setUsers(users);
clone.setCreated(new Date());
clone.setModified(new Date());
clone.setStatus(new Short("0"));
clone.setVersion(clone.getVersion()+1);
clone.setLabel(clone.getLabel()+"_clone");
clone.setPrevious(clone.getId());
clone.setId(null);
clone = dMPDao.create(clone);
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(clone));
}
catch(Exception ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}
}
@RequestMapping(method = RequestMethod.POST, value = { "/dmp/adduser" }, produces="text/plain")
public @ResponseBody ResponseEntity<Object> addUserToDmp(@RequestBody DMP dmp){

View File

@ -1,5 +1,6 @@
package rest.entities;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -137,7 +138,15 @@ public class Projects {
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/project/create" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> setProject(@RequestBody Project project) {
public @ResponseBody ResponseEntity<Object> createProject(@RequestBody Project project) {
Project createdProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
}
@RequestMapping(method = RequestMethod.POST, value = { "/project/update" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> updateProject(@RequestBody Project project) {
Project createdProject = projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body(createdProject);
}
@ -159,6 +168,23 @@ public class Projects {
}
@RequestMapping(method = RequestMethod.POST, value = { "/project/softdelete" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> softDelete(@RequestBody Project project) {
project.setStatus(new Short("-1"));
try {
projectDao.update(project);
return ResponseEntity.status(HttpStatus.CREATED).body("{\"msg\":\"Deleted project!\"}");
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not delete Project!\"}");
}
}
@Transactional
@RequestMapping(method = RequestMethod.POST, value = { "/project/getdmps" }, consumes = "application/json", produces="application/json")
public @ResponseBody ResponseEntity<Object> getProjectDmps(@RequestBody Project project) {
@ -230,13 +256,18 @@ public class Projects {
try {
project.setId(null);
project.setStatus(new Short("0"));
project.setCreated(new Date());
project.setModified(new Date());
Project newproj = projectDao.create(project);
DMP newdmp = new DMP();
newdmp.setId(null);
newdmp.setLabel("Auto-Generated");
newdmp.setCreated(new Date());
newdmp.setVersion(1);
newdmp.setStatus(new Short("0"));
newdmp.setProject(newproj);
Set<UserInfo> users = new HashSet<UserInfo>();
@ -248,6 +279,7 @@ public class Projects {
return ResponseEntity.status(HttpStatus.OK).body(SerializerProvider.toJson(newproj));
}
catch(Exception ex) {
ex.printStackTrace();
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Serialization issue: "+ex.getMessage());
}

View File

@ -181,8 +181,6 @@ public class TestRest {
System.out.println(SerializerProvider.toJson(userProjects));
assertEquals("aaa", "aaa");
}
@ -204,9 +202,18 @@ public class TestRest {
@Test
public void testDataset() {
public void testDmpClone() {
System.out.println(datasetsService.getAllDatasets().getBody());
System.out.println(dmpsService.getDmpsOfUser().getBody());
DMP dmp = new DMP();
dmp.setId(UUID.fromString("8faad611-7083-497c-ad96-9459e47ee175"));
String clonedJSON = dmpsService.cloneDmpOfUser(dmp).toString();
System.out.println(clonedJSON);
// System.out.println(datasetsService.getAllDatasets().getBody());
// System.out.println(dmpsService.getDatasetsOfDMP(dmp).getBody());
@ -215,5 +222,49 @@ public class TestRest {
}
//@Test
public void testProject() {
String projectJson = "{\"id\":\"d558e52c-a61b-4e16-a401-b27c579cf8e3\",\"dmps\":null,\"label\":\"Sample project\",\"abbreviation\":null,\"reference\":\"agasdfasdf\",\"uri\":\"hadfhadfgazfrg\",\"definition\":\"<info>sdfgsdg</info>\",\"startdate\":\"2017-11-01\",\"enddate\":\"2017-11-30\",\"status\":0,\"created\":1509638367900,\"modified\":1509638367900}";
try {
Project project = SerializerProvider.fromJson(projectJson, Project.class);
System.out.println(SerializerProvider.toJson(project));
} catch (Exception e) {
e.printStackTrace();
}
/*
// System.out.println(dmpsService.getAllDMPs().getBody().toString());
String dmpJSON = dmpsService.getDMP("d0d01f5e-9aed-4733-a0cf-aabe44cd30c9").getBody().toString();
System.out.println(dmpJSON);
try {
DMP dmp = SerializerProvider.fromJson(dmpJSON, DMP.class);
ResponseEntity<Object> resp = dmpsService.softDelete(dmp);
resp.getStatusCode();
}
catch(Exception ex) {
}
//dmpsService.softDelete(dmp)
//System.out.println(datasetsService.getAllDatasets().getBody());
// System.out.println(dmpsService.getDatasetsOfDMP(dmp).getBody());
*/
assertEquals("aaa", "aaa");
}
}