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 entities.DMPResearcher;
|
||||
import entities.Researcher;
|
||||
|
||||
public interface DMPResearcherDao extends Dao<DMPResearcher, UUID> {
|
||||
|
||||
|
||||
Researcher getResearcherByEmail(String email);
|
||||
|
||||
}
|
|
@ -2,9 +2,13 @@ package dao.entities;
|
|||
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.TypedQuery;
|
||||
|
||||
import org.hibernate.NonUniqueResultException;
|
||||
|
||||
import dao.JpaDao;
|
||||
import entities.DMPResearcher;
|
||||
import entities.Researcher;
|
||||
|
||||
public class DMPResearcherDaoImpl extends JpaDao<DMPResearcher, UUID> implements DMPResearcherDao {
|
||||
|
||||
|
@ -12,6 +16,20 @@ public class DMPResearcherDaoImpl extends JpaDao<DMPResearcher, UUID> implements
|
|||
// TODO Auto-generated method stub
|
||||
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 entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.responses.IDLabelPair;
|
||||
|
||||
public interface RegistryDao extends Dao<Registry, UUID> {
|
||||
|
@ -12,5 +13,6 @@ public interface RegistryDao extends Dao<Registry, UUID> {
|
|||
List<UUID> listAllIDs();
|
||||
|
||||
List<IDLabelPair> listAllIDsLabels();
|
||||
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import org.hibernate.query.Query;
|
|||
|
||||
import dao.JpaDao;
|
||||
import entities.Registry;
|
||||
import entities.Researcher;
|
||||
import entities.responses.IDLabelPair;
|
||||
|
||||
public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryDao {
|
||||
|
@ -37,6 +38,6 @@ public class RegistryDaoImpl extends JpaDao<Registry, UUID> implements RegistryD
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -12,5 +12,7 @@ public interface ResearcherDao extends Dao<Researcher, UUID> {
|
|||
List<UUID> listAllIDs();
|
||||
|
||||
List<IDLabelPair> listAllIDsLabels();
|
||||
|
||||
Researcher getResearcherByEmail(String email);
|
||||
|
||||
}
|
|
@ -38,6 +38,16 @@ public class ResearcherDaoImpl extends JpaDao<Researcher, UUID> implements Resea
|
|||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@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;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "ruleset", cascade = CascadeType.ALL)
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "ruleset")
|
||||
private DatasetProfile datasetProfile;
|
||||
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DatasetProfileViewstyle implements Serializable {
|
|||
private UUID id;
|
||||
|
||||
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "viewstyle", cascade = CascadeType.ALL)
|
||||
@OneToOne(fetch = FetchType.EAGER, mappedBy = "viewstyle")
|
||||
private DatasetProfile datasetProfile;
|
||||
|
||||
@Column(name = "\"Label\"")
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package rest.entities;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import org.apache.commons.lang3.SerializationUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.RestController;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import dao.entities.DMPDao;
|
||||
|
@ -34,9 +40,11 @@ import dao.entities.RegistryDao;
|
|||
import dao.entities.ResearcherDao;
|
||||
import dao.entities.ServiceDao;
|
||||
import entities.DMP;
|
||||
import entities.DMPProfile;
|
||||
import entities.Dataset;
|
||||
import entities.DatasetProfile;
|
||||
import entities.DatasetProfileRuleset;
|
||||
import entities.DatasetProfileViewstyle;
|
||||
import entities.Project;
|
||||
import helpers.Transformers;
|
||||
import responses.RestResponse;
|
||||
|
@ -59,7 +67,7 @@ public class Datasets {
|
|||
@Autowired private ResearcherDao researcherDao;
|
||||
@Autowired private ServiceDao serviceDao;
|
||||
|
||||
|
||||
private ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
|
||||
// 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) {
|
||||
|
||||
String reason = "";
|
||||
DatasetProfile storedDatasetProfile = null;
|
||||
//try first to create
|
||||
System.out.println("inside setDatasetProfile");
|
||||
try {
|
||||
storedDatasetProfile = datasetProfileDao.create(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(storedDatasetProfile));
|
||||
System.out.println(objectMapper.writeValueAsString(datasetProfile));
|
||||
} catch (JsonProcessingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
catch(Exception e) {
|
||||
reason += e.getMessage();
|
||||
//try updating
|
||||
try {
|
||||
storedDatasetProfile = datasetProfileDao.update(datasetProfile);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(new ObjectMapper().writeValueAsString(storedDatasetProfile));
|
||||
}
|
||||
catch(Exception ex) {
|
||||
reason += (System.lineSeparator()+e.getMessage());
|
||||
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("An error occurred! Reason: " + reason);
|
||||
}
|
||||
|
||||
if(datasetProfile.getRuleset()!=null && datasetProfile.getRuleset().getId()!=null){
|
||||
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 {
|
||||
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.setLabel("");
|
||||
datasetProfile.setDefinition("");
|
||||
datasetProfile.setRuleset(dpr);
|
||||
datasetProfile.setViewstyle(dpv);
|
||||
|
||||
Dataset ds = new Dataset();
|
||||
ds.setId(UUID.fromString(datasetID));
|
||||
datasetProfile.setDataset(ds);
|
||||
|
||||
try {
|
||||
datasetProfile = datasetProfileDao.create(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());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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")
|
||||
public @ResponseBody ResponseEntity<Object> getAllResearchers(){
|
||||
|
|
|
@ -35,8 +35,22 @@ export class ProjectsComponent implements OnInit{
|
|||
}
|
||||
|
||||
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(){
|
||||
let projects :Project[] =[];
|
||||
getProjects(){
|
||||
|
||||
let headers = new HttpHeaders().set("google-token", this.tokenService.getToken());
|
||||
|
||||
let project = new Project;
|
||||
project.name = "Project1";
|
||||
project.id = "Project1Id";
|
||||
console.log("google-token: "+ this.tokenService.getToken());
|
||||
|
||||
return this.httpClient.get<any>("http://dl010.madgik.di.uoa.gr:8080/dmp-backend-no-sec/rest/project/listAllLabelIDs");
|
||||
|
||||
projects.push(project);
|
||||
// let projects :Project[] =[];
|
||||
|
||||
// let project = new Project;
|
||||
// project.name = "Project1";
|
||||
// project.id = "Project1Id";
|
||||
|
||||
let project2 = new Project;
|
||||
project2.name = "Project2";
|
||||
project2.id = "Project2Id";
|
||||
// projects.push(project);
|
||||
|
||||
projects.push(project2);
|
||||
// let project2 = new Project;
|
||||
// project2.name = "Project2";
|
||||
// project2.id = "Project2Id";
|
||||
|
||||
return projects;
|
||||
// projects.push(project2);
|
||||
|
||||
// return projects;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue