Commit 1c6e0f74 authored by IevaBekmane's avatar IevaBekmane
Browse files

First commit

parent d5b6639c
Pipeline #1130 failed with stages
/*
* Copyright 2007-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.net.*;
import java.io.*;
import java.nio.channels.*;
import java.util.Properties;
public class MavenWrapperDownloader {
private static final String WRAPPER_VERSION = "0.5.6";
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/"
+ WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if(mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if(mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if(!outputFile.getParentFile().exists()) {
if(!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) {
String username = System.getenv("MVNW_USERNAME");
char[] password = System.getenv("MVNW_PASSWORD").toCharArray();
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar
......@@ -35,6 +35,11 @@
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
package lv.venta.demo.controllers;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import lv.venta.demo.models.Appointment;
import lv.venta.demo.models.Doctor;
import lv.venta.demo.models.Patient;
import lv.venta.demo.models.User;
import lv.venta.demo.services.impl.HospitalServiceImpl;
@Controller
@RequestMapping(value = "/hospital")
public class HospitalController {
@Autowired
HospitalServiceImpl hospitalServiceImpl;
@GetMapping(value = "/dummyDataInput")
@GetMapping("/main")
public String main() {
return "main";
}
@GetMapping("/dummydatainput")
public String callInputDataService() {
return "";
hospitalServiceImpl.dataInput();
return "ok";
}
@GetMapping(value = "/showAllDoctors")
@GetMapping("/showalldoctors")
public String showAllDoctorsInHospital(Model model) {
return "";
model.addAttribute("doctor", hospitalServiceImpl.selectAllDoctors());
return "showalldoctors";
}
@GetMapping(value = "/showAllPatients")
@GetMapping("/showallpatients")
public String showAllPatientsInHospital(Model model) {
return "";
model.addAttribute("patient", hospitalServiceImpl.selectAllPatients());
return "showallpatients";
}
@GetMapping("/showallappointments")
public String showAllAppointmentsInHospital(Model model) {
model.addAttribute("appointment", hospitalServiceImpl.selectAllAppointments());
return "showallappointments";
}
@GetMapping(value = "/insertNewPatient")
@GetMapping("/insertnewpatient")
public String insertNewPatientGet(Patient patient) {
return "";
return "insertnewpatient";
}
@PostMapping(value = "/insertNewPatient")
public String insertNewPatientPost() {
return "";
@PostMapping("/insertnewpatient")
public String insertNewPatientPost(@Valid Patient patient, BindingResult result) {
System.out.println(patient);
if(hospitalServiceImpl.insertNewPatientByObject(patient)) {
return "redirect:/showallpatients";
}
else {
return "insertnewpatient";
}
}
@GetMapping(value = "/insertNewDoctor")
@GetMapping("/insertnewdoctor")
public String insertNewDoctorGet(Doctor doctor) {
return "";
return "insertnewdoctor";
}
@PostMapping(value = "/insertNewDoctor")
public String insertNewDoctorPost() {
return "";
@PostMapping("/insertnewdoctor")
public String insertNewDoctorPost(@Valid Doctor doctor) {
System.out.println(doctor);
if(hospitalServiceImpl.insertNewDoctorByObject(doctor)) {
return "redirect:/showalldoctors";
}
else {
return "insertnewdoctor";
}
}
@GetMapping(value = "/autorise")
public String autoriseGet() {
return "";
@GetMapping("/authorise")
public String authoriseGet(User user) {
return "authorise";
}
@PostMapping(value = "/autorise")
public String autorisePost() {
return "";
@PostMapping("/authorise")
public String authorisePost(User user, BindingResult result) {
if(hospitalServiceImpl.authorise(user) && !result.hasErrors()) {
return "redirect:/main";
}
return "authorise";
}
@GetMapping(value = "/insertNewAppointment")
@GetMapping("/insertnewappointment")
public String insertNewAppointmentGet(Appointment app) {
return "";
return "insertnewappointment";
}
@PostMapping(value = "/insertNewAppointment")
public String insertNewAppointmentPost() {
return "";
@PostMapping("/insertnewappointment")
public String insertNewAppointmentPost(@Valid Appointment app, BindingResult result) {
System.out.println(app);
if(hospitalServiceImpl.insertNewAppointmant(app) && !result.hasErrors()) {
return "redirect:/showalldoctors";
}
else {
return "insertnewappointment";
}
}
@GetMapping(value = "/showAllAppointmentsByPatient/{id}")
public String showAllAppointmentsByPatient(Model model) {
return "";
@GetMapping("/showallappointmentsbypatient/{id}")
public String showAllAppointmentsByPatient(Model model, @PathVariable(name = "id") int id) {
model.addAttribute("allapp", hospitalServiceImpl.showAllAppointmentsByPatientId(id));
return "showallappointmentsbyid";
}
@GetMapping(value = "/showAllAppointmentsByDoctor/{id}")
public String showAllAppointmentsByDoctor(Model model) {
return "";
@GetMapping("/showallappointmentsbydoctor/{id}")
public String showAllAppointmentsByDoctor(Model model, @PathVariable(name = "id") int id) {
model.addAttribute("alldoc", hospitalServiceImpl.showAllAppointmentsByDoctorId(id));
return "showallappointmentsbyid";
}
@GetMapping(value = "/showAllAppointmentsByDoctorToday/{id}")
@GetMapping("/showallappointmentsbydoctortoday/{id}")
public String showAllAppointmentsByDoctorToday(Model model) {
return "";
......
......@@ -4,14 +4,19 @@ import java.util.Date;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Size;
import org.springframework.format.annotation.DateTimeFormat;
@Entity
@Table(name = "AppointmentTable")
public class Appointment {
@Id
......@@ -19,7 +24,7 @@ public class Appointment {
@Column(name = "AppointmentID")
private int appId;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
//@DateTimeFormat(pattern = "dd-MM-yyyy hh:mm")
@Column(name = "DateAndTime")
private Date date;
......@@ -28,11 +33,11 @@ public class Appointment {
private String description;
@ManyToOne(cascade = CascadeType.ALL)
@Column(name = "PatientID")
@JoinColumn(name = "PatientID")
private Patient patient;
@ManyToOne(cascade = CascadeType.ALL)
@Column(name = "DoctorID")
@JoinColumn(name = "DoctorID")
private Doctor doctor;
public int getAppId() {
......@@ -64,12 +69,15 @@ public class Appointment {
}
public void setDoctor(Doctor doctor) {
this.doctor = doctor;
}
public Appointment() {
}
public Appointment(Date date, String description, Patient patient, Doctor doctor) {
setDate(date);
setDescription(description);
setPatient(patient);
setDoctor(doctor);
this.date = date;
this.description = description;
this.doctor = doctor;
this.patient = patient;
}
@Override
public String toString() {
......
package lv.venta.demo.models;
import java.util.Arrays;
import java.util.Collection;
import javax.persistence.Column;
......@@ -12,54 +11,51 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import lv.venta.demo.enums.Gender;
import lv.venta.demo.enums.Nationality;
import lv.venta.demo.enums.Speciality;
@Entity
@Table(name = "DoctorTable")
@Table(name = "DoctotTable")
public class Doctor {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name = "DoctorID")
private int doctorId;
@Column(name = "doctorID")
public int doctorID;
@Column(name = "name")
@Column(name = "Name")
@Size(min = 3, max = 30)
@Pattern(regexp = "[a-zA-Z\\s]+$")
private String name;
public String name;
@Column(name = "Surname")
@Size(min = 3, max = 30)
@Pattern(regexp = "[a-zA-Z\\s]+$")
private String surname;
public String surname;
@Column(name = "Identificator")
private int[] identificator;
@Column(name = "Gender")
private Gender gender;
@Column(name = "Nationality")
private Nationality nationality;
@Size(min = 11, max = 11)
@Pattern(regexp = "\\d+")
@Column(name = "IdentificationNum")
public String identificationNum;
@Column(name = "Speciality")
private Speciality speciality;
public Speciality speciality;
@Column(name = "Office Number")
@Size(min = 100, max = 1000)
private short officeNum;
@Min(value = 100)
@Max(value = 1000)
@Column(name = "OfficeNumber")
public int officeNum;
@OneToMany(mappedBy = "doctor")
private Collection<Doctor> appointmentsForDoctor;
private Collection<Appointment> allAppointmentsForDoctor;
@OneToOne
@JoinColumn(name = "UserID")
private User user;
private User doctorUser;
public String getName() {
return name;
......@@ -73,56 +69,45 @@ public class Doctor {
public void setSurname(String surname) {
this.surname = surname;
}
public int[] getIdentificator() {
return identificator;
}
public void setIdentificator(int[] identificator) {
this.identificator = identificator;
public String getIdentificationNum() {
return identificationNum;
}
public Gender getGender() {
return gender;
public void setIdentificationNum(String identificationNum) {
this.identificationNum = identificationNum;
}
public void setGender(Gender gender) {
this.gender = gender;
}
public Nationality getNationality() {
return nationality;
public Speciality getSpeciality() {
return speciality;
}
public void setNationality(Nationality nationality) {
this.nationality = nationality;
public void setSpeciality(Speciality speciality) {
this.speciality = speciality;
}
public short getOfficeNum() {
public int getOfficeNum() {
return officeNum;
}
public void setOfficeNum(short officeNum) {
public void setOfficeNum(int officeNum) {
this.officeNum = officeNum;
}
public Speciality getSpeciality() {
return speciality;
}
public void setSpeciality(Speciality speciality) {
this.speciality = speciality;
public int getDoctorID() {
return doctorID;
}
public int getDoctorId() {
return doctorId;
public User getDoctorUser() {
return doctorUser;
}
public void setDoctorId(int doctprId) {
this.doctorId = doctprId;
public Doctor(String name, String surname, String identificationNum, Speciality speciality, int officeNum, User doctorUser) {
this.name = name;
this.surname = surname;
this.identificationNum = identificationNum;
this.speciality = speciality;
this.officeNum = officeNum;
this.doctorUser = doctorUser;
}
public Doctor(String name, String surname, int[] identificator, Gender gender, Nationality nationality,
Speciality speciality, short officeNum) {
setName(name);
setSurname(surname);
setIdentificator(identificator);
setGender(gender);
setNationality(nationality);
setSpeciality(speciality);
setOfficeNum(officeNum);
public Doctor() {
}
@Override
public String toString() {
return "Doctor: " + name + " " + surname + ", Identificator: " + Arrays.toString(identificator)
+ ", Gender: " + gender + ", Nationality: " + nationality + ", Speciality: " + speciality + ", Office Number: "
+ officeNum + ", ID: " + doctorId;
return "Doctor: " + name + ", " + surname + ", ID: " + doctorID +", Identification Number: "
+ identificationNum + ", Speciality: " + speciality + ", Office Number: " + officeNum + "|" ;
}
}
package lv.venta.demo.models;
import java.util.Arrays;
import java.util.Collection;
import javax.persistence.Column;
......@@ -37,8 +36,10 @@ public class Patient {
@Pattern(regexp = "[a-zA-Z\\s]+$")
private String surname;
@Column(name = "Identificator")
private int[] identificator;
@Size(min = 11, max = 11)
@Pattern(regexp = "\\d+")
@Column(name = "IdentificationNum")
private String identificationNum;
@Column(name = "Gender")
private Gender gender;
......@@ -46,15 +47,12 @@ public class Patient {
@Column(name = "Nationality")
private Nationality nationality;
@Column(name = "isHospitalised")
private boolean isHospitalised;
@OneToMany(mappedBy = "patient")
private Collection<Appointment> appointmentsForPatient;
@OneToOne
@JoinColumn(name = "UserID")
private User user;
private User patientUser;
public String getName() {
return name;
......@@ -68,11 +66,11 @@ public class Patient {
public void setSurname(String surname) {
this.surname = surname;
}
public int[] getIdentificator() {
return identificator;
public String getIdentificationNum() {
return identificationNum;
}
public void setIdentificator(int[] identificator) {
this.identificator = identificator;
public void setIdentificationNum(String identificationNum) {