From f07f9125950687bfff4db4bfd34f3ff7d4892777 Mon Sep 17 00:00:00 2001 From: Glenn Osborne Date: Wed, 8 Apr 2020 13:26:20 -0400 Subject: [PATCH 1/3] Create .gitignore --- .gitignore | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3dc211b --- /dev/null +++ b/.gitignore @@ -0,0 +1,22 @@ + +target/ +pom.xml.tag +pom.xml.releaseBackup +pom.xml.versionsBackup +pom.xml.next +release.properties +dependency-reduced-pom.xml +buildNumber.properties +.mvn/timing.properties + +# Avoid ignoring Maven wrapper jar file (.jar files are usually ignored) +!/.mvn/wrapper/maven-wrapper.jar + +# Ignore all IntelliJ Idea files +.idea/ +out/ +*.iws +*.iml +*.ipr + +untracked/ From 62380091c0386426a2d6d3e0f6c479c51400e5e7 Mon Sep 17 00:00:00 2001 From: glennosborne Date: Thu, 9 Apr 2020 07:24:41 -0400 Subject: [PATCH 2/3] Got the initial display working (Google is my friend) --- .../dao/configurations/ConfigurationDao.java | 47 ++++++++++++++++--- .../ConfigurationController.java | 14 +++--- .../src/main/resources/static/index.html | 2 +- .../src/main/resources/static/js/app.js | 38 ++++++++------- 4 files changed, 69 insertions(+), 32 deletions(-) diff --git a/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java b/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java index f889558..86bec5e 100644 --- a/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java +++ b/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java @@ -3,10 +3,7 @@ import com.att.data.configurations.ConfigValue; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; @Service public class ConfigurationDao { @@ -25,16 +22,44 @@ public int getNextId() { /** * No DB, so store the configs in a map. */ - private Map> currentConfigurations; - private IdProvider idProvider; + private final Map> currentConfigurations; + private final Map allConfigValues; + private final IdProvider idProvider; public ConfigurationDao() { idProvider = new IdProvider(); + // Acknowledging that configurations are different subsets over the same universe of config values + allConfigValues = new HashMap<>(); + createConfigValue("A"); + createConfigValue("B"); + createConfigValue("C"); + createConfigValue("D"); + createConfigValue("E"); + createConfigValue("F"); + createConfigValue("G"); + createConfigValue("H"); currentConfigurations = new HashMap<>(); + currentConfigurations.put("012018", Arrays.asList( + allConfigValues.get(0), + allConfigValues.get(1), + allConfigValues.get(2), + allConfigValues.get(3) + )); + currentConfigurations.put("022018", Arrays.asList( + allConfigValues.get(0), + allConfigValues.get(2), + allConfigValues.get(5), + allConfigValues.get(6), + allConfigValues.get(7) + )); } public List getConfigurationsForYearMonth(String yearMonth) { - return new ArrayList<>(); + List result = currentConfigurations.get(yearMonth); + if (result == null) { + return Collections.emptyList(); + } + return result; } public void addConfiguration(String yearMonth, ConfigValue value) { @@ -45,4 +70,12 @@ public void addConfiguration(String yearMonth, ConfigValue value) { public void removeAllConfigurationsForYearMonth(String yearMonth) { } + + private ConfigValue createConfigValue(String name) { + int id = idProvider.getNextId(); + ConfigValue cv = new ConfigValue(name, id); + allConfigValues.put(id, cv); + return cv; + } + } diff --git a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java b/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java index 995402a..9193a35 100644 --- a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java +++ b/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java @@ -22,24 +22,26 @@ public ConfigurationController(ConfigurationDao dao) { @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.GET) @ResponseBody public List getConfigurationsForYearMonth( - @PathVariable("yearMonthNumber") String yearMonth) { - - return new ArrayList<>(); + @PathVariable("yearMonthNumber") String yearMonth) + { + return dao.getConfigurationsForYearMonth(yearMonth); } @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.DELETE) public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") String yearMonth) { try { - + System.err.println("HERE deleteConfigurationsForYearMonth"); } catch (Exception ex) { - + throw new RuntimeException(ex); } } @RequestMapping(value="/{yearMonthNumber}", method={ RequestMethod.POST, RequestMethod.PUT }) public void addConfigurationForYearMonth( @PathVariable("yearMonthNumber") String yearMonth, - @RequestBody ConfigValue value) { + @RequestBody ConfigValue value) + { + System.err.println("HERE addConfigurationForYearMonth"); } } diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index 7cd14ba..c90e536 100644 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -2,7 +2,7 @@ Configuration App - + diff --git a/configurationapp/src/main/resources/static/js/app.js b/configurationapp/src/main/resources/static/js/app.js index 2d4b945..4ad38b6 100644 --- a/configurationapp/src/main/resources/static/js/app.js +++ b/configurationapp/src/main/resources/static/js/app.js @@ -1,25 +1,27 @@ (function() { function App() { - } - - App.prototype.getData = function() { - $.ajax('',{ - - }).then(function(data) { + this.init = function() { + $('#configTable').DataTable({ + serverSide: true, + ajax: { + url: '/configuration/022018', + type: 'GET', + dataSrc: '' + }, + columns: [ + { data: 'configId'}, + { data: 'configName'} + ], + scrollY: 300, + paging: false, + sorting: false, + searching: false, + info: false + }); + }; - }) - }; - - App.prototype.init = function() { - $('#configTable').DataTable({ - scrollY: 300, - paging: false, - sorting: false, - searching: false, - info: false - }); - }; + } window.app = new App; })($); \ No newline at end of file From b496b6d65ac2acbebbd5eaa935e0d03c49cff357 Mon Sep 17 00:00:00 2001 From: glennosborne Date: Thu, 9 Apr 2020 13:10:28 -0400 Subject: [PATCH 3/3] Completed the assignment --- .../dao/configurations/ConfigurationDao.java | 41 ++++++++------- .../ConfigurationController.java | 9 +--- .../src/main/resources/static/index.html | 4 +- .../src/main/resources/static/js/app.js | 52 ++++++++++++++++++- 4 files changed, 78 insertions(+), 28 deletions(-) diff --git a/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java b/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java index 86bec5e..2545753 100644 --- a/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java +++ b/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java @@ -39,36 +39,41 @@ public ConfigurationDao() { createConfigValue("G"); createConfigValue("H"); currentConfigurations = new HashMap<>(); - currentConfigurations.put("012018", Arrays.asList( - allConfigValues.get(0), - allConfigValues.get(1), - allConfigValues.get(2), - allConfigValues.get(3) - )); - currentConfigurations.put("022018", Arrays.asList( - allConfigValues.get(0), - allConfigValues.get(2), - allConfigValues.get(5), - allConfigValues.get(6), - allConfigValues.get(7) - )); + ArrayList configValues = new ArrayList<>(); + configValues.add(allConfigValues.get(0)); + configValues.add(allConfigValues.get(1)); + configValues.add(allConfigValues.get(2)); + configValues.add(allConfigValues.get(3)); + currentConfigurations.put("012018", configValues); + configValues = new ArrayList<>(); + configValues.add(allConfigValues.get(0)); + configValues.add(allConfigValues.get(2)); + configValues.add(allConfigValues.get(5)); + configValues.add(allConfigValues.get(6)); + configValues.add(allConfigValues.get(7)); + currentConfigurations.put("022018", configValues); } public List getConfigurationsForYearMonth(String yearMonth) { List result = currentConfigurations.get(yearMonth); if (result == null) { - return Collections.emptyList(); + return new ArrayList<>(); } return result; } - public void addConfiguration(String yearMonth, ConfigValue value) { - int newId = idProvider.getNextId(); - + public void addConfiguration(String yearMonth, ConfigValue prototype) { + ConfigValue newValue = createConfigValue(prototype.getConfigName()); + List values = currentConfigurations.get(yearMonth); + if (values == null) { + values = new ArrayList<>(); + currentConfigurations.put(yearMonth, values); + } + values.add(newValue); } public void removeAllConfigurationsForYearMonth(String yearMonth) { - + currentConfigurations.remove(yearMonth); } private ConfigValue createConfigValue(String name) { diff --git a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java b/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java index 9193a35..ec95937 100644 --- a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java +++ b/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java @@ -29,11 +29,7 @@ public List getConfigurationsForYearMonth( @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.DELETE) public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") String yearMonth) { - try { - System.err.println("HERE deleteConfigurationsForYearMonth"); - } catch (Exception ex) { - throw new RuntimeException(ex); - } + dao.removeAllConfigurationsForYearMonth(yearMonth); } @RequestMapping(value="/{yearMonthNumber}", method={ RequestMethod.POST, RequestMethod.PUT }) @@ -41,7 +37,6 @@ public void addConfigurationForYearMonth( @PathVariable("yearMonthNumber") String yearMonth, @RequestBody ConfigValue value) { - System.err.println("HERE addConfigurationForYearMonth"); - + dao.addConfiguration(yearMonth, value); } } diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index c90e536..81fcdb6 100644 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -35,7 +35,9 @@

Welcome To The Configuration App

- + + +