└── plantplaces └── plantplaces ├── .gitignore ├── logs └── severe-logger.log ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── plantplaces │ │ ├── PlantPlacesController.java │ │ ├── PlantplacesApplication.java │ │ ├── dao │ │ ├── DashboardDAO.java │ │ ├── GetPlants.java │ │ ├── IDashboardDAO.java │ │ ├── IPhotoDAO.java │ │ ├── IPlantDAO.java │ │ ├── ISpecimenDAO.java │ │ ├── NetworkDAO.java │ │ ├── PhotoDAO.java │ │ ├── PhotoRepository.java │ │ ├── PlantDAO.java │ │ ├── SpecimenDAO.java │ │ └── SpecimenRepository.java │ │ ├── dto │ │ ├── LabelValueDTO.java │ │ ├── PhotoDTO.java │ │ ├── PlantDTO.java │ │ ├── PlantList.java │ │ └── SpecimenDTO.java │ │ └── service │ │ ├── DashboardService.java │ │ ├── IDashboardService.java │ │ ├── ISpecimenService.java │ │ ├── SpecimenService.java │ │ └── SpecimenServiceStub.java └── resources │ ├── application.properties │ ├── logback-spring.xml │ └── templates │ ├── dashboard.html │ ├── fragments │ └── topnav.html │ ├── plantResults.html │ ├── showSpecimens.html │ ├── specimenDetails.html │ ├── start.html │ ├── success.html │ └── sustainability.html └── test └── java └── com └── plantplaces ├── JUnitAnnotationExamples.java ├── PlantplacesApplicationTests.java └── SpecimenServiceTest.java /plantplaces/plantplaces/.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | 4 | ### STS ### 5 | .apt_generated 6 | .classpath 7 | .factorypath 8 | .project 9 | .settings 10 | .springBeans 11 | .sts4-cache 12 | 13 | ### IntelliJ IDEA ### 14 | .idea 15 | *.iws 16 | *.iml 17 | *.ipr 18 | 19 | ### NetBeans ### 20 | /nbproject/private/ 21 | /build/ 22 | /nbbuild/ 23 | /dist/ 24 | /nbdist/ 25 | /.nb-gradle/ 26 | 27 | # Created by https://www.gitignore.io/api/eclipse 28 | 29 | ### Eclipse ### 30 | 31 | .metadata 32 | bin/ 33 | tmp/ 34 | *.tmp 35 | *.bak 36 | *.swp 37 | *~.nib 38 | local.properties 39 | .settings/ 40 | .loadpath 41 | .recommenders 42 | 43 | # External tool builders 44 | .externalToolBuilders/ 45 | 46 | # Locally stored "Eclipse launch configurations" 47 | *.launch 48 | 49 | # PyDev specific (Python IDE for Eclipse) 50 | *.pydevproject 51 | 52 | # CDT-specific (C/C++ Development Tooling) 53 | .cproject 54 | 55 | # CDT- autotools 56 | .autotools 57 | 58 | # Java annotation processor (APT) 59 | .factorypath 60 | 61 | # PDT-specific (PHP Development Tools) 62 | .buildpath 63 | 64 | # sbteclipse plugin 65 | .target 66 | 67 | # Tern plugin 68 | .tern-project 69 | 70 | # TeXlipse plugin 71 | .texlipse 72 | 73 | # STS (Spring Tool Suite) 74 | .springBeans 75 | 76 | # Code Recommenders 77 | .recommenders/ 78 | 79 | # Annotation Processing 80 | .apt_generated/ 81 | 82 | # Scala IDE specific (Scala & Java development for Eclipse) 83 | .cache-main 84 | .scala_dependencies 85 | .worksheet 86 | 87 | ### Eclipse Patch ### 88 | # Eclipse Core 89 | .project 90 | 91 | # JDT-specific (Eclipse Java Development Tools) 92 | .classpath 93 | 94 | # Annotation Processing 95 | .apt_generated 96 | 97 | .sts4-cache/ 98 | 99 | 100 | # End of https://www.gitignore.io/api/eclipse 101 | 102 | maven-wrapper.jar 103 | maven-wrapper* 104 | mvnw* -------------------------------------------------------------------------------- /plantplaces/plantplaces/logs/severe-logger.log: -------------------------------------------------------------------------------- 1 | 2019-04-21 19:26:40,302 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-6] Exception in autocomplete 2 | java.lang.NullPointerException: null 3 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 4 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 5 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 6 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 7 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 8 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 9 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 10 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 11 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 12 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 13 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 14 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 15 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 16 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 17 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 18 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 19 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 20 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 21 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 22 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 23 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 24 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 25 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 26 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 27 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 28 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 29 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 30 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 31 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 32 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 33 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 34 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 35 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 36 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 37 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 38 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 39 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 40 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 41 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 42 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 43 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 44 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 45 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 46 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 47 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 48 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 49 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 50 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 51 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 52 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 53 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 54 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 55 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 56 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 57 | at java.base/java.lang.Thread.run(Thread.java:844) 58 | 2019-04-21 19:57:37,422 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-3] Exception in autocomplete 59 | java.lang.NullPointerException: null 60 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 61 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 62 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 63 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 64 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 65 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 66 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 67 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 68 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 69 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 70 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 71 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 72 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 73 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 74 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 75 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 76 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 77 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 78 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 79 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 80 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 81 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 82 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 83 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 84 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 85 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 86 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 87 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 88 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 89 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 90 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 91 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 92 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 93 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 94 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 95 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 96 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 97 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 98 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 99 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 100 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 101 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 102 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 103 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 104 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 105 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 106 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 107 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 108 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 109 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 110 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 111 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 112 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 113 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 114 | at java.base/java.lang.Thread.run(Thread.java:844) 115 | 2019-04-21 19:57:40,330 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-5] Exception in autocomplete 116 | java.lang.NullPointerException: null 117 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 118 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 119 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 120 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 121 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 122 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 123 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 124 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 125 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 126 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 127 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 128 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 129 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 130 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 131 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 132 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 133 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 134 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 135 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 136 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 137 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 138 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 139 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 140 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 141 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 142 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 143 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 144 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 145 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 146 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 147 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 148 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 149 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 150 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 151 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 152 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 153 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 154 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 155 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 156 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 157 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 158 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 159 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 160 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 161 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 162 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 163 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 164 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 165 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 166 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 167 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 168 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 169 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 170 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 171 | at java.base/java.lang.Thread.run(Thread.java:844) 172 | 2019-04-21 20:04:12,613 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-3] Exception in autocomplete 173 | java.lang.NullPointerException: null 174 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 175 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 176 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 177 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 178 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 179 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 180 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 181 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 182 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 183 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 184 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 185 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 186 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 187 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 188 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 189 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 190 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 191 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 192 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 193 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 194 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 195 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 196 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 197 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 198 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 199 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 200 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 201 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 202 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 203 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 204 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 205 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 206 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 207 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 208 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 209 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 210 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 211 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 212 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 213 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 214 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 215 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 216 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 217 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 218 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 219 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 220 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 221 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 222 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 223 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 224 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 225 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 226 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 227 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 228 | at java.base/java.lang.Thread.run(Thread.java:844) 229 | 2019-04-21 20:04:13,377 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-10] Exception in autocomplete 230 | java.lang.NullPointerException: null 231 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 232 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 233 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 234 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 235 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 236 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 237 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 238 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 239 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 240 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 241 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 242 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 243 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 244 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 245 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 246 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 247 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 248 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 249 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 250 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 251 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 252 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 253 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 254 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 255 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 256 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 257 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 258 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 259 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 260 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 261 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 262 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 263 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 264 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 265 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 266 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 267 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 268 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 269 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 270 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 271 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 272 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 273 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 274 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 275 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 276 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 277 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 278 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 279 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 280 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 281 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 282 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 283 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 284 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 285 | at java.base/java.lang.Thread.run(Thread.java:844) 286 | 2019-04-21 20:10:46,660 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-10] Exception in autocomplete 287 | java.lang.NullPointerException: null 288 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 289 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 290 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 291 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 292 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 293 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 294 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 295 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 296 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 297 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 298 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 299 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 300 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 301 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 302 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 303 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 304 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 305 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 306 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 307 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 308 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 309 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 310 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 311 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 312 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 313 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 314 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 315 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 316 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 317 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 318 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 319 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 320 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 321 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 322 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 323 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 324 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 325 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 326 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 327 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 328 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 329 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 330 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 331 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 332 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 333 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 334 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 335 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 336 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 337 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 338 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 339 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 340 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 341 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 342 | at java.base/java.lang.Thread.run(Thread.java:844) 343 | 2019-04-21 20:10:47,540 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-8] Exception in autocomplete 344 | java.lang.NullPointerException: null 345 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 346 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 347 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 348 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 349 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 350 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 351 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 352 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 353 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 354 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 355 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 356 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 357 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 358 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 359 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 360 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 361 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 362 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 363 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 364 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 365 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 366 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 367 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 368 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 369 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 370 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 371 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 372 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 373 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 374 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 375 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 376 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 377 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 378 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 379 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 380 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 381 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 382 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 383 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 384 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 385 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 386 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 387 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 388 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 389 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 390 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 391 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 392 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 393 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 394 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 395 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 396 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 397 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 398 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 399 | at java.base/java.lang.Thread.run(Thread.java:844) 400 | 2019-04-21 20:17:49,326 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-9] Exception in autocomplete 401 | java.lang.NullPointerException: null 402 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:205) 403 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 404 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 405 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 406 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 407 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 408 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 409 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 410 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 411 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 412 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 413 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 414 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 415 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 416 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 417 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 418 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 419 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 420 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 421 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 422 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 423 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 424 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 425 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 426 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 427 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 428 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 429 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 430 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 431 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 432 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 433 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 434 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 435 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 436 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 437 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 438 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 439 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 440 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 441 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 442 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 443 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 444 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 445 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 446 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 447 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 448 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 449 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 450 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 451 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 452 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 453 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 454 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 455 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 456 | at java.base/java.lang.Thread.run(Thread.java:844) 457 | 2019-04-21 21:04:20,357 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-5] Exception in autocomplete 458 | java.lang.NullPointerException: null 459 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:210) 460 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 461 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 462 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 463 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 464 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 465 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 466 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 467 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 468 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 469 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 470 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 471 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 472 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 473 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 474 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 475 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 476 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 477 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 478 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 479 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 480 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 481 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 482 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 483 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 484 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 485 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 486 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 487 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 488 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 489 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 490 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 491 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 492 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 493 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 494 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 495 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 496 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 497 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 498 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 499 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 500 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 501 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 502 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 503 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 504 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 505 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 506 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 507 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 508 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 509 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 510 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 511 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 512 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 513 | at java.base/java.lang.Thread.run(Thread.java:844) 514 | 2019-04-21 21:09:29,836 ERROR com.plantplaces.PlantPlacesController [http-nio-8080-exec-1] Exception in autocomplete 515 | java.lang.NullPointerException: null 516 | at com.plantplaces.PlantPlacesController.plantNamesAutocomplete(PlantPlacesController.java:210) 517 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 518 | at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 519 | at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 520 | at java.base/java.lang.reflect.Method.invoke(Method.java:564) 521 | at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:209) 522 | at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136) 523 | at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) 524 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:877) 525 | at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:783) 526 | at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) 527 | at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:991) 528 | at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:925) 529 | at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:974) 530 | at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:866) 531 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) 532 | at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:851) 533 | at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) 534 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) 535 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 536 | at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) 537 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 538 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 539 | at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) 540 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 541 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 542 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 543 | at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:109) 544 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 545 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 546 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 547 | at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) 548 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 549 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 550 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 551 | at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) 552 | at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) 553 | at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) 554 | at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) 555 | at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 556 | at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 557 | at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493) 558 | at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 559 | at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81) 560 | at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 561 | at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342) 562 | at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800) 563 | at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 564 | at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:800) 565 | at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1471) 566 | at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 567 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1135) 568 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) 569 | at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 570 | at java.base/java.lang.Thread.run(Thread.java:844) 571 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.plantplaces 8 | plantplaces 9 | 0.0.1-SNAPSHOT 10 | jar 11 | 12 | plantplaces 13 | Demo project for Spring Boot 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.4.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 1.8 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-thymeleaf 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | org.json 47 | json 48 | 20140107 49 | 50 | 51 | 52 | com.squareup.retrofit2 53 | retrofit 54 | 2.3.0 55 | 56 | 57 | 58 | com.google.code.gson 59 | gson 60 | 2.8.5 61 | 62 | 63 | 64 | com.squareup.retrofit2 65 | converter-gson 66 | 2.0.0-beta3 67 | 68 | 69 | org.springframework.boot 70 | spring-boot-starter-data-jpa 71 | 72 | 73 | mysql 74 | mysql-connector-java 75 | 76 | 77 | javax.xml.bind 78 | jaxb-api 79 | 2.3.0 80 | 81 | 82 | org.springframework.boot 83 | spring-boot-starter-activemq 84 | 85 | 86 | 87 | org.springframework.kafka 88 | spring-kafka 89 | 90 | 91 | 92 | org.springframework.kafka 93 | spring-kafka-test 94 | test 95 | 96 | 97 | 98 | 99 | 100 | 101 | org.springframework.boot 102 | spring-boot-maven-plugin 103 | 104 | 105 | 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/PlantPlacesController.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.Map; 6 | import java.util.Set; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.ModelAttribute; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestMethod; 15 | import org.springframework.web.bind.annotation.RequestParam; 16 | import org.springframework.web.bind.annotation.ResponseBody; 17 | import org.springframework.web.multipart.MultipartFile; 18 | import org.springframework.web.servlet.ModelAndView; 19 | 20 | import com.plantplaces.dto.LabelValueDTO; 21 | import com.plantplaces.dto.PhotoDTO; 22 | import com.plantplaces.dto.PlantDTO; 23 | import com.plantplaces.dto.SpecimenDTO; 24 | import com.plantplaces.service.IDashboardService; 25 | import com.plantplaces.service.ISpecimenService; 26 | 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | 30 | 31 | 32 | @Controller 33 | public class PlantPlacesController { 34 | 35 | Logger log = LoggerFactory.getLogger(this.getClass()); 36 | 37 | @Autowired 38 | private ISpecimenService specimenService; 39 | 40 | @Autowired 41 | private IDashboardService dashboardService; 42 | 43 | private List allPlants; 44 | 45 | private String firstThreeCharacters; 46 | 47 | @PostMapping(value="/savespecimen") 48 | public ModelAndView saveSpecimen(@RequestParam("imageFile") MultipartFile imageFile, SpecimenDTO specimenDTO) { 49 | ModelAndView modelAndView = new ModelAndView(); 50 | try { 51 | specimenService.save(specimenDTO); 52 | } catch (Exception e) { 53 | // TODO Auto-generated catch block 54 | log.error("unable to save specimen", e); 55 | e.printStackTrace(); 56 | modelAndView.setViewName("error"); 57 | return modelAndView; 58 | } 59 | 60 | 61 | PhotoDTO photoDTO = new PhotoDTO(); 62 | photoDTO.setFileName(imageFile.getOriginalFilename()); 63 | photoDTO.setPath("/photo/"); 64 | photoDTO.setSpecimenDTO(specimenDTO); 65 | modelAndView.setViewName("success"); 66 | try { 67 | specimenService.saveImage(imageFile, photoDTO); 68 | } catch (Exception e) { 69 | // TODO Auto-generated catch block 70 | e.printStackTrace(); 71 | log.error("Error saving photo", e); 72 | modelAndView.setViewName("error"); 73 | return modelAndView; 74 | } 75 | 76 | modelAndView.addObject("photoDTO", photoDTO); 77 | modelAndView.addObject("specimenDTO", specimenDTO); 78 | return modelAndView; 79 | 80 | } 81 | 82 | /** 83 | * Handle the /start endpoint. 84 | * @return 85 | */ 86 | @RequestMapping(value="/start", method=RequestMethod.GET, headers={"content-type=text/json"}) 87 | @ResponseBody 88 | public SpecimenDTO readJSON(Model model) { 89 | SpecimenDTO specimenDTO = specimenService.fetchById(43); 90 | model.addAttribute("specimenDTO", specimenDTO); 91 | return specimenDTO; 92 | 93 | } 94 | 95 | 96 | @RequestMapping(value="/start", method=RequestMethod.GET) 97 | public String read(Model model) { 98 | log.info("User has entered the /start endpoint"); 99 | model.addAttribute("specimenDTO", new SpecimenDTO()); 100 | return "start"; 101 | } 102 | 103 | @RequestMapping(value="/addspecimen", method=RequestMethod.GET) 104 | public String addSpecimen(Model model, @RequestParam(value="latitude", required=false, defaultValue="0.0") String latitude) { 105 | SpecimenDTO specimenDTO = specimenService.fetchById(43); 106 | specimenDTO.setLatitude(latitude); 107 | model.addAttribute("specimenDTO", specimenDTO); 108 | return "start"; 109 | } 110 | 111 | /** 112 | * Handle the /start endpoint. 113 | * @return 114 | */ 115 | @RequestMapping(value="/start", method=RequestMethod.GET, params= {"loyalty=blue"}) 116 | public String readBlue() { 117 | return "start"; 118 | } 119 | 120 | /** 121 | * Handle the /start endpoint. 122 | * @return 123 | */ 124 | @RequestMapping(value="/start", method=RequestMethod.GET, params= {"loyalty=silver"}) 125 | public ModelAndView readSilver() { 126 | SpecimenDTO specimenDTO = specimenService.fetchById(43); 127 | specimenDTO.setSpecimenId(83); 128 | ModelAndView modelAndView = new ModelAndView(); 129 | modelAndView.setViewName("start"); 130 | modelAndView.addObject("specimenDTO", specimenDTO); 131 | return modelAndView; 132 | } 133 | 134 | @PostMapping("/start") 135 | public String create() { 136 | return "start"; 137 | } 138 | 139 | /** 140 | * Handle the / endpoint 141 | * @return 142 | */ 143 | @RequestMapping("/") 144 | public String index() { 145 | return "start"; 146 | } 147 | 148 | @RequestMapping("/searchPlants") 149 | public ModelAndView searchPlants(@RequestParam(value="searchTerm", required=false, defaultValue="") String searchTerm) { 150 | log.debug("entering search plants"); 151 | ModelAndView modelAndView = new ModelAndView(); 152 | List plants = new ArrayList(); 153 | try { 154 | plants = specimenService.fetchPlants(searchTerm); 155 | modelAndView.setViewName("plantResults"); 156 | if (plants.size() == 0 ) { 157 | log.warn("Received 0 results for search string: " + searchTerm); 158 | } 159 | } catch (Exception e) { 160 | log.error("Error happened in searchPlants endpoint", e); 161 | e.printStackTrace(); 162 | modelAndView.setViewName("error"); 163 | } 164 | modelAndView.addObject("plants", plants); 165 | log.debug("exiting search Plants"); 166 | return modelAndView; 167 | } 168 | 169 | 170 | @RequestMapping("/searchPlantsAll") 171 | public String searchPlantsAll(@RequestParam Map requestParams) { 172 | int params = requestParams.size(); 173 | requestParams.get("searchTerm"); 174 | return "start"; 175 | } 176 | 177 | @RequestMapping("/sustainability") 178 | public String sustainability () { 179 | return "sustainability"; 180 | } 181 | 182 | @RequestMapping("/showSpecimens") 183 | public ModelAndView showSpecimens() { 184 | ModelAndView modelAndView = new ModelAndView(); 185 | 186 | try { 187 | Iterable allSpecimens = specimenService.fetchAllSpecimens(); 188 | modelAndView.setViewName("showSpecimens"); 189 | modelAndView.addObject("allSpecimens", allSpecimens); 190 | } catch (Exception e) { 191 | // TODO Auto-generated catch block 192 | e.printStackTrace(); 193 | log.error("Unable to retrieve specimens", e); 194 | modelAndView.setViewName("error"); 195 | } 196 | return modelAndView; 197 | } 198 | 199 | @RequestMapping(value="/plantNamesAutocomplete") 200 | @ResponseBody 201 | public List plantNamesAutocomplete(@RequestParam(value="term", required = false, defaultValue="") String term) { 202 | List suggestions = new ArrayList(); 203 | try { 204 | // only update when term is three characters. 205 | if (term.length() == 3) { 206 | firstThreeCharacters = term; 207 | allPlants = specimenService.fetchPlants(term); 208 | } 209 | 210 | for (PlantDTO plantDTO : allPlants) { 211 | if (plantDTO.toString().contains(term)) { 212 | LabelValueDTO lv = new LabelValueDTO(); 213 | lv.setLabel(plantDTO.toString()); 214 | lv.setValue(Integer.toString(plantDTO.getGuid())); 215 | suggestions.add(lv); 216 | } 217 | } 218 | } catch (Exception e) { 219 | // TODO Auto-generated catch block 220 | e.printStackTrace(); 221 | log.error("Exception in autocomplete", e); 222 | } 223 | 224 | return suggestions; 225 | 226 | } 227 | 228 | @PostMapping("/uploadImage") 229 | public String uploadImage(@RequestParam("imageFile") MultipartFile imageFile) { 230 | String returnValue = "start"; 231 | 232 | PhotoDTO photoDTO = new PhotoDTO(); 233 | photoDTO.setFileName(imageFile.getOriginalFilename()); 234 | photoDTO.setPath("/photo/"); 235 | 236 | try { 237 | specimenService.saveImage(imageFile, photoDTO); 238 | } catch (Exception e) { 239 | // TODO Auto-generated catch block 240 | e.printStackTrace(); 241 | log.error("Error saving photo", e); 242 | returnValue = "error"; 243 | } 244 | 245 | return returnValue; 246 | } 247 | 248 | @RequestMapping("/showSpecimenDetails") 249 | public ModelAndView showSpecimenDetails(@RequestParam("plant_ID") int plantId) { 250 | ModelAndView modelAndView = new ModelAndView(); 251 | modelAndView.setViewName("specimenDetails"); 252 | List specimens = specimenService.fetchSpecimensByPlantId(plantId); 253 | modelAndView.addObject("specimens", specimens); 254 | return modelAndView; 255 | } 256 | 257 | /** 258 | * Show the dashboard. 259 | * @return 260 | */ 261 | @RequestMapping(value="/dashboard") 262 | public ModelAndView dashboard() { 263 | ModelAndView modelAndView = new ModelAndView(); 264 | modelAndView.setViewName("dashboard"); 265 | Set exceptions = dashboardService.getExceptions(); 266 | 267 | Set processedPhotos = dashboardService.getProcessedPhotos(); 268 | 269 | Set unprocessedPhotos = dashboardService.getUnprocessedPhotos(); 270 | 271 | modelAndView.addObject("exceptions", exceptions); 272 | modelAndView.addObject("processedPhotos", processedPhotos); 273 | modelAndView.addObject("unprocessedPhotos", unprocessedPhotos); 274 | return modelAndView; 275 | } 276 | 277 | } 278 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/PlantplacesApplication.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.cache.annotation.EnableCaching; 6 | import org.springframework.jms.annotation.EnableJms; 7 | 8 | @SpringBootApplication 9 | @EnableCaching 10 | @EnableJms 11 | public class PlantplacesApplication { 12 | 13 | public static void main(String[] args) { 14 | SpringApplication.run(PlantplacesApplication.class, args); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/DashboardDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.springframework.kafka.annotation.KafkaListener; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | public class DashboardDAO implements IDashboardDAO { 11 | 12 | private Set photoOut = new HashSet(); 13 | private Set photoIn = new HashSet(); 14 | private Set photoException = new HashSet(); 15 | 16 | @KafkaListener(topics="photoOut", groupId="plantplaces") 17 | public void processPhotoOut(String path) { 18 | getPhotoOut().add(path); 19 | } 20 | 21 | @KafkaListener(topics="photoIn", groupId="plantplaces") 22 | public void processPhotoIn(String path) { 23 | photoIn.add(path); 24 | } 25 | 26 | @KafkaListener(topics="photoException", groupId="plantplaces") 27 | public void processPhotoException(String path) { 28 | photoException.add(path); 29 | } 30 | 31 | @Override 32 | public Set getPhotoOut() { 33 | return photoOut; 34 | } 35 | 36 | @Override 37 | public void setPhotoOut(Set photoOut) { 38 | this.photoOut = photoOut; 39 | } 40 | /* (non-Javadoc) 41 | * @see com.plantplaces.dao.IDashboardDAO#getPhotoIn() 42 | */ 43 | @Override 44 | public Set getPhotoIn() { 45 | return photoIn; 46 | } 47 | 48 | /* (non-Javadoc) 49 | * @see com.plantplaces.dao.IDashboardDAO#setPhotoIn(java.util.Set) 50 | */ 51 | @Override 52 | public void setPhotoIn(Set photoIn) { 53 | this.photoIn = photoIn; 54 | } 55 | 56 | /* (non-Javadoc) 57 | * @see com.plantplaces.dao.IDashboardDAO#getPhotoException() 58 | */ 59 | @Override 60 | public Set getPhotoException() { 61 | return photoException; 62 | } 63 | 64 | /* (non-Javadoc) 65 | * @see com.plantplaces.dao.IDashboardDAO#setPhotoException(java.util.Set) 66 | */ 67 | @Override 68 | public void setPhotoException(Set photoException) { 69 | this.photoException = photoException; 70 | } 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/GetPlants.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import com.plantplaces.dto.PlantList; 4 | 5 | import retrofit2.Call; 6 | import retrofit2.http.GET; 7 | import retrofit2.http.Query; 8 | 9 | public interface GetPlants { 10 | 11 | @GET("/perl/mobile/viewplantsjson.pl") 12 | Call getAllPlants(@Query("Combined_Name") String combinedName); 13 | 14 | } 15 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/IDashboardDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.util.Set; 4 | 5 | public interface IDashboardDAO { 6 | 7 | Set getPhotoIn(); 8 | 9 | void setPhotoIn(Set photoIn); 10 | 11 | Set getPhotoException(); 12 | 13 | void setPhotoException(Set photoException); 14 | 15 | void setPhotoOut(Set photoOut); 16 | 17 | Set getPhotoOut(); 18 | 19 | } -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/IPhotoDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import org.springframework.web.multipart.MultipartFile; 4 | 5 | import com.plantplaces.dto.PhotoDTO; 6 | 7 | public interface IPhotoDAO { 8 | 9 | void savePhotoImage(PhotoDTO photoDTO, MultipartFile imageFile) throws Exception; 10 | 11 | void save(PhotoDTO photoDTO); 12 | 13 | } -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/IPlantDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.plantplaces.dto.PlantDTO; 6 | 7 | public interface IPlantDAO { 8 | 9 | List fetch(String searchFilter) throws Exception; 10 | 11 | } -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/ISpecimenDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.util.List; 4 | 5 | import com.plantplaces.dto.SpecimenDTO; 6 | 7 | public interface ISpecimenDAO { 8 | 9 | boolean save(SpecimenDTO specimenDTO) throws Exception; 10 | 11 | Iterable fetchAll() throws Exception; 12 | 13 | List fetchSpecimensByPlantId(int plantID); 14 | 15 | } 16 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/NetworkDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedReader; 5 | import java.io.InputStream; 6 | import java.io.InputStreamReader; 7 | import java.net.HttpURLConnection; 8 | import java.net.URL; 9 | 10 | import org.springframework.stereotype.Component; 11 | 12 | @Component 13 | public class NetworkDAO { 14 | 15 | 16 | /** 17 | * Return the data found at the given endpoint 18 | * @param endpoint a URL or other location where we can find data. 19 | * @return All of the data returned as one string. 20 | * @throws Exception 21 | */ 22 | public String request(String endpoint) throws Exception { 23 | StringBuilder sb = new StringBuilder(); 24 | 25 | URL url = new URL(endpoint); 26 | 27 | // open a connection to this URL 28 | HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); 29 | try { 30 | // read in the bytes 31 | InputStream inputStream = urlConnection.getInputStream(); 32 | BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream); 33 | 34 | // read them as characters. 35 | InputStreamReader inputStreamReader = new InputStreamReader(bufferedInputStream); 36 | BufferedReader bufferedReader = new BufferedReader(inputStreamReader); 37 | 38 | // read one line at a time. 39 | String inputLine = bufferedReader.readLine(); 40 | while (inputLine != null) { 41 | // add this to our output 42 | sb.append(inputLine); 43 | // reading the next line 44 | inputLine = bufferedReader.readLine(); 45 | } 46 | } finally { 47 | urlConnection.disconnect(); 48 | } 49 | return sb.toString(); 50 | 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/PhotoDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Path; 5 | import java.nio.file.Paths; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.jms.core.JmsTemplate; 9 | import org.springframework.kafka.core.KafkaTemplate; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import com.plantplaces.dto.PhotoDTO; 14 | 15 | @Component 16 | public class PhotoDAO implements IPhotoDAO { 17 | 18 | @Autowired 19 | private JmsTemplate jmsTemplate; 20 | 21 | @Autowired 22 | private PhotoRepository photoRepository; 23 | 24 | @Autowired 25 | private KafkaTemplate kafkaTemplate; 26 | 27 | /* (non-Javadoc) 28 | * @see com.plantplaces.dao.IPhotoDAO#savePhotoImage(org.springframework.web.multipart.MultipartFile) 29 | */ 30 | @Override 31 | public void savePhotoImage(PhotoDTO photoDTO, MultipartFile imageFile) throws Exception { 32 | // this gets us to src/main/resources without knowing the full path (hardcoding) 33 | Path currentPath = Paths.get("."); 34 | Path absolutePath = currentPath.toAbsolutePath(); 35 | photoDTO.setPath(absolutePath + "/src/main/resources/static/photos/"); 36 | byte[] bytes = imageFile.getBytes(); 37 | Path path = Paths.get(photoDTO.getPath() + imageFile.getOriginalFilename()); 38 | Files.write(path, bytes); 39 | kafkaTemplate.send("photoIn", path.normalize().toString()); 40 | } 41 | 42 | /* (non-Javadoc) 43 | * @see com.plantplaces.dao.IPhotoDAO#save(com.plantplaces.dto.PhotoDTO) 44 | */ 45 | @Override 46 | public void save(PhotoDTO photoDTO) { 47 | photoRepository.save(photoDTO); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/PhotoRepository.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import com.plantplaces.dto.PhotoDTO; 6 | 7 | public interface PhotoRepository extends CrudRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/PlantDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | import java.util.ArrayList; 3 | import java.util.List; 4 | 5 | import org.json.JSONArray; 6 | import org.json.JSONObject; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | import com.plantplaces.dto.PlantDTO; 11 | import com.plantplaces.dto.PlantList; 12 | 13 | import retrofit2.Call; 14 | import retrofit2.GsonConverterFactory; 15 | import retrofit2.Response; 16 | import retrofit2.Retrofit; 17 | 18 | @Component 19 | public class PlantDAO implements IPlantDAO { 20 | @Autowired 21 | NetworkDAO networkDAO; 22 | 23 | 24 | 25 | /* (non-Javadoc) 26 | * @see com.plantplaces.dao.IPlantDAO#fetch(java.lang.String) 27 | */ 28 | public List fetchManual(String searchFilter) throws Exception { 29 | List allPlants = new ArrayList(); 30 | 31 | String rawJson = networkDAO.request("http://plantplaces.com/perl/mobile/viewplantsjson.pl?Combined_Name=Oak"); 32 | 33 | JSONObject root = new JSONObject(rawJson); 34 | 35 | JSONArray plants = root.getJSONArray("plants"); 36 | 37 | for(int i = 0; i < plants.length(); i++) { 38 | // the JSON data 39 | JSONObject jsonPlant = plants.getJSONObject(i); 40 | // Plant object that we will populate from JSON data. 41 | PlantDTO plant = new PlantDTO(); 42 | int guid = jsonPlant.getInt("id"); 43 | String genus = jsonPlant.getString("genus"); 44 | String species = jsonPlant.getString("species"); 45 | String cultivar = jsonPlant.getString("cultivar"); 46 | String common = jsonPlant.getString("common"); 47 | 48 | // populate our DTO with this information,. 49 | plant.setGuid(guid); 50 | plant.setGenus(genus); 51 | plant.setCommon(common); 52 | plant.setCultivar(cultivar); 53 | plant.setSpecies(species); 54 | 55 | // add the populated plant to our collection. 56 | allPlants.add(plant); 57 | 58 | } 59 | 60 | return allPlants; 61 | } 62 | 63 | 64 | 65 | @Override 66 | public List fetch(String searchFilter) throws Exception { 67 | Retrofit retrofit = new Retrofit.Builder() 68 | .baseUrl("http://plantplaces.com") 69 | .addConverterFactory(GsonConverterFactory.create()) 70 | .build(); 71 | 72 | GetPlants getPlants = retrofit.create(GetPlants.class); 73 | 74 | Call allPlants = getPlants.getAllPlants(searchFilter); 75 | Response execute = allPlants.execute(); 76 | PlantList plantList = execute.body(); 77 | 78 | List plants = plantList.getPlants(); 79 | 80 | // TODO Auto-generated method stub 81 | return plants; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/SpecimenDAO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import com.plantplaces.dto.SpecimenDTO; 4 | 5 | import java.util.List; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Component; 9 | 10 | @Component 11 | public class SpecimenDAO implements ISpecimenDAO { 12 | 13 | @Autowired 14 | SpecimenRepository specimenRepository; 15 | 16 | @Override 17 | public boolean save(SpecimenDTO specimenDTO) throws Exception { 18 | // TODO Auto-generated method stub 19 | SpecimenDTO savedSpecimen = specimenRepository.save(specimenDTO); 20 | specimenDTO = savedSpecimen; 21 | return false; 22 | } 23 | 24 | @Override 25 | public Iterable fetchAll() throws Exception { 26 | return specimenRepository.findAll(); 27 | } 28 | 29 | @Override 30 | public List fetchSpecimensByPlantId(int plantID) { 31 | return specimenRepository.findByPlantId(plantID); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dao/SpecimenRepository.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dao; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | 7 | import com.plantplaces.dto.SpecimenDTO; 8 | 9 | public interface SpecimenRepository extends CrudRepository { 10 | List findByPlantId(int plantId); 11 | } 12 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dto/LabelValueDTO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dto; 2 | 3 | public class LabelValueDTO { 4 | 5 | private String label; 6 | private String value; 7 | 8 | public String getLabel() { 9 | return label; 10 | } 11 | public void setLabel(String label) { 12 | this.label = label; 13 | } 14 | public String getValue() { 15 | return value; 16 | } 17 | public void setValue(String value) { 18 | this.value = value; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dto/PhotoDTO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dto; 2 | 3 | import javax.persistence.Entity; 4 | import javax.persistence.GeneratedValue; 5 | import javax.persistence.Id; 6 | import javax.persistence.JoinColumn; 7 | import javax.persistence.ManyToOne; 8 | import javax.persistence.Table; 9 | 10 | @Entity 11 | @Table(name="photos") 12 | public class PhotoDTO { 13 | 14 | 15 | @Id 16 | @GeneratedValue 17 | private int photoId; 18 | private String photographer; 19 | private String path; 20 | private String fileName; 21 | private String comments; 22 | 23 | @ManyToOne 24 | @JoinColumn(name="SPECIMEN_ID") 25 | private SpecimenDTO specimenDTO; 26 | 27 | public String getPhotographer() { 28 | return photographer; 29 | } 30 | public void setPhotographer(String photographer) { 31 | this.photographer = photographer; 32 | } 33 | public String getPath() { 34 | return path; 35 | } 36 | public void setPath(String path) { 37 | this.path = path; 38 | } 39 | public String getFileName() { 40 | return fileName; 41 | } 42 | public void setFileName(String fileName) { 43 | this.fileName = fileName; 44 | } 45 | public String getComments() { 46 | return comments; 47 | } 48 | public void setComments(String comments) { 49 | this.comments = comments; 50 | } 51 | public SpecimenDTO getSpecimenDTO() { 52 | return specimenDTO; 53 | } 54 | public void setSpecimenDTO(SpecimenDTO specimenDTO) { 55 | this.specimenDTO = specimenDTO; 56 | } 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dto/PlantDTO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dto; 2 | 3 | import com.google.gson.annotations.Expose; 4 | import com.google.gson.annotations.SerializedName; 5 | 6 | public class PlantDTO { 7 | @SerializedName("id") 8 | @Expose 9 | private int guid; 10 | @SerializedName("genus") 11 | @Expose 12 | private String genus; 13 | @SerializedName("species") 14 | @Expose 15 | private String species; 16 | @SerializedName("cultivar") 17 | @Expose 18 | private String cultivar; 19 | @SerializedName("common") 20 | @Expose 21 | private String common; 22 | 23 | public int getGuid() { 24 | return guid; 25 | } 26 | public void setGuid(int guid) { 27 | this.guid = guid; 28 | } 29 | public String getGenus() { 30 | return genus; 31 | } 32 | public void setGenus(String genus) { 33 | this.genus = genus; 34 | } 35 | public String getSpecies() { 36 | return species; 37 | } 38 | public void setSpecies(String species) { 39 | this.species = species; 40 | } 41 | public String getCultivar() { 42 | return cultivar; 43 | } 44 | public void setCultivar(String cultivar) { 45 | this.cultivar = cultivar; 46 | } 47 | public String getCommon() { 48 | return common; 49 | } 50 | public void setCommon(String common) { 51 | this.common = common; 52 | } 53 | 54 | @Override 55 | public String toString() { 56 | // TODO Auto-generated method stub 57 | return genus + " " + species + " " + cultivar + " " + common; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dto/PlantList.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dto; 2 | 3 | import java.util.List; 4 | 5 | import com.google.gson.annotations.Expose; 6 | import com.google.gson.annotations.SerializedName; 7 | 8 | public class PlantList { 9 | @SerializedName("plants") 10 | @Expose 11 | private List plants = null; 12 | 13 | public List getPlants() { 14 | return plants; 15 | } 16 | 17 | public void setPlants(List plants) { 18 | this.plants = plants; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/dto/SpecimenDTO.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.dto; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.OneToMany; 11 | import javax.persistence.Table; 12 | 13 | import org.springframework.stereotype.Component; 14 | 15 | @Entity 16 | @Table(name="specimens") 17 | public class SpecimenDTO { 18 | 19 | @Id 20 | @GeneratedValue 21 | @Column(name="SPECIMEN_ID") 22 | private int specimenId; 23 | @Column(name="LATITUDE") 24 | private String latitude; 25 | @Column(name="LONGITUDE") 26 | private String longitude; 27 | @Column(name="DESCRIPTION") 28 | private String description; 29 | @Column(name="PLANT_ID") 30 | private int plantId; 31 | @Column(name="PLANT_NAME") 32 | private String plantName; 33 | 34 | @OneToMany(mappedBy="specimenDTO") 35 | private List photos; 36 | 37 | public int getSpecimenId() { 38 | return specimenId; 39 | } 40 | public void setSpecimenId(int specimenId) { 41 | this.specimenId = specimenId; 42 | } 43 | public String getLatitude() { 44 | return latitude; 45 | } 46 | public void setLatitude(String latitude) { 47 | this.latitude = latitude; 48 | } 49 | public String getLongitude() { 50 | return longitude; 51 | } 52 | public void setLongitude(String longitude) { 53 | this.longitude = longitude; 54 | } 55 | public String getDescription() { 56 | return description; 57 | } 58 | public void setDescription(String description) { 59 | this.description = description; 60 | } 61 | 62 | public int getPlantId() { 63 | return plantId; 64 | } 65 | public void setPlantId(int plantId) { 66 | this.plantId = plantId; 67 | } 68 | public String getPlantName() { 69 | return plantName; 70 | } 71 | public void setPlantName(String plantName) { 72 | this.plantName = plantName; 73 | } 74 | public List getPhotos() { 75 | return photos; 76 | } 77 | public void setPhotos(List photos) { 78 | this.photos = photos; 79 | } 80 | @Override 81 | public String toString() { 82 | // TODO Auto-generated method stub 83 | return plantName + " " + specimenId + " " + latitude + " " + longitude + " " + description; 84 | } 85 | 86 | @Override 87 | public boolean equals(Object obj) { 88 | // assume they don't match. 89 | boolean returnValue = false; 90 | if (obj instanceof SpecimenDTO) { 91 | SpecimenDTO incomingSpecimen = (SpecimenDTO) obj; 92 | returnValue = incomingSpecimen.getSpecimenId() == getSpecimenId(); 93 | } 94 | return returnValue; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/service/DashboardService.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.service; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Service; 8 | 9 | import com.plantplaces.dao.IDashboardDAO; 10 | 11 | @Service 12 | public class DashboardService implements IDashboardService { 13 | 14 | @Autowired 15 | private IDashboardDAO dashboardDAO; 16 | 17 | @Override 18 | public Set getUnprocessedPhotos() { 19 | Set intersection = new HashSet(dashboardDAO.getPhotoIn()); 20 | intersection.removeAll(dashboardDAO.getPhotoOut()); 21 | return intersection; 22 | } 23 | 24 | @Override 25 | public Set getProcessedPhotos() { 26 | Set intersection = new HashSet(dashboardDAO.getPhotoIn()); 27 | intersection.retainAll(dashboardDAO.getPhotoOut()); 28 | return intersection; 29 | } 30 | 31 | @Override 32 | public Set getExceptions() { 33 | return dashboardDAO.getPhotoException(); 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/service/IDashboardService.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.service; 2 | 3 | import java.util.Set; 4 | 5 | public interface IDashboardService { 6 | 7 | Set getExceptions(); 8 | 9 | Set getProcessedPhotos(); 10 | 11 | Set getUnprocessedPhotos(); 12 | 13 | } -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/service/ISpecimenService.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.service; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.web.multipart.MultipartFile; 6 | 7 | import com.plantplaces.dao.ISpecimenDAO; 8 | import com.plantplaces.dto.PhotoDTO; 9 | import com.plantplaces.dto.PlantDTO; 10 | import com.plantplaces.dto.SpecimenDTO; 11 | 12 | /** 13 | * CRUD operations for specimens 14 | * @author Administrator 15 | * 16 | */ 17 | public interface ISpecimenService { 18 | 19 | /** 20 | * Get specimens from persistence layer. 21 | * @param id a unique lookup 22 | * @return a specimen with a matching ID. 23 | */ 24 | SpecimenDTO fetchById(int id); 25 | 26 | /** 27 | * Persist the given DTO 28 | * @param specimenDTO 29 | */ 30 | boolean save(SpecimenDTO specimenDTO) throws Exception; 31 | 32 | /** 33 | * Return a list of plants that contain this String. 34 | * @param string the search criteria: can be genus, species, cultivar, or common 35 | * @return a list of matching plants. 36 | */ 37 | List fetchPlants(String string) throws Exception; 38 | 39 | void setSpecimenDAO(ISpecimenDAO specimenDAO); 40 | 41 | ISpecimenDAO getSpecimenDAO(); 42 | 43 | Iterable fetchAllSpecimens() throws Exception; 44 | 45 | void saveImage(MultipartFile imageFile, PhotoDTO photoDTO) throws Exception; 46 | 47 | List fetchSpecimensByPlantId(int plantID); 48 | 49 | 50 | } -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/service/SpecimenService.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.service; 2 | 3 | import java.nio.file.Files; 4 | import java.nio.file.Path; 5 | import java.nio.file.Paths; 6 | import java.util.List; 7 | 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.cache.annotation.Cacheable; 10 | import org.springframework.stereotype.Component; 11 | import org.springframework.web.multipart.MultipartFile; 12 | 13 | import com.plantplaces.dao.IPhotoDAO; 14 | import com.plantplaces.dao.IPlantDAO; 15 | import com.plantplaces.dao.ISpecimenDAO; 16 | import com.plantplaces.dto.PhotoDTO; 17 | import com.plantplaces.dto.PlantDTO; 18 | import com.plantplaces.dto.SpecimenDTO; 19 | 20 | @Component 21 | public class SpecimenService implements ISpecimenService { 22 | 23 | @Autowired 24 | IPlantDAO plantDAO; 25 | 26 | @Autowired 27 | ISpecimenDAO specimenDAO; 28 | 29 | @Autowired 30 | IPhotoDAO photoDAO; 31 | 32 | @Override 33 | public SpecimenDTO fetchById(int id) { 34 | // TODO Auto-generated method stub 35 | return null; 36 | } 37 | 38 | @Override 39 | public boolean save(SpecimenDTO specimenDTO) throws Exception { 40 | // TODO Auto-generated method stub 41 | specimenDAO.save(specimenDTO); 42 | return false; 43 | } 44 | 45 | @Override 46 | @Cacheable("fetchPlants") 47 | public List fetchPlants(String searchTerm) throws Exception { 48 | // TODO Auto-generated method stub 49 | return plantDAO.fetch(searchTerm); 50 | 51 | } 52 | 53 | @Override 54 | public Iterable fetchAllSpecimens() throws Exception { 55 | return specimenDAO.fetchAll(); 56 | } 57 | 58 | @Override 59 | public void setSpecimenDAO(ISpecimenDAO specimenDAO) { 60 | // TODO Auto-generated method stub 61 | 62 | } 63 | 64 | @Override 65 | public ISpecimenDAO getSpecimenDAO() { 66 | // TODO Auto-generated method stub 67 | return null; 68 | } 69 | 70 | @Override 71 | public void saveImage(MultipartFile imageFile, PhotoDTO photoDTO) throws Exception { 72 | photoDAO.savePhotoImage(photoDTO, imageFile); 73 | photoDAO.save(photoDTO); 74 | } 75 | 76 | @Override 77 | public List fetchSpecimensByPlantId(int plantID) { 78 | return specimenDAO.fetchSpecimensByPlantId(plantID); 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/java/com/plantplaces/service/SpecimenServiceStub.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces.service; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.stereotype.Component; 8 | import org.springframework.web.multipart.MultipartFile; 9 | 10 | import com.plantplaces.dao.ISpecimenDAO; 11 | import com.plantplaces.dto.PhotoDTO; 12 | import com.plantplaces.dto.PlantDTO; 13 | import com.plantplaces.dto.SpecimenDTO; 14 | 15 | @Component 16 | public class SpecimenServiceStub implements ISpecimenService { 17 | 18 | private ISpecimenDAO specimenDAO; 19 | 20 | /* (non-Javadoc) 21 | * @see com.plantplaces.service.ISpecimenService#fetchById(int) 22 | */ 23 | @Override 24 | public SpecimenDTO fetchById(int id) { 25 | SpecimenDTO specimenDTO = new SpecimenDTO(); 26 | specimenDTO.setSpecimenId(43); 27 | specimenDTO.setLatitude("39.74"); 28 | specimenDTO.setLongitude("-84.51"); 29 | specimenDTO.setDescription("A beautiful Eastern Redbud"); 30 | return specimenDTO; 31 | 32 | } 33 | 34 | /* (non-Javadoc) 35 | * @see com.plantplaces.service.ISpecimenService#save(com.plantplaces.dto.SpecimenDTO) 36 | */ 37 | @Override 38 | public boolean save(SpecimenDTO specimenDTO) throws Exception { 39 | boolean result = specimenDAO.save(specimenDTO); 40 | return result; 41 | } 42 | 43 | @Override 44 | public List fetchPlants(String searchTerm) { 45 | // stub out a plant fetch mechanism. 46 | List matchingPlants = new ArrayList(); 47 | 48 | if (searchTerm.contains("edbud") || searchTerm.contains("Cercis")) { 49 | PlantDTO plant = new PlantDTO(); 50 | plant.setGenus("Cercis"); 51 | plant.setSpecies("canadensis"); 52 | plant.setCommon("Eastern Redbud"); 53 | matchingPlants.add(plant); 54 | 55 | } 56 | return matchingPlants; 57 | } 58 | 59 | @Override 60 | public ISpecimenDAO getSpecimenDAO() { 61 | return specimenDAO; 62 | } 63 | 64 | @Override 65 | public void setSpecimenDAO(ISpecimenDAO specimenDAO) { 66 | this.specimenDAO = specimenDAO; 67 | } 68 | 69 | @Override 70 | public Iterable fetchAllSpecimens() throws Exception { 71 | // TODO Auto-generated method stub 72 | return null; 73 | } 74 | 75 | @Override 76 | public void saveImage(MultipartFile imageFile, PhotoDTO photoDTO) throws Exception { 77 | // TODO Auto-generated method stub 78 | 79 | } 80 | 81 | @Override 82 | public List fetchSpecimensByPlantId(int plantID) { 83 | // TODO Auto-generated method stub 84 | return null; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | spring.jpa.hibernate.ddl-auto=update 2 | spring.datasource.url=jdbc:mysql://localhost:3306/plants 3 | spring.datasource.username=admin 4 | spring.datasource.password=Snoopy14+ 5 | spring.activemq.user=admin 6 | spring.activemq.password=admin 7 | spring.activemq.broker-url=tcp://localhost:61616 8 | 9 | spring.kafka.consumer.bootstrap-servers=localhost:9092 10 | spring.kafka.consumer.group-id=plantplaces 11 | spring.kafka.consumer.auto-offset-reset=earliest 12 | spring.kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer 13 | spring.kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer 14 | 15 | spring.kafka.producer.bootstrap-servers=localhost:9092 16 | spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer 17 | spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/logback-spring.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | %d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n 11 | 12 | 13 | 14 | 15 | 17 | ${LOGS}/spring-boot-logger.log 18 | 20 | %d %p %C{1.} [%t] %m%n 21 | 22 | 23 | 25 | 26 | ${LOGS}/archived/spring-boot-logger-%d{yyyy-MM-dd}.%i.log 27 | 28 | 30 | 10MB 31 | 32 | 33 | 34 | 35 | 37 | ${LOGS}/severe-logger.log 38 | 39 | WARN 40 | 41 | 43 | %d %p %C{1.} [%t] %m%n 44 | 45 | 46 | 48 | 49 | ${LOGS}/archived/severe-logger-%d{yyyy-MM-dd}.%i.log 50 | 51 | 53 | 10MB 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/dashboard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum: Dashboard 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |

Processed

16 |
    17 |
  • 18 |
19 |

Unprocessed

20 |
    21 |
  • 22 |
23 |

Exceptions

24 |
    25 |
  • 26 |
27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/fragments/topnav.html: -------------------------------------------------------------------------------- 1 |
2 | 26 |
-------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/plantResults.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
16 | 17 |

18 | 19 |

20 | 21 | 22 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/showSpecimens.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 |
    16 |
  • 17 |
18 | 19 | 20 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/specimenDetails.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 |
16 | 17 |
18 |
19 |

20 | 21 |

41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/start.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 31 | 32 | 33 | 34 |
35 |
36 | 37 |
38 | Your specimen is:

39 | 40 | 41 |

42 |
43 |
44 | Latitude 45 |
46 | 47 |
48 |
49 |
50 | Longitude 51 |
52 | 53 |
54 |
55 |
56 | Description 57 |
58 | 59 |
60 |
61 |
62 | Plant Name 63 |
64 | 65 |
66 | 67 | 68 | 69 | 70 |
71 | 72 | 73 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/success.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 31 | 32 | 33 | 34 |
35 |
36 |

Saved!

37 |
38 | Your specimen is:

39 | 40 | 41 |

42 |
43 |
44 | Latitude 45 |
46 | 47 |
48 |
49 |
50 | Longitude 51 |
52 | 53 |
54 |
55 |
56 | Description 57 |
58 | 59 |
60 |
61 |
62 | Plant Name 63 |
64 | 65 |
66 | 67 | 68 | 69 | 70 |
71 | Photo upload confirmation 72 | 73 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/main/resources/templates/sustainability.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PlantPlaces.com Virtual Arboretum 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 |
15 | Your sustainability rating is: 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/test/java/com/plantplaces/JUnitAnnotationExamples.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertNull; 5 | import static org.junit.Assert.assertTrue; 6 | import static org.junit.Assert.fail; 7 | 8 | import org.junit.After; 9 | import org.junit.AfterClass; 10 | import org.junit.Before; 11 | import org.junit.BeforeClass; 12 | import org.junit.Ignore; 13 | import org.junit.Test; 14 | 15 | public class JUnitAnnotationExamples { 16 | 17 | @BeforeClass 18 | public static void setupEverything() { 19 | int i = 1 + 1; 20 | } 21 | 22 | @Before 23 | public void setupBeforeEachTest() { 24 | int i = 1 + 1; 25 | } 26 | 27 | @Test 28 | public void runTests() { 29 | double i = 1.01 + 1.01; 30 | assertEquals(2.0, i, 0.3); 31 | } 32 | 33 | @Test 34 | public void runMoreTests() { 35 | int i = 1 + 1; 36 | assertEquals(2, i); 37 | Object o = null; 38 | assertNull(o); 39 | assertTrue(4 == 2 + 2); 40 | } 41 | 42 | @Ignore 43 | @Test 44 | public void runFailTests() { 45 | fail(); 46 | } 47 | 48 | @AfterClass 49 | public static void teardownEverything() { 50 | int i = 1 + 1; 51 | } 52 | 53 | @After 54 | public void teardownBeforeEachTest() { 55 | int i = 1 + 1; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/test/java/com/plantplaces/PlantplacesApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces; 2 | 3 | import org.junit.Test; 4 | import org.junit.runner.RunWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit4.SpringRunner; 7 | 8 | @RunWith(SpringRunner.class) 9 | @SpringBootTest 10 | public class PlantplacesApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /plantplaces/plantplaces/src/test/java/com/plantplaces/SpecimenServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.plantplaces; 2 | 3 | import static org.junit.Assert.assertEquals; 4 | import static org.junit.Assert.assertTrue; 5 | import static org.junit.Assert.fail; 6 | 7 | import java.util.List; 8 | 9 | import org.junit.Before; 10 | import org.junit.BeforeClass; 11 | import org.junit.Test; 12 | import org.junit.runner.RunWith; 13 | import org.mockito.Mockito; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.boot.test.context.SpringBootTest; 16 | import org.springframework.boot.test.mock.mockito.MockBean; 17 | import org.springframework.test.context.junit4.SpringRunner; 18 | 19 | import com.plantplaces.dao.ISpecimenDAO; 20 | import com.plantplaces.dto.PlantDTO; 21 | import com.plantplaces.dto.SpecimenDTO; 22 | import com.plantplaces.service.ISpecimenService; 23 | 24 | @RunWith(SpringRunner.class) 25 | @SpringBootTest() 26 | public class SpecimenServiceTest { 27 | 28 | @Autowired 29 | ISpecimenService specimenService; 30 | List plants; 31 | private SpecimenDTO specimen; 32 | 33 | @MockBean 34 | private ISpecimenDAO specimenDAO; 35 | 36 | @Before 37 | public void setup() throws Exception { 38 | SpecimenDTO specimen = new SpecimenDTO(); 39 | specimen.setDescription("A beautiful Redbud I planted myself"); 40 | specimen.setSpecimenId(83); 41 | Mockito.when(specimenDAO.save(specimen)).thenReturn(true); 42 | specimenService.setSpecimenDAO(specimenDAO); 43 | } 44 | 45 | @Test 46 | public void saveSpecimen_whenRedbudEntered() throws Exception { 47 | givenUserIsLoggedInToMyPlantDiary(); 48 | whenUserSearchesForEasternRedbud(); 49 | whenUserAddsTextDetails(); 50 | thenSpecimenIsSaved(); 51 | } 52 | 53 | private void whenUserSearchesForEasternRedbud() throws Exception { 54 | plants = specimenService.fetchPlants("Eastern Redbud"); 55 | } 56 | 57 | private void whenUserAddsTextDetails() { 58 | specimen = new SpecimenDTO(); 59 | PlantDTO plantDTO = plants.get(0); 60 | specimen.setPlantId(plantDTO.getGuid()); 61 | specimen.setDescription("A beautiful Redbud I planted myself"); 62 | specimen.setSpecimenId(83); 63 | 64 | } 65 | 66 | private void thenSpecimenIsSaved() { 67 | try { 68 | boolean result = specimenService.save(specimen); 69 | // if we have made it to this line, the test passes. 70 | assertTrue(result); 71 | } catch (Exception e) { 72 | // we should not get here if the test passes. 73 | fail(); 74 | } 75 | } 76 | 77 | @Test 78 | public void fetchPlants_validateNoResultsForJunkData() throws Exception { 79 | givenUserIsLoggedInToMyPlantDiary(); 80 | whenTheUserSearchesForJunk(); 81 | thenMyPlantDiaryReturnsZeroResults(); 82 | } 83 | 84 | @Test 85 | public void fetchPlants_validateResultsForCercis() throws Exception { 86 | givenUserIsLoggedInToMyPlantDiary(); 87 | whenTheUserSearchesForCercis(); 88 | thenMyPlantDiaryReturnsEasternRedbud(); 89 | } 90 | 91 | private void whenTheUserSearchesForCercis() throws Exception { 92 | // TODO Auto-generated method stub 93 | plants = specimenService.fetchPlants("Cercis"); 94 | } 95 | 96 | private void thenMyPlantDiaryReturnsEasternRedbud() { 97 | // TODO Auto-generated method stub 98 | boolean redbudFound = false; 99 | for (PlantDTO plantDTO : plants) { 100 | if (plantDTO.getCommon().contains("Eastern Redbud")) { 101 | redbudFound = true; 102 | } 103 | } 104 | assertTrue(redbudFound); 105 | } 106 | 107 | private void givenUserIsLoggedInToMyPlantDiary() { 108 | 109 | } 110 | 111 | 112 | private void whenTheUserSearchesForJunk() throws Exception { 113 | plants = specimenService.fetchPlants("kajsd;luaopuidfjo;aj;sd"); 114 | } 115 | 116 | 117 | private void thenMyPlantDiaryReturnsZeroResults() { 118 | assertEquals("Number of plants returned", 0, plants.size()); 119 | 120 | } 121 | 122 | 123 | } 124 | --------------------------------------------------------------------------------