minor changes
This commit is contained in:
parent
5863ad4e16
commit
deb527eef0
|
@ -39,7 +39,7 @@ public class DatasetProfileRuleset implements Serializable {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "ruleset", cascade = CascadeType.ALL)
|
@OneToOne(fetch = FetchType.EAGER, mappedBy = "ruleset")
|
||||||
private DatasetProfile datasetProfile;
|
private DatasetProfile datasetProfile;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class DatasetProfileViewstyle implements Serializable {
|
||||||
private UUID id;
|
private UUID id;
|
||||||
|
|
||||||
|
|
||||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "viewstyle", cascade = CascadeType.ALL)
|
@OneToOne(fetch = FetchType.EAGER, mappedBy = "viewstyle")
|
||||||
private DatasetProfile datasetProfile;
|
private DatasetProfile datasetProfile;
|
||||||
|
|
||||||
@Column(name = "\"Label\"")
|
@Column(name = "\"Label\"")
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package rest.entities;
|
package rest.entities;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.transaction.Transactional;
|
||||||
|
|
||||||
import org.apache.commons.lang3.SerializationUtils;
|
import org.apache.commons.lang3.SerializationUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -18,7 +22,9 @@ 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.core.JsonParseException;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
import dao.entities.DMPDao;
|
import dao.entities.DMPDao;
|
||||||
|
@ -34,9 +40,11 @@ import dao.entities.RegistryDao;
|
||||||
import dao.entities.ResearcherDao;
|
import dao.entities.ResearcherDao;
|
||||||
import dao.entities.ServiceDao;
|
import dao.entities.ServiceDao;
|
||||||
import entities.DMP;
|
import entities.DMP;
|
||||||
|
import entities.DMPProfile;
|
||||||
import entities.Dataset;
|
import entities.Dataset;
|
||||||
import entities.DatasetProfile;
|
import entities.DatasetProfile;
|
||||||
import entities.DatasetProfileRuleset;
|
import entities.DatasetProfileRuleset;
|
||||||
|
import entities.DatasetProfileViewstyle;
|
||||||
import entities.Project;
|
import entities.Project;
|
||||||
import helpers.Transformers;
|
import helpers.Transformers;
|
||||||
import responses.RestResponse;
|
import responses.RestResponse;
|
||||||
|
@ -59,7 +67,7 @@ public class Datasets {
|
||||||
@Autowired private ResearcherDao researcherDao;
|
@Autowired private ResearcherDao researcherDao;
|
||||||
@Autowired private ServiceDao serviceDao;
|
@Autowired private ServiceDao serviceDao;
|
||||||
|
|
||||||
|
private ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|
||||||
|
|
||||||
// FETCH BY DATASET(S)
|
// FETCH BY DATASET(S)
|
||||||
|
@ -211,37 +219,74 @@ public class Datasets {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.POST, value = { "/setDatasetProfile" }, consumes = "application/json")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//@Transactional
|
||||||
|
@RequestMapping(method = RequestMethod.POST, value = { "/datasetprofile/set" }, consumes = "application/json", produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> setDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
|
public @ResponseBody ResponseEntity<Object> setDatasetProfile(@RequestBody DatasetProfile datasetProfile) {
|
||||||
|
|
||||||
String reason = "";
|
System.out.println("inside setDatasetProfile");
|
||||||
DatasetProfile storedDatasetProfile = null;
|
|
||||||
//try first to create
|
|
||||||
try {
|
try {
|
||||||
storedDatasetProfile = datasetProfileDao.create(datasetProfile);
|
System.out.println(objectMapper.writeValueAsString(datasetProfile));
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(storedDatasetProfile));
|
} catch (JsonProcessingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
catch(Exception e) {
|
|
||||||
reason += e.getMessage();
|
if(datasetProfile.getRuleset()!=null && datasetProfile.getRuleset().getId()!=null){
|
||||||
//try updating
|
DatasetProfileRuleset dpr = datasetProfile.getRuleset();
|
||||||
try {
|
datasetProfileRulesetDao.update(dpr);
|
||||||
storedDatasetProfile = datasetProfileDao.update(datasetProfile);
|
DatasetProfileRuleset n = new DatasetProfileRuleset();
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(storedDatasetProfile));
|
n.setId(dpr.getId());
|
||||||
}
|
datasetProfile.setRuleset(n);
|
||||||
catch(Exception ex) {
|
}
|
||||||
reason += (System.lineSeparator()+e.getMessage());
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("An error occurred! Reason: " + reason);
|
if(datasetProfile.getViewstyle()!=null && datasetProfile.getViewstyle().getId()!=null){
|
||||||
}
|
DatasetProfileViewstyle dpv = datasetProfile.getViewstyle();
|
||||||
|
datasetProfileViewstyleDao.update(dpv);
|
||||||
|
DatasetProfileViewstyle n = new DatasetProfileViewstyle();
|
||||||
|
n.setId(dpv.getId());
|
||||||
|
datasetProfile.setViewstyle(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
datasetProfile.setDataset(null);
|
||||||
|
|
||||||
|
DatasetProfile createdDatasetProfile = datasetProfileDao.update(datasetProfile);
|
||||||
|
try {
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDatasetProfile));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not set dataset profile!\"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/createEmptyDatasetProfile" })
|
|
||||||
public @ResponseBody ResponseEntity<Object> createEmptyDatasetProfile() {
|
@RequestMapping(method = RequestMethod.POST, value = { "/createEmptyDatasetProfile" })
|
||||||
|
public @ResponseBody ResponseEntity<Object> createEmptyDatasetProfile(@RequestParam("datasetID") String datasetID) {
|
||||||
|
|
||||||
|
DatasetProfileRuleset dpr = new DatasetProfileRuleset();
|
||||||
|
dpr.setLabel("");
|
||||||
|
dpr.setDefinition("");
|
||||||
|
dpr.setId(datasetProfileRulesetDao.create(dpr).getId());
|
||||||
|
|
||||||
|
DatasetProfileViewstyle dpv = new DatasetProfileViewstyle();
|
||||||
|
dpv.setLabel("");
|
||||||
|
dpv.setDefinition("");
|
||||||
|
dpv.setId(datasetProfileViewstyleDao.create(dpv).getId());
|
||||||
|
|
||||||
DatasetProfile datasetProfile = new DatasetProfile();
|
DatasetProfile datasetProfile = new DatasetProfile();
|
||||||
datasetProfile.setLabel("");
|
datasetProfile.setLabel("");
|
||||||
datasetProfile.setDefinition("");
|
datasetProfile.setDefinition("");
|
||||||
|
datasetProfile.setRuleset(dpr);
|
||||||
|
datasetProfile.setViewstyle(dpv);
|
||||||
|
|
||||||
|
Dataset ds = new Dataset();
|
||||||
|
ds.setId(UUID.fromString(datasetID));
|
||||||
|
datasetProfile.setDataset(ds);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
datasetProfile = datasetProfileDao.create(datasetProfile);
|
datasetProfile = datasetProfileDao.create(datasetProfile);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(datasetProfile));
|
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(datasetProfile));
|
||||||
|
@ -250,7 +295,7 @@ public class Datasets {
|
||||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("FAILED: reason: "+e.getMessage());
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("FAILED: reason: "+e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue