diff --git a/src/main/java/org/hbp/mip/MIPApplication.java b/src/main/java/org/hbp/mip/MIPApplication.java
index 59516ca1705aa9d8b49c178f35e9c6d3ef002d56..609d0c2c373d1983417a1926ab5b299d9e1a3f5e 100644
--- a/src/main/java/org/hbp/mip/MIPApplication.java
+++ b/src/main/java/org/hbp/mip/MIPApplication.java
@@ -128,6 +128,11 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
User user = new User(getUserInfos());
try {
session.beginTransaction();
+ Boolean agreeNDA = (Boolean) session
+ .createQuery("SELECT agreeNDA FROM User WHERE username= :username")
+ .setString("username", user.getUsername())
+ .uniqueResult();
+ user.setAgreeNDA(agreeNDA);
session.merge(user);
session.getTransaction().commit();
} catch (Exception e)
@@ -135,6 +140,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
if(session.getTransaction() != null)
{
session.getTransaction().rollback();
+ throw e;
}
}
@@ -183,15 +189,14 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
}
@RequestMapping(path = "/user", method = RequestMethod.POST)
- public ResponseEntity<Void> postUser(Principal principal, HttpServletResponse response,
- @ApiParam(value = "Has the user agreed on the NDA") @RequestParam(value = "agreeNDA", required = true) Boolean agreeNDA) {
- ObjectMapper mapper = new ObjectMapper();
+ public ResponseEntity<Void> postUser(@ApiParam(value = "Has the user agreed on the NDA") @RequestParam(value = "agreeNDA", required = true) Boolean agreeNDA) {
+ String username = getUser().getUsername();
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
try {
session.beginTransaction();
User user = (User) session
.createQuery("from User where username= :username")
- .setString("username", principal.getName())
+ .setString("username", username)
.uniqueResult();
if (user != null) {
user.setAgreeNDA(agreeNDA);
@@ -203,6 +208,7 @@ public class MIPApplication extends WebSecurityConfigurerAdapter {
if(session.getTransaction() != null)
{
session.getTransaction().rollback();
+ throw e;
}
}
diff --git a/src/main/java/org/hbp/mip/controllers/MiningApi.java b/src/main/java/org/hbp/mip/controllers/MiningApi.java
index 89f69027297aeae83d9b675c8315cccabdb24de9..fe7bbb6f531d004b9d8057c0cffbcbd3c5356dea 100644
--- a/src/main/java/org/hbp/mip/controllers/MiningApi.java
+++ b/src/main/java/org/hbp/mip/controllers/MiningApi.java
@@ -31,7 +31,7 @@ public class MiningApi {
@ApiResponses(value = { @ApiResponse(code = 200, message = "Success") })
@RequestMapping(method = RequestMethod.POST)
public ResponseEntity<String> postMining(
- @RequestBody @ApiParam(value = "Model to create", required = true) String query
+ @RequestBody @ApiParam(value = "Query for the data mining", required = true) String query
) throws Exception {
StringBuilder results = new StringBuilder();