From 8e11ecbcf4d5d6ffc4da6b5d5930d9983a88b477 Mon Sep 17 00:00:00 2001 From: cugurlu Date: Sun, 31 Mar 2019 15:25:40 +0200 Subject: [PATCH 1/5] Add new methods for getInputMap from database --- .../greenify/client/rest/UserService.java | 21 +++++++++++++++++++ .../java/greenify/server/data/model/User.java | 9 ++++++-- .../greenify/server/rest/UserController.java | 9 ++++++++ .../greenify/server/service/UserService.java | 11 ++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/Client/src/main/java/greenify/client/rest/UserService.java b/src/Client/src/main/java/greenify/client/rest/UserService.java index f07534f..9cdd50f 100644 --- a/src/Client/src/main/java/greenify/client/rest/UserService.java +++ b/src/Client/src/main/java/greenify/client/rest/UserService.java @@ -1,5 +1,6 @@ package greenify.client.rest; +import com.sun.javafx.collections.MappingChange; import greenify.common.UserDto; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.web.client.RestTemplateBuilder; @@ -12,7 +13,10 @@ import org.springframework.stereotype.Service; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; +import java.awt.*; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Service public class UserService { @@ -173,6 +177,23 @@ public class UserService { .encode().toUri(), String.class); } + /** + * Gets the footprint inputs of the user. + * @param name the username of the current user. + */ + @SuppressWarnings("Duplicates") + public Map getInputs(String name) { + HttpHeaders headers = new HttpHeaders(); + headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); + UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getInputs") + .queryParam("name", name); + HttpEntity entity = new HttpEntity<>(headers); + System.out.println(builder.build().encode().toUri()); + Map result = this.restTemplate.getForObject(builder.build() + .encode().toUri(), Map.class); + return result; + } + /** * Gets the list of all users. */ diff --git a/src/Server/src/main/java/greenify/server/data/model/User.java b/src/Server/src/main/java/greenify/server/data/model/User.java index 3252ee7..70d92df 100644 --- a/src/Server/src/main/java/greenify/server/data/model/User.java +++ b/src/Server/src/main/java/greenify/server/data/model/User.java @@ -10,8 +10,13 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import javax.persistence.*; - +import javax.persistence.ElementCollection; +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.GenerationType; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.Table; import javax.validation.constraints.NotNull; @Entity diff --git a/src/Server/src/main/java/greenify/server/rest/UserController.java b/src/Server/src/main/java/greenify/server/rest/UserController.java index 0dab152..fd2b933 100644 --- a/src/Server/src/main/java/greenify/server/rest/UserController.java +++ b/src/Server/src/main/java/greenify/server/rest/UserController.java @@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import java.util.List; +import java.util.Map; @RestController public class UserController { @@ -102,6 +103,14 @@ public class UserController { return users; } + /** + * This method gets the input map of the user. + */ + @RequestMapping("/getInputs") + public Map getInputs(@RequestParam(value = "name") String name) { + return userService.getInputMap(name); + } + /** * This method adds friend for a user. * @param name name of the user diff --git a/src/Server/src/main/java/greenify/server/service/UserService.java b/src/Server/src/main/java/greenify/server/service/UserService.java index 9b9c3fb..7989e8f 100644 --- a/src/Server/src/main/java/greenify/server/service/UserService.java +++ b/src/Server/src/main/java/greenify/server/service/UserService.java @@ -12,6 +12,7 @@ import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; +import java.util.Map; @Service public class UserService { @@ -114,6 +115,16 @@ public class UserService { } } + /** + * This method gets the map of the inputs. + * @param name of the user + * @return input map + */ + public Map getInputMap(String name) { + User user = userRepository.findByName(name); + return user.getFootPrintInputs(); + } + /** * This method saves the footprint of a user. * @param name name of the user From 32c9713835e61e0143c60804621184da4d94f597 Mon Sep 17 00:00:00 2001 From: cugurlu Date: Sun, 31 Mar 2019 15:26:06 +0200 Subject: [PATCH 2/5] Add acitivitySummary to GUI --- .../src/main/resources/fxml/dashboard.fxml | 281 ++++++++++++------ 1 file changed, 190 insertions(+), 91 deletions(-) diff --git a/src/Client/src/main/resources/fxml/dashboard.fxml b/src/Client/src/main/resources/fxml/dashboard.fxml index 5ac6f85..af55c2e 100644 --- a/src/Client/src/main/resources/fxml/dashboard.fxml +++ b/src/Client/src/main/resources/fxml/dashboard.fxml @@ -1,17 +1,12 @@ - - - - - - - + + @@ -57,121 +52,225 @@ - + - + + - - - - - - - - - - - - - - - - - + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -275,16 +374,16 @@ - - - - + + + + - - - - + + + +