diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/DemoJakartaApplication.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/DemoJakartaApplication.java deleted file mode 100644 index b1800fb..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/DemoJakartaApplication.java +++ /dev/null @@ -1,43 +0,0 @@ -package edu.amu.pl.demo; - -import edu.amu.pl.demo.risk.entity.Client; -import edu.amu.pl.demo.risk.entity.Illness; -import edu.amu.pl.demo.risk.repository.ClientRepository; -import edu.amu.pl.demo.risk.repository.IllnessRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; - -import java.util.Set; - -@SpringBootApplication -public class DemoJakartaApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoJakartaApplication.class, args); - } - - @Bean - public CommandLineRunner populate( - @Autowired IllnessRepository illnessRepository, @Autowired ClientRepository repository) { - return (args) -> { - // Hypothetical conditions with corresponding risk factors - var hypertension = illnessRepository.save(new Illness(null, "Nadciśnienie", 0.7d)); - var liverCancer = illnessRepository.save(new Illness(null, "Rak wątroby", 0.95d)); - var obesity = illnessRepository.save(new Illness(null, "Otyłość", 0.6d)); - var stupidity = illnessRepository.save(new Illness(null, "Głupota", 0.8d)); - - // Clients with their conditions - repository.save(new Client(null, Set.of(hypertension, obesity, stupidity))); - repository.save(new Client(null, Set.of(liverCancer, obesity))); - repository.save(new Client(null, Set.of())); - - }; - } -} - diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/dto/RiskFactorDTO.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/dto/RiskFactorDTO.java deleted file mode 100644 index 05ac719..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/dto/RiskFactorDTO.java +++ /dev/null @@ -1,15 +0,0 @@ -package edu.amu.pl.demo.risk.dto; - -import lombok.*; - -@NoArgsConstructor -@AllArgsConstructor -@Setter -@Getter -@ToString -public class RiskFactorDTO { - - Long clientId; - Double riskFactor; - -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Client.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Client.java deleted file mode 100644 index 1264dd8..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Client.java +++ /dev/null @@ -1,30 +0,0 @@ -package edu.amu.pl.demo.risk.entity; - -import jakarta.persistence.*; -import lombok.*; - -import java.util.Set; - -@Entity(name = "client") -@Table(name = "client") -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@ToString -public class Client { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "client_id") - private Long id; - - @ManyToMany - @JoinTable( - name = "client_illness", - joinColumns = @JoinColumn(name = "client_id"), - inverseJoinColumns = @JoinColumn(name = "illness_id") - ) - private Set conditions; - -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Illness.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Illness.java deleted file mode 100644 index 56d6a06..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/entity/Illness.java +++ /dev/null @@ -1,27 +0,0 @@ -package edu.amu.pl.demo.risk.entity; - -import jakarta.persistence.*; -import lombok.*; - -@Entity(name = "illness") -@Table(name = "illness") -@NoArgsConstructor -@AllArgsConstructor -@Getter -@Setter -@EqualsAndHashCode -@ToString -public class Illness { - - @Id - @GeneratedValue(strategy = GenerationType.AUTO) - @Column(name = "illness_id") - private Long id; - - @Column(name = "illness_name", nullable = false, unique = true) - private String name; - - @Column(name = "illness_risk_factor", nullable = false) - private Double riskFactor; - -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/ClientRepository.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/ClientRepository.java deleted file mode 100644 index f8b946a..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/ClientRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package edu.amu.pl.demo.risk.repository; - -import edu.amu.pl.demo.risk.entity.Client; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ClientRepository extends CrudRepository { -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/IllnessRepository.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/IllnessRepository.java deleted file mode 100644 index fa0438c..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/repository/IllnessRepository.java +++ /dev/null @@ -1,9 +0,0 @@ -package edu.amu.pl.demo.risk.repository; - -import edu.amu.pl.demo.risk.entity.Illness; -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface IllnessRepository extends CrudRepository { -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/service/RiskService.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/service/RiskService.java deleted file mode 100644 index db5faad..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/service/RiskService.java +++ /dev/null @@ -1,32 +0,0 @@ -package edu.amu.pl.demo.risk.service; - -import edu.amu.pl.demo.risk.dto.RiskFactorDTO; -import edu.amu.pl.demo.risk.entity.Illness; -import edu.amu.pl.demo.risk.repository.ClientRepository; -import lombok.val; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class RiskService { - - @Autowired - private ClientRepository repository; - - public RiskFactorDTO calculateRiskFactor(Long clientId) { - if (!repository.existsById(clientId)) { - return new RiskFactorDTO(clientId, -1.0d); - } - val client = repository.findById(clientId).orElseThrow(); - if (client.getConditions().size() == 0) { - return new RiskFactorDTO(clientId, 0d); - } else { - val maxRisk = client.getConditions().stream() - .map(Illness::getRiskFactor) - .max(Double::compare) - .orElseThrow(); - return new RiskFactorDTO(clientId, maxRisk); - } - } - -} diff --git a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/web/RiskController.java b/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/web/RiskController.java deleted file mode 100644 index 190cef8..0000000 --- a/demo/05-06_2/src/main/java/edu/amu/pl/demo/risk/web/RiskController.java +++ /dev/null @@ -1,21 +0,0 @@ -package edu.amu.pl.demo.risk.web; - -import edu.amu.pl.demo.risk.dto.RiskFactorDTO; -import edu.amu.pl.demo.risk.service.RiskService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RestController; - -@RestController("/risk") -public class RiskController { - - @Autowired - private RiskService service; - - @GetMapping("/risk/{clientId}") - public RiskFactorDTO getRiskForClient(@PathVariable Long clientId) { - return service.calculateRiskFactor(clientId); - } - -} diff --git a/demo/05-06_2/src/main/resources/application.properties b/demo/05-06_2/src/main/resources/application.properties deleted file mode 100644 index c4df02b..0000000 --- a/demo/05-06_2/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ -server.port=8088 diff --git a/demo/05-06_2/src/test/java/edu/amu/pl/demo/DemojakartaApplicationTests.java b/demo/05-06_2/src/test/java/edu/amu/pl/demo/DemojakartaApplicationTests.java deleted file mode 100644 index d3c3ff9..0000000 --- a/demo/05-06_2/src/test/java/edu/amu/pl/demo/DemojakartaApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package edu.amu.pl.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemojakartaApplicationTests { - - @Test - void contextLoads() { - } - -} diff --git a/prezentacje/05-06-orm-spring-rest.pdf b/prezentacje/05-06-orm-spring-rest.pdf new file mode 100644 index 0000000..9359452 Binary files /dev/null and b/prezentacje/05-06-orm-spring-rest.pdf differ diff --git a/prezentacje/07-application-servers.pdf b/prezentacje/07-application-servers.pdf new file mode 100644 index 0000000..9aac475 Binary files /dev/null and b/prezentacje/07-application-servers.pdf differ diff --git a/prezentacje/08-user-interface.pdf b/prezentacje/08-user-interface.pdf new file mode 100644 index 0000000..9bc29eb Binary files /dev/null and b/prezentacje/08-user-interface.pdf differ