Merge pull request 'classes' (#3) from classes into master

This commit is contained in:
Marcin Woźniak 2020-07-28 16:28:29 +02:00
commit 3dd8f0d82d
64 changed files with 156682 additions and 105 deletions

View File

@ -39,6 +39,13 @@ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' con
W tym przykladzie `container_name_or_id` to backend_db_1 W tym przykladzie `container_name_or_id` to backend_db_1
Nastepnie
```
cd restservice
mvn spring-boot:run
```
## Troubleshooting ## Troubleshooting
Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali Ci blad `Connection Refused`, a wiesz, ze ta baza stoi na podanym ip i porcie to sprobuj Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali Ci blad `Connection Refused`, a wiesz, ze ta baza stoi na podanym ip i porcie to sprobuj

View File

@ -0,0 +1,9 @@
package com.plannaplan;
public class Acceptor {
public Acceptor() {
}
public void run() {
}
}

View File

@ -1,13 +1,46 @@
package com.plannaplan; package com.plannaplan;
/** import java.util.Date;
* Hello world!
* import com.plannaplan.types.AppStates;
*/
public class App public class App {
{ private static App instance;
public static void main( String[] args ) private Date round1;
{ private Date round2;
System.out.println( "Hello World!" ); private AppStates state;
private App() {
} }
}
public AppStates getState() {
return state;
}
public void setState(AppStates state) {
this.state = state;
}
public Date getRound2() {
return round2;
}
public void setRound2(Date round2) {
this.round2 = round2;
}
public Date getRound1() {
return round1;
}
public void setRound1(Date round1) {
this.round1 = round1;
}
public App getInstance() {
if (App.instance == null) {
App.instance = new App();
}
return App.instance;
}
}

View File

@ -0,0 +1,26 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class Assigner implements Historable, ProtectedAction {
public Assigner() {
}
public void assing() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -1,26 +0,0 @@
package com.plannaplan;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Book {
@Id
@GeneratedValue
private Long id;
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
// standard constructors
// standard getters and setters
}

View File

@ -1,8 +0,0 @@
package com.plannaplan;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface BookRepository extends JpaRepository<Book, Long> {
}

View File

@ -1,17 +0,0 @@
package com.plannaplan;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class BookService {
@Autowired
private BookRepository bookRepository;
public List<Book> list() {
return bookRepository.findAll();
}
}

View File

@ -0,0 +1,20 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
import com.plannaplan.models.ConfigData;
public class Configurator implements ProtectedAction {
public Configurator() {
}
public void config(ConfigData data) {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,30 @@
package com.plannaplan;
public class Controller {
public Controller() {
}
public void startApp() {
}
public void assignCourse() {
}
public void addUnavailibility() {
}
public void addGroup() {
}
public void editGroup() {
}
public void getHistoryAtPoint() {
}
public void config() {
}
public void createTransfer() {
}
}

View File

@ -0,0 +1,9 @@
package com.plannaplan;
public class Emailer {
public Emailer() {
}
public void performAllMails() {
}
}

View File

@ -0,0 +1,13 @@
package com.plannaplan;
import com.plannaplan.interfaces.EventCreator;
public class EventChcker implements EventCreator {
@Override
public void update() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,26 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class GroupAdder implements Historable, ProtectedAction {
public GroupAdder() {
}
public void addGroup() {
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,19 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
public class GroupEditor implements ProtectedAction {
public GroupEditor() {
}
public void setNewCapacity(int capaity) {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,22 @@
package com.plannaplan;
import com.plannaplan.interfaces.ProtectedAction;
public class HistoryResolver implements ProtectedAction {
public HistoryResolver() {
}
public void getHistoryAtPoint() {
}
public void reproduce() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
}

View File

@ -1,18 +0,0 @@
package com.plannaplan;
public class SampleClass {
private String xd;
public SampleClass(String xd) {
this.setXd(xd);
}
public String getXd() {
return xd;
}
public void setXd(String xd) {
this.xd = xd;
}
}

View File

@ -0,0 +1,26 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class TransferCreator implements Historable, ProtectedAction {
public TransferCreator() {
}
public void createTransfer() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,19 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
public class TransferValidator implements Historable {
public TransferValidator() {
}
public void performAllTransfers() {
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,26 @@
package com.plannaplan;
import com.plannaplan.interfaces.Historable;
import com.plannaplan.interfaces.ProtectedAction;
public class UnavailabilityAdder implements Historable, ProtectedAction {
public UnavailabilityAdder() {
}
public void add() {
}
@Override
public void validateAction() {
// TODO Auto-generated method stub
}
@Override
public void addActionToHistory() {
// TODO Auto-generated method stub
}
}

View File

@ -0,0 +1,26 @@
package com.plannaplan.abstracts;
import java.util.ArrayList;
import java.util.List;
import com.plannaplan.interfaces.EventCreator;
public abstract class EventWatcher {
protected List<EventCreator> creators;
public EventWatcher() {
this.creators = new ArrayList<>();
}
public void attach(EventCreator creator) {
this.creators.add(creator);
}
public void detach(EventCreator creator) {
this.creators.remove(creator);
}
public void update() {
}
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.configutils;
import java.io.File;
public class FileToDatabaseMigrator {
public FileToDatabaseMigrator() {
}
public void migrate(File file) {
}
}

View File

@ -0,0 +1,24 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Assignment {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "group_id")
private Groups group;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
public Assignment() {
}
}

View File

@ -0,0 +1,41 @@
package com.plannaplan.entities;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
@Entity
public class Course {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String symbol;
@OneToMany(mappedBy = "id")
private List<Groups> groups = new ArrayList<>();
public Course() {
}
public String getName() {
return name;
}
public String getSymbol() {
return symbol;
}
public void setSymbol(String symbol) {
this.symbol = symbol;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,32 @@
package com.plannaplan.entities;
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 com.plannaplan.types.EventTypes;
@Entity
public class Event {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private EventTypes type;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
public Event() {
}
public EventTypes getType() {
return type;
}
public void setType(EventTypes type) {
this.type = type;
}
}

View File

@ -0,0 +1,88 @@
package com.plannaplan.entities;
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 com.plannaplan.types.GroupType;
import com.plannaplan.types.WeekDay;
@Entity
public class Groups {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "course_id")
private Course courseId;
private int time;
private String room;
private int capacity;
private GroupType type;
private WeekDay day;
@ManyToOne
@JoinColumn(name = "lecturer_id")
private Lecturer lecturer;
public Groups() {
}
public Lecturer getLecturer() {
return lecturer;
}
public void setLecturer(Lecturer lecturer) {
this.lecturer = lecturer;
}
public WeekDay getDay() {
return day;
}
public void setDay(WeekDay day) {
this.day = day;
}
public GroupType getType() {
return type;
}
public void setType(GroupType type) {
this.type = type;
}
public int getCapacity() {
return capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
public Course getCourseId() {
return courseId;
}
public void setCourseId(Course courseId) {
this.courseId = courseId;
}
}

View File

@ -0,0 +1,25 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class HistoryElement {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id")
private User user;
@ManyToOne
@JoinColumn(name = "incoming_id")
private Groups incoming;
@ManyToOne
@JoinColumn(name = "outcoming_id")
private Groups outcoming;
}

View File

@ -0,0 +1,44 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Lecturer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String title;
private String name;
private String surname;
public Lecturer() {
}
public String getTitle() {
return title;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setTitle(String title) {
this.title = title;
}
}

View File

@ -0,0 +1,28 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Transfer {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "owner_id")
private User ownerUser;
@ManyToOne
@JoinColumn(name = "group_id")
private Groups ownerGroup;
@ManyToOne
@JoinColumn(name = "target_id")
private Groups targetGroup;
public Transfer() {
}
}

View File

@ -0,0 +1,30 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
@Entity
public class Unavailability {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@ManyToOne
@JoinColumn(name = "user_id")
private User lecturer;
private int time;
public Unavailability() {
}
public int getTime() {
return time;
}
public void setTime(int time) {
this.time = time;
}
}

View File

@ -0,0 +1,45 @@
package com.plannaplan.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import com.plannaplan.types.UserRoles;
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String surname;
private UserRoles role;
public User() {
}
public String getName() {
return name;
}
public UserRoles getRole() {
return role;
}
public void setRole(UserRoles role) {
this.role = role;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.interfaces;
public interface EventCreator {
void update();
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.interfaces;
public interface Historable {
void addActionToHistory();
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.interfaces;
public interface ProtectedAction {
void validateAction();
}

View File

@ -0,0 +1,29 @@
package com.plannaplan.models;
import java.io.File;
import java.util.Date;
public class ConfigData {
private Date start;
private Date end;
private File file;
public ConfigData(Date start, Date end, File file) {
this.start = start;
this.end = end;
this.file = file;
}
public File getFile() {
return file;
}
public Date getEnd() {
return end;
}
public Date getStart() {
return start;
}
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Assignment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface AssignmentRepository extends JpaRepository<Assignment, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Course;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface CourseRepository extends JpaRepository<Course, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Event;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface EventRepository extends JpaRepository<Event, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Groups;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface GroupRepository extends JpaRepository<Groups, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.HistoryElement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface HistoryRepository extends JpaRepository<HistoryElement, Long> {
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Lecturer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Transfer;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface TransferRepository extends JpaRepository<Transfer, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.Unavailability;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UnavailabilityRepository extends JpaRepository<Unavailability, Long> {
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.repositories;
import com.plannaplan.entities.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
}

View File

@ -0,0 +1,17 @@
package com.plannaplan.services;
import com.plannaplan.abstracts.EventWatcher;
import com.plannaplan.repositories.AssignmentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class AssignmentService extends EventWatcher {
@Autowired
private AssignmentRepository repo;
public AssignmentService() {
super();
}
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.CourseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CourseService {
@Autowired
private CourseRepository repo;
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.EventRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class EventService {
@Autowired
private EventRepository repo;
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.GroupRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class GroupService {
@Autowired
private GroupRepository repo;
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.HistoryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class HistoryService {
@Autowired
private HistoryRepository repo;
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.LecturerRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class LecturerService {
@Autowired
private LecturerRepository repo;
}

View File

@ -0,0 +1,17 @@
package com.plannaplan.services;
import com.plannaplan.abstracts.EventWatcher;
import com.plannaplan.repositories.TransferRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TransferService extends EventWatcher {
@Autowired
private TransferRepository repo;
public TransferService() {
super();
}
}

View File

@ -0,0 +1,12 @@
package com.plannaplan.services;
import com.plannaplan.repositories.UnavailabilityRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UnavailabilityService {
@Autowired
private UnavailabilityRepository repos;
}

View File

@ -0,0 +1,18 @@
package com.plannaplan.services;
import com.plannaplan.abstracts.EventWatcher;
import com.plannaplan.repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class UserService extends EventWatcher {
@Autowired
private UserRepository repo;
public UserService() {
super();
}
}

View File

@ -0,0 +1,10 @@
package com.plannaplan.statisticutils;
public class Statistics {
public Statistics() {
}
public void getAll() {
}
}

View File

@ -0,0 +1,9 @@
package com.plannaplan.transferutils;
public class TransferMatcher {
public TransferMatcher() {
}
public void findMatches() {
}
}

View File

@ -0,0 +1,9 @@
package com.plannaplan.transferutils;
public class TransfersExecuter {
public TransfersExecuter() {
}
public void execute() {
}
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum ActionTypes {
ADD, DELETE, REPLACE
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum AppStates {
STOPPED, RUNNING, PAUSED
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum EventTypes {
DROPPED_OUT, TOUR_STARTED, TRANSFER_FOUND, TOUR_FINISHED, COURSES_ACCEPTED
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum GroupType {
LECTURE, CLASS
}

View File

@ -0,0 +1,5 @@
package com.plannaplan.types;
public enum UserRoles {
STUDENT, DEANERY, ADMIN
}

View File

@ -0,0 +1,11 @@
package com.plannaplan.types;
public enum WeekDay {
MONDAY(1), TUESDAY(2), WEDNESDAY(3), THURSDAY(4), FRIDAY(5), SATURDAY(6), SUNDAY(7);
public final int label;
private WeekDay(int label) {
this.label = label;
}
}

View File

@ -1,24 +0,0 @@
package com.plannaplan;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.junit.Ignore;
import org.springframework.beans.factory.annotation.Autowired;
/**
* Unit test for simple App.
*/
public class AppTest {
@Autowired
private BookService bookService;
@Ignore
@Test
public void whenApplicationStarts_thenHibernateCreatesInitialRecords() {
List<Book> books = bookService.list();
Assert.assertEquals(books.size(), 1);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,10 @@
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.datasource.url=jdbc:mysql://172.20.0.2:3306/test spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=yes&characterEncoding=UTF-8
spring.datasource.username=root spring.datasource.username=root
spring.datasource.password=example spring.datasource.password=example
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=create spring.jpa.open-in-view=true
spring.jpa.hibernate.ddl-auto=create-drop
spring.jackson.serialization.fail-on-empty-beans=false
server.port=1285 server.port=1285

View File

@ -7,6 +7,10 @@ services:
restart: always restart: always
environment: environment:
MYSQL_ROOT_PASSWORD: example MYSQL_ROOT_PASSWORD: example
expose:
- "3306"
ports:
- "3306:3306"
adminer: adminer:
image: adminer image: adminer