From b25938a53d9e1290375fc6a5aa6011f34f10cce5 Mon Sep 17 00:00:00 2001 From: "Levyco Development, LLC" Date: Sun, 3 May 2020 23:49:45 -0400 Subject: [PATCH 1/3] Completed Test Per ReadMe * wow, re-remember java was fun! * Spring is cool, hadn't used it in the "old days" --- configurationapp/.classpath | 49 ++++++++++ configurationapp/.project | 23 +++++ .../org.eclipse.core.resources.prefs | 4 + .../.settings/org.eclipse.jdt.apt.core.prefs | 2 + .../.settings/org.eclipse.jdt.core.prefs | 10 ++ .../.settings/org.eclipse.m2e.core.prefs | 4 + .../main/java/com/att/ConfigurationApp.java | 1 + .../dao/configurations/ConfigurationDao.java | 37 +++++++- .../ConfigurationController.java | 29 +++++- .../target/classes/application.properties | 6 ++ .../classes/com/att/ConfigurationApp.class | Bin 0 -> 718 bytes .../ConfigurationDao$IdProvider.class | Bin 0 -> 736 bytes .../dao/configurations/ConfigurationDao.class | Bin 0 -> 2753 bytes .../att/data/configurations/ConfigValue.class | Bin 0 -> 993 bytes .../ConfigurationController.class | Bin 0 -> 3023 bytes .../target/classes/static/css/main.css | 11 +++ .../target/classes/static/index.html | 50 ++++++++++ .../target/classes/static/js/app.js | 88 ++++++++++++++++++ 18 files changed, 305 insertions(+), 9 deletions(-) create mode 100644 configurationapp/.classpath create mode 100644 configurationapp/.project create mode 100644 configurationapp/.settings/org.eclipse.core.resources.prefs create mode 100644 configurationapp/.settings/org.eclipse.jdt.apt.core.prefs create mode 100644 configurationapp/.settings/org.eclipse.jdt.core.prefs create mode 100644 configurationapp/.settings/org.eclipse.m2e.core.prefs create mode 100644 configurationapp/target/classes/application.properties create mode 100644 configurationapp/target/classes/com/att/ConfigurationApp.class create mode 100644 configurationapp/target/classes/com/att/dao/configurations/ConfigurationDao$IdProvider.class create mode 100644 configurationapp/target/classes/com/att/dao/configurations/ConfigurationDao.class create mode 100644 configurationapp/target/classes/com/att/data/configurations/ConfigValue.class create mode 100644 configurationapp/target/classes/com/att/web/configuarations/ConfigurationController.class create mode 100644 configurationapp/target/classes/static/css/main.css create mode 100644 configurationapp/target/classes/static/index.html create mode 100644 configurationapp/target/classes/static/js/app.js diff --git a/configurationapp/.classpath b/configurationapp/.classpath new file mode 100644 index 0000000..39abf1c --- /dev/null +++ b/configurationapp/.classpath @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/configurationapp/.project b/configurationapp/.project new file mode 100644 index 0000000..a04eb8b --- /dev/null +++ b/configurationapp/.project @@ -0,0 +1,23 @@ + + + configurationapp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/configurationapp/.settings/org.eclipse.core.resources.prefs b/configurationapp/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..abdea9a --- /dev/null +++ b/configurationapp/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +encoding//src/main/java=UTF-8 +encoding//src/main/resources=UTF-8 +encoding/=UTF-8 diff --git a/configurationapp/.settings/org.eclipse.jdt.apt.core.prefs b/configurationapp/.settings/org.eclipse.jdt.apt.core.prefs new file mode 100644 index 0000000..d4313d4 --- /dev/null +++ b/configurationapp/.settings/org.eclipse.jdt.apt.core.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.apt.aptEnabled=false diff --git a/configurationapp/.settings/org.eclipse.jdt.core.prefs b/configurationapp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..951833c --- /dev/null +++ b/configurationapp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,10 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.methodParameters=generate +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.processAnnotations=disabled +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/configurationapp/.settings/org.eclipse.m2e.core.prefs b/configurationapp/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/configurationapp/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/configurationapp/src/main/java/com/att/ConfigurationApp.java b/configurationapp/src/main/java/com/att/ConfigurationApp.java index 1ea7d60..f328da6 100644 --- a/configurationapp/src/main/java/com/att/ConfigurationApp.java +++ b/configurationapp/src/main/java/com/att/ConfigurationApp.java @@ -9,4 +9,5 @@ public class ConfigurationApp { public static void main(String[] args) { SpringApplication.run(ConfigurationApp.class, args); } + } 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..4b80b2d 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,13 @@ import com.att.data.configurations.ConfigValue; import org.springframework.stereotype.Service; +//import javafx.util.converter.CurrencyStringConverter; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Iterator; @Service public class ConfigurationDao { @@ -33,16 +36,40 @@ public ConfigurationDao() { currentConfigurations = new HashMap<>(); } - public List getConfigurationsForYearMonth(String yearMonth) { - return new ArrayList<>(); + public List getConfigurations(String yearMonth) { + if (currentConfigurations.containsKey(yearMonth)) { + return currentConfigurations.get(yearMonth); + } + else { + return new ArrayList<>(); + } } public void addConfiguration(String yearMonth, ConfigValue value) { - int newId = idProvider.getNextId(); - + if (!currentConfigurations.containsKey(yearMonth)) { + currentConfigurations.put(yearMonth,new ArrayList<>()); + } + if (currentConfigurations.containsKey(yearMonth)) { + value.setConfigId(idProvider.getNextId()); + currentConfigurations.get(yearMonth).add(value); + } } - public void removeAllConfigurationsForYearMonth(String yearMonth) { + public void removeConfiguration(String yearMonth, int id) { + if (currentConfigurations.containsKey(yearMonth)) { + Iterator i = currentConfigurations.get(yearMonth).iterator(); + while (i.hasNext()) { + ConfigValue item = i.next(); + if (item.getConfigId() == id) { + i.remove(); + } + } + } + } + public void removeAllConfigurations(String yearMonth) { + if (currentConfigurations.containsKey(yearMonth)) { + currentConfigurations.get(yearMonth).clear(); + } } } 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..1fa9fe5 100644 --- a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java +++ b/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java @@ -5,7 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.util.ArrayList; +//import java.util.ArrayList; import java.util.List; @RestController @@ -17,6 +17,17 @@ public class ConfigurationController { @Autowired public ConfigurationController(ConfigurationDao dao) { this.dao = dao; + this.dao.addConfiguration("012018", new ConfigValue("Test-012018-1",0)); + this.dao.addConfiguration("012018", new ConfigValue("Test-012018-2",0)); + this.dao.addConfiguration("012018", new ConfigValue("Test-012018-3",0)); + this.dao.addConfiguration("012018", new ConfigValue("Test-012018-4",0)); + this.dao.addConfiguration("012018", new ConfigValue("Test-012018-5",0)); + + this.dao.addConfiguration("022018", new ConfigValue("Test-202018-1",0)); + this.dao.addConfiguration("022018", new ConfigValue("Test-202018-2",0)); + this.dao.addConfiguration("022018", new ConfigValue("Test-202018-3",0)); + this.dao.addConfiguration("022018", new ConfigValue("Test-202018-4",0)); + this.dao.addConfiguration("022018", new ConfigValue("Test-202018-5",0)); } @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.GET) @@ -24,13 +35,22 @@ public ConfigurationController(ConfigurationDao dao) { public List getConfigurationsForYearMonth( @PathVariable("yearMonthNumber") String yearMonth) { - return new ArrayList<>(); + return dao.getConfigurations(yearMonth); } @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.DELETE) public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") String yearMonth) { try { + dao.removeAllConfigurations(yearMonth); + } catch (Exception ex) { + + } + } + @RequestMapping(value="/{yearMonthNumber}/{id}", method=RequestMethod.DELETE) + public void deleteConfigurationForYearMonth(@PathVariable("yearMonthNumber") String yearMonth, @PathVariable("id") int id) { + try { + dao.removeConfiguration(yearMonth, id); } catch (Exception ex) { } @@ -39,7 +59,8 @@ public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") St @RequestMapping(value="/{yearMonthNumber}", method={ RequestMethod.POST, RequestMethod.PUT }) public void addConfigurationForYearMonth( @PathVariable("yearMonthNumber") String yearMonth, - @RequestBody ConfigValue value) { - + @RequestBody String name) { + dao.addConfiguration(yearMonth, new ConfigValue(name,0)); } + } diff --git a/configurationapp/target/classes/application.properties b/configurationapp/target/classes/application.properties new file mode 100644 index 0000000..6c77a8e --- /dev/null +++ b/configurationapp/target/classes/application.properties @@ -0,0 +1,6 @@ +server.port=9000 +spring.mvc.favicon.enabled=false + +logging.level.root=WARN +logging.level.org.springframework.web=DEBUG +logging.level.org.hibernate=ERROR \ No newline at end of file diff --git a/configurationapp/target/classes/com/att/ConfigurationApp.class b/configurationapp/target/classes/com/att/ConfigurationApp.class new file mode 100644 index 0000000000000000000000000000000000000000..55b723fa6bfc81eddc0dc45e63a0d2362d031088 GIT binary patch literal 718 zcmZ`%%TD7k6g@62Eup;1`?X+Kx*!`gnPXP@FIQ`iDj5Rl1kcRhN<@cfT7yccOt+PW}2vBnqeW5N}QK@EX*~JGr`b`bi%U% zH`2wQ$*O&j1;bYK-TW?L=Ugg=wf1c^+M{ocRB3mA5MT+*b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VC>uONGXFFR;IvKXquE6;g1sSPIq2gKvBW;ykMvkppJ093o$Nk0m#P3`}`= zQRf-Gb-U=?b5_Z$?UXh3U4;_P$h|$SP=WU6THK`5c=d8Wt18bwu)1V{d5a0{xCE+RxQOp->+% zf^~u3gY6f;&#OIs>a%awU73Hz^7;*Nx&@$m0rxi--gsr1tbWKcHJYtBzSJjNZxu}) z6ald$kZL@q>US7wk#RG5`br3|uB=lnZL6Dn&mKWDo~V7vgiCB*fzEZi;^fsmOCJ`g zI@C1$+wh_$@o4>1*2jUroD%A)zcO%^H%%MwXws*z8;;sJjvz{Jj8+G&PX2ztDdV(4 z9RD@?4)M{kU(r4K2HnY?-_g63Jkjm1E-9KsEc*c3-M`OH6tDC1My;;+I2x4gqy zclpGrRxI+FFXNsrfHz+kAf`zkdyD(O(5Pmh>jYe=K@0=(O(2fR8f1w8S;9xQ!TJ1) z_%OoN^)NSavL(!HKv)%Ke~17AvV!3wk2i}@!Wxo?IQ14^5b|;ra*W{WA<1SAF@vH5gwBZAAC9h9}95~_*L`#6~6Wp7;NS_q$~bJzrOLvPBvumEko$S zZ?N+;_Pw-cv=Awn_UY JQCBsp{sqd3;=BL= literal 0 HcmV?d00001 diff --git a/configurationapp/target/classes/static/css/main.css b/configurationapp/target/classes/static/css/main.css new file mode 100644 index 0000000..d03098f --- /dev/null +++ b/configurationapp/target/classes/static/css/main.css @@ -0,0 +1,11 @@ +.controls { + +} + +.config-table-wrapper { + +} + +.content { + +} \ No newline at end of file diff --git a/configurationapp/target/classes/static/index.html b/configurationapp/target/classes/static/index.html new file mode 100644 index 0000000..8ecfbf3 --- /dev/null +++ b/configurationapp/target/classes/static/index.html @@ -0,0 +1,50 @@ + + + + Configuration App + + + + + + +

Welcome To The Configuration App

+
+
+ +
+
+ + + + + + + + + + + +
Configuration IdConfiguration NameDelete
+
+
+ + + +
+
+ + + \ No newline at end of file diff --git a/configurationapp/target/classes/static/js/app.js b/configurationapp/target/classes/static/js/app.js new file mode 100644 index 0000000..dc95e18 --- /dev/null +++ b/configurationapp/target/classes/static/js/app.js @@ -0,0 +1,88 @@ +(function() { + function App() { + this.table = null; + this.curMY = "012018"; + } + + // SORRY!!! hard-coded urls! + + App.prototype.getData = function(id) { + this.curMY = id; + $.ajax({ + url:'/configuration/'+id, method:'GET' + }).then(function(data) { + window.app.table.clear(); + window.app.table.rows.add(data); + window.app.table.draw(); + }) + }; + + App.prototype.delItem = function (id, value) { + if (confirm("Are you sure you want to delete " + value + "?")) { + $.ajax({ + url:'/configuration/'+window.app.curMY+'/'+id, method:'DELETE' + }).then(function(data) { + window.app.getData(window.app.curMY); + }); + } + }; + + App.prototype.addItem = function () { + var v = prompt("Enter the new configuration:", ""); + if (v != "") { + $.ajax({ + url:'/configuration/'+window.app.curMY, method:'POST', + contentType:'text/plain', + data:v + }).then(function(data) { + window.app.getData(window.app.curMY); + }) + } + }; + + App.prototype.clearAll = function () { + if (confirm("Are you sure you want to delete all the configurations for " + this.curMY + "?")) { + $.ajax({ + url:'/configuration/'+window.app.curMY, method:'DELETE' + }).then(function(data) { + window.app.getData(window.app.curMY); + }) + } + }; + + App.prototype.init = function() { + this.table = $('#configTable').DataTable({ + scrollY: 300, + paging: false, + sorting: false, + searching: false, + info: false, + columns:[ + {data:'configId'}, + {data:'configName'}, + {'render': function ( data, type, row ) { + return 'X'; + } + } + ] + }); + $("#timePeriod").change( + function() { + window.app.getData(this.options[this.selectedIndex].value); + } + ); + $("#addConfigurationItem").click( + function() { + window.app.addItem(); + } + ); + $("#clearConfiguration").click( + function() { + window.app.clearAll(); + } + ); + window.app.getData(this.curMY); + }; + + window.app = new App; +})($); \ No newline at end of file From 8bf13b23c9accfe4b8a1769bb702df6afe15df28 Mon Sep 17 00:00:00 2001 From: "Levyco Development, LLC" Date: Mon, 4 May 2020 08:18:01 -0400 Subject: [PATCH 2/3] Commit to include original source file edits these resource files were not saved before the last commit --- .../src/main/resources/static/index.html | 7 +- .../src/main/resources/static/js/app.js | 75 +++++++++++++++++-- .../target/classes/static/index.html | 2 +- 3 files changed, 75 insertions(+), 9 deletions(-) diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index 7cd14ba..ad59f35 100644 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -2,7 +2,7 @@ Configuration App - + @@ -27,6 +27,7 @@

Welcome To The Configuration App

Configuration Id Configuration Name + Delete @@ -35,7 +36,9 @@

Welcome To The Configuration App

- + + +