Merge branch 'master' of gitlab.eudat.eu:dmp/OpenAIRE-EUDAT-DMP-service-pilot
This commit is contained in:
commit
3607782464
|
@ -4,7 +4,11 @@ import java.util.UUID;
|
||||||
|
|
||||||
import dao.Dao;
|
import dao.Dao;
|
||||||
import entities.DMPResearcher;
|
import entities.DMPResearcher;
|
||||||
|
import entities.Researcher;
|
||||||
|
|
||||||
public interface DMPResearcherDao extends Dao<DMPResearcher, UUID> {
|
public interface DMPResearcherDao extends Dao<DMPResearcher, UUID> {
|
||||||
|
|
||||||
|
|
||||||
|
Researcher getResearcherByEmail(String email);
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,9 +2,13 @@ package dao.entities;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import javax.persistence.TypedQuery;
|
||||||
|
|
||||||
|
import org.hibernate.NonUniqueResultException;
|
||||||
|
|
||||||
import dao.JpaDao;
|
import dao.JpaDao;
|
||||||
import entities.DMPResearcher;
|
import entities.DMPResearcher;
|
||||||
|
import entities.Researcher;
|
||||||
|
|
||||||
public class DMPResearcherDaoImpl extends JpaDao<DMPResearcher, UUID> implements DMPResearcherDao {
|
public class DMPResearcherDaoImpl extends JpaDao<DMPResearcher, UUID> implements DMPResearcherDao {
|
||||||
|
|
||||||
|
@ -13,5 +17,19 @@ public class DMPResearcherDaoImpl extends JpaDao<DMPResearcher, UUID> implements
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Researcher getResearcherByEmail(String email) {
|
||||||
|
String queryString = "FROM Researcher researcher where primaryEmail=:email";
|
||||||
|
TypedQuery<Researcher> typedQuery = entityManager.createQuery(queryString, Researcher.class);
|
||||||
|
typedQuery.setParameter("email", email);
|
||||||
|
try {
|
||||||
|
return typedQuery.getSingleResult();
|
||||||
|
}catch(Exception ex) {
|
||||||
|
System.out.println(ex.getMessage());
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
import dao.Dao;
|
import dao.Dao;
|
||||||
import entities.Registry;
|
import entities.Registry;
|
||||||
|
import entities.Researcher;
|
||||||
import entities.responses.IDLabelPair;
|
import entities.responses.IDLabelPair;
|
||||||
|
|
||||||
public interface RegistryDao extends Dao<Registry, UUID> {
|
public interface RegistryDao extends Dao<Registry, UUID> {
|
||||||
|
@ -13,4 +14,5 @@ public interface RegistryDao extends Dao<Registry, UUID> {
|
||||||
|
|
||||||
List<IDLabelPair> listAllIDsLabels();
|
List<IDLabelPair> listAllIDsLabels();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -10,6 +10,7 @@ import org.hibernate.query.Query;
|
||||||
|
|
||||||
import dao.JpaDao;
|
import dao.JpaDao;
|
||||||
import entities.Registry;
|
import entities.Registry;
|
||||||
|
import entities.Researcher;
|
||||||
import entities.responses.IDLabelPair;
|
import entities.responses.IDLabelPair;
|
||||||
|
|
||||||
public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryDao {
|
public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryDao {
|
||||||
|
|
|
@ -13,4 +13,6 @@ public interface ResearcherDao extends Dao<Researcher, UUID> {
|
||||||
|
|
||||||
List<IDLabelPair> listAllIDsLabels();
|
List<IDLabelPair> listAllIDsLabels();
|
||||||
|
|
||||||
|
Researcher getResearcherByEmail(String email);
|
||||||
|
|
||||||
}
|
}
|
|
@ -40,4 +40,14 @@ public class ResearcherDaoImpl extends JpaDao<Researcher, UUID> implements Resea
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Researcher getResearcherByEmail(String email) {
|
||||||
|
String queryString = "FROM Researcher researcher where researcher.primaryEmail=:email";
|
||||||
|
TypedQuery<Researcher> typedQuery = entityManager.createQuery(queryString, Researcher.class);
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
datasetProfileRulesetDao.update(dpr);
|
||||||
|
DatasetProfileRuleset n = new DatasetProfileRuleset();
|
||||||
|
n.setId(dpr.getId());
|
||||||
|
datasetProfile.setRuleset(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
try {
|
||||||
storedDatasetProfile = datasetProfileDao.update(datasetProfile);
|
return ResponseEntity.status(HttpStatus.CREATED).body(objectMapper.writeValueAsString(createdDatasetProfile));
|
||||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(storedDatasetProfile));
|
} catch (JsonProcessingException e) {
|
||||||
}
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("{\"msg\":\"Could not set dataset profile!\"}");
|
||||||
catch(Exception ex) {
|
|
||||||
reason += (System.lineSeparator()+e.getMessage());
|
|
||||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("An error occurred! Reason: " + reason);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
@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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,18 @@ public class Researchers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getByEmail" }, produces="application/json")
|
||||||
|
public @ResponseBody ResponseEntity<Object> getResearcherByEmail(@RequestParam("email") String email){
|
||||||
|
try {
|
||||||
|
Researcher researcher = researcherDao.getResearcherByEmail(email);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK).body(new ObjectMapper().writeValueAsString(researcher));
|
||||||
|
}
|
||||||
|
catch(Exception ex) {
|
||||||
|
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Erroneous input: "+ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getAll" }, produces="application/json")
|
@RequestMapping(method = RequestMethod.GET, value = { "/researcher/getAll" }, produces="application/json")
|
||||||
public @ResponseBody ResponseEntity<Object> getAllResearchers(){
|
public @ResponseBody ResponseEntity<Object> getAllResearchers(){
|
||||||
|
|
|
@ -35,7 +35,21 @@ export class ProjectsComponent implements OnInit{
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.projects = this.serverService.getDummyProjects()
|
//this.projects = this.serverService.getDummyProjects();
|
||||||
|
this.projects = [];
|
||||||
|
this.serverService.getProjects().subscribe(
|
||||||
|
response => {
|
||||||
|
|
||||||
|
console.log("response");
|
||||||
|
console.log(response);
|
||||||
|
response.forEach(resp => {
|
||||||
|
let pr = new Project();
|
||||||
|
pr.id = resp.id;
|
||||||
|
pr.name = resp.label;
|
||||||
|
this.projects.push(pr);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -69,22 +69,29 @@ export class ServerService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getDummyProjects(){
|
getProjects(){
|
||||||
let projects :Project[] =[];
|
|
||||||
|
|
||||||
let project = new Project;
|
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
|
||||||
project.name = "Project1";
|
|
||||||
project.id = "Project1Id";
|
|
||||||
|
|
||||||
projects.push(project);
|
console.log("google-token: "+ this.tokenService.getToken());
|
||||||
|
|
||||||
let project2 = new Project;
|
return this.httpClient.get<any>("http://dl010.madgik.di.uoa.gr:8080/dmp-backend-no-sec/rest/project/listAllLabelIDs");
|
||||||
project2.name = "Project2";
|
|
||||||
project2.id = "Project2Id";
|
|
||||||
|
|
||||||
projects.push(project2);
|
// let projects :Project[] =[];
|
||||||
|
|
||||||
return projects;
|
// let project = new Project;
|
||||||
|
// project.name = "Project1";
|
||||||
|
// project.id = "Project1Id";
|
||||||
|
|
||||||
|
// projects.push(project);
|
||||||
|
|
||||||
|
// let project2 = new Project;
|
||||||
|
// project2.name = "Project2";
|
||||||
|
// project2.id = "Project2Id";
|
||||||
|
|
||||||
|
// projects.push(project2);
|
||||||
|
|
||||||
|
// return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue