Merge pull request 'refactor' (#11) from refactor into master
Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/11
This commit is contained in:
commit
9c02a0b596
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
6
buisnesslogic/pom.xml
Normal file → Executable file
6
buisnesslogic/pom.xml
Normal file → Executable file
@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.14</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.14</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.poi</groupId>
|
<groupId>org.apache.poi</groupId>
|
||||||
<artifactId>poi-ooxml</artifactId>
|
<artifactId>poi-ooxml</artifactId>
|
||||||
<version>3.17</version>
|
<version>4.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- dependency used for XLS older file format
|
<!-- dependency used for XLS older file format
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
public class Acceptor {
|
|
||||||
public Acceptor() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void run() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import com.plannaplan.types.AppStates;
|
|
||||||
|
|
||||||
public class App {
|
|
||||||
private static App instance;
|
|
||||||
private Date round1;
|
|
||||||
private Date round2;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,43 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
import com.plannaplan.interfaces.ProtectedAction;
|
|
||||||
import com.plannaplan.models.ConfigData;
|
|
||||||
import com.plannaplan.models.FileData;
|
|
||||||
import com.plannaplan.services.CourseService;
|
|
||||||
import com.plannaplan.services.GroupService;
|
|
||||||
import com.plannaplan.services.LecturerService;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.plannaplan.configutils.*;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class Configurator implements ProtectedAction {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private LecturerService lecturerService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private CourseService courseService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private GroupService groupService;
|
|
||||||
|
|
||||||
public Configurator() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void config(ConfigData data) {
|
|
||||||
FileReader reader = new FileReader(data.getFilestream());
|
|
||||||
FileData coursesData = reader.read();
|
|
||||||
FileToDatabaseMigrator mgtr = new FileToDatabaseMigrator(lecturerService, courseService, groupService);
|
|
||||||
mgtr.migrate(coursesData);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void validateAction() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,41 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
import com.plannaplan.models.ConfigData;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
@Component
|
|
||||||
public class Controller {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private Configurator configurator;
|
|
||||||
|
|
||||||
public Controller() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void startApp() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void assignCourse() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addUnavailibility() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addGroup() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void editGroup() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getHistoryAtPoint() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void config(ConfigData data) {
|
|
||||||
configurator.config(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void createTransfer() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
public class Emailer {
|
|
||||||
public Emailer() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void performAllMails() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package com.plannaplan;
|
|
||||||
|
|
||||||
import com.plannaplan.interfaces.EventCreator;
|
|
||||||
|
|
||||||
public class EventChcker implements EventCreator {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update() {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,19 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
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() {
|
|
||||||
}
|
|
||||||
}
|
|
6
buisnesslogic/src/main/java/com/plannaplan/configutils/FileReader.java
Normal file → Executable file
6
buisnesslogic/src/main/java/com/plannaplan/configutils/FileReader.java
Normal file → Executable file
@ -2,7 +2,7 @@ package com.plannaplan.configutils;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Hashtable;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
@ -33,12 +33,12 @@ public class FileReader {
|
|||||||
Row row = rowIt.next();
|
Row row = rowIt.next();
|
||||||
Iterator<Cell> cellIt = row.cellIterator();
|
Iterator<Cell> cellIt = row.cellIterator();
|
||||||
|
|
||||||
Hashtable<String, Integer> keys = new Hashtable<>();
|
HashMap<String, Integer> keys = new HashMap<>();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (cellIt.hasNext()) {
|
while (cellIt.hasNext()) {
|
||||||
Cell c = cellIt.next();
|
Cell c = cellIt.next();
|
||||||
keys.put(c.toString(), index);
|
keys.put(c.toString(), index);
|
||||||
index+=1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rowIt.remove();
|
rowIt.remove();
|
||||||
|
156
buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java
Normal file → Executable file
156
buisnesslogic/src/main/java/com/plannaplan/configutils/FileToDatabaseMigrator.java
Normal file → Executable file
@ -1,7 +1,6 @@
|
|||||||
package com.plannaplan.configutils;
|
package com.plannaplan.configutils;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.entities.Lecturer;
|
import com.plannaplan.entities.Lecturer;
|
||||||
@ -9,140 +8,85 @@ import com.plannaplan.models.FileData;
|
|||||||
import com.plannaplan.services.CourseService;
|
import com.plannaplan.services.CourseService;
|
||||||
import com.plannaplan.services.GroupService;
|
import com.plannaplan.services.GroupService;
|
||||||
import com.plannaplan.services.LecturerService;
|
import com.plannaplan.services.LecturerService;
|
||||||
import com.plannaplan.types.GroupType;
|
|
||||||
import com.plannaplan.types.WeekDay;
|
import com.plannaplan.types.WeekDay;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
public class FileToDatabaseMigrator {
|
public class FileToDatabaseMigrator {
|
||||||
public static String LECTURER_NAME_STRING = "imie";
|
|
||||||
public static String LECTURER_SURNAME_STRING = "nazwisko";
|
|
||||||
public static String LECTURER_TITLE_STRING = "tytul";
|
|
||||||
|
|
||||||
public static String COURSE_SYMBOL_STRING = "sym";
|
private static final String LECTURER_NAME_STRING = "imie";
|
||||||
public static String COURSE_NAME_STRING = "nazwa";
|
private static final String LECTURER_SURNAME_STRING = "nazwisko";
|
||||||
|
private static final String LECTURER_TITLE_STRING = "tytul";
|
||||||
|
|
||||||
public static String GROUP_DAY_STRING = "dzien";
|
private static final String COURSE_SYMBOL_STRING = "sym";
|
||||||
public static String GROUP_TIME_STRING = "godz_od";
|
private static final String COURSE_NAME_STRING = "nazwa";
|
||||||
public static String ROOM_STRING = "sala";
|
|
||||||
public static String CAPACITY_STRING = "Mc";
|
|
||||||
|
|
||||||
LecturerService lecturerService;
|
private static final String groupDay_STRING = "dzien";
|
||||||
CourseService courseService;
|
private static final String GROUP_TIME_STRING = "godz_od";
|
||||||
GroupService groupService;
|
private static final String ROOM_STRING = "sala";
|
||||||
|
private static final String CAPACITY_STRING = "Mc";
|
||||||
|
|
||||||
public FileToDatabaseMigrator(LecturerService lecturerService, CourseService courseService,
|
@Autowired
|
||||||
GroupService groupService) {
|
private LecturerService lecturerService;
|
||||||
this.lecturerService = lecturerService;
|
@Autowired
|
||||||
this.groupService = groupService;
|
private CourseService courseService;
|
||||||
this.courseService = courseService;
|
@Autowired
|
||||||
|
private GroupService groupService;
|
||||||
|
|
||||||
|
public FileToDatabaseMigrator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void migrate(FileData data) {
|
public void migrate(FileData data) {
|
||||||
Iterator<Row> rows = data.getRows();
|
Iterator<Row> rows = data.getRows();
|
||||||
|
int courseNameIndex = data.getIndexOf(FileToDatabaseMigrator.COURSE_NAME_STRING);
|
||||||
|
int symbolIndex = data.getIndexOf(FileToDatabaseMigrator.COURSE_SYMBOL_STRING);
|
||||||
|
|
||||||
int course_name_index = data.getIndexOf(FileToDatabaseMigrator.COURSE_NAME_STRING);
|
int titleIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_TITLE_STRING);
|
||||||
int sym_index = data.getIndexOf(FileToDatabaseMigrator.COURSE_SYMBOL_STRING);
|
int surnameIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
|
||||||
|
int nameIndex = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
|
||||||
|
|
||||||
int title_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_TITLE_STRING);
|
int dayIndex = data.getIndexOf(FileToDatabaseMigrator.groupDay_STRING);
|
||||||
int surname_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_SURNAME_STRING);
|
int timeIndex = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING);
|
||||||
int name_index = data.getIndexOf(FileToDatabaseMigrator.LECTURER_NAME_STRING);
|
int roomIndex = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING);
|
||||||
|
int capacityIndex = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING);
|
||||||
int day_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_DAY_STRING);
|
|
||||||
int time_index = data.getIndexOf(FileToDatabaseMigrator.GROUP_TIME_STRING);
|
|
||||||
int room_index = data.getIndexOf(FileToDatabaseMigrator.ROOM_STRING);
|
|
||||||
int capacity_index = data.getIndexOf(FileToDatabaseMigrator.CAPACITY_STRING);
|
|
||||||
|
|
||||||
while (rows.hasNext()) {
|
while (rows.hasNext()) {
|
||||||
Row row = rows.next();
|
Row row = rows.next();
|
||||||
|
|
||||||
Cell course_name_cell = row.getCell(course_name_index);
|
String courseName = row.getCell(courseNameIndex).toString().trim();
|
||||||
Cell sym = row.getCell(sym_index);
|
String symbol = row.getCell(symbolIndex).toString().trim();
|
||||||
|
|
||||||
Cell title_cell = row.getCell(title_index);
|
String lecturerTitle = row.getCell(titleIndex) != null ? row.getCell(titleIndex).toString().trim() : "";
|
||||||
Cell name_cell = row.getCell(name_index);
|
String lecturerName = row.getCell(nameIndex) != null ? row.getCell(nameIndex).toString().trim() : "";
|
||||||
Cell surname_cell = row.getCell(surname_index);
|
String lecturerSurname = row.getCell(surnameIndex) != null ? row.getCell(surnameIndex).toString().trim()
|
||||||
|
: "";
|
||||||
|
|
||||||
Cell day_cell = row.getCell(day_index);
|
int day = (int) Double.parseDouble(row.getCell(dayIndex).toString());
|
||||||
Cell time_cell = row.getCell(time_index);
|
WeekDay groupDay = WeekDay.getDay(day - 1);
|
||||||
Cell room_cell = row.getCell(room_index);
|
int time = parseTimeToInt(row.getCell(timeIndex).toString());
|
||||||
Cell capacity_cell = row.getCell(capacity_index);
|
String room = row.getCell(roomIndex).toString().trim();
|
||||||
|
int capacity = (int) Double.parseDouble(row.getCell(capacityIndex).toString());
|
||||||
|
|
||||||
String lecturer_title = "";
|
Course course = this.courseService.getCourseByName(courseName)
|
||||||
String lecturer_surname = "";
|
.orElseGet(() -> this.courseService.save(new Course(courseName, symbol)));
|
||||||
String lecturer_name = "";
|
|
||||||
|
|
||||||
String course_name = course_name_cell.toString().trim();
|
Lecturer lecturer = this.lecturerService.getLecturer(lecturerTitle, lecturerName, lecturerSurname)
|
||||||
String sym_str = sym.toString().trim();
|
.orElseGet(() -> this.lecturerService
|
||||||
|
.save(new Lecturer(lecturerTitle, lecturerName, lecturerSurname)));
|
||||||
|
|
||||||
int day = (int) Double.parseDouble(day_cell.toString());
|
this.groupService.find(time, capacity, room).orElseGet(
|
||||||
WeekDay group_day = WeekDay.getDay(day - 1);
|
() -> this.groupService.save(new Groups(capacity, room, course, time, groupDay, lecturer)));
|
||||||
String room = room_cell.toString().trim();
|
|
||||||
int time = this.parseTimeToInt(time_cell.toString());
|
|
||||||
|
|
||||||
int capacity = (int) Double.parseDouble(capacity_cell.toString());
|
|
||||||
|
|
||||||
Groups group = groupService.find(time, capacity, room);
|
|
||||||
|
|
||||||
Course course = this.courseService.getCourseByName(course_name);
|
|
||||||
|
|
||||||
if (course == null) {
|
|
||||||
course = new Course();
|
|
||||||
course.setName(course_name);
|
|
||||||
course.setSymbol(sym_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
courseService.save(course);
|
|
||||||
|
|
||||||
if (title_cell != null) {
|
|
||||||
lecturer_title = title_cell.toString().trim();
|
|
||||||
}
|
|
||||||
if (name_cell != null) {
|
|
||||||
lecturer_name = name_cell.toString().trim();
|
|
||||||
}
|
|
||||||
if (surname_cell != null) {
|
|
||||||
lecturer_surname = surname_cell.toString().trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
Lecturer lecturer = lecturerService.getLecturer(lecturer_title, lecturer_name, lecturer_surname);
|
|
||||||
|
|
||||||
if (lecturer == null) {
|
|
||||||
lecturer = new Lecturer(lecturer_title, lecturer_name, lecturer_surname);
|
|
||||||
lecturerService.save(lecturer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (group == null) {
|
|
||||||
group = new Groups();
|
|
||||||
group.setCapacity(capacity);
|
|
||||||
group.setRoom(room);
|
|
||||||
group.setCourseId(course);
|
|
||||||
group.setTime(time);
|
|
||||||
if (capacity >= 50) {
|
|
||||||
group.setType(GroupType.LECTURE);
|
|
||||||
} else {
|
|
||||||
group.setType(GroupType.CLASS);
|
|
||||||
}
|
|
||||||
group.setDay(group_day);
|
|
||||||
group.setLecturer(lecturer);
|
|
||||||
|
|
||||||
groupService.save(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer parseTimeToInt(String time) {
|
private static int parseTimeToInt(String time) {
|
||||||
String times[] = time.split("\\.");
|
String times[] = time.split("\\.|\\:");
|
||||||
if (times.length == 2) {
|
return times.length == 2 ? Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]) : 0;
|
||||||
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
|
|
||||||
}
|
|
||||||
times = time.split("\\:");
|
|
||||||
if (times.length == 2) {
|
|
||||||
return Integer.parseInt(times[0]) * 60 + Integer.parseInt(times[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
17
buisnesslogic/src/main/java/com/plannaplan/entities/Assignment.java
Normal file → Executable file
17
buisnesslogic/src/main/java/com/plannaplan/entities/Assignment.java
Normal file → Executable file
@ -16,9 +16,22 @@ public class Assignment {
|
|||||||
@JoinColumn(name = "group_id")
|
@JoinColumn(name = "group_id")
|
||||||
private Groups group;
|
private Groups group;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "user_id")
|
@JoinColumn(name = "commision_id")
|
||||||
private User user;
|
private Commision commision;
|
||||||
|
|
||||||
|
public Assignment(Groups group, Commision commision) {
|
||||||
|
this.commision = commision;
|
||||||
|
this.group = group;
|
||||||
|
}
|
||||||
|
|
||||||
public Assignment() {
|
public Assignment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Groups getGroup() {
|
||||||
|
return this.group;
|
||||||
|
}
|
||||||
}
|
}
|
47
buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java
Executable file
47
buisnesslogic/src/main/java/com/plannaplan/entities/Commision.java
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
package com.plannaplan.entities;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.GeneratedValue;
|
||||||
|
import javax.persistence.GenerationType;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.JoinColumn;
|
||||||
|
import javax.persistence.OneToMany;
|
||||||
|
import javax.persistence.OneToOne;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
public class Commision {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
@OneToOne
|
||||||
|
@JoinColumn(name = "owner_id")
|
||||||
|
private User commisionOwner;
|
||||||
|
private Timestamp commisionDate;
|
||||||
|
|
||||||
|
@OneToMany(mappedBy = "commision")
|
||||||
|
private List<Assignment> assignments;
|
||||||
|
|
||||||
|
public Commision(User user) {
|
||||||
|
this.commisionDate = new Timestamp(System.currentTimeMillis());
|
||||||
|
this.commisionOwner = user;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Commision() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getCommisionDate() {
|
||||||
|
return commisionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getCommisionOwner() {
|
||||||
|
return commisionOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
9
buisnesslogic/src/main/java/com/plannaplan/entities/Course.java
Normal file → Executable file
9
buisnesslogic/src/main/java/com/plannaplan/entities/Course.java
Normal file → Executable file
@ -17,12 +17,17 @@ public class Course {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private String name;
|
private String name;
|
||||||
private String symbol;
|
private String symbol;
|
||||||
@OneToMany(mappedBy = "courseId", fetch = FetchType.EAGER)
|
@OneToMany(mappedBy = "course", fetch = FetchType.EAGER)
|
||||||
private List<Groups> groups = new ArrayList<>();
|
private List<Groups> groups = new ArrayList<>();
|
||||||
|
|
||||||
public Course() {
|
public Course() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Course(String name, String symbol) {
|
||||||
|
this.name = name;
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
@ -43,7 +48,7 @@ public class Course {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Groups> getGroups(){
|
public List<Groups> getGroups() {
|
||||||
return this.groups;
|
return this.groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
18
buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java
Normal file → Executable file
18
buisnesslogic/src/main/java/com/plannaplan/entities/Groups.java
Normal file → Executable file
@ -10,6 +10,8 @@ import javax.persistence.ManyToOne;
|
|||||||
import com.plannaplan.types.GroupType;
|
import com.plannaplan.types.GroupType;
|
||||||
import com.plannaplan.types.WeekDay;
|
import com.plannaplan.types.WeekDay;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
public class Groups {
|
public class Groups {
|
||||||
@Id
|
@Id
|
||||||
@ -17,7 +19,7 @@ public class Groups {
|
|||||||
private Long id;
|
private Long id;
|
||||||
@ManyToOne
|
@ManyToOne
|
||||||
@JoinColumn(name = "course_id")
|
@JoinColumn(name = "course_id")
|
||||||
private Course courseId;
|
private Course course;
|
||||||
private int time;
|
private int time;
|
||||||
private String room;
|
private String room;
|
||||||
private int capacity;
|
private int capacity;
|
||||||
@ -30,6 +32,16 @@ public class Groups {
|
|||||||
public Groups() {
|
public Groups() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer) {
|
||||||
|
this.capacity = capacity;
|
||||||
|
this.room = room;
|
||||||
|
this.course = course;
|
||||||
|
this.time = time;
|
||||||
|
this.day = day;
|
||||||
|
this.lecturer = lecturer;
|
||||||
|
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
@ -83,11 +95,11 @@ public class Groups {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Course getCourseId() {
|
public Course getCourseId() {
|
||||||
return courseId;
|
return course;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCourseId(Course courseId) {
|
public void setCourseId(Course courseId) {
|
||||||
this.courseId = courseId;
|
this.course = courseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTimeString() {
|
public String getTimeString() {
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
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;
|
|
||||||
|
|
||||||
}
|
|
0
buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/entities/Lecturer.java
Normal file → Executable file
@ -1,28 +0,0 @@
|
|||||||
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() {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
12
buisnesslogic/src/main/java/com/plannaplan/entities/User.java
Normal file → Executable file
12
buisnesslogic/src/main/java/com/plannaplan/entities/User.java
Normal file → Executable file
@ -9,6 +9,7 @@ import javax.persistence.Id;
|
|||||||
|
|
||||||
import com.plannaplan.types.UserRoles;
|
import com.plannaplan.types.UserRoles;
|
||||||
|
|
||||||
|
//should setter be public?
|
||||||
@Entity
|
@Entity
|
||||||
public class User {
|
public class User {
|
||||||
@Id
|
@Id
|
||||||
@ -24,6 +25,13 @@ public class User {
|
|||||||
public User() {
|
public User() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public User(String name, String surname, String mail, UserRoles role) {
|
||||||
|
this.name = name;
|
||||||
|
this.surname = surname;
|
||||||
|
this.email = mail;
|
||||||
|
this.role = role;
|
||||||
|
}
|
||||||
|
|
||||||
public String getEmail() {
|
public String getEmail() {
|
||||||
return email;
|
return email;
|
||||||
}
|
}
|
||||||
@ -68,4 +76,8 @@ public class User {
|
|||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
}
|
}
|
0
buisnesslogic/src/main/java/com/plannaplan/exceptions/UserNotFoundException.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/exceptions/UserNotFoundException.java
Normal file → Executable file
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.interfaces;
|
|
||||||
|
|
||||||
public interface EventCreator {
|
|
||||||
void update();
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.interfaces;
|
|
||||||
|
|
||||||
public interface Historable {
|
|
||||||
void addActionToHistory();
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.interfaces;
|
|
||||||
|
|
||||||
public interface ProtectedAction {
|
|
||||||
void validateAction();
|
|
||||||
}
|
|
0
buisnesslogic/src/main/java/com/plannaplan/models/ConfigData.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/models/ConfigData.java
Normal file → Executable file
15
buisnesslogic/src/main/java/com/plannaplan/models/FileData.java
Normal file → Executable file
15
buisnesslogic/src/main/java/com/plannaplan/models/FileData.java
Normal file → Executable file
@ -1,18 +1,17 @@
|
|||||||
package com.plannaplan.models;
|
package com.plannaplan.models;
|
||||||
|
|
||||||
import java.util.Dictionary;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.apache.poi.ss.usermodel.Row;
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
|
||||||
public class FileData {
|
public class FileData {
|
||||||
|
|
||||||
private Dictionary<String, Integer> keys;
|
private HashMap<String, Integer> keys;
|
||||||
private Iterator<Row> rows;
|
private Iterator<Row> rows;
|
||||||
|
|
||||||
public FileData(Dictionary<String, Integer> keys, Iterator<Row> rows) {
|
public FileData(HashMap<String, Integer> keys, Iterator<Row> rows) {
|
||||||
this.setKeys(keys);
|
this.keys = keys;
|
||||||
this.setRows(rows);
|
this.rows = rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator<Row> getRows() {
|
public Iterator<Row> getRows() {
|
||||||
@ -23,11 +22,11 @@ public class FileData {
|
|||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<String, Integer> getKeys() {
|
public HashMap<String, Integer> getKeys() {
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKeys(Dictionary<String, Integer> keys) {
|
public void setKeys(HashMap<String, Integer> keys) {
|
||||||
this.keys = keys;
|
this.keys = keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
7
buisnesslogic/src/main/java/com/plannaplan/repositories/AssignmentRepository.java
Normal file → Executable file
7
buisnesslogic/src/main/java/com/plannaplan/repositories/AssignmentRepository.java
Normal file → Executable file
@ -1,11 +1,18 @@
|
|||||||
package com.plannaplan.repositories;
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.plannaplan.entities.Assignment;
|
import com.plannaplan.entities.Assignment;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface AssignmentRepository extends JpaRepository<Assignment, Long> {
|
public interface AssignmentRepository extends JpaRepository<Assignment, Long> {
|
||||||
|
|
||||||
|
@Query("FROM Assignment WHERE commision_id = ?1")
|
||||||
|
List<Assignment> getByCommision(@Param("commision_id") Long id);
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.Query;
|
||||||
|
import org.springframework.data.repository.query.Param;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CommisionRepository extends JpaRepository<Commision, Long> {
|
||||||
|
@Query("FROM Commision WHERE owner_id = ?1")
|
||||||
|
List<Commision> getUsers(@Param("owner_id") Long id);
|
||||||
|
|
||||||
|
@Query("FROM Commision WHERE owner_id = ?1 order by commisionDate desc")
|
||||||
|
List<Commision> getNewestCommision(@Param("owner_id") Long id);
|
||||||
|
|
||||||
|
}
|
4
buisnesslogic/src/main/java/com/plannaplan/repositories/CourseRepository.java
Normal file → Executable file
4
buisnesslogic/src/main/java/com/plannaplan/repositories/CourseRepository.java
Normal file → Executable file
@ -1,5 +1,7 @@
|
|||||||
package com.plannaplan.repositories;
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@ -10,5 +12,5 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface CourseRepository extends JpaRepository<Course, Long> {
|
public interface CourseRepository extends JpaRepository<Course, Long> {
|
||||||
@Query("FROM Course WHERE name = ?1")
|
@Query("FROM Course WHERE name = ?1")
|
||||||
Course findByName(@Param("name") String name);
|
Optional<Course> findByName(@Param("name") String name);
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
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> {
|
|
||||||
|
|
||||||
}
|
|
3
buisnesslogic/src/main/java/com/plannaplan/repositories/GroupRepository.java
Normal file → Executable file
3
buisnesslogic/src/main/java/com/plannaplan/repositories/GroupRepository.java
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
package com.plannaplan.repositories;
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
public interface GroupRepository extends JpaRepository<Groups, Long> {
|
||||||
@Query("FROM Groups WHERE time = ?1 AND room = ?2 AND capacity = ?3")
|
@Query("FROM Groups WHERE time = ?1 AND room = ?2 AND capacity = ?3")
|
||||||
Groups find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
Optional<Groups> find(@Param("time") int time, @Param("room") String room, @Param("capacity") int capacity);
|
||||||
|
|
||||||
@Query("FROM Groups WHERE course_id = ?1")
|
@Query("FROM Groups WHERE course_id = ?1")
|
||||||
List<Groups> getByCourse(@Param("id") Long id);
|
List<Groups> getByCourse(@Param("id") Long id);
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
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> {
|
|
||||||
|
|
||||||
}
|
|
4
buisnesslogic/src/main/java/com/plannaplan/repositories/LecturerRepository.java
Normal file → Executable file
4
buisnesslogic/src/main/java/com/plannaplan/repositories/LecturerRepository.java
Normal file → Executable file
@ -1,5 +1,7 @@
|
|||||||
package com.plannaplan.repositories;
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Lecturer;
|
import com.plannaplan.entities.Lecturer;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@ -10,5 +12,5 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
|
public interface LecturerRepository extends JpaRepository<Lecturer, Long> {
|
||||||
@Query("FROM Lecturer WHERE title = ?1 AND name = ?2 AND surname = ?3")
|
@Query("FROM Lecturer WHERE title = ?1 AND name = ?2 AND surname = ?3")
|
||||||
Lecturer find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
|
Optional<Lecturer> find(@Param("title") String title, @Param("name") String name, @Param("surname") String surname);
|
||||||
}
|
}
|
@ -1,11 +0,0 @@
|
|||||||
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> {
|
|
||||||
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
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> {
|
|
||||||
|
|
||||||
}
|
|
6
buisnesslogic/src/main/java/com/plannaplan/repositories/UserRepository.java
Normal file → Executable file
6
buisnesslogic/src/main/java/com/plannaplan/repositories/UserRepository.java
Normal file → Executable file
@ -1,5 +1,7 @@
|
|||||||
package com.plannaplan.repositories;
|
package com.plannaplan.repositories;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
@ -10,8 +12,8 @@ import org.springframework.stereotype.Repository;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Long> {
|
||||||
@Query("FROM User WHERE email = ?1")
|
@Query("FROM User WHERE email = ?1")
|
||||||
User getByAuthority(@Param("authority") String authority);
|
Optional<User> getByAuthority(@Param("authority") String authority);
|
||||||
|
|
||||||
@Query("FROM User WHERE token = ?1")
|
@Query("FROM User WHERE token = ?1")
|
||||||
User getByToken(@Param("token") String token);
|
Optional<User> getByToken(@Param("token") String token);
|
||||||
}
|
}
|
20
buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java
Normal file → Executable file
20
buisnesslogic/src/main/java/com/plannaplan/services/AssignmentService.java
Normal file → Executable file
@ -1,17 +1,31 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
import com.plannaplan.abstracts.EventWatcher;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
import com.plannaplan.repositories.AssignmentRepository;
|
import com.plannaplan.repositories.AssignmentRepository;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class AssignmentService extends EventWatcher {
|
public class AssignmentService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AssignmentRepository repo;
|
private AssignmentRepository repo;
|
||||||
|
|
||||||
public AssignmentService() {
|
public AssignmentService() {
|
||||||
super();
|
}
|
||||||
|
|
||||||
|
public void save(Assignment assignment) {
|
||||||
|
this.repo.save(assignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Assignment> getCommisionAssignments(Commision com) {
|
||||||
|
return this.repo.getByCommision(com.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAssignmentsAmmount() {
|
||||||
|
return this.repo.count();
|
||||||
}
|
}
|
||||||
}
|
}
|
38
buisnesslogic/src/main/java/com/plannaplan/services/CommisionService.java
Executable file
38
buisnesslogic/src/main/java/com/plannaplan/services/CommisionService.java
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
import com.plannaplan.entities.User;
|
||||||
|
import com.plannaplan.repositories.CommisionRepository;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CommisionService {
|
||||||
|
@Autowired
|
||||||
|
private CommisionRepository repo;
|
||||||
|
|
||||||
|
public CommisionService() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Commision save(Commision commision) {
|
||||||
|
this.repo.save(commision);
|
||||||
|
return commision;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Commision> getUsersCommisions(User user) {
|
||||||
|
return this.repo.getUsers(user.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Commision> getNewestCommision(User user) {
|
||||||
|
return this.repo.getNewestCommision(user.getId()).stream().findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCommisionsAmmount() {
|
||||||
|
return this.repo.count();
|
||||||
|
}
|
||||||
|
}
|
26
buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java
Executable file
26
buisnesslogic/src/main/java/com/plannaplan/services/ConfiguratorService.java
Executable file
@ -0,0 +1,26 @@
|
|||||||
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import com.plannaplan.models.ConfigData;
|
||||||
|
import com.plannaplan.models.FileData;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import com.plannaplan.configutils.*;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ConfiguratorService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FileToDatabaseMigrator migrator;
|
||||||
|
|
||||||
|
public ConfiguratorService() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void config(ConfigData data) {
|
||||||
|
FileReader reader = new FileReader(data.getFilestream());
|
||||||
|
FileData coursesData = reader.read();
|
||||||
|
migrator.migrate(coursesData);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
12
buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java
Normal file → Executable file
12
buisnesslogic/src/main/java/com/plannaplan/services/CourseService.java
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.repositories.CourseRepository;
|
import com.plannaplan.repositories.CourseRepository;
|
||||||
@ -13,7 +14,7 @@ public class CourseService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CourseRepository repo;
|
private CourseRepository repo;
|
||||||
|
|
||||||
public Course getCourseByName(String name) {
|
public Optional<Course> getCourseByName(String name) {
|
||||||
return this.repo.findByName(name);
|
return this.repo.findByName(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -21,15 +22,16 @@ public class CourseService {
|
|||||||
return this.repo.findAll();
|
return this.repo.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Course course) {
|
public Course save(Course course) {
|
||||||
this.repo.save(course);
|
this.repo.save(course);
|
||||||
|
return course;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Course course){
|
public void delete(Course course) {
|
||||||
this.repo.delete(course);
|
this.repo.delete(course);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCoursesAmmount(){
|
public int getCoursesAmmount() {
|
||||||
return (int)this.repo.count();
|
return (int) this.repo.count();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
16
buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java
Normal file → Executable file
16
buisnesslogic/src/main/java/com/plannaplan/services/GroupService.java
Normal file → Executable file
@ -1,6 +1,7 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
import com.plannaplan.repositories.GroupRepository;
|
import com.plannaplan.repositories.GroupRepository;
|
||||||
@ -16,7 +17,7 @@ public class GroupService {
|
|||||||
public GroupService() {
|
public GroupService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Groups find(int time, int capacity, String room) {
|
public Optional<Groups> find(int time, int capacity, String room) {
|
||||||
return this.repo.find(time, room, capacity);
|
return this.repo.find(time, room, capacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,15 +25,20 @@ public class GroupService {
|
|||||||
return this.repo.getByCourse(id);
|
return this.repo.getByCourse(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Groups group) {
|
public Groups save(Groups group) {
|
||||||
this.repo.save(group);
|
this.repo.save(group);
|
||||||
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Groups groups){
|
public void delete(Groups groups) {
|
||||||
this.repo.delete(groups);
|
this.repo.delete(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGroupsAmmount(){
|
public int getGroupsAmmount() {
|
||||||
return (int)this.repo.count();
|
return (int) this.repo.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<Groups> getGroupById(Long id) {
|
||||||
|
return this.repo.findById(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
11
buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java
Normal file → Executable file
11
buisnesslogic/src/main/java/com/plannaplan/services/LecturerService.java
Normal file → Executable file
@ -1,5 +1,7 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
import com.plannaplan.entities.Lecturer;
|
import com.plannaplan.entities.Lecturer;
|
||||||
import com.plannaplan.repositories.LecturerRepository;
|
import com.plannaplan.repositories.LecturerRepository;
|
||||||
|
|
||||||
@ -11,19 +13,20 @@ public class LecturerService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private LecturerRepository repo;
|
private LecturerRepository repo;
|
||||||
|
|
||||||
public Lecturer getLecturer(String title, String name, String surname) {
|
public Optional<Lecturer> getLecturer(String title, String name, String surname) {
|
||||||
return repo.find(title, name, surname);
|
return repo.find(title, name, surname);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save(Lecturer lecturer) {
|
public Lecturer save(Lecturer lecturer) {
|
||||||
repo.save(lecturer);
|
repo.save(lecturer);
|
||||||
|
return lecturer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete(Lecturer lecturer) {
|
public void delete(Lecturer lecturer) {
|
||||||
repo.delete(lecturer);
|
repo.delete(lecturer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLecturersAmmount(){
|
public int getLecturersAmmount() {
|
||||||
return (int)this.repo.count();
|
return (int) this.repo.count();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
19
buisnesslogic/src/main/java/com/plannaplan/services/UserService.java
Normal file → Executable file
19
buisnesslogic/src/main/java/com/plannaplan/services/UserService.java
Normal file → Executable file
@ -1,8 +1,8 @@
|
|||||||
package com.plannaplan.services;
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.plannaplan.abstracts.EventWatcher;
|
|
||||||
import com.plannaplan.entities.User;
|
import com.plannaplan.entities.User;
|
||||||
import com.plannaplan.exceptions.UserNotFoundException;
|
import com.plannaplan.exceptions.UserNotFoundException;
|
||||||
import com.plannaplan.repositories.UserRepository;
|
import com.plannaplan.repositories.UserRepository;
|
||||||
@ -11,7 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UserService extends EventWatcher {
|
public class UserService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository repo;
|
private UserRepository repo;
|
||||||
|
|
||||||
@ -20,10 +20,9 @@ public class UserService extends EventWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String login(String authority) throws UserNotFoundException {
|
public String login(String authority) throws UserNotFoundException {
|
||||||
User user = this.repo.getByAuthority(authority.replace("\n", "").trim());
|
User user = this.repo.getByAuthority(authority.replace("\n", "").trim())
|
||||||
if (user == null) {
|
.orElseThrow(() -> new UserNotFoundException("Can not find user with given authority"));
|
||||||
throw new UserNotFoundException("Can not find user with given authority");
|
|
||||||
}
|
|
||||||
String token = UUID.randomUUID().toString();
|
String token = UUID.randomUUID().toString();
|
||||||
user.setToken(token);
|
user.setToken(token);
|
||||||
this.repo.save(user);
|
this.repo.save(user);
|
||||||
@ -34,11 +33,13 @@ public class UserService extends EventWatcher {
|
|||||||
this.repo.save(user);
|
this.repo.save(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUserByEmail(String email) {
|
public User getUserByEmail(String email) throws UserNotFoundException {
|
||||||
return this.repo.getByAuthority(email.replace("\n", "").trim());
|
return this.repo.getByAuthority(email.replace("\n", "").trim())
|
||||||
|
.orElseThrow(() -> new UserNotFoundException("Cannot find user with given authority"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getByToken(String token) {
|
public Optional<User> getByToken(String token) {
|
||||||
return this.repo.getByToken(token);
|
return this.repo.getByToken(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package com.plannaplan.statisticutils;
|
|
||||||
|
|
||||||
public class Statistics {
|
|
||||||
|
|
||||||
public Statistics() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void getAll() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.plannaplan.transferutils;
|
|
||||||
|
|
||||||
public class TransferMatcher {
|
|
||||||
public TransferMatcher() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void findMatches() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package com.plannaplan.transferutils;
|
|
||||||
|
|
||||||
public class TransfersExecuter {
|
|
||||||
public TransfersExecuter() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void execute() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.types;
|
|
||||||
|
|
||||||
public enum ActionTypes {
|
|
||||||
ADD, DELETE, REPLACE
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.types;
|
|
||||||
|
|
||||||
public enum AppStates {
|
|
||||||
STOPPED, RUNNING, PAUSED
|
|
||||||
}
|
|
@ -1,5 +0,0 @@
|
|||||||
package com.plannaplan.types;
|
|
||||||
|
|
||||||
public enum EventTypes {
|
|
||||||
DROPPED_OUT, TOUR_STARTED, TRANSFER_FOUND, TOUR_FINISHED, COURSES_ACCEPTED
|
|
||||||
}
|
|
0
buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/types/GroupType.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/types/UserRoles.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/types/UserRoles.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/types/WeekDay.java
Normal file → Executable file
0
buisnesslogic/src/main/java/com/plannaplan/types/WeekDay.java
Normal file → Executable file
2
buisnesslogic/src/test/java/com/plannaplan/TestApplication.java
Normal file → Executable file
2
buisnesslogic/src/test/java/com/plannaplan/TestApplication.java
Normal file → Executable file
@ -4,5 +4,5 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class TestApplication {
|
public class TestApplication {
|
||||||
|
public final static String TEST_CONFIG_FILE = "Zajecia.xlsx";
|
||||||
}
|
}
|
||||||
|
6
buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java
Normal file → Executable file
6
buisnesslogic/src/test/java/com/plannaplan/configutils/FileReaderTest.java
Normal file → Executable file
@ -11,9 +11,9 @@ import org.junit.Test;
|
|||||||
public class FileReaderTest {
|
public class FileReaderTest {
|
||||||
@Test
|
@Test
|
||||||
public void shoulReturnNull() {
|
public void shoulReturnNull() {
|
||||||
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
|
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream("Zajecia.xlsx");
|
||||||
FileReader r = new FileReader(inputStream);
|
final FileReader r = new FileReader(inputStream);
|
||||||
FileData d = r.read();
|
final FileData d = r.read();
|
||||||
assertTrue(d.getRows().next().getCell(0).toString().equals("1.0"));
|
assertTrue(d.getRows().next().getCell(0).toString().equals("1.0"));
|
||||||
assertTrue(d.getKeys().size() == 22);
|
assertTrue(d.getKeys().size() == 22);
|
||||||
assertTrue(d != null);
|
assertTrue(d != null);
|
||||||
|
15
buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java
Normal file → Executable file
15
buisnesslogic/src/test/java/com/plannaplan/configutils/FileToDatabaseMigratorTest.java
Normal file → Executable file
@ -9,8 +9,7 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
import com.plannaplan.Configurator;
|
import com.plannaplan.TestApplication;
|
||||||
import com.plannaplan.models.ConfigData;
|
|
||||||
import com.plannaplan.services.CourseService;
|
import com.plannaplan.services.CourseService;
|
||||||
import com.plannaplan.services.GroupService;
|
import com.plannaplan.services.GroupService;
|
||||||
import com.plannaplan.services.LecturerService;
|
import com.plannaplan.services.LecturerService;
|
||||||
@ -18,16 +17,13 @@ import com.plannaplan.services.LecturerService;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
public class FileToDatabaseMigratorTest {
|
public class FileToDatabaseMigratorTest {
|
||||||
|
|
||||||
private static String FILE_NAME = "Zajecia.xlsx";
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Configurator restTemplate;
|
private FileToDatabaseMigrator migrator;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CourseService courseService;
|
private CourseService courseService;
|
||||||
@ -40,9 +36,10 @@ public class FileToDatabaseMigratorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldImportDataFromFileToDatabase() throws Exception {
|
public void shouldImportDataFromFileToDatabase() throws Exception {
|
||||||
final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(FILE_NAME);
|
final InputStream inputStream = getClass().getClassLoader()
|
||||||
final ConfigData data = new ConfigData(null, null, inputStream);
|
.getResourceAsStream(TestApplication.TEST_CONFIG_FILE);
|
||||||
this.restTemplate.config(data);
|
final FileReader reader = new FileReader(inputStream);
|
||||||
|
this.migrator.migrate(reader.read());
|
||||||
int courses_ammount = this.courseService.getCoursesAmmount();
|
int courses_ammount = this.courseService.getCoursesAmmount();
|
||||||
int groups_ammount = this.groupService.getGroupsAmmount();
|
int groups_ammount = this.groupService.getGroupsAmmount();
|
||||||
int lecturers_ammount = this.lecturerService.getLecturersAmmount();
|
int lecturers_ammount = this.lecturerService.getLecturersAmmount();
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@ContextConfiguration
|
||||||
|
public class AssignmentServiceTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignmentService service;
|
||||||
|
@Autowired
|
||||||
|
private CommisionService comServie;
|
||||||
|
private Commision com;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void init() {
|
||||||
|
this.com = new Commision();
|
||||||
|
this.comServie.save(this.com);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSaveAssignment() {
|
||||||
|
long beginState = this.service.getAssignmentsAmmount();
|
||||||
|
this.addAssignmentToCommision(this.com);
|
||||||
|
assertTrue("Assign ammount should increase", this.service.getAssignmentsAmmount() > beginState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGetCommisionAssignments() {
|
||||||
|
this.addAssignmentToCommision(this.com);
|
||||||
|
final List<Assignment> response = this.service.getCommisionAssignments(com);
|
||||||
|
assertTrue("Returned list size should be 1", response.size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addAssignmentToCommision(Commision com) {
|
||||||
|
Assignment a = new Assignment(null, com);
|
||||||
|
this.service.save(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
import com.plannaplan.entities.User;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@ContextConfiguration
|
||||||
|
public class CommisionServiceTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommisionService service;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldSaveCommision() {
|
||||||
|
long beginState = this.service.getCommisionsAmmount();
|
||||||
|
this.service.save(new Commision());
|
||||||
|
assertTrue("Commision ammount should have changed", this.service.getCommisionsAmmount() > beginState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGetUserCommisions() {
|
||||||
|
User usr = new User();
|
||||||
|
this.userService.save(usr);
|
||||||
|
this.service.save(new Commision(usr));
|
||||||
|
|
||||||
|
assertTrue("User should have one commision", this.service.getUsersCommisions(usr).size() == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldGetNewestCommision() throws NullPointerException, InterruptedException {
|
||||||
|
User usr = new User();
|
||||||
|
this.userService.save(usr);
|
||||||
|
this.service.save(new Commision(usr));
|
||||||
|
|
||||||
|
Thread.sleep(2000);
|
||||||
|
|
||||||
|
final Commision newestCommision = new Commision(usr);
|
||||||
|
this.service.save(newestCommision);
|
||||||
|
|
||||||
|
final Commision result = this.service.getNewestCommision(usr)
|
||||||
|
.orElseThrow(() -> new NullPointerException("There was no commision"));
|
||||||
|
|
||||||
|
assertTrue("Wrong commision was returned", result.getId().equals(newestCommision.getId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,49 @@
|
|||||||
|
package com.plannaplan.services;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
|
import com.plannaplan.TestApplication;
|
||||||
|
import com.plannaplan.models.ConfigData;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
@ContextConfiguration
|
||||||
|
public class ConfiguratorServiceTest {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConfiguratorService configuratorService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CourseService courseService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupService groupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LecturerService lecturerService;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void shouldImportDataToDataBase() {
|
||||||
|
final InputStream inputStream = getClass().getClassLoader()
|
||||||
|
.getResourceAsStream(TestApplication.TEST_CONFIG_FILE);
|
||||||
|
final ConfigData data = new ConfigData(null, null, inputStream);
|
||||||
|
this.configuratorService.config(data);
|
||||||
|
|
||||||
|
int courses_ammount = this.courseService.getCoursesAmmount();
|
||||||
|
int groups_ammount = this.groupService.getGroupsAmmount();
|
||||||
|
int lecturers_ammount = this.lecturerService.getLecturersAmmount();
|
||||||
|
|
||||||
|
assertTrue(courses_ammount > 0 && groups_ammount > 0 && lecturers_ammount > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
7
buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java
Normal file → Executable file
7
buisnesslogic/src/test/java/com/plannaplan/services/CourseServiceTest.java
Normal file → Executable file
@ -20,17 +20,12 @@ public class CourseServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAndDeleteCourse() {
|
public void createAndDeleteCourse() {
|
||||||
Course course;
|
Course course = new Course("Testowy kurs", "TK");
|
||||||
int startAmmount = this.courseService.getCoursesAmmount();
|
int startAmmount = this.courseService.getCoursesAmmount();
|
||||||
|
|
||||||
// Create course
|
|
||||||
course = new Course();
|
|
||||||
course.setName("Testowy kurs");
|
|
||||||
course.setSymbol("TK");
|
|
||||||
courseService.save(course);
|
courseService.save(course);
|
||||||
assertTrue(this.courseService.getCoursesAmmount() > startAmmount);
|
assertTrue(this.courseService.getCoursesAmmount() > startAmmount);
|
||||||
|
|
||||||
// Delete course
|
|
||||||
courseService.delete(course);
|
courseService.delete(course);
|
||||||
assertTrue(this.courseService.getCoursesAmmount() == startAmmount);
|
assertTrue(this.courseService.getCoursesAmmount() == startAmmount);
|
||||||
}
|
}
|
||||||
|
5
buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java
Normal file → Executable file
5
buisnesslogic/src/test/java/com/plannaplan/services/GroupServiceTest.java
Normal file → Executable file
@ -21,16 +21,13 @@ public class GroupServiceTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAndDeleteGroup() {
|
public void createAndDeleteGroup() {
|
||||||
Groups group;
|
|
||||||
int startAmmount = this.groupService.getGroupsAmmount();
|
int startAmmount = this.groupService.getGroupsAmmount();
|
||||||
|
|
||||||
//Create group
|
Groups group = new Groups();
|
||||||
group = new Groups();
|
|
||||||
group.setRoom("A1");
|
group.setRoom("A1");
|
||||||
groupService.save(group);
|
groupService.save(group);
|
||||||
assertTrue(this.groupService.getGroupsAmmount() > startAmmount);
|
assertTrue(this.groupService.getGroupsAmmount() > startAmmount);
|
||||||
|
|
||||||
// Delete course
|
|
||||||
groupService.delete(group);
|
groupService.delete(group);
|
||||||
assertTrue(this.groupService.getGroupsAmmount() == startAmmount);
|
assertTrue(this.groupService.getGroupsAmmount() == startAmmount);
|
||||||
}
|
}
|
||||||
|
10
buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java
Normal file → Executable file
10
buisnesslogic/src/test/java/com/plannaplan/services/LecturerServiceTest.java
Normal file → Executable file
@ -19,19 +19,13 @@ public class LecturerServiceTest {
|
|||||||
private LecturerService lecturerService;
|
private LecturerService lecturerService;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void createAndDeleteLecturer(){
|
public void createAndDeleteLecturer() {
|
||||||
Lecturer lecturer;
|
|
||||||
int startAmmount = this.lecturerService.getLecturersAmmount();
|
int startAmmount = this.lecturerService.getLecturersAmmount();
|
||||||
|
|
||||||
// Create lecturer
|
Lecturer lecturer = new Lecturer("prof.", "Tomasz", "Kowalski");
|
||||||
lecturer = new Lecturer();
|
|
||||||
lecturer.setName("Tomasz");
|
|
||||||
lecturer.setSurname("Kowalski");
|
|
||||||
lecturer.setTitle("prof.");
|
|
||||||
lecturerService.save(lecturer);
|
lecturerService.save(lecturer);
|
||||||
assertTrue(this.lecturerService.getLecturersAmmount() > startAmmount);
|
assertTrue(this.lecturerService.getLecturersAmmount() > startAmmount);
|
||||||
|
|
||||||
// Delete lecturer
|
|
||||||
lecturerService.delete(lecturer);
|
lecturerService.delete(lecturer);
|
||||||
assertTrue(this.lecturerService.getLecturersAmmount() == startAmmount);
|
assertTrue(this.lecturerService.getLecturersAmmount() == startAmmount);
|
||||||
}
|
}
|
||||||
|
16
buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java
Normal file → Executable file
16
buisnesslogic/src/test/java/com/plannaplan/services/UserServiceTest.java
Normal file → Executable file
@ -22,27 +22,23 @@ import org.junit.runner.RunWith;
|
|||||||
@ContextConfiguration
|
@ContextConfiguration
|
||||||
@TestMethodOrder(OrderAnnotation.class)
|
@TestMethodOrder(OrderAnnotation.class)
|
||||||
public class UserServiceTest {
|
public class UserServiceTest {
|
||||||
public static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
private static String TEST_USER_MAIL = "noteexisitingmail@notexistingdomain.com";
|
||||||
public static String TEST_USER_NAME = "Tom";
|
private static String TEST_USER_NAME = "Tom";
|
||||||
public static String TEST_USER_SUERNAME = "Kovalsky";
|
private static String TEST_USER_SUERNAME = "Kovalsky";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
User testUser = new User();
|
User testUser = new User(TEST_USER_NAME, TEST_USER_SUERNAME, TEST_USER_MAIL, UserRoles.TEST_USER);
|
||||||
testUser.setEmail(TEST_USER_MAIL);
|
|
||||||
testUser.setName(TEST_USER_NAME);
|
|
||||||
testUser.setSurname(TEST_USER_SUERNAME);
|
|
||||||
testUser.setRole(UserRoles.TEST_USER);
|
|
||||||
this.userService.save(testUser);
|
this.userService.save(testUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shouldReturnToken() {
|
public void shouldReturnToken() {
|
||||||
try {
|
try {
|
||||||
String token = this.userService.login(TEST_USER_MAIL);
|
final String token = this.userService.login(TEST_USER_MAIL);
|
||||||
System.out.println("Returned token: " + token);
|
System.out.println("Returned token: " + token);
|
||||||
assertTrue(token != null);
|
assertTrue(token != null);
|
||||||
assertTrue(this.userService.getUserByEmail(TEST_USER_MAIL).getToken() != null);
|
assertTrue(this.userService.getUserByEmail(TEST_USER_MAIL).getToken() != null);
|
||||||
|
0
buisnesslogic/src/test/resources/Zajecia.xlsx
Normal file → Executable file
0
buisnesslogic/src/test/resources/Zajecia.xlsx
Normal file → Executable file
0
buisnesslogic/src/test/resources/application.properties
Normal file → Executable file
0
buisnesslogic/src/test/resources/application.properties
Normal file → Executable file
0
docs/api.md
Normal file → Executable file
0
docs/api.md
Normal file → Executable file
4
pom.xml
Normal file → Executable file
4
pom.xml
Normal file → Executable file
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>14</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>14</maven.compiler.target>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
20
restservice/pom.xml
Normal file → Executable file
20
restservice/pom.xml
Normal file → Executable file
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<maven.compiler.source>1.8</maven.compiler.source>
|
<maven.compiler.source>1.14</maven.compiler.source>
|
||||||
<maven.compiler.target>1.8</maven.compiler.target>
|
<maven.compiler.target>1.14</maven.compiler.target>
|
||||||
<start-class>com.plannaplan.App</start-class>
|
<start-class>com.plannaplan.App</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -27,10 +27,16 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.12</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.vavr</groupId>
|
||||||
|
<artifactId>vavr</artifactId>
|
||||||
|
<version>0.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
<artifactId>httpclient</artifactId>
|
<artifactId>httpclient</artifactId>
|
||||||
@ -42,6 +48,14 @@
|
|||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.springframework.security/spring-security-test -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.security</groupId>
|
||||||
|
<artifactId>spring-security-test</artifactId>
|
||||||
|
<version>5.3.4.RELEASE</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-security</artifactId>
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
34
restservice/src/main/java/com/plannaplan/App.java
Normal file → Executable file
34
restservice/src/main/java/com/plannaplan/App.java
Normal file → Executable file
@ -28,11 +28,33 @@ public class App {
|
|||||||
|
|
||||||
@EventListener(ApplicationReadyEvent.class)
|
@EventListener(ApplicationReadyEvent.class)
|
||||||
public void importData() {
|
public void importData() {
|
||||||
User testUser = new User();
|
User filip = new User();
|
||||||
testUser.setEmail("filizy@st.amu.edu.pl");
|
filip.setEmail("filizy@st.amu.edu.pl");
|
||||||
testUser.setName("Filip");
|
filip.setName("Filip");
|
||||||
testUser.setSurname("Izydorczyk");
|
filip.setSurname("Izydorczyk");
|
||||||
testUser.setRole(UserRoles.STUDENT);
|
filip.setRole(UserRoles.STUDENT);
|
||||||
this.userService.save(testUser);
|
this.userService.save(filip);
|
||||||
|
|
||||||
|
User hub = new User();
|
||||||
|
hub.setEmail("hubwrz1@st.amu.edu.pl");
|
||||||
|
hub.setName("Hubert");
|
||||||
|
hub.setSurname("Wrzesiński");
|
||||||
|
hub.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(hub);
|
||||||
|
|
||||||
|
User mac = new User();
|
||||||
|
mac.setEmail("macglo2@st.amu.edu.pl");
|
||||||
|
mac.setName("Maciej");
|
||||||
|
mac.setSurname("Głowacki");
|
||||||
|
mac.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(mac);
|
||||||
|
|
||||||
|
User mar = new User();
|
||||||
|
mar.setEmail("marwoz16@st.amu.edu.pl");
|
||||||
|
mar.setName("Marcin");
|
||||||
|
mar.setSurname("Woźniak");
|
||||||
|
mar.setRole(UserRoles.STUDENT);
|
||||||
|
this.userService.save(mar);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
0
restservice/src/main/java/com/plannaplan/Logo.java
Normal file → Executable file
0
restservice/src/main/java/com/plannaplan/Logo.java
Normal file → Executable file
@ -0,0 +1,47 @@
|
|||||||
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.plannaplan.App;
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
import com.plannaplan.entities.User;
|
||||||
|
import com.plannaplan.responses.mappers.AssignmentResponseMappers;
|
||||||
|
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
|
||||||
|
import com.plannaplan.services.AssignmentService;
|
||||||
|
import com.plannaplan.services.CommisionService;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping("/api/" + App.API_VERSION + "/assignments")
|
||||||
|
public class AssignmentsController extends TokenBasedController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommisionService commisionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignmentService assignmentService;
|
||||||
|
|
||||||
|
@GetMapping("/getCurrentAssignments")
|
||||||
|
public ResponseEntity<List<GetCurrentAssignmentsResponse>> getCurrentAssignments() throws Exception {
|
||||||
|
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException("User not found"));
|
||||||
|
Optional<Commision> com = this.commisionService.getNewestCommision(user);
|
||||||
|
|
||||||
|
if (com.isPresent()) {
|
||||||
|
List<Assignment> respone = this.assignmentService.getCommisionAssignments(com.get());
|
||||||
|
return new ResponseEntity<>(AssignmentResponseMappers.mapToResponse(respone), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.App;
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.entities.User;
|
||||||
|
import com.plannaplan.exceptions.UserNotFoundException;
|
||||||
|
import com.plannaplan.responses.mappers.CommisionResponseMappers;
|
||||||
|
import com.plannaplan.responses.models.CommisionResponse;
|
||||||
|
import com.plannaplan.services.AssignmentService;
|
||||||
|
import com.plannaplan.services.CommisionService;
|
||||||
|
import com.plannaplan.services.GroupService;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@CrossOrigin
|
||||||
|
@RequestMapping("/api/" + App.API_VERSION + "/commisions")
|
||||||
|
public class CommisionController extends TokenBasedController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommisionService commisionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupService groupServcicxe;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AssignmentService assignmentService;
|
||||||
|
|
||||||
|
public CommisionController() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/add")
|
||||||
|
public ResponseEntity<String> addCommision(@RequestBody List<Long> groups) throws UserNotFoundException {
|
||||||
|
|
||||||
|
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException());
|
||||||
|
Commision com = new Commision(user);
|
||||||
|
this.commisionService.save(com);
|
||||||
|
|
||||||
|
groups.stream().forEach((groupId) -> {
|
||||||
|
Groups group = this.groupServcicxe.getGroupById(groupId).orElseThrow(() -> new NullPointerException());
|
||||||
|
Assignment a = new Assignment(group, com);
|
||||||
|
this.assignmentService.save(a);
|
||||||
|
});
|
||||||
|
|
||||||
|
return new ResponseEntity<>("Succes", HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/getAllCommisions")
|
||||||
|
public ResponseEntity<List<CommisionResponse>> getAlCommisions() throws UserNotFoundException {
|
||||||
|
User user = this.getCurrentUser().orElseThrow(() -> new NullPointerException());
|
||||||
|
List<CommisionResponse> result = CommisionResponseMappers
|
||||||
|
.mapToResponse(this.commisionService.getUsersCommisions(user));
|
||||||
|
return new ResponseEntity<>(result, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
6
restservice/src/main/java/com/plannaplan/controllers/ConfigController.java
Normal file → Executable file
6
restservice/src/main/java/com/plannaplan/controllers/ConfigController.java
Normal file → Executable file
@ -6,8 +6,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.Controller;
|
|
||||||
import com.plannaplan.models.ConfigData;
|
import com.plannaplan.models.ConfigData;
|
||||||
|
import com.plannaplan.services.ConfiguratorService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
@ -23,12 +23,12 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
public class ConfigController {
|
public class ConfigController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Controller contrl;
|
private ConfiguratorService contrl;
|
||||||
|
|
||||||
@PostMapping("/config")
|
@PostMapping("/config")
|
||||||
public ResponseEntity<String> configApp(@RequestParam("file") MultipartFile file) {
|
public ResponseEntity<String> configApp(@RequestParam("file") MultipartFile file) {
|
||||||
try {
|
try {
|
||||||
ConfigData data = new ConfigData(null, null, file.getInputStream());
|
final ConfigData data = new ConfigData(null, null, file.getInputStream());
|
||||||
this.contrl.config(data);
|
this.contrl.config(data);
|
||||||
return new ResponseEntity<>("Sucess", HttpStatus.OK);
|
return new ResponseEntity<>("Sucess", HttpStatus.OK);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
46
restservice/src/main/java/com/plannaplan/controllers/CoursesController.java
Normal file → Executable file
46
restservice/src/main/java/com/plannaplan/controllers/CoursesController.java
Normal file → Executable file
@ -1,13 +1,12 @@
|
|||||||
package com.plannaplan.controllers;
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.entities.Course;
|
import com.plannaplan.entities.Course;
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.responses.mappers.CoursesResponseMappers;
|
||||||
|
import com.plannaplan.responses.models.GetCoursesResponse;
|
||||||
|
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
|
||||||
import com.plannaplan.services.CourseService;
|
import com.plannaplan.services.CourseService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -26,44 +25,19 @@ public class CoursesController {
|
|||||||
private CourseService courseService;
|
private CourseService courseService;
|
||||||
|
|
||||||
@GetMapping("/getCourses")
|
@GetMapping("/getCourses")
|
||||||
public ResponseEntity<List<Dictionary<String, Object>>> getMethodName() {
|
public ResponseEntity<List<GetCoursesResponse>> getMethodName() {
|
||||||
List<Course> courses = this.courseService.getAllCourses();
|
List<Course> courses = this.courseService.getAllCourses();
|
||||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
List<GetCoursesResponse> response = CoursesResponseMappers.mapToGetCoursesResponse(courses);
|
||||||
for (Course c : courses) {
|
|
||||||
Dictionary<String, Object> element = new Hashtable<>();
|
|
||||||
element.put("id", c.getId());
|
|
||||||
element.put("name", c.getName());
|
|
||||||
response.add(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/getCoursesWithGroups")
|
@GetMapping("/getCoursesWithGroups")
|
||||||
public ResponseEntity<List<Dictionary<String, Object>>> getCoursesWithGroups() {
|
public ResponseEntity<List<GetCoursesWithGroupsResponse>> getCoursesWithGroups() {
|
||||||
List<Course> courses = this.courseService.getAllCourses();
|
final List<Course> courses = this.courseService.getAllCourses();
|
||||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
final List<GetCoursesWithGroupsResponse> response = CoursesResponseMappers
|
||||||
for (Course c : courses) {
|
.mapToGetCoursesWithGroupsResponse(courses);
|
||||||
Dictionary<String, Object> element = new Hashtable<>();
|
|
||||||
element.put("id", c.getId());
|
|
||||||
element.put("name", c.getName());
|
|
||||||
List<Dictionary<String, Object>> groups = new ArrayList<>();
|
|
||||||
for (Groups g : c.getGroups()) {
|
|
||||||
Dictionary<String, Object> group = new Hashtable<>();
|
|
||||||
group.put("id", g.getId());
|
|
||||||
group.put("day", g.getDay().label);
|
|
||||||
group.put("time", g.getTimeString());
|
|
||||||
group.put("lecturer", g.getLecturer().toString());
|
|
||||||
group.put("room", g.getRoom());
|
|
||||||
group.put("type", g.getType());
|
|
||||||
groups.add(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
element.put("groups", groups);
|
|
||||||
response.add(element);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
return new ResponseEntity<>(response, HttpStatus.OK);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
25
restservice/src/main/java/com/plannaplan/controllers/GroupController.java
Normal file → Executable file
25
restservice/src/main/java/com/plannaplan/controllers/GroupController.java
Normal file → Executable file
@ -1,12 +1,11 @@
|
|||||||
package com.plannaplan.controllers;
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Dictionary;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.plannaplan.App;
|
import com.plannaplan.App;
|
||||||
import com.plannaplan.entities.Groups;
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.responses.mappers.GroupsMappers;
|
||||||
|
import com.plannaplan.responses.models.DefaultGroupResponse;
|
||||||
import com.plannaplan.services.GroupService;
|
import com.plannaplan.services.GroupService;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -26,26 +25,12 @@ public class GroupController {
|
|||||||
private GroupService groupService;
|
private GroupService groupService;
|
||||||
|
|
||||||
@GetMapping("/getCourseGroups")
|
@GetMapping("/getCourseGroups")
|
||||||
public ResponseEntity<List<Dictionary<String, Object>>> getCourses(@RequestParam("id") Long id,
|
public ResponseEntity<List<? extends DefaultGroupResponse>> getCourses(@RequestParam("id") Long id,
|
||||||
@RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) {
|
@RequestParam(name = "capacity", defaultValue = "true") Boolean capacity) {
|
||||||
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
List<Groups> groups = this.groupService.getGroupsByCourse(id);
|
||||||
List<Dictionary<String, Object>> response = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Groups g : groups) {
|
|
||||||
Dictionary<String, Object> group = new Hashtable<>();
|
|
||||||
group.put("id", g.getId());
|
|
||||||
group.put("day", g.getDay().label);
|
|
||||||
group.put("time", g.getTimeString());
|
|
||||||
group.put("lecturer", g.getLecturer().toString());
|
|
||||||
group.put("room", g.getRoom());
|
|
||||||
if (capacity) {
|
if (capacity) {
|
||||||
group.put("capacity", g.getCapacity());
|
return new ResponseEntity<>(GroupsMappers.mapToCapacityResponse(groups), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
group.put("type", g.getType());
|
return new ResponseEntity<>(GroupsMappers.mapToDefaultResponse(groups), HttpStatus.OK);
|
||||||
|
|
||||||
response.add(group);
|
|
||||||
}
|
|
||||||
|
|
||||||
return new ResponseEntity<>(response, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.plannaplan.controllers;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.User;
|
||||||
|
import com.plannaplan.exceptions.UserNotFoundException;
|
||||||
|
import com.plannaplan.services.UserService;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.Authentication;
|
||||||
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.authentication.AnonymousAuthenticationToken;
|
||||||
|
|
||||||
|
public abstract class TokenBasedController {
|
||||||
|
@Autowired
|
||||||
|
protected UserService userService;
|
||||||
|
|
||||||
|
public TokenBasedController() {
|
||||||
|
}
|
||||||
|
|
||||||
|
protected Optional<User> getCurrentUser() throws UserNotFoundException {
|
||||||
|
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
|
||||||
|
if (!(authentication instanceof AnonymousAuthenticationToken)) {
|
||||||
|
return Optional.of(this.userService.getUserByEmail(authentication.getName()));
|
||||||
|
} else {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
restservice/src/main/java/com/plannaplan/controllers/TokenController.java
Normal file → Executable file
4
restservice/src/main/java/com/plannaplan/controllers/TokenController.java
Normal file → Executable file
@ -17,14 +17,14 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
public class TokenController {
|
public class TokenController {
|
||||||
|
|
||||||
public static String SERVICE_URL = "http://localhost:3000";
|
private final static String SERVICE_URL = "http://localhost:3000";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@GetMapping("/token")
|
@GetMapping("/token")
|
||||||
public ResponseEntity<String> getToken(@RequestParam("ticket") final String ticket) {
|
public ResponseEntity<String> getToken(@RequestParam("ticket") final String ticket) {
|
||||||
CasValidator validator = new CasValidator(SERVICE_URL, ticket);
|
final CasValidator validator = new CasValidator(SERVICE_URL, ticket);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String authority = validator.validate();
|
String authority = validator.validate();
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.plannaplan.responses.mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.responses.models.GetCurrentAssignmentsResponse;
|
||||||
|
|
||||||
|
public class AssignmentResponseMappers {
|
||||||
|
|
||||||
|
public static final List<GetCurrentAssignmentsResponse> mapToResponse(List<Assignment> assignments) {
|
||||||
|
return assignments.stream().filter(Objects::nonNull).map(GetCurrentAssignmentsResponse::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.plannaplan.responses.mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
import com.plannaplan.responses.models.CommisionResponse;
|
||||||
|
|
||||||
|
public class CommisionResponseMappers {
|
||||||
|
public static final List<CommisionResponse> mapToResponse(List<Commision> commisions) {
|
||||||
|
return commisions.stream().filter(Objects::nonNull).map(CommisionResponse::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.plannaplan.responses.mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Course;
|
||||||
|
import com.plannaplan.responses.models.GetCoursesResponse;
|
||||||
|
import com.plannaplan.responses.models.GetCoursesWithGroupsResponse;
|
||||||
|
|
||||||
|
public class CoursesResponseMappers {
|
||||||
|
public static final List<GetCoursesResponse> mapToGetCoursesResponse(List<Course> courses) {
|
||||||
|
return courses.stream().filter(Objects::nonNull).map(GetCoursesResponse::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final List<GetCoursesWithGroupsResponse> mapToGetCoursesWithGroupsResponse(List<Course> courses) {
|
||||||
|
return courses.stream().filter(Objects::nonNull).map(GetCoursesWithGroupsResponse::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package com.plannaplan.responses.mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.responses.models.DefaultGroupResponse;
|
||||||
|
import com.plannaplan.responses.models.WithCapacityGroupResponse;
|
||||||
|
|
||||||
|
public class GroupsMappers {
|
||||||
|
public static List<DefaultGroupResponse> mapToDefaultResponse(List<Groups> groups) {
|
||||||
|
return groups.stream().filter(Objects::nonNull).map(DefaultGroupResponse::new).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<WithCapacityGroupResponse> mapToCapacityResponse(List<Groups> groups) {
|
||||||
|
return groups.stream().filter(Objects::nonNull).map(WithCapacityGroupResponse::new)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Commision;
|
||||||
|
|
||||||
|
public class CommisionResponse {
|
||||||
|
private Long id;
|
||||||
|
private Timestamp commisionDate;
|
||||||
|
|
||||||
|
public CommisionResponse(Commision commision) {
|
||||||
|
this.id = commision.getId();
|
||||||
|
this.commisionDate = commision.getCommisionDate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getCommisionDate() {
|
||||||
|
return commisionDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
|
public class DefaultGroupResponse {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private int day;
|
||||||
|
private String time;
|
||||||
|
private String lecturer;
|
||||||
|
private String room;
|
||||||
|
private GroupType type;
|
||||||
|
|
||||||
|
public DefaultGroupResponse(Groups group) {
|
||||||
|
this.id = group.getId() != null ? group.getId() : null;
|
||||||
|
this.day = group.getDay() != null ? group.getDay().label : -1;
|
||||||
|
this.time = group.getTimeString() != null ? group.getTimeString() : "";
|
||||||
|
this.lecturer = group.getLecturer() != null ? group.getLecturer().toString() : "";
|
||||||
|
this.room = group.getRoom() != null ? group.getRoom() : "";
|
||||||
|
this.type = group.getType() != null ? group.getType() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DefaultGroupResponse(Assignment assignment) {
|
||||||
|
this(assignment.getGroup());
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupType getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRoom() {
|
||||||
|
return room;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLecturer() {
|
||||||
|
return lecturer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTime() {
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getDay() {
|
||||||
|
return day;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Course;
|
||||||
|
import com.plannaplan.responses.models.abstracts.CoursesResponse;
|
||||||
|
|
||||||
|
public class GetCoursesResponse extends CoursesResponse {
|
||||||
|
|
||||||
|
public GetCoursesResponse(Course course) {
|
||||||
|
super(course);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Course;
|
||||||
|
import com.plannaplan.responses.models.abstracts.CoursesResponse;
|
||||||
|
import com.plannaplan.types.GroupType;
|
||||||
|
|
||||||
|
public class GetCoursesWithGroupsResponse extends CoursesResponse {
|
||||||
|
|
||||||
|
private List<DefaultGroupResponse> lectures = new ArrayList<>();
|
||||||
|
private List<DefaultGroupResponse> classes = new ArrayList<>();
|
||||||
|
|
||||||
|
public GetCoursesWithGroupsResponse(Course course) {
|
||||||
|
super(course);
|
||||||
|
course.getGroups().stream().forEach(group -> {
|
||||||
|
if (group.getType() == GroupType.CLASS) {
|
||||||
|
this.classes.add(new DefaultGroupResponse(group));
|
||||||
|
} else {
|
||||||
|
this.lectures.add(new DefaultGroupResponse(group));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DefaultGroupResponse> getClasses() {
|
||||||
|
return this.classes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<DefaultGroupResponse> getLectures() {
|
||||||
|
return this.lectures;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
|
||||||
|
public class GetCurrentAssignmentsResponse extends WithCapacityGroupResponse {
|
||||||
|
|
||||||
|
public GetCurrentAssignmentsResponse(Assignment assignment) {
|
||||||
|
super(assignment);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.plannaplan.responses.models;
|
||||||
|
|
||||||
|
import com.plannaplan.entities.Assignment;
|
||||||
|
import com.plannaplan.entities.Groups;
|
||||||
|
|
||||||
|
public class WithCapacityGroupResponse extends DefaultGroupResponse {
|
||||||
|
|
||||||
|
private int capacity;
|
||||||
|
|
||||||
|
public WithCapacityGroupResponse(Groups group) {
|
||||||
|
super(group);
|
||||||
|
this.capacity = group.getCapacity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public WithCapacityGroupResponse(Assignment assignment) {
|
||||||
|
this(assignment.getGroup());
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCapacity() {
|
||||||
|
return capacity;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user