├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── src ├── main │ ├── java │ │ └── com │ │ │ └── book │ │ │ └── healthapp │ │ │ ├── helpers │ │ │ ├── DoctorList.java │ │ │ ├── HelloMessage.java │ │ │ └── ExecutionStatus.java │ │ │ ├── repositories │ │ │ ├── RxMedicineDAO.java │ │ │ ├── HealthCentreDAO.java │ │ │ ├── DoctorDAO.java │ │ │ ├── RxDAO.java │ │ │ ├── UserDAO.java │ │ │ └── UserDAOImpl.java │ │ │ ├── services │ │ │ ├── DoctorService.java │ │ │ ├── RxService.java │ │ │ ├── UserService.java │ │ │ ├── RxServiceImpl.java │ │ │ ├── DoctorServiceImpl.java │ │ │ └── UserServiceImpl.java │ │ │ ├── exceptions │ │ │ ├── UnmatchingUserCredentialsException.java │ │ │ └── UserNotFoundException.java │ │ │ ├── interceptors │ │ │ ├── SignupChecks.java │ │ │ └── SignupInterceptor.java │ │ │ ├── controllers │ │ │ ├── LoginController.java │ │ │ ├── DoctorSearchController.java │ │ │ ├── RestDemoController.java │ │ │ └── UserAccountController.java │ │ │ ├── domain │ │ │ ├── Medicine.java │ │ │ ├── DoctorQualification.java │ │ │ ├── Doctor.java │ │ │ ├── DoctorLocation.java │ │ │ ├── Rx.java │ │ │ ├── RxMedicine.java │ │ │ ├── HealthCentre.java │ │ │ └── User.java │ │ │ ├── HealthAppApplication.java │ │ │ └── configuration │ │ │ └── AppConfig.java │ └── resources │ │ ├── application.properties │ │ ├── hibernate.cfg.xml │ │ └── META-INF │ │ └── resources │ │ └── WEB-INF │ │ └── jsp │ │ ├── forgotpassword.jsp │ │ ├── login.jsp │ │ ├── signup.jsp │ │ └── index.jsp └── test │ └── java │ └── com │ └── book │ └── healthapp │ ├── HealthappApplicationTests.java │ └── UserServiceTests.java ├── Dockerfile ├── .gitignore ├── pom.xml ├── mvnw.cmd └── mvnw /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eajitesh/Sample-Spring4-Angular2-App/master/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.3.9/apache-maven-3.3.9-bin.zip 2 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/helpers/DoctorList.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.helpers; 2 | 3 | import java.util.ArrayList; 4 | 5 | import com.book.healthapp.domain.Doctor; 6 | 7 | public class DoctorList extends ArrayList { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM frolvlad/alpine-oraclejdk8:slim 2 | VOLUME /tmp 3 | ADD target/smart-0.0.1-SNAPSHOT.jar app.jar 4 | RUN sh -c 'touch /app.jar' 5 | ENV JAVA_OPTS="" 6 | ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -jar /app.jar" ] 7 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/RxMedicineDAO.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import com.book.healthapp.domain.RxMedicine; 6 | 7 | public interface RxMedicineDAO extends CrudRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/HealthCentreDAO.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import com.book.healthapp.domain.HealthCentre; 6 | 7 | public interface HealthCentreDAO extends CrudRepository { 8 | 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/DoctorService.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 2 | 3 | import java.util.List; 4 | 5 | import com.book.healthapp.domain.Doctor; 6 | 7 | 8 | public interface DoctorService { 9 | 10 | void save(Doctor doctor); 11 | 12 | Iterable findBySpeciality(String specialityCode); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/RxService.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 2 | 3 | import java.util.List; 4 | 5 | import com.book.healthapp.domain.Rx; 6 | 7 | public interface RxService { 8 | 9 | void save(Rx rx); 10 | 11 | Iterable findRxByDoctorId(int doctorId); 12 | 13 | Iterable findRxByPatientId(int userId); 14 | } 15 | -------------------------------------------------------------------------------- /.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 | 12 | ### IntelliJ IDEA ### 13 | .idea 14 | *.iws 15 | *.iml 16 | *.ipr 17 | 18 | ### NetBeans ### 19 | nbproject/private/ 20 | build/ 21 | nbbuild/ 22 | dist/ 23 | nbdist/ 24 | .nb-gradle/ -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/DoctorDAO.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import com.book.healthapp.domain.Doctor; 6 | 7 | public interface DoctorDAO extends CrudRepository { 8 | Iterable findBySpecialityCode(String code); 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/exceptions/UnmatchingUserCredentialsException.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.exceptions; 2 | 3 | public class UnmatchingUserCredentialsException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public UnmatchingUserCredentialsException(String message) { 8 | super(message); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/RxDAO.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import org.springframework.data.repository.CrudRepository; 4 | 5 | import com.book.healthapp.domain.Rx; 6 | 7 | public interface RxDAO extends CrudRepository { 8 | Iterable findByDoctorId(int doctorId); 9 | 10 | Iterable findByUserId(int userId); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/exceptions/UserNotFoundException.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.exceptions; 2 | 3 | public class UserNotFoundException extends Exception { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public UserNotFoundException(String message) { 8 | super(message); 9 | } 10 | 11 | public UserNotFoundException() { 12 | // TODO Auto-generated constructor stub 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/interceptors/SignupChecks.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.interceptors; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Target({ElementType.METHOD, ElementType.TYPE}) 9 | @Retention(RetentionPolicy.RUNTIME) 10 | public @interface SignupChecks { 11 | 12 | } -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/UserDAO.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import java.util.List; 4 | 5 | import com.book.healthapp.domain.User; 6 | 7 | public interface UserDAO { 8 | 9 | User save(User user); 10 | 11 | List findByEmail(String email); 12 | 13 | List findByEmailAndPassword(String email, String password); 14 | 15 | void update(User user); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /src/test/java/com/book/healthapp/HealthappApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp; 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 HealthappApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/helpers/HelloMessage.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.helpers; 2 | 3 | public class HelloMessage { 4 | private String message; 5 | private String name; 6 | public String getMessage() { 7 | return message; 8 | } 9 | public void setMessage(String message) { 10 | this.message = message; 11 | } 12 | public String getName() { 13 | return name; 14 | } 15 | public void setName(String name) { 16 | this.name = name; 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/UserService.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 2 | 3 | import com.book.healthapp.domain.User; 4 | import com.book.healthapp.exceptions.UnmatchingUserCredentialsException; 5 | import com.book.healthapp.exceptions.UserNotFoundException; 6 | 7 | public interface UserService { 8 | 9 | User save(User user); 10 | 11 | void update(User user); 12 | 13 | User doesUserExist(String email) throws UserNotFoundException; 14 | 15 | User isValidUser(String email, String password) throws UnmatchingUserCredentialsException; 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/helpers/ExecutionStatus.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.helpers; 2 | 3 | public class ExecutionStatus { 4 | private String code; 5 | private String message; 6 | 7 | public ExecutionStatus(String code, String message) { 8 | this.code = code; 9 | this.message = message; 10 | } 11 | 12 | public String getCode() { 13 | return code; 14 | } 15 | public void setCode(String code) { 16 | this.code = code; 17 | } 18 | public String getMessage() { 19 | return message; 20 | } 21 | public void setMessage(String message) { 22 | this.message = message; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/controllers/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.ui.Model; 5 | import org.springframework.web.bind.annotation.GetMapping; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | 10 | @Controller 11 | @RequestMapping("/account/login") 12 | public class LoginController { 13 | 14 | @GetMapping 15 | public String login() { 16 | return "login"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # JSP related configuration 2 | spring.mvc.view.prefix=/WEB-INF/jsp/ 3 | spring.mvc.view.suffix=.jsp 4 | 5 | #MySQL Database Configuration 6 | spring.datasource.driverClassName=com.mysql.jdbc.Driver 7 | spring.datasource.url=jdbc:mysql://${DB_HOST}:${DB_PORT}/${DB_NAME} 8 | spring.datasource.username=${DB_USERNAME} 9 | spring.datasource.password=${DB_PASSWORD} 10 | 11 | # Show or not log for each sql query 12 | spring.jpa.show-sql = true 13 | 14 | # Naming strategy 15 | spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy 16 | 17 | # Allows Hibernate to generate SQL optimized for a particular DBMS 18 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect -------------------------------------------------------------------------------- /src/main/resources/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/RxServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 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.Service; 8 | 9 | import com.book.healthapp.domain.Rx; 10 | import com.book.healthapp.repositories.RxDAO; 11 | 12 | @Service 13 | public class RxServiceImpl implements RxService { 14 | 15 | @Autowired private RxDAO rxDAO; 16 | 17 | @Override 18 | public Iterable findRxByDoctorId(int id) { 19 | return rxDAO.findByDoctorId(id); 20 | } 21 | 22 | @Override 23 | public void save(Rx rx) { 24 | rxDAO.save(rx); 25 | } 26 | 27 | @Override 28 | public Iterable findRxByPatientId(int id) { 29 | return rxDAO.findByUserId(id); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/DoctorServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.book.healthapp.domain.Doctor; 9 | import com.book.healthapp.helpers.DoctorList; 10 | import com.book.healthapp.repositories.DoctorDAO; 11 | import com.book.healthapp.repositories.RxDAO; 12 | 13 | @Service 14 | public class DoctorServiceImpl implements DoctorService { 15 | 16 | @Autowired private DoctorDAO doctorDAO; 17 | 18 | @Override 19 | public Iterable findBySpeciality(String specialityCode) { 20 | return doctorDAO.findBySpecialityCode(specialityCode); 21 | } 22 | 23 | @Override 24 | public void save(Doctor doctor) { 25 | doctorDAO.save(doctor); 26 | } 27 | 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/controllers/DoctorSearchController.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.web.bind.annotation.RequestMapping; 5 | import org.springframework.web.bind.annotation.RequestMethod; 6 | import org.springframework.web.bind.annotation.RequestParam; 7 | import org.springframework.web.bind.annotation.RestController; 8 | 9 | import com.book.healthapp.helpers.DoctorList; 10 | import com.book.healthapp.services.DoctorServiceImpl; 11 | 12 | @RestController 13 | public class DoctorSearchController { 14 | 15 | @Autowired 16 | DoctorServiceImpl docService; 17 | 18 | // @RequestMapping(value="/doctors", method=RequestMethod.GET, produces="application/json") 19 | // public DoctorList searchDoctor(@RequestParam(value="location", required=false) String location, 20 | // @RequestParam(value="speciality", required=false) String speciality) { 21 | // DoctorList docList = docService.find(location, speciality); 22 | // return docList; 23 | // } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/controllers/RestDemoController.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.controllers; 2 | 3 | import org.springframework.stereotype.Controller; 4 | import org.springframework.web.bind.annotation.PostMapping; 5 | import org.springframework.web.bind.annotation.RequestBody; 6 | import org.springframework.web.bind.annotation.RequestMapping; 7 | import org.springframework.web.bind.annotation.RequestMethod; 8 | import org.springframework.web.bind.annotation.ResponseBody; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import com.book.healthapp.domain.User; 12 | import com.book.healthapp.helpers.HelloMessage; 13 | 14 | @Controller 15 | public class RestDemoController { 16 | 17 | // @RequestMapping(value="/hello", method=RequestMethod.POST, produces="application/json") 18 | // @ResponseBody 19 | // public HelloMessage getHelloMessage(@RequestBody User user) { 20 | // HelloMessage helloMessage = new HelloMessage(); 21 | // String name = user.getName(); 22 | // helloMessage.setMessage( "Hello " + name + "! How are you doing?"); 23 | // helloMessage.setName(name); 24 | // return helloMessage; 25 | // } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/jsp/forgotpassword.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | 5 | 6 | 7 | Welcome! Forgot Password 8 | 9 | 10 | 11 |
12 | 15 |
16 |
17 |
18 | 19 | 20 |
21 | 22 |
23 |
24 |
25 | 26 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/Medicine.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class Medicine { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private String name; 17 | private String composition; 18 | private Timestamp createTime; 19 | private Timestamp lastUpdated; 20 | public int getId() { 21 | return id; 22 | } 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | public String getName() { 27 | return name; 28 | } 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | public String getComposition() { 33 | return composition; 34 | } 35 | public void setComposition(String composition) { 36 | this.composition = composition; 37 | } 38 | public Timestamp getCreateTime() { 39 | return createTime; 40 | } 41 | public void setCreateTime(Timestamp createTime) { 42 | this.createTime = createTime; 43 | } 44 | public Timestamp getLastUpdated() { 45 | return lastUpdated; 46 | } 47 | public void setLastUpdated(Timestamp lastUpdated) { 48 | this.lastUpdated = lastUpdated; 49 | } 50 | 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/DoctorQualification.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class DoctorQualification { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private int doctorId; 17 | private String degreeCode; 18 | private Timestamp createTime; 19 | private Timestamp lastUpdated; 20 | public int getId() { 21 | return id; 22 | } 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | public int getDoctorId() { 27 | return doctorId; 28 | } 29 | public void setDoctorId(int doctorId) { 30 | this.doctorId = doctorId; 31 | } 32 | public String getDegreeCode() { 33 | return degreeCode; 34 | } 35 | public void setDegreeCode(String degreeCode) { 36 | this.degreeCode = degreeCode; 37 | } 38 | public Timestamp getCreateTime() { 39 | return createTime; 40 | } 41 | public void setCreateTime(Timestamp createTime) { 42 | this.createTime = createTime; 43 | } 44 | public Timestamp getLastUpdated() { 45 | return lastUpdated; 46 | } 47 | public void setLastUpdated(Timestamp lastUpdated) { 48 | this.lastUpdated = lastUpdated; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/Doctor.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class Doctor { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private int userId; 17 | private String specialityCode; 18 | private Timestamp createTime; 19 | private Timestamp lastUpdated; 20 | 21 | 22 | public int getId() { 23 | return id; 24 | } 25 | public void setId(int id) { 26 | this.id = id; 27 | } 28 | 29 | public int getUserId() { 30 | return userId; 31 | } 32 | public void setUserId(int user_id) { 33 | this.userId = user_id; 34 | } 35 | public String getSpecialityCode() { 36 | return specialityCode; 37 | } 38 | public void setSpecialityCode(String specialityCode) { 39 | this.specialityCode = specialityCode; 40 | } 41 | public Timestamp getCreateTime() { 42 | return createTime; 43 | } 44 | public void setCreateTime(Timestamp createTime) { 45 | this.createTime = createTime; 46 | } 47 | public Timestamp getLastUpdated() { 48 | return lastUpdated; 49 | } 50 | public void setLastUpdated(Timestamp lastUpdated) { 51 | this.lastUpdated = lastUpdated; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/DoctorLocation.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class DoctorLocation { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private int doctorId; 17 | private int healthCentreId; 18 | private Timestamp createTime; 19 | private Timestamp lastUpdated; 20 | public int getId() { 21 | return id; 22 | } 23 | public void setId(int id) { 24 | this.id = id; 25 | } 26 | public int getDoctorId() { 27 | return doctorId; 28 | } 29 | public void setDoctorId(int doctorId) { 30 | this.doctorId = doctorId; 31 | } 32 | public int getHealthCentreId() { 33 | return healthCentreId; 34 | } 35 | public void setHealthCentreId(int healthCentreId) { 36 | this.healthCentreId = healthCentreId; 37 | } 38 | public Timestamp getCreateTime() { 39 | return createTime; 40 | } 41 | public void setCreateTime(Timestamp createTime) { 42 | this.createTime = createTime; 43 | } 44 | public Timestamp getLastUpdated() { 45 | return lastUpdated; 46 | } 47 | public void setLastUpdated(Timestamp lastUpdated) { 48 | this.lastUpdated = lastUpdated; 49 | } 50 | 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/HealthAppApplication.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | import org.springframework.boot.autoconfigure.domain.EntityScan; 6 | import org.springframework.context.annotation.ComponentScan; 7 | import org.springframework.stereotype.Controller; 8 | import org.springframework.ui.Model; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RequestMapping; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | 14 | 15 | @Controller 16 | @SpringBootApplication 17 | public class HealthAppApplication { 18 | 19 | @RequestMapping("/") 20 | public String usingRequestParam(Model model, @RequestParam(value="name", required=false) String nickname) { 21 | model.addAttribute("nickname", nickname); 22 | System.out.println("Name: " + nickname); 23 | return "index"; 24 | } 25 | 26 | @GetMapping("/{nickname}") 27 | public String usingPathVariable(Model model, @PathVariable String nickname) { 28 | model.addAttribute("nickname", nickname); 29 | return "index"; 30 | } 31 | 32 | public static void main(String[] args) { 33 | SpringApplication.run(HealthAppApplication.class, args); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/Rx.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class Rx { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private int userId; 17 | private int doctorId; 18 | private String symptoms; 19 | private Timestamp createTime; 20 | private Timestamp lastUpdated; 21 | 22 | public int getId() { 23 | return id; 24 | } 25 | public void setId(int id) { 26 | this.id = id; 27 | } 28 | 29 | public Timestamp getCreateTime() { 30 | return createTime; 31 | } 32 | public void setCreateTime(Timestamp createTime) { 33 | this.createTime = createTime; 34 | } 35 | public Timestamp getLastUpdated() { 36 | return lastUpdated; 37 | } 38 | public void setLastUpdated(Timestamp lastUpdated) { 39 | this.lastUpdated = lastUpdated; 40 | } 41 | public int getUserId() { 42 | return userId; 43 | } 44 | public void setUserId(int user_id) { 45 | this.userId = user_id; 46 | } 47 | public int getDoctorId() { 48 | return doctorId; 49 | } 50 | public void setDoctorId(int doctor_id) { 51 | this.doctorId = doctor_id; 52 | } 53 | public String getSymptoms() { 54 | return symptoms; 55 | } 56 | public void setSymptoms(String symptoms) { 57 | this.symptoms = symptoms; 58 | } 59 | 60 | 61 | 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/RxMedicine.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class RxMedicine { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private int rxId; 17 | private int medicineId; 18 | private String durationCode; 19 | private Timestamp createTime; 20 | private Timestamp lastUpdated; 21 | public int getId() { 22 | return id; 23 | } 24 | public void setId(int id) { 25 | this.id = id; 26 | } 27 | public int getRxId() { 28 | return rxId; 29 | } 30 | public void setRxId(int rxId) { 31 | this.rxId = rxId; 32 | } 33 | public int getMedicineId() { 34 | return medicineId; 35 | } 36 | public void setMedicineId(int medicineId) { 37 | this.medicineId = medicineId; 38 | } 39 | public String getDurationCode() { 40 | return durationCode; 41 | } 42 | public void setDurationCode(String durationCode) { 43 | this.durationCode = durationCode; 44 | } 45 | public Timestamp getCreateTime() { 46 | return createTime; 47 | } 48 | public void setCreateTime(Timestamp createTime) { 49 | this.createTime = createTime; 50 | } 51 | public Timestamp getLastUpdated() { 52 | return lastUpdated; 53 | } 54 | public void setLastUpdated(Timestamp lastUpdated) { 55 | this.lastUpdated = lastUpdated; 56 | } 57 | 58 | 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/jsp/login.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | 5 | 6 | 7 | Welcome! App for Doctors & Patients 8 | 9 | 10 | 11 |
12 | 15 |
16 |
17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 |
25 | 26 |
27 | 31 |
32 | 33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/services/UserServiceImpl.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.services; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import com.book.healthapp.domain.User; 9 | import com.book.healthapp.exceptions.UnmatchingUserCredentialsException; 10 | import com.book.healthapp.exceptions.UserNotFoundException; 11 | import com.book.healthapp.repositories.UserDAO; 12 | 13 | @Service 14 | public class UserServiceImpl implements UserService { 15 | 16 | private UserDAO userDAO; 17 | 18 | @Autowired 19 | public UserServiceImpl(UserDAO userDAO) { 20 | this.userDAO = userDAO; 21 | } 22 | 23 | @Override 24 | public User save(User user) { 25 | return userDAO.save(user); 26 | } 27 | 28 | @Override 29 | public void update(User user) { 30 | userDAO.update(user); 31 | } 32 | 33 | @Override 34 | public User doesUserExist(String email) throws UserNotFoundException { 35 | List users = (List) userDAO.findByEmail(email); 36 | if(users.size() == 0) { 37 | throw new UserNotFoundException("User does not exist in the database."); 38 | } 39 | return users.get(0); 40 | } 41 | 42 | @Override 43 | public User isValidUser(String email, String password) throws UnmatchingUserCredentialsException { 44 | List users = (List) userDAO.findByEmailAndPassword(email, password); 45 | if(users == null || users.size() == 0) { 46 | throw new UnmatchingUserCredentialsException("User with given credentials is not found in the database."); 47 | } 48 | return users.get(0); 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/interceptors/SignupInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.interceptors; 2 | 3 | import javax.servlet.http.HttpServletRequest; 4 | import javax.servlet.http.HttpServletResponse; 5 | 6 | import org.springframework.util.StringUtils; 7 | import org.springframework.web.method.HandlerMethod; 8 | import org.springframework.web.servlet.HandlerInterceptor; 9 | import org.springframework.web.servlet.ModelAndView; 10 | import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; 11 | 12 | public class SignupInterceptor extends HandlerInterceptorAdapter { 13 | 14 | @Override 15 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception exception) 16 | throws Exception { 17 | // TODO Auto-generated method stub 18 | 19 | } 20 | 21 | @Override 22 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) 23 | throws Exception { 24 | // TODO Auto-generated method stub 25 | 26 | } 27 | 28 | @Override 29 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 30 | 31 | String emailAddress = request.getParameter("email"); 32 | String password = request.getParameter("password"); 33 | 34 | if(StringUtils.isEmpty(emailAddress) || StringUtils.containsWhitespace(emailAddress) || 35 | StringUtils.isEmpty(password) || StringUtils.containsWhitespace(password)) { 36 | throw new Exception("Invalid Email Address or Password. Please try again."); 37 | } 38 | 39 | return true; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/jsp/signup.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | 5 | 6 | 7 | Welcome! App for Doctors & Patients 8 | 9 | 10 | 11 |
12 | 15 |
16 |
17 |
18 | 19 | 20 |
21 |
22 | 23 | 24 |
25 |
26 | 27 | 28 |
29 |
30 | 31 |
32 | 33 |
34 |
35 |
36 | 37 | -------------------------------------------------------------------------------- /src/test/java/com/book/healthapp/UserServiceTests.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp; 2 | 3 | import static org.assertj.core.api.Assertions.assertThatThrownBy; 4 | import static org.junit.Assert.*; 5 | 6 | import java.util.ArrayList; 7 | 8 | import org.junit.After; 9 | import org.junit.Before; 10 | import org.junit.jupiter.api.DisplayName; 11 | import org.junit.jupiter.api.Test; 12 | import org.mockito.Mockito; 13 | import org.springframework.boot.test.mock.mockito.MockBean; 14 | 15 | import com.book.healthapp.domain.User; 16 | import com.book.healthapp.exceptions.UserNotFoundException; 17 | import com.book.healthapp.repositories.UserDAO; 18 | import com.book.healthapp.services.UserService; 19 | import com.book.healthapp.services.UserServiceImpl; 20 | 21 | public class UserServiceTests { 22 | 23 | @MockBean UserDAO userDAO; 24 | 25 | private UserService userService; 26 | 27 | @Before 28 | public void setUp() throws Exception { 29 | this.userService = new UserServiceImpl(this.userDAO); 30 | } 31 | 32 | @After 33 | public void tearDown() throws Exception { 34 | } 35 | 36 | @Test 37 | @DisplayName("Throws exception if user with given email does not exist") 38 | void Should_throwException_When_UserDoesNotExist() { 39 | String email = "foo@bar.com"; 40 | Mockito.when(this.userDAO.findByEmail(email)).thenReturn(new ArrayList()); 41 | assertThatThrownBy(() -> this.userService.doesUserExist(email)).isInstanceOf(UserNotFoundException.class) 42 | .hasMessage("User does not exist in the database."); 43 | } 44 | 45 | @Test 46 | @DisplayName("Throws exception if user with given email & password is not found in the database") 47 | void Should_throwException_When_UnmatchingUserCredentialsFound() { 48 | fail("Not yet implemented"); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/HealthCentre.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 4 | 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | 10 | @Entity 11 | public class HealthCentre { 12 | 13 | @Id 14 | @GeneratedValue(strategy=GenerationType.AUTO) 15 | private int id; 16 | private String name; 17 | private String address; 18 | private String cityCode; 19 | private String stateCode; 20 | private String countryCode; 21 | private Timestamp createTime; 22 | private Timestamp lastUpdated; 23 | 24 | public int getId() { 25 | return id; 26 | } 27 | public void setId(int id) { 28 | this.id = id; 29 | } 30 | public String getName() { 31 | return name; 32 | } 33 | public void setName(String name) { 34 | this.name = name; 35 | } 36 | public String getAddress() { 37 | return address; 38 | } 39 | public void setAddress(String address) { 40 | this.address = address; 41 | } 42 | public String getCityCode() { 43 | return cityCode; 44 | } 45 | public void setCityCode(String cityCode) { 46 | this.cityCode = cityCode; 47 | } 48 | public String getStateCode() { 49 | return stateCode; 50 | } 51 | public void setStateCode(String stateCode) { 52 | this.stateCode = stateCode; 53 | } 54 | public String getCountryCode() { 55 | return countryCode; 56 | } 57 | public void setCountryCode(String countryCode) { 58 | this.countryCode = countryCode; 59 | } 60 | public Timestamp getCreateTime() { 61 | return createTime; 62 | } 63 | public void setCreateTime(Timestamp createTime) { 64 | this.createTime = createTime; 65 | } 66 | public Timestamp getLastUpdated() { 67 | return lastUpdated; 68 | } 69 | public void setLastUpdated(Timestamp lastUpdated) { 70 | this.lastUpdated = lastUpdated; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/resources/META-INF/resources/WEB-INF/jsp/index.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | 4 | <%@ taglib prefix='c' uri='http://java.sun.com/jsp/jstl/core' %> 5 | 6 | 7 | 8 | Welcome! Healthcare App 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 |

Welcome to Health App, ${nickname}! ${message}

19 |

This is an app to help patients find doctors, fix appointments and interact with them on ongoing basis.

20 | 21 | 22 |

Sign in

23 |
24 | 25 |

Sign in

26 |
27 | 28 | 29 |
30 |
31 | 32 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/configuration/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.configuration; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.hibernate.SessionFactory; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.beans.factory.annotation.Value; 8 | import org.springframework.boot.autoconfigure.domain.EntityScan; 9 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.ComponentScan; 12 | import org.springframework.context.annotation.Configuration; 13 | import org.springframework.context.annotation.PropertySource; 14 | import org.springframework.orm.hibernate5.HibernateTransactionManager; 15 | import org.springframework.orm.hibernate5.LocalSessionFactoryBuilder; 16 | import org.springframework.transaction.annotation.EnableTransactionManagement; 17 | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; 18 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; 19 | 20 | import com.book.healthapp.domain.User; 21 | import com.book.healthapp.interceptors.SignupInterceptor; 22 | 23 | @Configuration 24 | @EntityScan("com.book.healthapp.domain") 25 | @EnableTransactionManagement 26 | @PropertySource("classpath:application.properties") 27 | public class AppConfig { 28 | 29 | @Value("${spring.datasource.driverClassName}") String driverClassName; 30 | @Value("${spring.datasource.url}") String url; 31 | @Value("${spring.datasource.username}") String username; 32 | @Value("${spring.datasource.password}") String password; 33 | 34 | @Bean(name = "dataSource") 35 | public DataSource getDataSource() { 36 | DataSource dataSource = DataSourceBuilder 37 | .create() 38 | .username(username) 39 | .password(password) 40 | .url(url) 41 | .driverClassName(driverClassName) 42 | .build(); 43 | return dataSource; 44 | } 45 | 46 | @Bean(name = "sessionFactory") 47 | public SessionFactory getSessionFactory(DataSource dataSource) { 48 | LocalSessionFactoryBuilder sessionBuilder = new LocalSessionFactoryBuilder(dataSource); 49 | sessionBuilder.scanPackages("com.book.healthapp.domain"); 50 | return sessionBuilder.buildSessionFactory(); 51 | } 52 | 53 | @Bean(name = "transactionManager") 54 | public HibernateTransactionManager getTransactionManager( 55 | SessionFactory sessionFactory) { 56 | HibernateTransactionManager transactionManager = new HibernateTransactionManager( 57 | sessionFactory); 58 | return transactionManager; 59 | } 60 | 61 | // @Override 62 | // public void addInterceptors(InterceptorRegistry registry) { 63 | // registry.addInterceptor(new SignupInterceptor()).addPathPatterns("/account/signup/process"); 64 | // } 65 | } -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/repositories/UserDAOImpl.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.repositories; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | 6 | import org.hibernate.Query; 7 | import org.hibernate.Session; 8 | import org.hibernate.SessionFactory; 9 | import org.hibernate.Transaction; 10 | import org.hibernate.criterion.Restrictions; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.stereotype.Repository; 13 | import org.springframework.transaction.annotation.Propagation; 14 | import org.springframework.transaction.annotation.Transactional; 15 | 16 | import com.book.healthapp.domain.User; 17 | 18 | @Repository 19 | @Transactional 20 | public class UserDAOImpl implements UserDAO { 21 | 22 | @Autowired private SessionFactory sessionFactory; 23 | 24 | @SuppressWarnings("unchecked") 25 | @Override 26 | public List findByEmail(String email) { 27 | Session session = this.sessionFactory.getCurrentSession(); 28 | Query query = session.getNamedQuery("findByEmail"); 29 | query.setString("email", email); 30 | return query.list(); 31 | } 32 | 33 | @SuppressWarnings("unchecked") 34 | @Override 35 | public List findByEmailAndPassword(String email, String password) { 36 | Session session = this.sessionFactory.getCurrentSession(); 37 | return session.createCriteria(User.class) 38 | .add(Restrictions.eq("email", email)) 39 | .add(Restrictions.eq("password", password)) 40 | .list(); 41 | // Query query = session.getNamedQuery("findByEmailAndPassword"); 42 | // query.setString("email", email); 43 | // query.setString("password", password); 44 | // return query.list(); 45 | // return this.sessionFactory.getCurrentSession() 46 | // .createQuery("from User u where u.email= :email and u.password = :password") 47 | // .setString("email", email) 48 | // .setString("password", password) 49 | // .list(); 50 | } 51 | 52 | @Override 53 | // @Transactional(propagation=Propagation.REQUIRES_NEW) 54 | public User save(User user) { 55 | // Session session = this.sessionFactory.openSession(); 56 | // session.save(user); 57 | // session.flush(); 58 | Session session = this.sessionFactory.openSession(); 59 | // session.beginTransaction(); 60 | // Serializable userId = session.save(user); 61 | session.persist(user); 62 | // user.setFirstName("dummyName"); 63 | // session.getTransaction().commit(); 64 | session.close(); 65 | return user; 66 | } 67 | 68 | @Override 69 | public void update(User user) { 70 | // Session session = this.sessionFactory.openSession(); 71 | // User persistentUser = (User) session.load(User.class, new Integer(user.getId())); 72 | // Transaction tx = session.beginTransaction(); 73 | // persistentUser.setFirstName(user.getFirstname()); 74 | // persistentUser.setLastname(user.getLastname()); 75 | // session.update(persistentUser); 76 | // tx.commit(); 77 | 78 | // Session session = this.sessionFactory.openSession(); 79 | // Transaction tx1 = session.beginTransaction(); 80 | // User persistentUser = (User) session.load(User.class, new Integer(user.getId())); 81 | // tx1.commit(); 82 | // Transaction tx2 = session.beginTransaction(); 83 | // user.setEmail(persistentUser.getEmail()); 84 | // user.setPassword(persistentUser.getPassword()); 85 | // session.merge(user); 86 | // tx2.commit(); 87 | 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/domain/User.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.domain; 2 | 3 | import java.sql.Timestamp; 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.NamedQueries; 11 | import javax.persistence.NamedQuery; 12 | import javax.persistence.Table; 13 | 14 | 15 | 16 | 17 | @Entity 18 | @Table(name="user") 19 | @NamedQueries({ 20 | @NamedQuery( 21 | name = "findByEmail", 22 | query = "from User u where u.email = :email" 23 | ), 24 | @NamedQuery( 25 | name = "findByEmailAndPassword", 26 | query = "from User u where u.email= :email and u.password = :password" 27 | ), 28 | }) 29 | public class User { 30 | 31 | @Id 32 | @GeneratedValue(strategy=GenerationType.IDENTITY) 33 | private int id; 34 | private String email; 35 | private String password; 36 | @Column(name = "first_name") private String firstname; 37 | @Column(name = "last_name") private String lastname; 38 | private int age; 39 | private int gender; 40 | @Column(name = "contact_number") private String contactNumber; 41 | @Column(name = "alternate_contact_number") private String alternateContactNumber; 42 | private String address; 43 | @Column(name = "city_code") private String cityCode; 44 | @Column(name = "state_code") private String stateCode; 45 | @Column(name = "country_code") private String countryCode; 46 | @Column(name = "create_time") private Timestamp createTime; 47 | @Column(name = "last_updated") private Timestamp lastUpdated; 48 | 49 | public String getFirstname() { 50 | return firstname; 51 | } 52 | public void setFirstName(String firstname) { 53 | this.firstname = firstname; 54 | } 55 | public String getLastname() { 56 | return lastname; 57 | } 58 | public void setLastname(String lastname) { 59 | this.lastname = lastname; 60 | } 61 | public int getAge() { 62 | return age; 63 | } 64 | public void setAge(int age) { 65 | this.age = age; 66 | } 67 | public int getGender() { 68 | return gender; 69 | } 70 | public void setGender(int gender) { 71 | this.gender = gender; 72 | } 73 | public String getContactNumber() { 74 | return contactNumber; 75 | } 76 | public void setContactNumber(String contactNumber) { 77 | this.contactNumber = contactNumber; 78 | } 79 | public String getAlternateContactNumber() { 80 | return alternateContactNumber; 81 | } 82 | public void setAlternateContactNumber(String alternateContactNumber) { 83 | this.alternateContactNumber = alternateContactNumber; 84 | } 85 | public Timestamp getCreateTime() { 86 | return createTime; 87 | } 88 | public void setCreateTime(Timestamp createTime) { 89 | this.createTime = createTime; 90 | } 91 | public Timestamp getLastUpdated() { 92 | return lastUpdated; 93 | } 94 | public void setLastUpdated(Timestamp lastUpdated) { 95 | this.lastUpdated = lastUpdated; 96 | } 97 | public String getAddress() { 98 | return address; 99 | } 100 | public void setAddress(String address) { 101 | this.address = address; 102 | } 103 | public String getCityCode() { 104 | return cityCode; 105 | } 106 | public void setCityCode(String cityCode) { 107 | this.cityCode = cityCode; 108 | } 109 | public String getStateCode() { 110 | return stateCode; 111 | } 112 | public void setStateCode(String stateCode) { 113 | this.stateCode = stateCode; 114 | } 115 | public String getCountryCode() { 116 | return countryCode; 117 | } 118 | public void setCountryCode(String countryCode) { 119 | this.countryCode = countryCode; 120 | } 121 | public int getId() { 122 | return id; 123 | } 124 | public void setId(int id) { 125 | this.id = id; 126 | } 127 | public String getEmail() { 128 | return email; 129 | } 130 | public void setEmail(String email) { 131 | this.email = email; 132 | } 133 | public String getPassword() { 134 | return password; 135 | } 136 | public void setPassword(String password) { 137 | this.password = password; 138 | } 139 | 140 | 141 | 142 | 143 | } 144 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | com.book 7 | healthapp 8 | 0.0.1-SNAPSHOT 9 | jar 10 | 11 | healthapp 12 | Demo Healthcare App 13 | 14 | 15 | org.springframework.boot 16 | spring-boot-starter-parent 17 | 1.5.2.RELEASE 18 | 19 | 20 | 21 | 22 | UTF-8 23 | UTF-8 24 | 1.8 25 | 4.12 26 | 5.0.0-M4 27 | ${junit.version}.0-M4 28 | 1.0.0-M4 29 | 1.10.19 30 | 31 | 32 | 33 | 34 | org.springframework.boot 35 | spring-boot-starter-data-jpa 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-web 40 | 41 | 42 | org.springframework.boot 43 | spring-boot-starter-web-services 44 | 45 | 46 | 47 | mysql 48 | mysql-connector-java 49 | runtime 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-test 54 | test 55 | 56 | 57 | org.junit.platform 58 | junit-platform-surefire-provider 59 | ${junit.platform.version} 60 | 61 | 62 | org.junit.jupiter 63 | junit-jupiter-api 64 | ${junit.jupiter.version} 65 | test 66 | 67 | 68 | org.junit.jupiter 69 | junit-jupiter-engine 70 | ${junit.jupiter.version} 71 | 72 | 73 | org.junit.vintage 74 | junit-vintage-engine 75 | ${junit.vintage.version} 76 | 77 | 78 | org.mockito 79 | mockito-core 80 | ${mockito.version} 81 | 82 | 83 | 84 | 85 | 86 | 87 | org.springframework.boot 88 | spring-boot-maven-plugin 89 | 90 | 91 | maven-compiler-plugin 92 | 3.1 93 | 94 | ${java.version} 95 | ${java.version} 96 | 97 | 98 | 99 | maven-surefire-plugin 100 | 2.19.1 101 | 102 | 103 | **/Test*.java 104 | **/*Test.java 105 | **/*Tests.java 106 | **/*TestCase.java 107 | 108 | 109 | 110 | slow 111 | 112 | 113 | 114 | 115 | org.junit.platform 116 | junit-platform-surefire-provider 117 | ${junit.platform.version} 118 | 119 | 120 | org.junit.jupiter 121 | junit-jupiter-engine 122 | ${junit.jupiter.version} 123 | 124 | 125 | org.junit.vintage 126 | junit-vintage-engine 127 | ${junit.vintage.version} 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 39 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 40 | 41 | @REM set %HOME% to equivalent of $HOME 42 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 43 | 44 | @REM Execute a user defined script before this one 45 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 46 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 47 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 48 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 49 | :skipRcPre 50 | 51 | @setlocal 52 | 53 | set ERROR_CODE=0 54 | 55 | @REM To isolate internal variables from possible post scripts, we use another setlocal 56 | @setlocal 57 | 58 | @REM ==== START VALIDATION ==== 59 | if not "%JAVA_HOME%" == "" goto OkJHome 60 | 61 | echo. 62 | echo Error: JAVA_HOME not found in your environment. >&2 63 | echo Please set the JAVA_HOME variable in your environment to match the >&2 64 | echo location of your Java installation. >&2 65 | echo. 66 | goto error 67 | 68 | :OkJHome 69 | if exist "%JAVA_HOME%\bin\java.exe" goto init 70 | 71 | echo. 72 | echo Error: JAVA_HOME is set to an invalid directory. >&2 73 | echo JAVA_HOME = "%JAVA_HOME%" >&2 74 | echo Please set the JAVA_HOME variable in your environment to match the >&2 75 | echo location of your Java installation. >&2 76 | echo. 77 | goto error 78 | 79 | @REM ==== END VALIDATION ==== 80 | 81 | :init 82 | 83 | set MAVEN_CMD_LINE_ARGS=%* 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | 121 | set WRAPPER_JAR="".\.mvn\wrapper\maven-wrapper.jar"" 122 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 123 | 124 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CMD_LINE_ARGS% 125 | if ERRORLEVEL 1 goto error 126 | goto end 127 | 128 | :error 129 | set ERROR_CODE=1 130 | 131 | :end 132 | @endlocal & set ERROR_CODE=%ERROR_CODE% 133 | 134 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 135 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 136 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 137 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 138 | :skipRcPost 139 | 140 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 141 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 142 | 143 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 144 | 145 | exit /B %ERROR_CODE% -------------------------------------------------------------------------------- /src/main/java/com/book/healthapp/controllers/UserAccountController.java: -------------------------------------------------------------------------------- 1 | package com.book.healthapp.controllers; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Controller; 5 | import org.springframework.ui.Model; 6 | import org.springframework.ui.ModelMap; 7 | import org.springframework.web.bind.annotation.GetMapping; 8 | import org.springframework.web.bind.annotation.PostMapping; 9 | import org.springframework.web.bind.annotation.RequestBody; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RequestMethod; 12 | import org.springframework.web.bind.annotation.RequestParam; 13 | import org.springframework.web.bind.annotation.ResponseBody; 14 | import org.springframework.web.bind.annotation.RestController; 15 | import org.springframework.web.servlet.ModelAndView; 16 | 17 | import com.book.healthapp.domain.User; 18 | import com.book.healthapp.exceptions.UnmatchingUserCredentialsException; 19 | import com.book.healthapp.exceptions.UserNotFoundException; 20 | import com.book.healthapp.helpers.ExecutionStatus; 21 | import com.book.healthapp.services.UserService; 22 | 23 | @RestController 24 | @RequestMapping("/account/*") 25 | public class UserAccountController { 26 | 27 | @Autowired UserService userService; 28 | 29 | @GetMapping 30 | public String login() { 31 | return "login"; 32 | } 33 | 34 | @PostMapping(value="/login/process", produces="application/json") 35 | public @ResponseBody ExecutionStatus processLogin(ModelMap model, @RequestBody User reqUser) { 36 | 37 | User user = null; 38 | try { 39 | user = userService.isValidUser(reqUser.getEmail(), reqUser.getPassword()); 40 | } catch (UnmatchingUserCredentialsException e) { 41 | // TODO Auto-generated catch block 42 | e.printStackTrace(); 43 | } 44 | if(user == null) { 45 | return new ExecutionStatus("USER_LOGIN_UNSUCCESSFUL", "Username or password is incorrect. Please try again!"); 46 | } 47 | return new ExecutionStatus("USER_LOGIN_SUCCESSFUL", "Login Successful!"); 48 | } 49 | 50 | 51 | @GetMapping("/signup") 52 | public String signup() { 53 | return "signup"; 54 | } 55 | 56 | @RequestMapping(value="/signup/process", method=RequestMethod.POST, produces="application/json") 57 | public @ResponseBody ExecutionStatus processSignup(ModelMap model, @RequestBody User reqUser) { 58 | 59 | User user = null; 60 | try { 61 | user = userService.doesUserExist(reqUser.getEmail()); 62 | } catch (UserNotFoundException e) { 63 | // TODO Auto-generated catch block 64 | e.printStackTrace(); 65 | } 66 | if(user != null) { 67 | return new ExecutionStatus("USER_ACCOUNT_EXISTS", "User account with same email address exists. Please try again!"); 68 | } 69 | user = new User(); 70 | user.setEmail(reqUser.getEmail()); 71 | user.setPassword(reqUser.getPassword()); 72 | user.setFirstName(reqUser.getFirstname()); 73 | user.setLastname(reqUser.getLastname()); 74 | user.setContactNumber(reqUser.getContactNumber()); 75 | user.setAlternateContactNumber(reqUser.getAlternateContactNumber()); 76 | user.setCityCode(reqUser.getCityCode()); 77 | user.setStateCode(reqUser.getStateCode()); 78 | user.setCountryCode(reqUser.getCountryCode()); 79 | user.setAge(reqUser.getAge()); 80 | user.setGender(reqUser.getGender()); 81 | User persistedUser = userService.save(user); 82 | return new ExecutionStatus("USER_ACCOUNT_CREATED", "User account successfully created"); 83 | } 84 | 85 | @RequestMapping(value="/user/update", method=RequestMethod.POST, produces="application/json") 86 | public @ResponseBody ExecutionStatus updateUser(ModelMap model, @RequestBody User reqUser) { 87 | User user = new User(); 88 | user.setId(reqUser.getId()); 89 | user.setFirstName(reqUser.getFirstname()); 90 | user.setLastname(reqUser.getLastname()); 91 | user.setContactNumber(reqUser.getContactNumber()); 92 | user.setAlternateContactNumber(reqUser.getAlternateContactNumber()); 93 | user.setCityCode(reqUser.getCityCode()); 94 | user.setStateCode(reqUser.getStateCode()); 95 | user.setCountryCode(reqUser.getCountryCode()); 96 | user.setAge(reqUser.getAge()); 97 | user.setGender(reqUser.getGender()); 98 | userService.update(user); 99 | return new ExecutionStatus("USER_ACCOUNT_UPDATED", "User account successfully updated"); 100 | } 101 | 102 | @PostMapping(value="/update", produces="application/json") 103 | public ModelAndView updateProfile(ModelMap model, @RequestParam("firstName") String firstName, 104 | @RequestParam("lastName") String lastName, @RequestParam("address") String address, 105 | @RequestParam("contact_number") String contactNumber) { 106 | return new ModelAndView("update", model); 107 | } 108 | 109 | 110 | @GetMapping("/forgotpassword") 111 | public String forgotpassword() { 112 | return "forgotpassword"; 113 | } 114 | 115 | @PostMapping(value="/forgotpassword/process", produces="application/json") 116 | public ModelAndView processForgotPassword(ModelMap model, @RequestParam("emailaddress") String email) { 117 | 118 | User user = null; 119 | try { 120 | user = userService.doesUserExist(email); 121 | } catch (UserNotFoundException e) { 122 | // TODO Auto-generated catch block 123 | e.printStackTrace(); 124 | } 125 | if(user != null) { 126 | 127 | } 128 | model.addAttribute("message", "An email notification is sent to the registered email address."); 129 | return new ModelAndView("forgotpassword", model); 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # 58 | # Look for the Apple JDKs first to preserve the existing behaviour, and then look 59 | # for the new JDKs provided by Oracle. 60 | # 61 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then 62 | # 63 | # Apple JDKs 64 | # 65 | export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home 66 | fi 67 | 68 | if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then 69 | # 70 | # Apple JDKs 71 | # 72 | export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 73 | fi 74 | 75 | if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then 76 | # 77 | # Oracle JDKs 78 | # 79 | export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home 80 | fi 81 | 82 | if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then 83 | # 84 | # Apple JDKs 85 | # 86 | export JAVA_HOME=`/usr/libexec/java_home` 87 | fi 88 | ;; 89 | esac 90 | 91 | if [ -z "$JAVA_HOME" ] ; then 92 | if [ -r /etc/gentoo-release ] ; then 93 | JAVA_HOME=`java-config --jre-home` 94 | fi 95 | fi 96 | 97 | if [ -z "$M2_HOME" ] ; then 98 | ## resolve links - $0 may be a link to maven's home 99 | PRG="$0" 100 | 101 | # need this for relative symlinks 102 | while [ -h "$PRG" ] ; do 103 | ls=`ls -ld "$PRG"` 104 | link=`expr "$ls" : '.*-> \(.*\)$'` 105 | if expr "$link" : '/.*' > /dev/null; then 106 | PRG="$link" 107 | else 108 | PRG="`dirname "$PRG"`/$link" 109 | fi 110 | done 111 | 112 | saveddir=`pwd` 113 | 114 | M2_HOME=`dirname "$PRG"`/.. 115 | 116 | # make it fully qualified 117 | M2_HOME=`cd "$M2_HOME" && pwd` 118 | 119 | cd "$saveddir" 120 | # echo Using m2 at $M2_HOME 121 | fi 122 | 123 | # For Cygwin, ensure paths are in UNIX format before anything is touched 124 | if $cygwin ; then 125 | [ -n "$M2_HOME" ] && 126 | M2_HOME=`cygpath --unix "$M2_HOME"` 127 | [ -n "$JAVA_HOME" ] && 128 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 129 | [ -n "$CLASSPATH" ] && 130 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 131 | fi 132 | 133 | # For Migwn, ensure paths are in UNIX format before anything is touched 134 | if $mingw ; then 135 | [ -n "$M2_HOME" ] && 136 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 137 | [ -n "$JAVA_HOME" ] && 138 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 139 | # TODO classpath? 140 | fi 141 | 142 | if [ -z "$JAVA_HOME" ]; then 143 | javaExecutable="`which javac`" 144 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 145 | # readlink(1) is not available as standard on Solaris 10. 146 | readLink=`which readlink` 147 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 148 | if $darwin ; then 149 | javaHome="`dirname \"$javaExecutable\"`" 150 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 151 | else 152 | javaExecutable="`readlink -f \"$javaExecutable\"`" 153 | fi 154 | javaHome="`dirname \"$javaExecutable\"`" 155 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 156 | JAVA_HOME="$javaHome" 157 | export JAVA_HOME 158 | fi 159 | fi 160 | fi 161 | 162 | if [ -z "$JAVACMD" ] ; then 163 | if [ -n "$JAVA_HOME" ] ; then 164 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 165 | # IBM's JDK on AIX uses strange locations for the executables 166 | JAVACMD="$JAVA_HOME/jre/sh/java" 167 | else 168 | JAVACMD="$JAVA_HOME/bin/java" 169 | fi 170 | else 171 | JAVACMD="`which java`" 172 | fi 173 | fi 174 | 175 | if [ ! -x "$JAVACMD" ] ; then 176 | echo "Error: JAVA_HOME is not defined correctly." >&2 177 | echo " We cannot execute $JAVACMD" >&2 178 | exit 1 179 | fi 180 | 181 | if [ -z "$JAVA_HOME" ] ; then 182 | echo "Warning: JAVA_HOME environment variable is not set." 183 | fi 184 | 185 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 186 | 187 | # For Cygwin, switch paths to Windows format before running java 188 | if $cygwin; then 189 | [ -n "$M2_HOME" ] && 190 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 191 | [ -n "$JAVA_HOME" ] && 192 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 193 | [ -n "$CLASSPATH" ] && 194 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 195 | fi 196 | 197 | # traverses directory structure from process work directory to filesystem root 198 | # first directory with .mvn subdirectory is considered project base directory 199 | find_maven_basedir() { 200 | local basedir=$(pwd) 201 | local wdir=$(pwd) 202 | while [ "$wdir" != '/' ] ; do 203 | if [ -d "$wdir"/.mvn ] ; then 204 | basedir=$wdir 205 | break 206 | fi 207 | wdir=$(cd "$wdir/.."; pwd) 208 | done 209 | echo "${basedir}" 210 | } 211 | 212 | # concatenates all lines of a file 213 | concat_lines() { 214 | if [ -f "$1" ]; then 215 | echo "$(tr -s '\n' ' ' < "$1")" 216 | fi 217 | } 218 | 219 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)} 220 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 221 | 222 | # Provide a "standardized" way to retrieve the CLI args that will 223 | # work with both Windows and non-Windows executions. 224 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 225 | export MAVEN_CMD_LINE_ARGS 226 | 227 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 228 | 229 | exec "$JAVACMD" \ 230 | $MAVEN_OPTS \ 231 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 232 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 233 | ${WRAPPER_LAUNCHER} "$@" 234 | --------------------------------------------------------------------------------