diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 37e76631..00000000 --- a/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -# Jetbrains IntelliJ Idea -.idea -*.iml - -# Linux -# backup files -*~ - -# Windows -# thumbnails -Thumbs.db - -# Mac OS X -# metadata -.DS_Store -# thumbnails -._* - -# GIT -.git/ - -# Java -*.class - -# packages -*.jar -*.war -*.ear - -# Logging -*.log - -# jME (binaries) -*.so diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7a4bc7ff..00000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2019 Lambda, Inc. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md deleted file mode 100644 index 233b9af8..00000000 --- a/README.md +++ /dev/null @@ -1,1605 +0,0 @@ -# Project Country Search - -A student that completes this project shows that they can: - -* Use IntelliJ in the following areas: application creation, code entry, and code execution -* Explain the uses of and differences between Maven, Spring, and Tomcat -* Build a REST service using Spring Boot -* Use and implement inversion of control and dependency injection with Spring -* Implement Beans throughout the Beans’ lifecycle controlling the Beans using annotations - -## Introduction - -The countries of the world have many different defining attributes including land size, population, and median age. Below is a list of countries to include in your data. As most people do their research using websites, we are going to create web services to help search this data. We will be returning JSON objects. Nothing fancy for now! - -We will be creating an table for country data. The country model should contain the following fields. The model should be named `Country` and the table `countries` - -* String name -* long population -* long landmasskm2 -* int medianage - -The model should also include the standard getters and setters. You should use the provided data.sql file to seed your data - -Some Important Notes That Might help: - -* The sort method must work with `int` - so not `long`. the solution - type casting! See the code snippet below: - `.sort((c1, c2) -> (int)(c1.getPopulation() - c2.getPopulation()))` -* To calculate median for stretch goals - if the list contains an odd number of items, pick the middle one. If the list contains an even number of items, pick either of the two items that lie in the middle. - -Using the data.sql at the end, the endpoints will produce the following outputs. Expand to see the suggested outputs! Note that id numbers may vary. - -To set up this project you will need to - -* [ ] Create a forked copy of this project -* [ ] Clone your OWN version of the repository (Not Lambda's by mistake!) -* [ ] Create a new branch: git checkout -b . -* [ ] Push commits: git push -u origin -* [ ] Using the cloned repository as your working directory, create an initial application using the IntelliJ GUI interface remembering to implement the project on your newly created branch, committing changes regularly -* [ ] Push commits: git push origin - -[![Video on how to set up your project](https://img.youtube.com/vi/4Yrm93HxeT8/0.jpg)](https://youtu.be/4Yrm93HxeT8) - -* [ ] When completed, submit on Canvas the link to YOUR GitHub Repository - -### MVP - -
-http://localhost:2019/names/all - -```JSON -[ - { - "countryid": 39, - "name": "Afghanistan", - "population": 37209007, - "landmasskm2": 652860, - "medianage": 19 - }, - { - "countryid": 138, - "name": "Albania", - "population": 2938428, - "landmasskm2": 27400, - "medianage": 38 - }, - { - "countryid": 34, - "name": "Algeria", - "population": 42679018, - "landmasskm2": 2381740, - "medianage": 29 - }, - { - "countryid": 46, - "name": "Angola", - "population": 31787566, - "landmasskm2": 1246700, - "medianage": 17 - }, - { - "countryid": 200, - "name": "Antigua and Barbuda", - "population": 104084, - "landmasskm2": 440, - "medianage": 32 - }, - { - "countryid": 32, - "name": "Argentina", - "population": 45101781, - "landmasskm2": 2736690, - "medianage": 32 - }, - { - "countryid": 139, - "name": "Armenia", - "population": 2936706, - "landmasskm2": 28470, - "medianage": 36 - }, - { - "countryid": 198, - "name": "Aruba", - "population": 106053, - "landmasskm2": 180, - "medianage": 41 - }, - { - "countryid": 55, - "name": "Australia", - "population": 25088636, - "landmasskm2": 7682300, - "medianage": 38 - }, - { - "countryid": 97, - "name": "Austria", - "population": 8766201, - "landmasskm2": 82409, - "medianage": 44 - }, - { - "countryid": 91, - "name": "Azerbaijan", - "population": 10014575, - "landmasskm2": 82658, - "medianage": 32 - }, - { - "countryid": 177, - "name": "Bahamas", - "population": 403095, - "landmasskm2": 10010, - "medianage": 34 - }, - { - "countryid": 152, - "name": "Bahrain", - "population": 1637896, - "landmasskm2": 760, - "medianage": 32 - }, - { - "countryid": 8, - "name": "Bangladesh", - "population": 168065920, - "landmasskm2": 130170, - "medianage": 27 - }, - { - "countryid": 184, - "name": "Barbados", - "population": 287010, - "landmasskm2": 430, - "medianage": 40 - }, - { - "countryid": 95, - "name": "Belarus", - "population": 9433874, - "landmasskm2": 202910, - "medianage": 40 - }, - { - "countryid": 81, - "name": "Belgium", - "population": 11562784, - "landmasskm2": 30280, - "medianage": 42 - }, - { - "countryid": 178, - "name": "Belize", - "population": 390231, - "landmasskm2": 22810, - "medianage": 25 - }, - { - "countryid": 78, - "name": "Benin", - "population": 11801595, - "landmasskm2": 112760, - "medianage": 19 - }, - { - "countryid": 164, - "name": "Bhutan", - "population": 826229, - "landmasskm2": 38117, - "medianage": 29 - }, - { - "countryid": 83, - "name": "Bolivia", - "population": 11379861, - "landmasskm2": 1083300, - "medianage": 25 - }, - { - "countryid": 135, - "name": "Bosnia & Herzegovina", - "population": 3501774, - "landmasskm2": 51000, - "medianage": 42 - }, - { - "countryid": 144, - "name": "Botswana", - "population": 2374636, - "landmasskm2": 566730, - "medianage": 26 - }, - { - "countryid": 5, - "name": "Brazil", - "population": 212392717, - "landmasskm2": 8358140, - "medianage": 33 - }, - { - "countryid": 175, - "name": "Brunei", - "population": 439336, - "landmasskm2": 5270, - "medianage": 32 - }, - { - "countryid": 106, - "name": "Bulgaria", - "population": 6988739, - "landmasskm2": 108560, - "medianage": 45 - }, - { - "countryid": 59, - "name": "Burkina Faso", - "population": 20321560, - "landmasskm2": 273600, - "medianage": 18 - }, - { - "countryid": 80, - "name": "Burundi", - "population": 11575964, - "landmasskm2": 25680, - "medianage": 18 - }, - { - "countryid": 172, - "name": "Cabo Verde", - "population": 560349, - "landmasskm2": 4030, - "medianage": 26 - }, - { - "countryid": 72, - "name": "Cambodia", - "population": 16482646, - "landmasskm2": 176520, - "medianage": 26 - }, - { - "countryid": 54, - "name": "Cameroon", - "population": 25312993, - "landmasskm2": 472710, - "medianage": 19 - }, - { - "countryid": 38, - "name": "Canada", - "population": 37279811, - "landmasskm2": 9093510, - "medianage": 41 - }, - { - "countryid": 126, - "name": "Central African Republic", - "population": 4825711, - "landmasskm2": 622980, - "medianage": 18 - }, - { - "countryid": 73, - "name": "Chad", - "population": 15814345, - "landmasskm2": 1259200, - "medianage": 17 - }, - { - "countryid": 191, - "name": "Channel Islands", - "population": 166828, - "landmasskm2": 190, - "medianage": 44 - }, - { - "countryid": 65, - "name": "Chile", - "population": 18336653, - "landmasskm2": 743532, - "medianage": 35 - }, - { - "countryid": 1, - "name": "China", - "population": 1420062022, - "landmasskm2": 9388211, - "medianage": 39 - }, - { - "countryid": 29, - "name": "Colombia", - "population": 49849818, - "landmasskm2": 1109500, - "medianage": 32 - }, - { - "countryid": 163, - "name": "Comoros", - "population": 850910, - "landmasskm2": 1861, - "medianage": 20 - }, - { - "countryid": 117, - "name": "Congo", - "population": 5542197, - "landmasskm2": 341500, - "medianage": 19 - }, - { - "countryid": 123, - "name": "Costa Rica", - "population": 4999384, - "landmasskm2": 51060, - "medianage": 34 - }, - { - "countryid": 53, - "name": "Cote dIvoire", - "population": 25531083, - "landmasskm2": 318000, - "medianage": 19 - }, - { - "countryid": 131, - "name": "Croatia", - "population": 4140148, - "landmasskm2": 55960, - "medianage": 44 - }, - { - "countryid": 82, - "name": "Cuba", - "population": 11492046, - "landmasskm2": 106440, - "medianage": 43 - }, - { - "countryid": 192, - "name": "Curacao", - "population": 162547, - "landmasskm2": 444, - "medianage": 42 - }, - { - "countryid": 159, - "name": "Cyprus", - "population": 1198427, - "landmasskm2": 9240, - "medianage": 37 - }, - { - "countryid": 87, - "name": "Czech Republic", - "population": 10630589, - "landmasskm2": 77240, - "medianage": 43 - }, - { - "countryid": 115, - "name": "Denmark", - "population": 5775224, - "landmasskm2": 42430, - "medianage": 42 - }, - { - "countryid": 160, - "name": "Djibouti", - "population": 985690, - "landmasskm2": 23180, - "medianage": 25 - }, - { - "countryid": 86, - "name": "Dominican Republic", - "population": 10996774, - "landmasskm2": 48320, - "medianage": 28 - }, - { - "countryid": 16, - "name": "DR Congo", - "population": 86727573, - "landmasskm2": 2267050, - "medianage": 17 - }, - { - "countryid": 70, - "name": "Ecuador", - "population": 17100444, - "landmasskm2": 248360, - "medianage": 28 - }, - { - "countryid": 14, - "name": "Egypt", - "population": 101168745, - "landmasskm2": 995450, - "medianage": 25 - }, - { - "countryid": 109, - "name": "El Salvador", - "population": 6445405, - "landmasskm2": 20720, - "medianage": 28 - }, - { - "countryid": 155, - "name": "Equatorial Guinea", - "population": 1360104, - "landmasskm2": 28050, - "medianage": 22 - }, - { - "countryid": 120, - "name": "Eritrea", - "population": 5309659, - "landmasskm2": 101000, - "medianage": 19 - }, - { - "countryid": 157, - "name": "Estonia", - "population": 1303798, - "landmasskm2": 42390, - "medianage": 43 - }, - { - "countryid": 12, - "name": "Ethiopia", - "population": 110135635, - "landmasskm2": 1000000, - "medianage": 20 - }, - { - "countryid": 161, - "name": "Fiji", - "population": 918757, - "landmasskm2": 18270, - "medianage": 29 - }, - { - "countryid": 116, - "name": "Finland", - "population": 5561389, - "landmasskm2": 303890, - "medianage": 43 - }, - { - "countryid": 22, - "name": "France", - "population": 65480710, - "landmasskm2": 547557, - "medianage": 42 - }, - { - "countryid": 181, - "name": "French Guiana", - "population": 296847, - "landmasskm2": 82200, - "medianage": 25 - }, - { - "countryid": 182, - "name": "French Polynesia", - "population": 288506, - "landmasskm2": 3660, - "medianage": 33 - }, - { - "countryid": 147, - "name": "Gabon", - "population": 2109099, - "landmasskm2": 257670, - "medianage": 23 - }, - { - "countryid": 146, - "name": "Gambia", - "population": 2228075, - "landmasskm2": 10120, - "medianage": 18 - }, - { - "countryid": 133, - "name": "Georgia", - "population": 3904204, - "landmasskm2": 69490, - "medianage": 39 - }, - { - "countryid": 19, - "name": "Germany", - "population": 82438639, - "landmasskm2": 348560, - "medianage": 47 - }, - { - "countryid": 48, - "name": "Ghana", - "population": 30096970, - "landmasskm2": 227540, - "medianage": 21 - }, - { - "countryid": 85, - "name": "Greece", - "population": 11124603, - "landmasskm2": 128900, - "medianage": 45 - }, - { - "countryid": 196, - "name": "Grenada", - "population": 108825, - "landmasskm2": 340, - "medianage": 29 - }, - { - "countryid": 174, - "name": "Guadeloupe", - "population": 448798, - "landmasskm2": 1690, - "medianage": 43 - }, - { - "countryid": 190, - "name": "Guam", - "population": 167245, - "landmasskm2": 540, - "medianage": 31 - }, - { - "countryid": 67, - "name": "Guatemala", - "population": 17577842, - "landmasskm2": 107160, - "medianage": 23 - }, - { - "countryid": 75, - "name": "Guinea", - "population": 13398180, - "landmasskm2": 245720, - "medianage": 19 - }, - { - "countryid": 150, - "name": "Guinea-Bissau", - "population": 1953723, - "landmasskm2": 28120, - "medianage": 19 - }, - { - "countryid": 165, - "name": "Guyana", - "population": 786508, - "landmasskm2": 196850, - "medianage": 26 - }, - { - "countryid": 84, - "name": "Haiti", - "population": 11242856, - "landmasskm2": 27560, - "medianage": 24 - }, - { - "countryid": 94, - "name": "Honduras", - "population": 9568688, - "landmasskm2": 111890, - "medianage": 25 - }, - { - "countryid": 104, - "name": "Hong Kong", - "population": 7490776, - "landmasskm2": 1050, - "medianage": 45 - }, - { - "countryid": 93, - "name": "Hungary", - "population": 9655361, - "landmasskm2": 90530, - "medianage": 43 - }, - { - "countryid": 180, - "name": "Iceland", - "population": 340566, - "landmasskm2": 100250, - "medianage": 37 - }, - { - "countryid": 2, - "name": "India", - "population": 1368737513, - "landmasskm2": 2973190, - "medianage": 28 - }, - { - "countryid": 4, - "name": "Indonesia", - "population": 269536482, - "landmasskm2": 1811570, - "medianage": 29 - }, - { - "countryid": 18, - "name": "Iran", - "population": 82820766, - "landmasskm2": 1628550, - "medianage": 32 - }, - { - "countryid": 36, - "name": "Iraq", - "population": 40412299, - "landmasskm2": 434320, - "medianage": 20 - }, - { - "countryid": 125, - "name": "Ireland", - "population": 4847139, - "landmasskm2": 68890, - "medianage": 39 - }, - { - "countryid": 101, - "name": "Israel", - "population": 8583916, - "landmasskm2": 21640, - "medianage": 31 - }, - { - "countryid": 24, - "name": "Italy", - "population": 59216525, - "landmasskm2": 294140, - "medianage": 48 - }, - { - "countryid": 140, - "name": "Jamaica", - "population": 2906339, - "landmasskm2": 10830, - "medianage": 31 - }, - { - "countryid": 11, - "name": "Japan", - "population": 126854745, - "landmasskm2": 364555, - "medianage": 48 - }, - { - "countryid": 89, - "name": "Jordan", - "population": 10069794, - "landmasskm2": 88780, - "medianage": 23 - }, - { - "countryid": 63, - "name": "Kazakhstan", - "population": 18592970, - "landmasskm2": 2699700, - "medianage": 31 - }, - { - "countryid": 27, - "name": "Kenya", - "population": 52214791, - "landmasskm2": 569140, - "medianage": 20 - }, - { - "countryid": 193, - "name": "Kiribati", - "population": 120428, - "landmasskm2": 810, - "medianage": 23 - }, - { - "countryid": 129, - "name": "Kuwait", - "population": 4248974, - "landmasskm2": 17820, - "medianage": 34 - }, - { - "countryid": 111, - "name": "Kyrgyzstan", - "population": 6218616, - "landmasskm2": 191800, - "medianage": 26 - }, - { - "countryid": 105, - "name": "Laos", - "population": 7064242, - "landmasskm2": 230800, - "medianage": 24 - }, - { - "countryid": 151, - "name": "Latvia", - "population": 1911108, - "landmasskm2": 62200, - "medianage": 44 - }, - { - "countryid": 112, - "name": "Lebanon", - "population": 6065922, - "landmasskm2": 10230, - "medianage": 31 - }, - { - "countryid": 145, - "name": "Lesotho", - "population": 2292682, - "landmasskm2": 30360, - "medianage": 22 - }, - { - "countryid": 124, - "name": "Liberia", - "population": 4977720, - "landmasskm2": 96320, - "medianage": 19 - }, - { - "countryid": 108, - "name": "Libya", - "population": 6569864, - "landmasskm2": 1759540, - "medianage": 29 - }, - { - "countryid": 141, - "name": "Lithuania", - "population": 2864459, - "landmasskm2": 62674, - "medianage": 43 - }, - { - "countryid": 169, - "name": "Luxembourg", - "population": 596992, - "landmasskm2": 2590, - "medianage": 40 - }, - { - "countryid": 166, - "name": "Macao", - "population": 642090, - "landmasskm2": 30, - "medianage": 39 - }, - { - "countryid": 51, - "name": "Madagascar", - "population": 26969642, - "landmasskm2": 581795, - "medianage": 20 - }, - { - "countryid": 60, - "name": "Malawi", - "population": 19718743, - "landmasskm2": 94280, - "medianage": 18 - }, - { - "countryid": 45, - "name": "Malaysia", - "population": 32454455, - "landmasskm2": 328550, - "medianage": 30 - }, - { - "countryid": 173, - "name": "Maldives", - "population": 451738, - "landmasskm2": 300, - "medianage": 31 - }, - { - "countryid": 61, - "name": "Mali", - "population": 19689140, - "landmasskm2": 1220190, - "medianage": 16 - }, - { - "countryid": 176, - "name": "Malta", - "population": 433245, - "landmasskm2": 320, - "medianage": 42 - }, - { - "countryid": 179, - "name": "Martinique", - "population": 385320, - "landmasskm2": 1060, - "medianage": 46 - }, - { - "countryid": 128, - "name": "Mauritania", - "population": 4661149, - "landmasskm2": 1030700, - "medianage": 20 - }, - { - "countryid": 158, - "name": "Mauritius", - "population": 1271368, - "landmasskm2": 2030, - "medianage": 37 - }, - { - "countryid": 186, - "name": "Mayotte", - "population": 266380, - "landmasskm2": 375, - "medianage": 20 - }, - { - "countryid": 10, - "name": "Mexico", - "population": 132328035, - "landmasskm2": 1943950, - "medianage": 29 - }, - { - "countryid": 197, - "name": "Micronesia", - "population": 106983, - "landmasskm2": 700, - "medianage": 23 - }, - { - "countryid": 132, - "name": "Moldova", - "population": 4029750, - "landmasskm2": 32850, - "medianage": 38 - }, - { - "countryid": 137, - "name": "Mongolia", - "population": 3166244, - "landmasskm2": 1553560, - "medianage": 29 - }, - { - "countryid": 168, - "name": "Montenegro", - "population": 629355, - "landmasskm2": 13450, - "medianage": 39 - }, - { - "countryid": 40, - "name": "Morocco", - "population": 36635156, - "landmasskm2": 446300, - "medianage": 30 - }, - { - "countryid": 47, - "name": "Mozambique", - "population": 31408823, - "landmasskm2": 786380, - "medianage": 18 - }, - { - "countryid": 26, - "name": "Myanmar", - "population": 54336138, - "landmasskm2": 653290, - "medianage": 29 - }, - { - "countryid": 143, - "name": "Namibia", - "population": 2641996, - "landmasskm2": 823290, - "medianage": 22 - }, - { - "countryid": 49, - "name": "Nepal", - "population": 29942018, - "landmasskm2": 143350, - "medianage": 25 - }, - { - "countryid": 69, - "name": "Netherlands", - "population": 17132908, - "landmasskm2": 33720, - "medianage": 43 - }, - { - "countryid": 185, - "name": "New Caledonia", - "population": 283376, - "landmasskm2": 18280, - "medianage": 33 - }, - { - "countryid": 127, - "name": "New Zealand", - "population": 4792409, - "landmasskm2": 263310, - "medianage": 38 - }, - { - "countryid": 110, - "name": "Nicaragua", - "population": 6351157, - "landmasskm2": 120340, - "medianage": 27 - }, - { - "countryid": 57, - "name": "Niger", - "population": 23176691, - "landmasskm2": 1266700, - "medianage": 15 - }, - { - "countryid": 7, - "name": "Nigeria", - "population": 200962417, - "landmasskm2": 910770, - "medianage": 18 - }, - { - "countryid": 52, - "name": "North Korea", - "population": 25727408, - "landmasskm2": 120410, - "medianage": 35 - }, - { - "countryid": 119, - "name": "Norway", - "population": 5400916, - "landmasskm2": 365268, - "medianage": 40 - }, - { - "countryid": 122, - "name": "Oman", - "population": 5001875, - "landmasskm2": 309500, - "medianage": 31 - }, - { - "countryid": 6, - "name": "Pakistan", - "population": 204596442, - "landmasskm2": 770880, - "medianage": 23 - }, - { - "countryid": 130, - "name": "Panama", - "population": 4226197, - "landmasskm2": 74340, - "medianage": 30 - }, - { - "countryid": 100, - "name": "Papua New Guinea", - "population": 8586525, - "landmasskm2": 452860, - "medianage": 23 - }, - { - "countryid": 107, - "name": "Paraguay", - "population": 6981981, - "landmasskm2": 397300, - "medianage": 27 - }, - { - "countryid": 42, - "name": "Peru", - "population": 32933835, - "landmasskm2": 1280000, - "medianage": 29 - }, - { - "countryid": 13, - "name": "Philippines", - "population": 108106310, - "landmasskm2": 298170, - "medianage": 25 - }, - { - "countryid": 37, - "name": "Poland", - "population": 38028278, - "landmasskm2": 306230, - "medianage": 42 - }, - { - "countryid": 88, - "name": "Portugal", - "population": 10254666, - "landmasskm2": 91590, - "medianage": 46 - }, - { - "countryid": 134, - "name": "Puerto Rico", - "population": 3654978, - "landmasskm2": 8870, - "medianage": 38 - }, - { - "countryid": 142, - "name": "Qatar", - "population": 2743901, - "landmasskm2": 11610, - "medianage": 32 - }, - { - "countryid": 162, - "name": "Reunion", - "population": 889918, - "landmasskm2": 2500, - "medianage": 36 - }, - { - "countryid": 62, - "name": "Romania", - "population": 19483360, - "landmasskm2": 230170, - "medianage": 43 - }, - { - "countryid": 9, - "name": "Russia", - "population": 143895551, - "landmasskm2": 16376870, - "medianage": 40 - }, - { - "countryid": 77, - "name": "Rwanda", - "population": 12794412, - "landmasskm2": 24670, - "medianage": 20 - }, - { - "countryid": 189, - "name": "Saint Lucia", - "population": 180454, - "landmasskm2": 610, - "medianage": 35 - }, - { - "countryid": 188, - "name": "Samoa", - "population": 198909, - "landmasskm2": 2830, - "medianage": 22 - }, - { - "countryid": 187, - "name": "Sao Tome & Principe", - "population": 213379, - "landmasskm2": 960, - "medianage": 19 - }, - { - "countryid": 41, - "name": "Saudi Arabia", - "population": 34140662, - "landmasskm2": 2149690, - "medianage": 32 - }, - { - "countryid": 71, - "name": "Senegal", - "population": 16743859, - "landmasskm2": 192530, - "medianage": 19 - }, - { - "countryid": 98, - "name": "Serbia", - "population": 8733407, - "landmasskm2": 87460, - "medianage": 41 - }, - { - "countryid": 201, - "name": "Seychelles", - "population": 95702, - "landmasskm2": 460, - "medianage": 36 - }, - { - "countryid": 103, - "name": "Sierra Leone", - "population": 7883123, - "landmasskm2": 72180, - "medianage": 19 - }, - { - "countryid": 114, - "name": "Singapore", - "population": 5868104, - "landmasskm2": 700, - "medianage": 42 - }, - { - "countryid": 118, - "name": "Slovakia", - "population": 5450987, - "landmasskm2": 48088, - "medianage": 41 - }, - { - "countryid": 149, - "name": "Slovenia", - "population": 2081900, - "landmasskm2": 20140, - "medianage": 45 - }, - { - "countryid": 167, - "name": "Solomon Islands", - "population": 635254, - "landmasskm2": 27990, - "medianage": 21 - }, - { - "countryid": 74, - "name": "Somalia", - "population": 15636171, - "landmasskm2": 627340, - "medianage": 17 - }, - { - "countryid": 25, - "name": "South Africa", - "population": 58065097, - "landmasskm2": 1213090, - "medianage": 27 - }, - { - "countryid": 28, - "name": "South Korea", - "population": 51339238, - "landmasskm2": 97230, - "medianage": 43 - }, - { - "countryid": 76, - "name": "South Sudan", - "population": 13263184, - "landmasskm2": 610952, - "medianage": 19 - }, - { - "countryid": 30, - "name": "Spain", - "population": 46441049, - "landmasskm2": 498800, - "medianage": 46 - }, - { - "countryid": 58, - "name": "Sri Lanka", - "population": 21018859, - "landmasskm2": 62710, - "medianage": 34 - }, - { - "countryid": 194, - "name": "St. Vincent & Grenadines", - "population": 110488, - "landmasskm2": 390, - "medianage": 32 - }, - { - "countryid": 121, - "name": "State of Palestine", - "population": 5186790, - "landmasskm2": 6020, - "medianage": 20 - }, - { - "countryid": 35, - "name": "Sudan", - "population": 42514094, - "landmasskm2": 1765048, - "medianage": 20 - }, - { - "countryid": 171, - "name": "Suriname", - "population": 573085, - "landmasskm2": 156000, - "medianage": 30 - }, - { - "countryid": 153, - "name": "Swaziland", - "population": 1415414, - "landmasskm2": 17200, - "medianage": 21 - }, - { - "countryid": 90, - "name": "Sweden", - "population": 10053135, - "landmasskm2": 410340, - "medianage": 41 - }, - { - "countryid": 99, - "name": "Switzerland", - "population": 8608259, - "landmasskm2": 39516, - "medianage": 43 - }, - { - "countryid": 64, - "name": "Syria", - "population": 18499181, - "landmasskm2": 183630, - "medianage": 22 - }, - { - "countryid": 56, - "name": "Taiwan", - "population": 23758247, - "landmasskm2": 35410, - "medianage": 42 - }, - { - "countryid": 96, - "name": "Tajikistan", - "population": 9292000, - "landmasskm2": 139960, - "medianage": 23 - }, - { - "countryid": 23, - "name": "Tanzania", - "population": 60913557, - "landmasskm2": 885800, - "medianage": 18 - }, - { - "countryid": 148, - "name": "TFYR Macedonia", - "population": 2086720, - "landmasskm2": 25220, - "medianage": 39 - }, - { - "countryid": 20, - "name": "Thailand", - "population": 69306160, - "landmasskm2": 510890, - "medianage": 40 - }, - { - "countryid": 156, - "name": "Timor-Leste", - "population": 1352360, - "landmasskm2": 14870, - "medianage": 18 - }, - { - "countryid": 102, - "name": "Togo", - "population": 8186384, - "landmasskm2": 54390, - "medianage": 19 - }, - { - "countryid": 195, - "name": "Tonga", - "population": 110041, - "landmasskm2": 720, - "medianage": 22 - }, - { - "countryid": 154, - "name": "Trinidad and Tobago", - "population": 1375443, - "landmasskm2": 5130, - "medianage": 36 - }, - { - "countryid": 79, - "name": "Tunisia", - "population": 11783168, - "landmasskm2": 155360, - "medianage": 33 - }, - { - "countryid": 17, - "name": "Turkey", - "population": 82961805, - "landmasskm2": 769630, - "medianage": 32 - }, - { - "countryid": 113, - "name": "Turkmenistan", - "population": 5942561, - "landmasskm2": 469930, - "medianage": 27 - }, - { - "countryid": 21, - "name": "U.K.", - "population": 66959016, - "landmasskm2": 241930, - "medianage": 41 - }, - { - "countryid": 3, - "name": "U.S.", - "population": 329093110, - "landmasskm2": 9147420, - "medianage": 38 - }, - { - "countryid": 199, - "name": "U.S. Virgin Islands", - "population": 104909, - "landmasskm2": 350, - "medianage": 42 - }, - { - "countryid": 31, - "name": "Uganda", - "population": 45711874, - "landmasskm2": 199810, - "medianage": 16 - }, - { - "countryid": 33, - "name": "Ukraine", - "population": 43795220, - "landmasskm2": 579320, - "medianage": 41 - }, - { - "countryid": 92, - "name": "United Arab Emirates", - "population": 9682088, - "landmasskm2": 83600, - "medianage": 34 - }, - { - "countryid": 136, - "name": "Uruguay", - "population": 3482156, - "landmasskm2": 175020, - "medianage": 36 - }, - { - "countryid": 43, - "name": "Uzbekistan", - "population": 32807368, - "landmasskm2": 425400, - "medianage": 28 - }, - { - "countryid": 183, - "name": "Vanuatu", - "population": 288017, - "landmasskm2": 12190, - "medianage": 23 - }, - { - "countryid": 44, - "name": "Venezuela", - "population": 32779868, - "landmasskm2": 882050, - "medianage": 29 - }, - { - "countryid": 15, - "name": "Viet Nam", - "population": 97429061, - "landmasskm2": 310070, - "medianage": 33 - }, - { - "countryid": 170, - "name": "Western Sahara", - "population": 582478, - "landmasskm2": 266000, - "medianage": 28 - }, - { - "countryid": 50, - "name": "Yemen", - "population": 29579986, - "landmasskm2": 527970, - "medianage": 20 - }, - { - "countryid": 66, - "name": "Zambia", - "population": 18137369, - "landmasskm2": 743390, - "medianage": 18 - }, - { - "countryid": 68, - "name": "Zimbabwe", - "population": 17297495, - "landmasskm2": 386850, - "medianage": 20 - } -] -``` - -
- -
-http://localhost:2019/names/start/u - -```JSON -[ - { - "countryid": 21, - "name": "U.K.", - "population": 66959016, - "landmasskm2": 241930, - "medianage": 41 - }, - { - "countryid": 3, - "name": "U.S.", - "population": 329093110, - "landmasskm2": 9147420, - "medianage": 38 - }, - { - "countryid": 199, - "name": "U.S. Virgin Islands", - "population": 104909, - "landmasskm2": 350, - "medianage": 42 - }, - { - "countryid": 31, - "name": "Uganda", - "population": 45711874, - "landmasskm2": 199810, - "medianage": 16 - }, - { - "countryid": 33, - "name": "Ukraine", - "population": 43795220, - "landmasskm2": 579320, - "medianage": 41 - }, - { - "countryid": 92, - "name": "United Arab Emirates", - "population": 9682088, - "landmasskm2": 83600, - "medianage": 34 - }, - { - "countryid": 136, - "name": "Uruguay", - "population": 3482156, - "landmasskm2": 175020, - "medianage": 36 - }, - { - "countryid": 43, - "name": "Uzbekistan", - "population": 32807368, - "landmasskm2": 425400, - "medianage": 28 - } -] -``` - -
- -
-http://localhost:2019/population/total - -In the console - -```TEXT -The Total Population is 7713495811 -``` - -In the REST client - -```JSON -Status OK -``` - -
- -
-http://localhost:2019/population/min - -```JSON -{ - "countryid": 201, - "name": "Seychelles", - "population": 95702, - "landmasskm2": 460, - "medianage": 36 -} -``` - -
- -
-http://localhost:2019/population/max - -```JSON -{ - "countryid": 1, - "name": "China", - "population": 1420062022, - "landmasskm2": 9388211, - "medianage": 39 -} -``` - -
- -### Stretch Goal - -
-http://localhost:2019/population/median - -```JSON -{ - "countryid": 100, - "name": "Papua New Guinea", - "population": 8586525, - "landmasskm2": 452860, - "medianage": 23 -} -``` - -## Instruction - -The following URLs should return the requested data given the parameters - -* [ ] /names/all - return the names of all the countries alphabetically -* [ ] /names/start/{letter} - return the countries alphabetically that begin with the given letter - -* [ ] /population/total - return the total population of all countries in the console while returning Http Status OK as the response. -* [ ] /population/min - return the country with the smallest population -* [ ] /population/max - return the country with the largest population - -### Stretch Goal - -* [ ] /population/median - return the country with the median population diff --git a/countriesmp/.gitignore b/countriesmp/.gitignore new file mode 100644 index 00000000..549e00a2 --- /dev/null +++ b/countriesmp/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/countriesmp/.mvn/wrapper/MavenWrapperDownloader.java b/countriesmp/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 00000000..a45eb6ba --- /dev/null +++ b/countriesmp/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,118 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if (mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if (mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if (!outputFile.getParentFile().exists()) { + if (!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/countriesmp/.mvn/wrapper/maven-wrapper.jar b/countriesmp/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 00000000..2cc7d4a5 Binary files /dev/null and b/countriesmp/.mvn/wrapper/maven-wrapper.jar differ diff --git a/countriesmp/.mvn/wrapper/maven-wrapper.properties b/countriesmp/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 00000000..ffdc10e5 --- /dev/null +++ b/countriesmp/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.1/apache-maven-3.8.1-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/countriesmp/mvnw b/countriesmp/mvnw new file mode 100644 index 00000000..a16b5431 --- /dev/null +++ b/countriesmp/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/countriesmp/mvnw.cmd b/countriesmp/mvnw.cmd new file mode 100644 index 00000000..c8d43372 --- /dev/null +++ b/countriesmp/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/countriesmp/pom.xml b/countriesmp/pom.xml new file mode 100644 index 00000000..14d096d8 --- /dev/null +++ b/countriesmp/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.8.RELEASE + + + lambda.school + countriesmp + 0.0.1-SNAPSHOT + countriesmp + Demo project for Spring Boot + + 11 + + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.h2database + h2 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/countriesmp/src/main/java/lambda/school/countriesmp/CountriesmpApplication.java b/countriesmp/src/main/java/lambda/school/countriesmp/CountriesmpApplication.java new file mode 100644 index 00000000..c5821f55 --- /dev/null +++ b/countriesmp/src/main/java/lambda/school/countriesmp/CountriesmpApplication.java @@ -0,0 +1,13 @@ +package lambda.school.countriesmp; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CountriesmpApplication { + + public static void main(String[] args) { + SpringApplication.run(CountriesmpApplication.class, args); + } + +} diff --git a/countriesmp/src/main/java/lambda/school/countriesmp/controllers/CountryController.java b/countriesmp/src/main/java/lambda/school/countriesmp/controllers/CountryController.java new file mode 100644 index 00000000..392bd64a --- /dev/null +++ b/countriesmp/src/main/java/lambda/school/countriesmp/controllers/CountryController.java @@ -0,0 +1,50 @@ +package lambda.school.countriesmp.controllers; + +import lambda.school.countriesmp.models.Country; +import lambda.school.countriesmp.repositories.CountryRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.ArrayList; +import java.util.List; + +@RestController +public class CountryController { + @Autowired + private CountryRepository countryRepository; + + @GetMapping(value = "/population/max", produces = "application/json") + public ResponseEntity getMaxPopulation() + { + List countryList = new ArrayList<>(); + countryRepository.findAll().iterator().forEachRemaining(c -> countryList.add(c)); + countryList.sort((c1,c2) -> (c1.getPopulation()>c2.getPopulation()) ? -1:1); + return new ResponseEntity<>(countryList.get(0), HttpStatus.OK); + } + + @GetMapping(value = "/population/total", produces = "application/json") + public ResponseEntity getTotalPopulation() + { + List countryList = new ArrayList<>(); + countryRepository.findAll().iterator().forEachRemaining(c -> countryList.add(c)); + long population = 0; + for (Country c: countryList) + { + population+=c.getPopulation(); + + } + System.out.println(population); + return new ResponseEntity<>(population, HttpStatus.OK); + } + + @GetMapping(value = "/names/all", produces = "application/json") + public ResponseEntity listAllCountries() + { + List countryList = new ArrayList<>(); + countryRepository.findAll().iterator().forEachRemaining(c -> countryList.add(c)); + return new ResponseEntity<>(countryList, HttpStatus.OK); + } +} diff --git a/countriesmp/src/main/java/lambda/school/countriesmp/models/Country.java b/countriesmp/src/main/java/lambda/school/countriesmp/models/Country.java new file mode 100644 index 00000000..0157c31d --- /dev/null +++ b/countriesmp/src/main/java/lambda/school/countriesmp/models/Country.java @@ -0,0 +1,71 @@ +package lambda.school.countriesmp.models; + +import javax.persistence.*; + +@Entity +@Table(name = "countries") + +public class Country { + + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private long countryid; + + private String name; + + private long population; + + private long landmasskm2; + + private int medianage; + + public Country() { + } + + public Country(String name, long population, long landmasskm2, int medianage) { + this.name = name; + this.population = population; + this.landmasskm2 = landmasskm2; + this.medianage = medianage; + } + + public long getCountryid() { + return countryid; + } + + public void setCountryid(long countryid) { + this.countryid = countryid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getPopulation() { + return population; + } + + public void setPopulation(long population) { + this.population = population; + } + + public long getLandmasskm2() { + return landmasskm2; + } + + public void setLandmasskm2(long landmasskm2) { + this.landmasskm2 = landmasskm2; + } + + public int getMedianage() { + return medianage; + } + + public void setMedianage(int medianage) { + this.medianage = medianage; + } +} diff --git a/countriesmp/src/main/java/lambda/school/countriesmp/repositories/CountryRepository.java b/countriesmp/src/main/java/lambda/school/countriesmp/repositories/CountryRepository.java new file mode 100644 index 00000000..d6776b02 --- /dev/null +++ b/countriesmp/src/main/java/lambda/school/countriesmp/repositories/CountryRepository.java @@ -0,0 +1,7 @@ +package lambda.school.countriesmp.repositories; + +import lambda.school.countriesmp.models.Country; +import org.springframework.data.repository.CrudRepository; + +public interface CountryRepository extends CrudRepository { +} diff --git a/countriesmp/src/main/resources/application.properties b/countriesmp/src/main/resources/application.properties new file mode 100644 index 00000000..257d5b40 --- /dev/null +++ b/countriesmp/src/main/resources/application.properties @@ -0,0 +1,13 @@ +spring.h2.console.enabled=true +spring.h2.console.path=/h2-console +# +server.port=${PORT:2019} +# +spring.jackson.serialization.fail-on-empty-beans=false +spring.jackson.date-format=yyyy-MM-dd HH:mm:ss +spring.jackson.time-zone=America/Los_Angeles +# +spring.jpa.open-in-view=true +# +spring.jpa.hibernate.ddl-auto=create +spring.datasource.initialization-mode=always diff --git a/countriesmp/src/main/resources/data.sql b/countriesmp/src/main/resources/data.sql new file mode 100644 index 00000000..79477590 --- /dev/null +++ b/countriesmp/src/main/resources/data.sql @@ -0,0 +1,213 @@ +DELETE +FROM countries; + +INSERT INTO countries (countryid, name, population, landmasskm2, medianage) +VALUES (1, 'China',1420062022,9388211,39), + (2, 'India',1368737513,2973190,28), + (3, 'U.S.',329093110,9147420,38), + (4, 'Indonesia',269536482,1811570,29), + (5, 'Brazil',212392717,8358140,33), + (6, 'Pakistan',204596442,770880,23), + (7, 'Nigeria',200962417,910770,18), + (8, 'Bangladesh',168065920,130170,27), + (9, 'Russia',143895551,16376870,40), + (10, 'Mexico',132328035,1943950,29), + (11, 'Japan',126854745,364555,48), + (12, 'Ethiopia',110135635,1000000,20), + (13, 'Philippines',108106310,298170,25), + (14, 'Egypt',101168745,995450,25), + (15, 'Viet Nam',97429061,310070,33), + (16, 'DR Congo',86727573,2267050,17), + (17, 'Turkey',82961805,769630,32), + (18, 'Iran',82820766,1628550,32), + (19, 'Germany',82438639,348560,47), + (20, 'Thailand',69306160,510890,40), + (21, 'U.K.',66959016,241930,41), + (22, 'France',65480710,547557,42), + (23, 'Tanzania',60913557,885800,18), + (24, 'Italy',59216525,294140,48), + (25, 'South Africa',58065097,1213090,27), + (26, 'Myanmar',54336138,653290,29), + (27, 'Kenya',52214791,569140,20), + (28, 'South Korea',51339238,97230,43), + (29, 'Colombia',49849818,1109500,32), + (30, 'Spain',46441049,498800,46), + (31, 'Uganda',45711874,199810,16), + (32, 'Argentina',45101781,2736690,32), + (33, 'Ukraine',43795220,579320,41), + (34, 'Algeria',42679018,2381740,29), + (35, 'Sudan',42514094,1765048,20), + (36, 'Iraq',40412299,434320,20), + (37, 'Poland',38028278,306230,42), + (38, 'Canada',37279811,9093510,41), + (39, 'Afghanistan',37209007,652860,19), + (40, 'Morocco',36635156,446300,30), + (41, 'Saudi Arabia',34140662,2149690,32), + (42, 'Peru',32933835,1280000,29), + (43, 'Uzbekistan',32807368,425400,28), + (44, 'Venezuela',32779868,882050,29), + (45, 'Malaysia',32454455,328550,30), + (46, 'Angola',31787566,1246700,17), + (47, 'Mozambique',31408823,786380,18), + (48, 'Ghana',30096970,227540,21), + (49, 'Nepal',29942018,143350,25), + (50, 'Yemen',29579986,527970,20), + (51, 'Madagascar',26969642,581795,20), + (52, 'North Korea',25727408,120410,35), + (53, 'Cote dIvoire',25531083,318000,19), + (54, 'Cameroon',25312993,472710,19), + (55, 'Australia',25088636,7682300,38), + (56, 'Taiwan',23758247,35410,42), + (57, 'Niger',23176691,1266700,15), + (58, 'Sri Lanka',21018859,62710,34), + (59, 'Burkina Faso',20321560,273600,18), + (60, 'Malawi',19718743,94280,18), + (61, 'Mali',19689140,1220190,16), + (62, 'Romania',19483360,230170,43), + (63, 'Kazakhstan',18592970,2699700,31), + (64, 'Syria',18499181,183630,22), + (65, 'Chile',18336653,743532,35), + (66, 'Zambia',18137369,743390,18), + (67, 'Guatemala',17577842,107160,23), + (68, 'Zimbabwe',17297495,386850,20), + (69, 'Netherlands',17132908,33720,43), + (70, 'Ecuador',17100444,248360,28), + (71, 'Senegal',16743859,192530,19), + (72, 'Cambodia',16482646,176520,26), + (73, 'Chad',15814345,1259200,17), + (74, 'Somalia',15636171,627340,17), + (75, 'Guinea',13398180,245720,19), + (76, 'South Sudan',13263184,610952,19), + (77, 'Rwanda',12794412,24670,20), + (78, 'Benin',11801595,112760,19), + (79, 'Tunisia',11783168,155360,33), + (80, 'Burundi',11575964,25680,18), + (81, 'Belgium',11562784,30280,42), + (82, 'Cuba',11492046,106440,43), + (83, 'Bolivia',11379861,1083300,25), + (84, 'Haiti',11242856,27560,24), + (85, 'Greece',11124603,128900,45), + (86, 'Dominican Republic',10996774,48320,28), + (87, 'Czech Republic',10630589,77240,43), + (88, 'Portugal',10254666,91590,46), + (89, 'Jordan',10069794,88780,23), + (90, 'Sweden',10053135,410340,41), + (91, 'Azerbaijan',10014575,82658,32), + (92, 'United Arab Emirates',9682088,83600,34), + (93, 'Hungary',9655361,90530,43), + (94, 'Honduras',9568688,111890,25), + (95, 'Belarus',9433874,202910,40), + (96, 'Tajikistan',9292000,139960,23), + (97, 'Austria',8766201,82409,44), + (98, 'Serbia',8733407,87460,41), + (99, 'Switzerland',8608259,39516,43), + (100, 'Papua New Guinea',8586525,452860,23), + (101, 'Israel',8583916,21640,31), + (102, 'Togo',8186384,54390,19), + (103, 'Sierra Leone',7883123,72180,19), + (104, 'Hong Kong',7490776,1050,45), + (105, 'Laos',7064242,230800,24), + (106, 'Bulgaria',6988739,108560,45), + (107, 'Paraguay',6981981,397300,27), + (108, 'Libya',6569864,1759540,29), + (109, 'El Salvador',6445405,20720,28), + (110, 'Nicaragua',6351157,120340,27), + (111, 'Kyrgyzstan',6218616,191800,26), + (112, 'Lebanon',6065922,10230,31), + (113, 'Turkmenistan',5942561,469930,27), + (114, 'Singapore',5868104,700,42), + (115, 'Denmark',5775224,42430,42), + (116, 'Finland',5561389,303890,43), + (117, 'Congo',5542197,341500,19), + (118, 'Slovakia',5450987,48088,41), + (119, 'Norway',5400916,365268,40), + (120, 'Eritrea',5309659,101000,19), + (121, 'State of Palestine',5186790,6020,20), + (122, 'Oman',5001875,309500,31), + (123, 'Costa Rica',4999384,51060,34), + (124, 'Liberia',4977720,96320,19), + (125, 'Ireland',4847139,68890,39), + (126, 'Central African Republic',4825711,622980,18), + (127, 'New Zealand',4792409,263310,38), + (128, 'Mauritania',4661149,1030700,20), + (129, 'Kuwait',4248974,17820,34), + (130, 'Panama',4226197,74340,30), + (131, 'Croatia',4140148,55960,44), + (132, 'Moldova',4029750,32850,38), + (133, 'Georgia',3904204,69490,39), + (134, 'Puerto Rico',3654978,8870,38), + (135, 'Bosnia & Herzegovina',3501774,51000,42), + (136, 'Uruguay',3482156,175020,36), + (137, 'Mongolia',3166244,1553560,29), + (138, 'Albania',2938428,27400,38), + (139, 'Armenia',2936706,28470,36), + (140, 'Jamaica',2906339,10830,31), + (141, 'Lithuania',2864459,62674,43), + (142, 'Qatar',2743901,11610,32), + (143, 'Namibia',2641996,823290,22), + (144, 'Botswana',2374636,566730,26), + (145, 'Lesotho',2292682,30360,22), + (146, 'Gambia',2228075,10120,18), + (147, 'Gabon',2109099,257670,23), + (148, 'TFYR Macedonia',2086720,25220,39), + (149, 'Slovenia',2081900,20140,45), + (150, 'Guinea-Bissau',1953723,28120,19), + (151, 'Latvia',1911108,62200,44), + (152, 'Bahrain',1637896,760,32), + (153, 'Swaziland',1415414,17200,21), + (154, 'Trinidad and Tobago',1375443,5130,36), + (155, 'Equatorial Guinea',1360104,28050,22), + (156, 'Timor-Leste',1352360,14870,18), + (157, 'Estonia',1303798,42390,43), + (158, 'Mauritius',1271368,2030,37), + (159, 'Cyprus',1198427,9240,37), + (160, 'Djibouti',985690,23180,25), + (161, 'Fiji',918757,18270,29), + (162, 'Reunion',889918,2500,36), + (163, 'Comoros',850910,1861,20), + (164, 'Bhutan',826229,38117,29), + (165, 'Guyana',786508,196850,26), + (166, 'Macao',642090,30,39), + (167, 'Solomon Islands',635254,27990,21), + (168, 'Montenegro',629355,13450,39), + (169, 'Luxembourg',596992,2590,40), + (170, 'Western Sahara',582478,266000,28), + (171, 'Suriname',573085,156000,30), + (172, 'Cabo Verde',560349,4030,26), + (173, 'Maldives',451738,300,31), + (174, 'Guadeloupe',448798,1690,43), + (175, 'Brunei',439336,5270,32), + (176, 'Malta',433245,320,42), + (177, 'Bahamas',403095,10010,34), + (178, 'Belize',390231,22810,25), + (179, 'Martinique',385320,1060,46), + (180, 'Iceland',340566,100250,37), + (181, 'French Guiana',296847,82200,25), + (182, 'French Polynesia',288506,3660,33), + (183, 'Vanuatu',288017,12190,23), + (184, 'Barbados',287010,430,40), + (185, 'New Caledonia',283376,18280,33), + (186, 'Mayotte',266380,375,20), + (187, 'Sao Tome & Principe',213379,960,19), + (188, 'Samoa',198909,2830,22), + (189, 'Saint Lucia',180454,610,35), + (190, 'Guam',167245,540,31), + (191, 'Channel Islands',166828,190,44), + (192, 'Curacao',162547,444,42), + (193, 'Kiribati',120428,810,23), + (194, 'St. Vincent & Grenadines',110488,390,32), + (195, 'Tonga',110041,720,22), + (196, 'Grenada',108825,340,29), + (197, 'Micronesia',106983,700,23), + (198, 'Aruba',106053,180,41), + (199, 'U.S. Virgin Islands',104909,350,42), + (200, 'Antigua and Barbuda',104084,440,32), + (201, 'Seychelles',95702,460,36); + +/* +We must tell hibernate the ids that have already been used. +The number must be larger than the last used id. +250 > 201 so we are good! + */ + +alter sequence hibernate_sequence restart with 250; \ No newline at end of file diff --git a/countriesmp/src/test/java/lambda/school/countriesmp/CountriesmpApplicationTests.java b/countriesmp/src/test/java/lambda/school/countriesmp/CountriesmpApplicationTests.java new file mode 100644 index 00000000..e8e8580d --- /dev/null +++ b/countriesmp/src/test/java/lambda/school/countriesmp/CountriesmpApplicationTests.java @@ -0,0 +1,13 @@ +package lambda.school.countriesmp; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CountriesmpApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/data.sql b/data.sql deleted file mode 100644 index ca0bca40..00000000 --- a/data.sql +++ /dev/null @@ -1,213 +0,0 @@ -DELETE -FROM countries; - -INSERT INTO countries (countryid, name, population, landmasskm2, medianage) - VALUES (1, 'China',1420062022,9388211,39), - (2, 'India',1368737513,2973190,28), - (3, 'U.S.',329093110,9147420,38), - (4, 'Indonesia',269536482,1811570,29), - (5, 'Brazil',212392717,8358140,33), - (6, 'Pakistan',204596442,770880,23), - (7, 'Nigeria',200962417,910770,18), - (8, 'Bangladesh',168065920,130170,27), - (9, 'Russia',143895551,16376870,40), - (10, 'Mexico',132328035,1943950,29), - (11, 'Japan',126854745,364555,48), - (12, 'Ethiopia',110135635,1000000,20), - (13, 'Philippines',108106310,298170,25), - (14, 'Egypt',101168745,995450,25), - (15, 'Viet Nam',97429061,310070,33), - (16, 'DR Congo',86727573,2267050,17), - (17, 'Turkey',82961805,769630,32), - (18, 'Iran',82820766,1628550,32), - (19, 'Germany',82438639,348560,47), - (20, 'Thailand',69306160,510890,40), - (21, 'U.K.',66959016,241930,41), - (22, 'France',65480710,547557,42), - (23, 'Tanzania',60913557,885800,18), - (24, 'Italy',59216525,294140,48), - (25, 'South Africa',58065097,1213090,27), - (26, 'Myanmar',54336138,653290,29), - (27, 'Kenya',52214791,569140,20), - (28, 'South Korea',51339238,97230,43), - (29, 'Colombia',49849818,1109500,32), - (30, 'Spain',46441049,498800,46), - (31, 'Uganda',45711874,199810,16), - (32, 'Argentina',45101781,2736690,32), - (33, 'Ukraine',43795220,579320,41), - (34, 'Algeria',42679018,2381740,29), - (35, 'Sudan',42514094,1765048,20), - (36, 'Iraq',40412299,434320,20), - (37, 'Poland',38028278,306230,42), - (38, 'Canada',37279811,9093510,41), - (39, 'Afghanistan',37209007,652860,19), - (40, 'Morocco',36635156,446300,30), - (41, 'Saudi Arabia',34140662,2149690,32), - (42, 'Peru',32933835,1280000,29), - (43, 'Uzbekistan',32807368,425400,28), - (44, 'Venezuela',32779868,882050,29), - (45, 'Malaysia',32454455,328550,30), - (46, 'Angola',31787566,1246700,17), - (47, 'Mozambique',31408823,786380,18), - (48, 'Ghana',30096970,227540,21), - (49, 'Nepal',29942018,143350,25), - (50, 'Yemen',29579986,527970,20), - (51, 'Madagascar',26969642,581795,20), - (52, 'North Korea',25727408,120410,35), - (53, 'Cote dIvoire',25531083,318000,19), - (54, 'Cameroon',25312993,472710,19), - (55, 'Australia',25088636,7682300,38), - (56, 'Taiwan',23758247,35410,42), - (57, 'Niger',23176691,1266700,15), - (58, 'Sri Lanka',21018859,62710,34), - (59, 'Burkina Faso',20321560,273600,18), - (60, 'Malawi',19718743,94280,18), - (61, 'Mali',19689140,1220190,16), - (62, 'Romania',19483360,230170,43), - (63, 'Kazakhstan',18592970,2699700,31), - (64, 'Syria',18499181,183630,22), - (65, 'Chile',18336653,743532,35), - (66, 'Zambia',18137369,743390,18), - (67, 'Guatemala',17577842,107160,23), - (68, 'Zimbabwe',17297495,386850,20), - (69, 'Netherlands',17132908,33720,43), - (70, 'Ecuador',17100444,248360,28), - (71, 'Senegal',16743859,192530,19), - (72, 'Cambodia',16482646,176520,26), - (73, 'Chad',15814345,1259200,17), - (74, 'Somalia',15636171,627340,17), - (75, 'Guinea',13398180,245720,19), - (76, 'South Sudan',13263184,610952,19), - (77, 'Rwanda',12794412,24670,20), - (78, 'Benin',11801595,112760,19), - (79, 'Tunisia',11783168,155360,33), - (80, 'Burundi',11575964,25680,18), - (81, 'Belgium',11562784,30280,42), - (82, 'Cuba',11492046,106440,43), - (83, 'Bolivia',11379861,1083300,25), - (84, 'Haiti',11242856,27560,24), - (85, 'Greece',11124603,128900,45), - (86, 'Dominican Republic',10996774,48320,28), - (87, 'Czech Republic',10630589,77240,43), - (88, 'Portugal',10254666,91590,46), - (89, 'Jordan',10069794,88780,23), - (90, 'Sweden',10053135,410340,41), - (91, 'Azerbaijan',10014575,82658,32), - (92, 'United Arab Emirates',9682088,83600,34), - (93, 'Hungary',9655361,90530,43), - (94, 'Honduras',9568688,111890,25), - (95, 'Belarus',9433874,202910,40), - (96, 'Tajikistan',9292000,139960,23), - (97, 'Austria',8766201,82409,44), - (98, 'Serbia',8733407,87460,41), - (99, 'Switzerland',8608259,39516,43), - (100, 'Papua New Guinea',8586525,452860,23), - (101, 'Israel',8583916,21640,31), - (102, 'Togo',8186384,54390,19), - (103, 'Sierra Leone',7883123,72180,19), - (104, 'Hong Kong',7490776,1050,45), - (105, 'Laos',7064242,230800,24), - (106, 'Bulgaria',6988739,108560,45), - (107, 'Paraguay',6981981,397300,27), - (108, 'Libya',6569864,1759540,29), - (109, 'El Salvador',6445405,20720,28), - (110, 'Nicaragua',6351157,120340,27), - (111, 'Kyrgyzstan',6218616,191800,26), - (112, 'Lebanon',6065922,10230,31), - (113, 'Turkmenistan',5942561,469930,27), - (114, 'Singapore',5868104,700,42), - (115, 'Denmark',5775224,42430,42), - (116, 'Finland',5561389,303890,43), - (117, 'Congo',5542197,341500,19), - (118, 'Slovakia',5450987,48088,41), - (119, 'Norway',5400916,365268,40), - (120, 'Eritrea',5309659,101000,19), - (121, 'State of Palestine',5186790,6020,20), - (122, 'Oman',5001875,309500,31), - (123, 'Costa Rica',4999384,51060,34), - (124, 'Liberia',4977720,96320,19), - (125, 'Ireland',4847139,68890,39), - (126, 'Central African Republic',4825711,622980,18), - (127, 'New Zealand',4792409,263310,38), - (128, 'Mauritania',4661149,1030700,20), - (129, 'Kuwait',4248974,17820,34), - (130, 'Panama',4226197,74340,30), - (131, 'Croatia',4140148,55960,44), - (132, 'Moldova',4029750,32850,38), - (133, 'Georgia',3904204,69490,39), - (134, 'Puerto Rico',3654978,8870,38), - (135, 'Bosnia & Herzegovina',3501774,51000,42), - (136, 'Uruguay',3482156,175020,36), - (137, 'Mongolia',3166244,1553560,29), - (138, 'Albania',2938428,27400,38), - (139, 'Armenia',2936706,28470,36), - (140, 'Jamaica',2906339,10830,31), - (141, 'Lithuania',2864459,62674,43), - (142, 'Qatar',2743901,11610,32), - (143, 'Namibia',2641996,823290,22), - (144, 'Botswana',2374636,566730,26), - (145, 'Lesotho',2292682,30360,22), - (146, 'Gambia',2228075,10120,18), - (147, 'Gabon',2109099,257670,23), - (148, 'TFYR Macedonia',2086720,25220,39), - (149, 'Slovenia',2081900,20140,45), - (150, 'Guinea-Bissau',1953723,28120,19), - (151, 'Latvia',1911108,62200,44), - (152, 'Bahrain',1637896,760,32), - (153, 'Swaziland',1415414,17200,21), - (154, 'Trinidad and Tobago',1375443,5130,36), - (155, 'Equatorial Guinea',1360104,28050,22), - (156, 'Timor-Leste',1352360,14870,18), - (157, 'Estonia',1303798,42390,43), - (158, 'Mauritius',1271368,2030,37), - (159, 'Cyprus',1198427,9240,37), - (160, 'Djibouti',985690,23180,25), - (161, 'Fiji',918757,18270,29), - (162, 'Reunion',889918,2500,36), - (163, 'Comoros',850910,1861,20), - (164, 'Bhutan',826229,38117,29), - (165, 'Guyana',786508,196850,26), - (166, 'Macao',642090,30,39), - (167, 'Solomon Islands',635254,27990,21), - (168, 'Montenegro',629355,13450,39), - (169, 'Luxembourg',596992,2590,40), - (170, 'Western Sahara',582478,266000,28), - (171, 'Suriname',573085,156000,30), - (172, 'Cabo Verde',560349,4030,26), - (173, 'Maldives',451738,300,31), - (174, 'Guadeloupe',448798,1690,43), - (175, 'Brunei',439336,5270,32), - (176, 'Malta',433245,320,42), - (177, 'Bahamas',403095,10010,34), - (178, 'Belize',390231,22810,25), - (179, 'Martinique',385320,1060,46), - (180, 'Iceland',340566,100250,37), - (181, 'French Guiana',296847,82200,25), - (182, 'French Polynesia',288506,3660,33), - (183, 'Vanuatu',288017,12190,23), - (184, 'Barbados',287010,430,40), - (185, 'New Caledonia',283376,18280,33), - (186, 'Mayotte',266380,375,20), - (187, 'Sao Tome & Principe',213379,960,19), - (188, 'Samoa',198909,2830,22), - (189, 'Saint Lucia',180454,610,35), - (190, 'Guam',167245,540,31), - (191, 'Channel Islands',166828,190,44), - (192, 'Curacao',162547,444,42), - (193, 'Kiribati',120428,810,23), - (194, 'St. Vincent & Grenadines',110488,390,32), - (195, 'Tonga',110041,720,22), - (196, 'Grenada',108825,340,29), - (197, 'Micronesia',106983,700,23), - (198, 'Aruba',106053,180,41), - (199, 'U.S. Virgin Islands',104909,350,42), - (200, 'Antigua and Barbuda',104084,440,32), - (201, 'Seychelles',95702,460,36); - -/* -We must tell hibernate the ids that have already been used. -The number must be larger than the last used id. -250 > 201 so we are good! - */ - -alter sequence hibernate_sequence restart with 250;