Minor edit
This commit is contained in:
parent
deb527eef0
commit
f8490cbc2b
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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(){
|
||||||
|
|
Loading…
Reference in New Issue