From da116e0c156873333d0a557e9cd6c827c3fb088c Mon Sep 17 00:00:00 2001 From: gregcanter <5223851+gregcanter@users.noreply.github.com> Date: Sun, 23 Jun 2019 20:11:21 -0400 Subject: [PATCH 1/5] 1st commit - added H2 in-memory database and lombok to pom; added gitignore file; Added GREGS-README.md file for notes --- .gitignore | 153 ++++++++++++++++++ configurationapp/GREGS-README.md | 0 configurationapp/pom.xml | 10 +- .../src/main/java/com/att/init/Bootstrap.java | 13 ++ .../main/java/com/att/init/DevBootstrap.java | 13 ++ 5 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 .gitignore create mode 100644 configurationapp/GREGS-README.md create mode 100644 configurationapp/src/main/java/com/att/init/Bootstrap.java create mode 100644 configurationapp/src/main/java/com/att/init/DevBootstrap.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9fd246c --- /dev/null +++ b/.gitignore @@ -0,0 +1,153 @@ +###################### +# Project Specific +###################### +/build/www/** +/src/test/javascript/coverage/ +/src/test/javascript/PhantomJS*/ + +###################### +# Node +###################### +/node/ +node_tmp/ +node_modules/ +npm-debug.log.* + +###################### +# SASS +###################### +.sass-cache/ + +###################### +# Eclipse +###################### +*.pydevproject +.project +.metadata +tmp/ +tmp/**/* +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath +.factorypath +/src/main/resources/rebel.xml + +# External tool builders +.externalToolBuilders/** + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + +###################### +# Intellij +###################### +.idea/ +*.iml +*.iws +*.ipr +*.ids +*.orig + +###################### +# Visual Studio Code +###################### +.vscode/ + +###################### +# Maven +###################### +/log/ +/target/ + +###################### +# Gradle +###################### +.gradle/ +/build/ + +###################### +# Package Files +###################### +*.jar +*.war +*.ear +*.db + +###################### +# Windows +###################### +# Windows image file caches +Thumbs.db + +# Folder config file +Desktop.ini + +###################### +# Mac OSX +###################### +.DS_Store +.svn + +# Thumbnails +._* + +# Files that might appear on external disk +.Spotlight-V100 +.Trashes + +###################### +# Directories +###################### +/bin/ +/deploy/ + +###################### +# Logs +###################### +*.log + +###################### +# Others +###################### +*.class +*.*~ +*~ +.merge_file* + +###################### +# Gradle Wrapper +###################### +!gradle/wrapper/gradle-wrapper.jar + +###################### +# Maven Wrapper +###################### +!.mvn/wrapper/maven-wrapper.jar + +###################### +# ESLint +###################### +.eslintcache +© 2019 GitHub, Inc. +Terms +Privacy +Security +Status +Help +Contact GitHub +Pricing +API +Training +Blog +About diff --git a/configurationapp/GREGS-README.md b/configurationapp/GREGS-README.md new file mode 100644 index 0000000..e69de29 diff --git a/configurationapp/pom.xml b/configurationapp/pom.xml index 78931d3..c2fbb59 100644 --- a/configurationapp/pom.xml +++ b/configurationapp/pom.xml @@ -39,8 +39,16 @@ spring-boot-starter-test test + + org.springframework.boot + spring-boot-starter-thymeleaf + + + com.h2database + h2 + runtime + - diff --git a/configurationapp/src/main/java/com/att/init/Bootstrap.java b/configurationapp/src/main/java/com/att/init/Bootstrap.java new file mode 100644 index 0000000..933ace8 --- /dev/null +++ b/configurationapp/src/main/java/com/att/init/Bootstrap.java @@ -0,0 +1,13 @@ +package com.att.init; + +/** + *

com.att.init.Bootstrap

+ * Description : + * + * @author gcanter + * on 2019-06-23 + */ + + +public class Bootstrap { +} diff --git a/configurationapp/src/main/java/com/att/init/DevBootstrap.java b/configurationapp/src/main/java/com/att/init/DevBootstrap.java new file mode 100644 index 0000000..6fc5ff6 --- /dev/null +++ b/configurationapp/src/main/java/com/att/init/DevBootstrap.java @@ -0,0 +1,13 @@ +package com.att.init; + +/** + *

com.att.init.DevBootstrap

+ * Description : + * + * @author gcanter + * on 2019-06-23 + */ + + +public class DevBootstrap { +} From 17fbcef9b17daf807f4fd2486328000812e82b98 Mon Sep 17 00:00:00 2001 From: gregcanter <5223851+gregcanter@users.noreply.github.com> Date: Mon, 24 Jun 2019 13:59:19 -0400 Subject: [PATCH 2/5] Made changes in the model, controller, and added a service layer. Also added bootstrap files for initializing the database. --- configurationapp/GREGS-README.md | 8 ++ configurationapp/configurationapp.iml | 116 ++++++++++++++++++ configurationapp/pom.xml | 18 ++- .../main/java/com/att/ConfigurationApp.java | 4 + .../att/data/configurations/ConfigValue.java | 81 +++++++++--- .../src/main/java/com/att/init/Bootstrap.java | 37 +++++- .../main/java/com/att/init/DevBootstrap.java | 13 -- .../repositories/ConfigValueRepository.java | 21 ++++ .../com/att/services/ConfigValueService.java | 21 ++++ .../ConfigValueController.java} | 33 +++-- .../src/main/resources/application.properties | 13 +- configurationapp/src/main/resources/data.sql | 4 + .../src/main/resources/schema.sql | 6 + .../src/main/resources/static/index.html | 2 +- .../src/main/resources/static/js/app.js | 8 +- 15 files changed, 337 insertions(+), 48 deletions(-) create mode 100644 configurationapp/configurationapp.iml delete mode 100644 configurationapp/src/main/java/com/att/init/DevBootstrap.java create mode 100644 configurationapp/src/main/java/com/att/repositories/ConfigValueRepository.java create mode 100644 configurationapp/src/main/java/com/att/services/ConfigValueService.java rename configurationapp/src/main/java/com/att/web/{configuarations/ConfigurationController.java => controllers/ConfigValueController.java} (52%) create mode 100644 configurationapp/src/main/resources/data.sql create mode 100644 configurationapp/src/main/resources/schema.sql diff --git a/configurationapp/GREGS-README.md b/configurationapp/GREGS-README.md index e69de29..3ddc3c7 100644 --- a/configurationapp/GREGS-README.md +++ b/configurationapp/GREGS-README.md @@ -0,0 +1,8 @@ +# Notes + +* commit with this value : + gregcanter <5223851+gregcanter@users.noreply.github.com> + + + + \ No newline at end of file diff --git a/configurationapp/configurationapp.iml b/configurationapp/configurationapp.iml new file mode 100644 index 0000000..e7479c5 --- /dev/null +++ b/configurationapp/configurationapp.iml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/configurationapp/pom.xml b/configurationapp/pom.xml index c2fbb59..146895c 100644 --- a/configurationapp/pom.xml +++ b/configurationapp/pom.xml @@ -28,7 +28,19 @@ org.springframework.boot spring-boot-starter-web - + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + org.springframework.boot + spring-boot-devtools + runtime + org.springframework.boot spring-boot-devtools @@ -48,6 +60,10 @@ h2 runtime + + org.projectlombok + lombok + diff --git a/configurationapp/src/main/java/com/att/ConfigurationApp.java b/configurationapp/src/main/java/com/att/ConfigurationApp.java index 1ea7d60..4f4215f 100644 --- a/configurationapp/src/main/java/com/att/ConfigurationApp.java +++ b/configurationapp/src/main/java/com/att/ConfigurationApp.java @@ -2,7 +2,11 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.data.jpa.repository.config.EnableJpaRepositories; +@EntityScan +@EnableJpaRepositories @SpringBootApplication public class ConfigurationApp { diff --git a/configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java b/configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java index 55339a3..7acf008 100644 --- a/configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java +++ b/configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java @@ -1,34 +1,81 @@ package com.att.data.configurations; +import lombok.Getter; +import lombok.Setter; +import javax.persistence.*; +import javax.persistence.Entity; +import java.util.Date; +import java.util.Objects; + /** * Data Model */ + +@Getter +@Setter +@Entity public class ConfigValue { - private String configName; - private int configId; - public ConfigValue(String name, int id) { - this.configId = id; - this.configName = name; - } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private int configID; - public ConfigValue() { + @Column(nullable = true) + private String configName; // 'A, B, C, D' etc - } + @Column(nullable = true) + private String configDate; // 022019 for Feb 2019 - public void setConfigName(String name) { - this.configName = name; - } - public String getConfigName() { - return this.configName; + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ConfigValue that = (ConfigValue) o; + return configID == that.configID; } - public void setConfigId(int id) { - this.configId = id; + @Override + public int hashCode() { + return Objects.hash(configID); } - public int getConfigId() { - return this.configId; + @Override + public String toString() { + return "ConfigValue{" + + "configID=" + configID + + ", configName='" + configName + '\'' + + ", configDate='" + configDate + '\'' + + '}'; } } + + + + + +// public ConfigValue(String name, int id) { +// this.configId = id; +// this.configName = name; +// } + +// public ConfigValue() { +// +// } + +// public void setConfigName(String name) { +// this.configName = name; +// } +// +// public String getConfigName() { +// return this.configName; +// } +// +// public void setConfigId(int id) { +// this.configId = id; +// } +// +// public int getConfigId() { +// return this.configId; +// } +//} diff --git a/configurationapp/src/main/java/com/att/init/Bootstrap.java b/configurationapp/src/main/java/com/att/init/Bootstrap.java index 933ace8..8988530 100644 --- a/configurationapp/src/main/java/com/att/init/Bootstrap.java +++ b/configurationapp/src/main/java/com/att/init/Bootstrap.java @@ -1,13 +1,46 @@ package com.att.init; +import com.att.data.configurations.ConfigValue; +import com.att.repositories.ConfigValueRepository; +import org.springframework.context.ApplicationListener; +import org.springframework.context.event.ContextRefreshedEvent; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + + /** *

com.att.init.Bootstrap

- * Description : + * Description : This class seeds the database with a few values. Does this thru Crudrepository/Spring/H2 * * @author gcanter * on 2019-06-23 */ -public class Bootstrap { +// todo :: @log4j +@Component +public class Bootstrap implements ApplicationListener { + + private ConfigValueRepository configValueRepository; + + public Bootstrap(ConfigValueRepository configValueRepository) { + this.configValueRepository = configValueRepository; + } + + @Override + public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { + initData(); + } + + +private void initData() { + ConfigValue configValue = new ConfigValue(); + configValue.setConfigID(1); + configValue.setConfigName("Alpha"); + configValue.setConfigDate("022019"); + + configValueRepository.save(configValue); } + + +} \ No newline at end of file diff --git a/configurationapp/src/main/java/com/att/init/DevBootstrap.java b/configurationapp/src/main/java/com/att/init/DevBootstrap.java deleted file mode 100644 index 6fc5ff6..0000000 --- a/configurationapp/src/main/java/com/att/init/DevBootstrap.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.att.init; - -/** - *

com.att.init.DevBootstrap

- * Description : - * - * @author gcanter - * on 2019-06-23 - */ - - -public class DevBootstrap { -} diff --git a/configurationapp/src/main/java/com/att/repositories/ConfigValueRepository.java b/configurationapp/src/main/java/com/att/repositories/ConfigValueRepository.java new file mode 100644 index 0000000..d6f601a --- /dev/null +++ b/configurationapp/src/main/java/com/att/repositories/ConfigValueRepository.java @@ -0,0 +1,21 @@ +package com.att.repositories; + +import com.att.dao.configurations.ConfigurationDao; +import com.att.data.configurations.ConfigValue; +import org.springframework.data.repository.CrudRepository; + +import java.util.List; + +/** + *

com.att.repositories.ConfigurationRepository

+ * Description : + * + * @author gcanter + * on 2019-06-23 + */ + + +public interface ConfigValueRepository extends CrudRepository { + List findByConfigID( int ConfigID); + +} diff --git a/configurationapp/src/main/java/com/att/services/ConfigValueService.java b/configurationapp/src/main/java/com/att/services/ConfigValueService.java new file mode 100644 index 0000000..9841ce8 --- /dev/null +++ b/configurationapp/src/main/java/com/att/services/ConfigValueService.java @@ -0,0 +1,21 @@ +package com.att.services; + +import com.att.data.configurations.ConfigValue; + +import java.util.List; + +import com.att.data.configurations.ConfigValue; + +/** + *

com.att.services.ConfigurationService

+ * Description : + * + * @author gcanter + * on 2019-06-23 + */ + + +public interface ConfigValueService { + List findByConfigDate(); + ConfigValue getConfigValueByName(); +} diff --git a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java b/configurationapp/src/main/java/com/att/web/controllers/ConfigValueController.java similarity index 52% rename from configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java rename to configurationapp/src/main/java/com/att/web/controllers/ConfigValueController.java index 995402a..b99cecc 100644 --- a/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java +++ b/configurationapp/src/main/java/com/att/web/controllers/ConfigValueController.java @@ -1,8 +1,10 @@ -package com.att.web.configuarations; +package com.att.web.controllers; import com.att.dao.configurations.ConfigurationDao; import com.att.data.configurations.ConfigValue; +import com.att.repositories.ConfigValueRepository; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.*; import java.util.ArrayList; @@ -10,22 +12,33 @@ @RestController @RequestMapping(value="/configuration") -public class ConfigurationController { +public class ConfigValueController { - private ConfigurationDao dao; + //private ConfigurationDao dao; + private ConfigValueRepository configValueRepository; - @Autowired - public ConfigurationController(ConfigurationDao dao) { - this.dao = dao; + + public ConfigValueController (ConfigValueRepository configValueRepository) { + this.configValueRepository = configValueRepository; } +// @Autowired +// public ConfigValueController(ConfigurationDao dao) { +// this.dao = dao; +// } + @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.GET) - @ResponseBody - public List getConfigurationsForYearMonth( - @PathVariable("yearMonthNumber") String yearMonth) { + public String getConfigValues(Model model) { + model.addAttribute("configValues", configValueRepository.findAll()); - return new ArrayList<>(); + return "index"; } +// @ResponseBody +// public List getConfigurationsForYearMonth( +// @PathVariable("yearMonthNumber") String yearMonth) { +// +// return new ArrayList<>(); +// } @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.DELETE) public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") String yearMonth) { diff --git a/configurationapp/src/main/resources/application.properties b/configurationapp/src/main/resources/application.properties index 6c77a8e..e17ca3f 100644 --- a/configurationapp/src/main/resources/application.properties +++ b/configurationapp/src/main/resources/application.properties @@ -3,4 +3,15 @@ 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 +logging.level.org.hibernate=ERROR + +spring.h2.console.enabled=true + +spring.datasource.url=jdbc:h2:mem:testdb + +#spring.datasource.url=jdbc:h2:file:/data/demo + +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect \ No newline at end of file diff --git a/configurationapp/src/main/resources/data.sql b/configurationapp/src/main/resources/data.sql new file mode 100644 index 0000000..3e6756d --- /dev/null +++ b/configurationapp/src/main/resources/data.sql @@ -0,0 +1,4 @@ +INSERT INTO `Config` (`configID`, `configName`, `configDate`) VALUES (1, 'A', '022019'); +INSERT INTO `Config` (`configID`, `configName`, `configDate`) VALUES (2, 'B', '022019'); +INSERT INTO `Config` (`configID`, `configName`, `configDate`) VALUES (3, 'C', '022019'); +INSERT INTO `Config` (`configID`, `configName`, `configDate`) VALUES (4, 'D', '022019'); \ No newline at end of file diff --git a/configurationapp/src/main/resources/schema.sql b/configurationapp/src/main/resources/schema.sql new file mode 100644 index 0000000..5ec3d71 --- /dev/null +++ b/configurationapp/src/main/resources/schema.sql @@ -0,0 +1,6 @@ + +CREATE TABLE Config ( + configID bigint NOT NULL auto_increment primary key, + configName VARCHAR(50) NULL DEFAULT NULL, + configDate VARCHAR(50) NULL DEFAULT NULL +); \ No newline at end of file diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index 7cd14ba..e5789ff 100644 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -22,7 +22,7 @@

Welcome To The Configuration App

- +
diff --git a/configurationapp/src/main/resources/static/js/app.js b/configurationapp/src/main/resources/static/js/app.js index 2d4b945..9ba6a11 100644 --- a/configurationapp/src/main/resources/static/js/app.js +++ b/configurationapp/src/main/resources/static/js/app.js @@ -14,12 +14,14 @@ App.prototype.init = function() { $('#configTable').DataTable({ scrollY: 300, - paging: false, - sorting: false, + paging: true, + sorting: true, + ordering: true, + select: true, searching: false, info: false }); }; window.app = new App; -})($); \ No newline at end of file +})($); From 0b43a5f0ed87f3938799f1836e150a60947ee179 Mon Sep 17 00:00:00 2001 From: gregcanter <5223851+gregcanter@users.noreply.github.com> Date: Tue, 25 Jun 2019 09:41:20 -0400 Subject: [PATCH 3/5] Shook out datatable-spring problem by using special datatable repo library that extends JpaRepository. Application will do the following : show all items in grid; remove items in grid for a selected month. --- configurationapp/configurationapp.iml | 49 +++++- configurationapp/pom.xml | 25 ++- .../main/java/com/att/ConfigurationApp.java | 5 +- .../com/att/Init/ConfigvaluesInitializer.java | 56 ++++++ .../controllers/ConfigvaluesController.java | 160 ++++++++++++++++++ .../dao/configurations/ConfigurationDao.java | 48 ------ .../att/data/configurations/ConfigValue.java | 81 --------- .../exceptions/ConfigNotFoundException.java | 28 +++ .../src/main/java/com/att/init/Bootstrap.java | 46 ----- .../main/java/com/att/model/Configvalues.java | 30 ++++ .../repositories/ConfigValueRepository.java | 21 --- .../repositories/ConfigvaluesRepository.java | 28 +++ .../com/att/services/ConfigValueService.java | 21 --- .../controllers/ConfigValueController.java | 58 ------- configurationapp/src/main/resources/data.sql | 8 +- .../src/main/resources/schema.sql | 6 - .../src/main/resources/static/css/main.css | 11 -- .../src/main/resources/static/index.html | 150 ++++++++++++---- .../static/js/jquery.spring-friendly.js | 73 ++++++++ .../src/test/com/att/BootstrapTest.java | 48 ++++++ .../com/att/SpringContextIntegrationTest.java | 24 +++ .../target/classes/application.properties | 17 ++ configurationapp/target/classes/data.sql | 4 + .../target/classes/static/index.html | 123 ++++++++++++++ .../target/classes/static/js/app.js | 27 +++ .../static/js/jquery.spring-friendly.js | 73 ++++++++ .../target/configurationapp.jar.original | Bin 0 -> 8128 bytes .../target/maven-archiver/pom.properties | 4 + .../compile/default-compile/createdFiles.lst | 5 + .../compile/default-compile/inputFiles.lst | 4 + 30 files changed, 887 insertions(+), 346 deletions(-) create mode 100755 configurationapp/src/main/java/com/att/Init/ConfigvaluesInitializer.java create mode 100644 configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java delete mode 100644 configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java delete mode 100644 configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java create mode 100644 configurationapp/src/main/java/com/att/exceptions/ConfigNotFoundException.java delete mode 100644 configurationapp/src/main/java/com/att/init/Bootstrap.java create mode 100644 configurationapp/src/main/java/com/att/model/Configvalues.java delete mode 100644 configurationapp/src/main/java/com/att/repositories/ConfigValueRepository.java create mode 100644 configurationapp/src/main/java/com/att/repositories/ConfigvaluesRepository.java delete mode 100644 configurationapp/src/main/java/com/att/services/ConfigValueService.java delete mode 100644 configurationapp/src/main/java/com/att/web/controllers/ConfigValueController.java delete mode 100644 configurationapp/src/main/resources/schema.sql delete mode 100644 configurationapp/src/main/resources/static/css/main.css mode change 100644 => 100755 configurationapp/src/main/resources/static/index.html create mode 100755 configurationapp/src/main/resources/static/js/jquery.spring-friendly.js create mode 100644 configurationapp/src/test/com/att/BootstrapTest.java create mode 100644 configurationapp/src/test/com/att/SpringContextIntegrationTest.java create mode 100644 configurationapp/target/classes/application.properties create mode 100644 configurationapp/target/classes/data.sql create mode 100755 configurationapp/target/classes/static/index.html create mode 100644 configurationapp/target/classes/static/js/app.js create mode 100755 configurationapp/target/classes/static/js/jquery.spring-friendly.js create mode 100644 configurationapp/target/configurationapp.jar.original create mode 100644 configurationapp/target/maven-archiver/pom.properties create mode 100644 configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/configurationapp/configurationapp.iml b/configurationapp/configurationapp.iml index e7479c5..80a3010 100644 --- a/configurationapp/configurationapp.iml +++ b/configurationapp/configurationapp.iml @@ -9,6 +9,10 @@ + + + + @@ -17,6 +21,7 @@ + @@ -33,9 +38,6 @@ - - - @@ -44,7 +46,6 @@ - @@ -92,7 +93,7 @@ - + @@ -104,7 +105,43 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Configuration Id
- - - - - - - - - -
Configuration IdConfiguration Name
-
-
- -
+ + + + + + + + + + + + + + + + + + + + + + + + +

Welcome To The Configuration App

+ +

Current Configurations (All)

+ +
+ + + + + + + + +
Config IDConfig NameConfig Date
+ +

To Add a Configuration

+ +
+ + + + + + + + + + + + + + + + + + +
+ +

To Delete a Configuration for a Selected Month

+
+ + + + + + +
+ + + + + + + \ No newline at end of file diff --git a/configurationapp/src/main/resources/static/js/jquery.spring-friendly.js b/configurationapp/src/main/resources/static/js/jquery.spring-friendly.js new file mode 100755 index 0000000..c786bdd --- /dev/null +++ b/configurationapp/src/main/resources/static/js/jquery.spring-friendly.js @@ -0,0 +1,73 @@ +// From https://github.com/jquery/jquery/blob/master/src/serialize.js +// Overrides data serialization to allow Spring MVC to correctly map input parameters : column[0][data] now becomes column[0].data +(function($) { + var r20 = /%20/g, rbracket = /\[\]$/, rCRLF = /\r?\n/g, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmittable = /^(?:input|select|textarea|keygen)/i; + + function customBuildParams(prefix, obj, traditional, add) { + var name; + + if (jQuery.isArray(obj)) { + // Serialize array item. + jQuery.each(obj, function(i, v) { + if (traditional || rbracket.test(prefix)) { + // Treat each array item as a scalar. + add(prefix, v); + + } else { + // Item is non-scalar (array or object), encode its numeric + // index. + customBuildParams(prefix + "[" + + (typeof v === "object" ? i : "") + "]", v, + traditional, add); + } + }); + + } else if (!traditional && jQuery.type(obj) === "object") { + // Serialize object item. + for (name in obj) { + // This is where the magic happens + customBuildParams(prefix + "." + name, obj[name], traditional, + add); + } + + } else { + // Serialize scalar item. + add(prefix, obj); + } + } + + $.param = function(a, traditional) { + var prefix, s = [], add = function(key, value) { + // If value is a function, invoke it and return its value + value = jQuery.isFunction(value) ? value() : (value == null ? "" + : value); + s[s.length] = encodeURIComponent(key) + "=" + + encodeURIComponent(value); + }; + + // Set traditional to true for jQuery <= 1.3.2 behavior. + if (traditional === undefined) { + traditional = jQuery.ajaxSettings + && jQuery.ajaxSettings.traditional; + } + + // If an array was passed in, assume that it is an array of form + // elements. + if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) { + // Serialize the form elements + jQuery.each(a, function() { + add(this.name, this.value); + }); + + } else { + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for (prefix in a) { + customBuildParams(prefix, a[prefix], traditional, add); + } + } + + // Return the resulting serialization + return s.join("&").replace(r20, "+"); + }; +})(jQuery); \ No newline at end of file diff --git a/configurationapp/src/test/com/att/BootstrapTest.java b/configurationapp/src/test/com/att/BootstrapTest.java new file mode 100644 index 0000000..77e2305 --- /dev/null +++ b/configurationapp/src/test/com/att/BootstrapTest.java @@ -0,0 +1,48 @@ +package com.att; + +/** + *

java.com.att.BootstrapTest

+ * Description : + * + * @author gcanter + * on 2019-06-24 + */ + + +import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic; +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + + +import org.springframework.http.HttpStatus; + +import io.restassured.RestAssured; +import io.restassured.response.Response; + +public class BootstrapTest { + + private static final String API_ROOT = "http://localhost:9000"; + + + // test to see if connection to http://localhost:9000 is working and returns all data + @Test + public void whenGetAllConfigs_thenOK() { + final Response response = RestAssured.get(API_ROOT); + assertEquals(HttpStatus.OK.value(), response.getStatusCode()); + } + + // Test to see if app returns just 1 single record + + + + + + + + + + + +} diff --git a/configurationapp/src/test/com/att/SpringContextIntegrationTest.java b/configurationapp/src/test/com/att/SpringContextIntegrationTest.java new file mode 100644 index 0000000..2495f44 --- /dev/null +++ b/configurationapp/src/test/com/att/SpringContextIntegrationTest.java @@ -0,0 +1,24 @@ +package com.att; + +/** + *

java.com.att.SpringContextIntegrationTest

+ * Description : Tests the Spring Context Integration to see if it loads. I always include it in + * all of my Spring Boot projects as the first test * + * @author gcanter + * on 2019-06-24 + */ + + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest +public class SpringContextIntegrationTest { + + @Test + public void contextLoads() { + } +} diff --git a/configurationapp/target/classes/application.properties b/configurationapp/target/classes/application.properties new file mode 100644 index 0000000..e17ca3f --- /dev/null +++ b/configurationapp/target/classes/application.properties @@ -0,0 +1,17 @@ +server.port=9000 +spring.mvc.favicon.enabled=false + +logging.level.root=WARN +logging.level.org.springframework.web=DEBUG +logging.level.org.hibernate=ERROR + +spring.h2.console.enabled=true + +spring.datasource.url=jdbc:h2:mem:testdb + +#spring.datasource.url=jdbc:h2:file:/data/demo + +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=sa +spring.datasource.password= +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect \ No newline at end of file diff --git a/configurationapp/target/classes/data.sql b/configurationapp/target/classes/data.sql new file mode 100644 index 0000000..9ce4cf4 --- /dev/null +++ b/configurationapp/target/classes/data.sql @@ -0,0 +1,4 @@ +INSERT INTO CONFIGVALUES (config_Name, config_Date) VALUES ('A', '022019'); +INSERT INTO CONFIGVALUES (config_Name, config_Date) VALUES ('B', '022019'); +INSERT INTO CONFIGVALUES (config_Name, config_Date) VALUES ('C', '032019'); +INSERT INTO CONFIGVALUES (config_Name, config_Date) VALUES ('D', '042019'); \ 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 100755 index 0000000..ee79762 --- /dev/null +++ b/configurationapp/target/classes/static/index.html @@ -0,0 +1,123 @@ + + + + + + + DataTables + + + + + + + + + + + + + + + + + + + + + + + + + + +

Welcome To The Configuration App

+ +

Current Configurations (All)

+ +
+ + + + + + + + +
Config IDConfig NameConfig Date
+
+ +

To Add a Configuration

+ +
+ + + + + + + + + + + + + + + + + + +
+ +

To Delete a Configuration for a Selected Month

+
+ + + + + + +
+ + + + + + + + + + \ 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..9ba6a11 --- /dev/null +++ b/configurationapp/target/classes/static/js/app.js @@ -0,0 +1,27 @@ +(function() { + function App() { + + } + + App.prototype.getData = function() { + $.ajax('',{ + + }).then(function(data) { + + }) + }; + + App.prototype.init = function() { + $('#configTable').DataTable({ + scrollY: 300, + paging: true, + sorting: true, + ordering: true, + select: true, + searching: false, + info: false + }); + }; + + window.app = new App; +})($); diff --git a/configurationapp/target/classes/static/js/jquery.spring-friendly.js b/configurationapp/target/classes/static/js/jquery.spring-friendly.js new file mode 100755 index 0000000..c786bdd --- /dev/null +++ b/configurationapp/target/classes/static/js/jquery.spring-friendly.js @@ -0,0 +1,73 @@ +// From https://github.com/jquery/jquery/blob/master/src/serialize.js +// Overrides data serialization to allow Spring MVC to correctly map input parameters : column[0][data] now becomes column[0].data +(function($) { + var r20 = /%20/g, rbracket = /\[\]$/, rCRLF = /\r?\n/g, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmittable = /^(?:input|select|textarea|keygen)/i; + + function customBuildParams(prefix, obj, traditional, add) { + var name; + + if (jQuery.isArray(obj)) { + // Serialize array item. + jQuery.each(obj, function(i, v) { + if (traditional || rbracket.test(prefix)) { + // Treat each array item as a scalar. + add(prefix, v); + + } else { + // Item is non-scalar (array or object), encode its numeric + // index. + customBuildParams(prefix + "[" + + (typeof v === "object" ? i : "") + "]", v, + traditional, add); + } + }); + + } else if (!traditional && jQuery.type(obj) === "object") { + // Serialize object item. + for (name in obj) { + // This is where the magic happens + customBuildParams(prefix + "." + name, obj[name], traditional, + add); + } + + } else { + // Serialize scalar item. + add(prefix, obj); + } + } + + $.param = function(a, traditional) { + var prefix, s = [], add = function(key, value) { + // If value is a function, invoke it and return its value + value = jQuery.isFunction(value) ? value() : (value == null ? "" + : value); + s[s.length] = encodeURIComponent(key) + "=" + + encodeURIComponent(value); + }; + + // Set traditional to true for jQuery <= 1.3.2 behavior. + if (traditional === undefined) { + traditional = jQuery.ajaxSettings + && jQuery.ajaxSettings.traditional; + } + + // If an array was passed in, assume that it is an array of form + // elements. + if (jQuery.isArray(a) || (a.jquery && !jQuery.isPlainObject(a))) { + // Serialize the form elements + jQuery.each(a, function() { + add(this.name, this.value); + }); + + } else { + // If traditional, encode the "old" way (the way 1.3.2 or older + // did it), otherwise encode params recursively. + for (prefix in a) { + customBuildParams(prefix, a[prefix], traditional, add); + } + } + + // Return the resulting serialization + return s.join("&").replace(r20, "+"); + }; +})(jQuery); \ No newline at end of file diff --git a/configurationapp/target/configurationapp.jar.original b/configurationapp/target/configurationapp.jar.original new file mode 100644 index 0000000000000000000000000000000000000000..a2dfe08362959357d443a41e9e2d5ac216966f96 GIT binary patch literal 8128 zcmb7J2{@GP*B@gaM2uYtr9rkK5t4l!`x0dtV~^}aO4hQZ>_kLkPqxS|ge)mrWZxp$ zw-&_znY=Q*)%U&kT+cPnb6w|m&b^#-?sNZcb!A*U2#AP?2$XBrs~Wt?@Z~iK1d_l3 zfuO)YLRMRnTTxYx7a^&tC?~6>&4ZA$yDxba%uf-pNV3Tc7FSE*`awk>;0yS zKtIi^kE*E#MpDbEtfq?9;BrCQ>YftIRnT#0j`rXOlQG zPyg^*o<2R&+B45UD&-Z)R9U*{3nTq;NiTL3Q>&Zq<2iRZ?m2nu zu;U8^%n#TW8CEZDH{;XN>n_wW2?mF-{kNBIh4KKUo-(D`YC~QaruiBDVCJGx#?dd znGQ*!?5|l^Te>2hfT7!8`&(bJZI~hL|6+p?%LYdB9~=L-39mcrT@ljMQ=JC9@WVKdooD9k*WtEF4>1ID<+e-Jmgj1qcD3$z+43D6E#Af+%?4|OPy9uJ%SwM7f+ORwlq>%wub5spIgA6PCNQiNWvih7#HGAy;F$^ zNeo|x*&Caz4~-pSA0@qw`BLIxVz+c5OkJZMbrB-UNvrn;0*({4UKC~#{2ZJfR1noY z5`-VEF)bRZi*sFxlVmm$!Z}nBOp)UMq(+P`@mc66H^rQjJ7CB?aG{`?K2Ff}F!W0r zCuJoa;nDmZ>ykOCoq9-+w&2yKsS^;ij= zS|mYi=(ON&dykn@R0s6L*U3`cg3ZO($xB}EN#ydXeB1Yk!>dprL%cUJ<3>uk{9VKI zO#Po8izKaeI5$njlg*24S{HQH9{=(ZbcCCtPdcN~^W{jppEo}vAsBXqy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?yl4j76H{o^$O zFpi%M?SuLI6+Bp%2D=&nPWun^`YxUVG%pDOHlJS_uwlQW+xKDo0PGj}j_K{Lt-~M; z{k{*<-3RTG@qY$l==go0_df6^Isa!IhMwQYWdJzLj{3K8Vd(mOMDst0UAp+sb}-cX zK57vQwM*vz8Hu66_mT8K7TnwOe@9mQt>*{(poOJrm+b#@A24+PejjcgLLNxFnEQo4 zE5gwK`-(~qDEfIB@Mq}3c^Eqk{YxhfllPeGf&ES}0+rM+hu*s^*zd++Fy^{oAFS|i z@ZM&GJq?GIV6G4LmE8QZk^`f{>}b1McSHSm*9m)i(LVKn)_+|t9EM}_z!+|Muc3X` z@qfXwndZX^4%5Z^3Q)lD{vZ3l$m7FkY=REMw(d2wk14Rz@AkP74x7O~l4013y@vK_0OD)U%>SFqIIJGK^2eO(_8Qs; z0qbFZO&WPn@i-xr+N zI(}F3?d$jk=r|Oxz`XptutQ;c3RVG#t^9Yp{JwHiAin>L^8GzuT^S$nco2vY_yqvo Jdx{S8^*=UA^1A>4 literal 0 HcmV?d00001 diff --git a/configurationapp/target/maven-archiver/pom.properties b/configurationapp/target/maven-archiver/pom.properties new file mode 100644 index 0000000..02b9c6b --- /dev/null +++ b/configurationapp/target/maven-archiver/pom.properties @@ -0,0 +1,4 @@ +#Created by Apache Maven 3.6.0 +groupId=com.att +artifactId=configurationapp +version=0.0.1-SNAPSHOT diff --git a/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..4e0519f --- /dev/null +++ b/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,5 @@ +com/att/dao/configurations/ConfigurationDao.class +com/att/ConfigurationApp.class +com/att/web/configuarations/ConfigurationController.class +com/att/dao/configurations/ConfigurationDao$IdProvider.class +com/att/data/configurations/ConfigValue.class diff --git a/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..6aa7b0a --- /dev/null +++ b/configurationapp/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,4 @@ +/Users/gcanter/dev/springboot/configurationapp/src/main/java/com/att/dao/configurations/ConfigurationDao.java +/Users/gcanter/dev/springboot/configurationapp/src/main/java/com/att/ConfigurationApp.java +/Users/gcanter/dev/springboot/configurationapp/src/main/java/com/att/data/configurations/ConfigValue.java +/Users/gcanter/dev/springboot/configurationapp/src/main/java/com/att/web/configuarations/ConfigurationController.java From 03f09857b1898f729659f747498fc077536ce076 Mon Sep 17 00:00:00 2001 From: gregcanter <5223851+gregcanter@users.noreply.github.com> Date: Tue, 25 Jun 2019 10:19:07 -0400 Subject: [PATCH 4/5] Can now add a configuration and have it immediately shown. --- .../controllers/ConfigvaluesController.java | 28 ++++++++++++++++++- .../src/main/resources/static/index.html | 27 ++++++++---------- 2 files changed, 39 insertions(+), 16 deletions(-) diff --git a/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java b/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java index 3a3f3b8..139b748 100644 --- a/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java +++ b/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java @@ -28,7 +28,8 @@ public DataTablesOutput list (@Valid DataTablesInput input) { return configvaluesRepository.findAll(input); } - @Transactional + // DELETION OF CONFIGS BY CONFIG DATE VALUE + @Transactional // REQUIRED by Spring or will get Entity errors @RequestMapping(value = "/delete/{ConfigDate}", method = RequestMethod.POST) public RedirectView deleteConfig (@RequestParam String ConfigDate) { configvaluesRepository.deleteAllByConfigDate(ConfigDate); @@ -36,6 +37,31 @@ public RedirectView deleteConfig (@RequestParam String ConfigDate) { RedirectView redirectView = new RedirectView(); redirectView.setUrl(("http://localhost:9000/index.html")); return redirectView; + } + + // ADDITION OF A CONFIG + @Transactional // REQUIRED by Spring or will get Entity errors + @RequestMapping(value = "/add/{ConfigDate1}/{ConfigName1}", method = RequestMethod.POST) + public RedirectView addConfig (@RequestParam String ConfigDate1, String ConfigName1) { + int newID = (((int) configvaluesRepository.count()) + 1); + Configvalues configvalues = Configvalues.builder() + .configID(newID) + .configName(ConfigName1) + .configDate(ConfigDate1) + .build(); + configvaluesRepository.save(configvalues); + + System.out.println(" ########## ADDED FOR " + configvalues.toString() + " ############## "); + RedirectView redirectView = new RedirectView(); + redirectView.setUrl(("http://localhost:9000/index.html")); + return redirectView; + + + + + + + // // DELETE to delete a single config in a month diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index ee79762..c5dc3f9 100755 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -49,33 +49,30 @@

Current Configurations (All)

To Add a Configuration

-
+ - + + + + + + + + - + - - - + - -

To Delete a Configuration for a Selected Month

From 4206cee45aabdad131f0fa48faf8989536c6643b Mon Sep 17 00:00:00 2001 From: gregcanter <5223851+gregcanter@users.noreply.github.com> Date: Tue, 25 Jun 2019 10:32:28 -0400 Subject: [PATCH 5/5] Added ability to delete a single configuration. --- .../com/att/Init/ConfigvaluesInitializer.java | 3 - .../controllers/ConfigvaluesController.java | 171 +++--------------- .../repositories/ConfigvaluesRepository.java | 7 - .../src/main/resources/static/index.html | 18 +- .../target/classes/static/index.html | 45 +++-- 5 files changed, 74 insertions(+), 170 deletions(-) diff --git a/configurationapp/src/main/java/com/att/Init/ConfigvaluesInitializer.java b/configurationapp/src/main/java/com/att/Init/ConfigvaluesInitializer.java index 83c50c8..54dc887 100755 --- a/configurationapp/src/main/java/com/att/Init/ConfigvaluesInitializer.java +++ b/configurationapp/src/main/java/com/att/Init/ConfigvaluesInitializer.java @@ -24,9 +24,6 @@ public ConfigvaluesInitializer(ConfigvaluesRepository configvaluesRepository) { @PostConstruct public void init() { log.info("generating {} random employees", NUMBER_TO_GENERATE); - // TODO CLEAN-UP THIS - //Random randomGenerator = new Random(); - //Faker faker = new Faker(); ArrayList arrayList = new ArrayList(); arrayList.add("A"); diff --git a/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java b/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java index 139b748..98ca938 100644 --- a/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java +++ b/configurationapp/src/main/java/com/att/controllers/ConfigvaluesController.java @@ -22,7 +22,7 @@ public ConfigvaluesController(ConfigvaluesRepository configvaluesRepository) { // SHOW ALL VALUES @RequestMapping(value = "/api/configvalues", method = RequestMethod.GET) - public DataTablesOutput list (@Valid DataTablesInput input) { + public DataTablesOutput list(@Valid DataTablesInput input) { // configvaluesRepository.deleteAllByConfigDate("102019"); // System.out.println(" DELETION IN AFFECT "); return configvaluesRepository.findAll(input); @@ -31,7 +31,7 @@ public DataTablesOutput list (@Valid DataTablesInput input) { // DELETION OF CONFIGS BY CONFIG DATE VALUE @Transactional // REQUIRED by Spring or will get Entity errors @RequestMapping(value = "/delete/{ConfigDate}", method = RequestMethod.POST) - public RedirectView deleteConfig (@RequestParam String ConfigDate) { + public RedirectView deleteConfig(@RequestParam String ConfigDate) { configvaluesRepository.deleteAllByConfigDate(ConfigDate); System.out.println(" ########## DELETION IN AFFECT FOR " + ConfigDate.toString() + " ############## "); RedirectView redirectView = new RedirectView(); @@ -39,148 +39,33 @@ public RedirectView deleteConfig (@RequestParam String ConfigDate) { return redirectView; } - // ADDITION OF A CONFIG - @Transactional // REQUIRED by Spring or will get Entity errors - @RequestMapping(value = "/add/{ConfigDate1}/{ConfigName1}", method = RequestMethod.POST) - public RedirectView addConfig (@RequestParam String ConfigDate1, String ConfigName1) { - int newID = (((int) configvaluesRepository.count()) + 1); - Configvalues configvalues = Configvalues.builder() - .configID(newID) - .configName(ConfigName1) - .configDate(ConfigDate1) - .build(); - configvaluesRepository.save(configvalues); - - System.out.println(" ########## ADDED FOR " + configvalues.toString() + " ############## "); - RedirectView redirectView = new RedirectView(); - redirectView.setUrl(("http://localhost:9000/index.html")); - return redirectView; - - - - - - - - + // ADDITION OF A CONFIG + @Transactional // REQUIRED by Spring or will get Entity errors + @RequestMapping(value = "/add/{ConfigDate1}/{ConfigName1}", method = RequestMethod.POST) + public RedirectView addConfig(@RequestParam String ConfigDate1, String ConfigName1) { + int newID = (((int) configvaluesRepository.count()) + 1); + Configvalues configvalues = Configvalues.builder() + .configID(newID) + .configName(ConfigName1) + .configDate(ConfigDate1) + .build(); + configvaluesRepository.save(configvalues); + + System.out.println(" ########## ADDED FOR " + configvalues.toString() + " ############## "); + RedirectView redirectView = new RedirectView(); + redirectView.setUrl(("http://localhost:9000/index.html")); + return redirectView; -// // DELETE to delete a single config in a month -// @RequestMapping(value="/api/delete/{ConfigDate}") // http://localhost:9000 -// // /configuration/delete/?ConfigDate=012019 -// public @ResponseBody String deleteConfig(@RequestParam String ConfigDate) { -// configvaluesRepository.deleteAllByConfigDate(ConfigDate); -// return ("Deletion of " + ConfigDate + " is complete"); } - - - - - - - - - - - - // TODO CLEAN THIS UP -// @RequestMapping(value = "/api/configvalues", method = RequestMethod.POST) -// public DataTablesOutput listPost (@Valid DataTablesInput input) { -// return configvaluesRepository.findAll(input); -// } - + // DELETION OF A SINGLE CONFIG BY CONFIG ID VALUE + @Transactional // REQUIRED by Spring or will get Entity errors + @RequestMapping(value = "/deleteSingle/{ConfigID}", method = RequestMethod.POST) + public RedirectView deleteSingleConfig(@RequestParam Integer ConfigID) { + configvaluesRepository.deleteById(ConfigID); + System.out.println(" ########## *SINGLE* DELETION IN AFFECT FOR " + ConfigID.toString() + " ############## "); + RedirectView redirectView = new RedirectView(); + redirectView.setUrl(("http://localhost:9000/index.html")); + return redirectView; + } } - -// TODO: DELETE ALL THE BELOW THAT IS NOT NEEDED -// -// @Autowired -// private ConfigValueRepository configValueRepository; -// -// public ConfigValueController (ConfigValueRepository configValueRepository) { -// this.configValueRepository = configValueRepository; -// } -// -//// // GET to show all values -//// @GetMapping // http://localhost:9000/configuration -//// public Iterable findAll() { -//// return configValueRepository.findAll(); -//// } -//// -// -// -// -// @RequestMapping(value = "/findAll", method = RequestMethod.GET) -// public DataTablesOutput list(@Valid DataTablesInput input) { -// return configValueRepository.findAll(input); -// } -// -// @RequestMapping(value = "/findAll", method = RequestMethod.POST) -// public DataTablesOutput listPost(@Valid DataTablesInput input) { -// return configValueRepository.findAll(input); -// } -// -// -// -// -// // GET to show all values by date -// @GetMapping("/showall/{configDate}") // http://localhost:9000/configuration/showall/042019 -// public List findByConfigDate(@PathVariable String configDate) { -// return configValueRepository.findByConfigDate(configDate); -// } -// -// // GET to show all values by date -// @Transactional -// @GetMapping("/showall2/{configID}") // http://localhost:9000/configuration/showall/3 -// public List findByConfigID(@PathVariable int configID) { -// return configValueRepository.findByConfigID(configID); -// } -// -// - -// -// -// // DELETE to delete all values of a month -// @Transactional -// @GetMapping("/deleteDate/{configDate}") //http://localhost:9000/configuration/deleteDate/042019 -// public void deleteMonth(@PathVariable String configDate) { -// configValueRepository.deleteConfigValuesByConfigDate(configDate); -//// configValueRepository.findByConfigDate(configDate); -//// System.out.println("Found for deletion date " + configDate.toString()); -// configValueRepository.deleteConfigValuesByConfigDate(configDate); -// System.out.println("Deleted date "+ configDate.toString()); -// } -// -// // Add items for a time period -// @PostMapping("/create") -// @ResponseStatus(HttpStatus.CREATED) -// public ConfigValue create(@RequestBody ConfigValue configValue) { -// //ConfigValue configValue1 = configValueRepository.save(configValue); -// //return configValue1; -// return configValueRepository.save(configValue); -// } -// -//// @ResponseBody -//// public List getConfigurationsForYearMonth( -//// @PathVariable("yearMonthNumber") String yearMonth) { -//// -//// return new ArrayList<>(); -//// } -// -// // DELETE to delete all values -//// @RequestMapping(value="/{yearMonthNumber}", method=RequestMethod.DELETE) -//// public void deleteConfigurationsForYearMonth(@PathVariable("yearMonthNumber") String yearMonth) { -//// try { -//// -//// } catch (Exception ex) { -//// -//// } -//// } -//// -//// // PUT to create 1 entry/ 1 config -//// @RequestMapping(value="/{yearMonthNumber}", method={ RequestMethod.POST, RequestMethod.PUT }) -//// public void addConfigurationForYearMonth( -//// @PathVariable("yearMonthNumber") String yearMonth, -//// @RequestBody ConfigValue value) { -//// -//// } -//} diff --git a/configurationapp/src/main/java/com/att/repositories/ConfigvaluesRepository.java b/configurationapp/src/main/java/com/att/repositories/ConfigvaluesRepository.java index af88ced..e9d6f25 100644 --- a/configurationapp/src/main/java/com/att/repositories/ConfigvaluesRepository.java +++ b/configurationapp/src/main/java/com/att/repositories/ConfigvaluesRepository.java @@ -17,12 +17,5 @@ @Repository public interface ConfigvaluesRepository extends DataTablesRepository { - - // TODO - CLEAN THIS UP -// List findByConfigID( int ConfigID); -// List findByConfigDate( String configDate); -// void deleteConfigValuesByConfigDate( String configDate); void deleteAllByConfigDate(String configDate); -// void deleteByConfigID(int configID); - } diff --git a/configurationapp/src/main/resources/static/index.html b/configurationapp/src/main/resources/static/index.html index c5dc3f9..fc8e983 100755 --- a/configurationapp/src/main/resources/static/index.html +++ b/configurationapp/src/main/resources/static/index.html @@ -75,7 +75,7 @@

To Add a Configuration

-

To Delete a Configuration for a Selected Month

+

To Delete ALL Configurations for a Selected Month

@@ -93,6 +93,22 @@

To Delete a Configuration for a Selected Month

+

To Delete a SINGLE Configuration

+
+ + + + + + + + +
+ + + + + diff --git a/configurationapp/target/classes/static/index.html b/configurationapp/target/classes/static/index.html index ee79762..fc8e983 100755 --- a/configurationapp/target/classes/static/index.html +++ b/configurationapp/target/classes/static/index.html @@ -49,36 +49,33 @@

Current Configurations (All)

To Add a Configuration

-
+ - + + + + + + + + - + - - - + - -
-

To Delete a Configuration for a Selected Month

+

To Delete ALL Configurations for a Selected Month

@@ -96,6 +93,22 @@

To Delete a Configuration for a Selected Month

+

To Delete a SINGLE Configuration

+
+ + + + + + + + +
+ + + + +