Merge pull request 'ZPI-163: Dodanie dokumentacji do kodu + javadoc' (#24) from ZPI-163 into master

Reviewed-on: http://git.plannaplan.pl/filipizydorczyk/backend/pulls/24
This commit is contained in:
filipizydorczyk 2020-12-02 12:28:38 +01:00
commit c3fd450499
28 changed files with 546 additions and 35 deletions

View File

@ -57,6 +57,12 @@ mvn clean package spring-boot:repackage
Utworzony zostanie jar w `restservice/target/restservice-1.0-SNAPSHOT.jar`. Oczywiscie zeby jar zadzialal kontenery dockerowe musza byc odpalone (lub baza danych na serwerze jesli zmienialismy propertisy z localhost) Utworzony zostanie jar w `restservice/target/restservice-1.0-SNAPSHOT.jar`. Oczywiscie zeby jar zadzialal kontenery dockerowe musza byc odpalone (lub baza danych na serwerze jesli zmienialismy propertisy z localhost)
## Generowanie dokumentacji - javadoc
```bash
mvn javadoc:javadoc
```
## Troubleshooting ## Troubleshooting
Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali Ci blad `Connection Refused`, a wiesz, ze ta baza stoi na podanym ip i porcie to sprobuj Spring chyba cacheuje jakies dane dotyczace polaczenia wiec jesli spring wywali Ci blad `Connection Refused`, a wiesz, ze ta baza stoi na podanym ip i porcie to sprobuj

View File

@ -84,6 +84,15 @@
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version> <version>3.0.2</version>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.8.0</version>

View File

@ -11,6 +11,9 @@ import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import com.plannaplan.models.FileData; import com.plannaplan.models.FileData;
/**
* FileReader is used for reading xls file from input stream.
*/
public class FileReader { public class FileReader {
private InputStream fileInputStream; private InputStream fileInputStream;
@ -22,7 +25,7 @@ public class FileReader {
public FileData read() { public FileData read() {
FileData result = null; FileData result = null;
try { try {
InputStream fis = this.fileInputStream; InputStream fis = this.fileInputStream;
XSSFWorkbook workbook = new XSSFWorkbook(fis); XSSFWorkbook workbook = new XSSFWorkbook(fis);
@ -53,4 +56,4 @@ public class FileReader {
return result; return result;
} }
} }

View File

@ -14,6 +14,9 @@ import org.apache.poi.ss.usermodel.Row;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/**
* FileToDatabaseMigrator is used for migrate data from file (it reads line by line) and push it into database
*/
@Component @Component
public class FileToDatabaseMigrator { public class FileToDatabaseMigrator {

View File

@ -7,6 +7,11 @@ import javax.persistence.Id;
import javax.persistence.JoinColumn; import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne; import javax.persistence.ManyToOne;
/**
* Entity of Assignment grouping of state associated about group_id and commision_id
*
*/
@Entity @Entity
public class Assignment { public class Assignment {
@Id @Id
@ -19,12 +24,23 @@ public class Assignment {
@JoinColumn(name = "commision_id") @JoinColumn(name = "commision_id")
private Commision commision; private Commision commision;
private boolean isPastAssignment; private boolean isPastAssignment;
/**
* Assignment
* @param group group we would like to assign
* @param commision commision that assignment belongs to
* @param isPastAssignment is assignment past or no
*/
public Assignment(Groups group, Commision commision, boolean isPastAssignment) { public Assignment(Groups group, Commision commision, boolean isPastAssignment) {
this.commision = commision; this.commision = commision;
this.group = group; this.group = group;
} }
/**
* Assignment
* @param group group we would like to assign
* @param commision commision that assignment belongs to
*/
public Assignment(Groups group, Commision commision) { public Assignment(Groups group, Commision commision) {
this(group, commision, false); this(group, commision, false);
} }
@ -32,18 +48,36 @@ public class Assignment {
public Assignment() { public Assignment() {
} }
/**
* Id getter
* @return id id of assignment
*/
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
/**
* getGroup
*
* @return group
*/
public Groups getGroup() { public Groups getGroup() {
return this.group; return this.group;
} }
/**
* isPastAssignment getter
* @return isPastAssignment
*/
public boolean isPastAssignment() { public boolean isPastAssignment() {
return isPastAssignment; return isPastAssignment;
} }
/**
* setter isPastAssignment
* @param isPastAssignment
*/
public void setPastAssignment(boolean isPastAssignment) { public void setPastAssignment(boolean isPastAssignment) {
this.isPastAssignment = isPastAssignment; this.isPastAssignment = isPastAssignment;
} }

View File

@ -12,6 +12,10 @@ import javax.persistence.JoinColumn;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
import javax.persistence.OneToOne; import javax.persistence.OneToOne;
/**
* Entity of Commision grouping of state associated about commison and owner_id
*/
@Entity @Entity
public class Commision { public class Commision {
@Id @Id
@ -38,18 +42,34 @@ public class Commision {
public Commision() { public Commision() {
} }
/**
* Id getter
* @return id id of commision
*/
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
/**
* CommisionDate getter
* @return commisionDate
*/
public Timestamp getCommisionDate() { public Timestamp getCommisionDate() {
return commisionDate; return commisionDate;
} }
/**
* User of given commision getter
* @return User commisionOwner
*/
public User getCommisionOwner() { public User getCommisionOwner() {
return commisionOwner; return commisionOwner;
} }
/**
* Assigments getter
* @return List of assignments
*/
public List<Assignment> getAssignments() { public List<Assignment> getAssignments() {
return this.assignments; return this.assignments;
} }

View File

@ -10,6 +10,10 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.OneToMany; import javax.persistence.OneToMany;
/**
* Entity of Course grouping of state of course
*/
@Entity @Entity
public class Course { public class Course {
@Id @Id
@ -23,31 +27,61 @@ public class Course {
public Course() { public Course() {
} }
/**
* Course
*
* @param name name given to the course
* @param symbol symbol given to the course
*/
public Course(String name, String symbol) { public Course(String name, String symbol) {
this.name = name; this.name = name;
this.symbol = symbol; this.symbol = symbol;
} }
/**
* getId
* @return id
*/
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
/**
* getName
* @return name
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* getSymbol
* @return symbol
*/
public String getSymbol() { public String getSymbol() {
return symbol; return symbol;
} }
/**
* setSymbol
* @param symbol set symbol in the course
*/
public void setSymbol(String symbol) { public void setSymbol(String symbol) {
this.symbol = symbol; this.symbol = symbol;
} }
/**
* setName
* @param name set name in the course
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/**
* getGroups
* @return groups return list groups
*/
public List<Groups> getGroups() { public List<Groups> getGroups() {
return this.groups; return this.groups;
} }

View File

@ -10,7 +10,9 @@ 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 of Groups grouping of state ssociated about course,time,room,capacity,type,day
*/
@Entity @Entity
public class Groups { public class Groups {
@ -32,6 +34,16 @@ public class Groups {
public Groups() { public Groups() {
} }
/**
* Groups
*
* @param capacity capacity given to the groups
* @param room room given to the groups
* @param course course given to the groups
* @param time time given to the groups
* @param day day given to the groups
* @param lecturer lecturer given to the groups
*/
public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer) { public Groups(int capacity, String room, Course course, int time, WeekDay day, Lecturer lecturer) {
this.capacity = capacity; this.capacity = capacity;
this.room = room; this.room = room;
@ -42,66 +54,130 @@ public class Groups {
this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS; this.type = capacity >= 50 ? GroupType.LECTURE : GroupType.CLASS;
} }
/**
* getId
* @return id
*/
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
/**
* getLecturer
* @return lecturer
*/
public Lecturer getLecturer() { public Lecturer getLecturer() {
return lecturer; return lecturer;
} }
/**
* setLecturer
* @param lecturer set lecturer into groups
*/
public void setLecturer(Lecturer lecturer) { public void setLecturer(Lecturer lecturer) {
this.lecturer = lecturer; this.lecturer = lecturer;
} }
/**
* WeekDay
* @return day
*/
public WeekDay getDay() { public WeekDay getDay() {
return day; return day;
} }
/**
* setLecturer
* @param day set day into groups
*/
public void setDay(WeekDay day) { public void setDay(WeekDay day) {
this.day = day; this.day = day;
} }
/**
* GroupType
* @return type
*/
public GroupType getType() { public GroupType getType() {
return type; return type;
} }
/**
* setType
* @param type set type into groups
*/
public void setType(GroupType type) { public void setType(GroupType type) {
this.type = type; this.type = type;
} }
/**
* getCapacity
* @return capacity
*/
public int getCapacity() { public int getCapacity() {
return capacity; return capacity;
} }
/**
* setCapacity
* @param capacity set capacity into groups
*/
public void setCapacity(int capacity) { public void setCapacity(int capacity) {
this.capacity = capacity; this.capacity = capacity;
} }
/**
* getRoom
* @return room
*/
public String getRoom() { public String getRoom() {
return room; return room;
} }
/**
* setRoom
* @param room set room into groups
*/
public void setRoom(String room) { public void setRoom(String room) {
this.room = room; this.room = room;
} }
/**
* getTime
* @return time
*/
public int getTime() { public int getTime() {
return time; return time;
} }
/**
* setTime
* @param time set time into groups
*/
public void setTime(int time) { public void setTime(int time) {
this.time = time; this.time = time;
} }
/**
* getCourseId
* @return course
*/
public Course getCourseId() { public Course getCourseId() {
return course; return course;
} }
/**
* setCourseId
* @param courseId set courseId into groups
*/
public void setCourseId(Course courseId) { public void setCourseId(Course courseId) {
this.course = courseId; this.course = courseId;
} }
/**
* getTimeString
* @return time as formated String
*/
public String getTimeString() { public String getTimeString() {
int minutes = this.getTime() % 60; int minutes = this.getTime() % 60;
String hoursString = Integer.toString(this.getTime() / 60); String hoursString = Integer.toString(this.getTime() / 60);

View File

@ -5,6 +5,10 @@ import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType; import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
/**
* Entity of Lecturer grouping of state ssociated about id,title,name,surname
*/
@Entity @Entity
public class Lecturer { public class Lecturer {
@Id @Id
@ -14,30 +18,14 @@ public class Lecturer {
private String name; private String name;
private String surname; private String surname;
public String getTitle() {
return title;
}
public String getSurname() {
return surname;
}
public void setSurname(String surname) {
this.surname = surname;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setTitle(String title) {
this.title = title;
}
/**
* Lecturer
*
* @param title title given to the lecturer
* @param name name given to the lecturer
* @param surname surname given to the lecturer
*/
public Lecturer(String title, String name, String surname) { public Lecturer(String title, String name, String surname) {
this.title = title; this.title = title;
this.name = name; this.name = name;
@ -47,9 +35,63 @@ public class Lecturer {
public Lecturer() { public Lecturer() {
} }
/**
* getTitle
* @return title
*
*/
public String getTitle() {
return title;
}
/**
* getSurname
* @return surname
*
*/
public String getSurname() {
return surname;
}
/**
* setSurname
* @param surname set surname to the lecturer
*
*/
public void setSurname(String surname) {
this.surname = surname;
}
/**
* getName
* @return name
*
*/
public String getName() {
return name;
}
/**
* setName
* @param name set name to the lecturer
*
*/
public void setName(String name) {
this.name = name;
}
/**
* setTitle
* @param title set title to the lecturer
*
*/
public void setTitle(String title) {
this.title = title;
}
@Override @Override
public String toString() { public String toString() {
return String.format("%s %s %s", this.title, this.name, this.surname); return String.format("%s %s %s", this.title, this.name, this.surname);
} }
} }

View File

@ -10,6 +10,10 @@ import javax.persistence.Id;
import com.plannaplan.types.UserRoles; import com.plannaplan.types.UserRoles;
/**
* Entity of User grouping of state ssociated about id,name,surname,email,role,token,tokenCreatedDate
*/
@Entity @Entity
public class User { public class User {
private static final float TOKEN_EXPIRE_MINUTES = 15; private static final float TOKEN_EXPIRE_MINUTES = 15;
@ -27,6 +31,14 @@ public class User {
public User() { public User() {
} }
/*
* User
*
* @param name name given to the user
* @param surname surname given to the user
* @param email mail given to the user
* @param role role given to the user
*/
public User(String name, String surname, String mail, UserRoles role) { public User(String name, String surname, String mail, UserRoles role) {
this.name = name; this.name = name;
this.surname = surname; this.surname = surname;
@ -34,56 +46,113 @@ public class User {
this.role = role; this.role = role;
} }
/*
* getEmail
*
* @return email
*/
public String getEmail() { public String getEmail() {
return email; return email;
} }
/*
* setEmail
*
* @param email set email to the user
*/
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
/*
* getTokenUsageDate
*
* @return tokenUsageDate
*/
public Timestamp getTokenUsageDate() { public Timestamp getTokenUsageDate() {
return tokenUsageDate; return tokenUsageDate;
} }
/*
* getToken
*
* @return token
*/
public String getToken() { public String getToken() {
return token; return token;
} }
/*
* setToken
*
* @param token set token to the entity
*/
public void setToken(String token) { public void setToken(String token) {
this.tokenUsageDate = new Timestamp(System.currentTimeMillis()); this.tokenUsageDate = new Timestamp(System.currentTimeMillis());
this.token = token; this.token = token;
} }
/* getName
*
* @return name
*/
public String getName() { public String getName() {
return name; return name;
} }
/* getRole
*
* @return role
*/
public UserRoles getRole() { public UserRoles getRole() {
return role; return role;
} }
/* setRole
*
* @param role set role to the entity
*/
public void setRole(UserRoles role) { public void setRole(UserRoles role) {
this.role = role; this.role = role;
} }
/*
* getSurname
* @return surname
*/
public String getSurname() { public String getSurname() {
return surname; return surname;
} }
/*
* setSurname
* @param surname set surname into entity user
*/
public void setSurname(String surname) { public void setSurname(String surname) {
this.surname = surname; this.surname = surname;
} }
/*
* setName
* @param name set name into entity user
*/
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
/*
* getId
* @return id
*/
public Long getId() { public Long getId() {
return this.id; return this.id;
} }
public boolean isCredentialsNonExpired() { /*
* isCredentialsNonExpired
* Returns TRUE if is Credentials Non Expired in the otherwise it returns false
*/
public boolean isCredentialsNonExpired() {
final long diffInMilliseconds = Math final long diffInMilliseconds = Math
.abs(this.tokenUsageDate.getTime() - new Timestamp(System.currentTimeMillis()).getTime()); .abs(this.tokenUsageDate.getTime() - new Timestamp(System.currentTimeMillis()).getTime());
final long minutes = TimeUnit.MILLISECONDS.toMinutes(diffInMilliseconds); final long minutes = TimeUnit.MILLISECONDS.toMinutes(diffInMilliseconds);
@ -94,4 +163,4 @@ public class User {
this.tokenUsageDate = new Timestamp(System.currentTimeMillis()); this.tokenUsageDate = new Timestamp(System.currentTimeMillis());
return true; return true;
} }
} }

View File

@ -8,22 +8,44 @@ public class ConfigData {
private Date end; private Date end;
private InputStream filestream; private InputStream filestream;
/*
* ConfigData
*
* @param start when the configdata begins
* @param end when the configdata ends
* @param filestream where the filestream is
*/
public ConfigData(Date start, Date end, InputStream filestream) { public ConfigData(Date start, Date end, InputStream filestream) {
this.start = start; this.start = start;
this.end = end; this.end = end;
this.filestream = filestream; this.filestream = filestream;
} }
/*
* getFilestream
*
* @return filestream
*/
public InputStream getFilestream() { public InputStream getFilestream() {
return filestream; return filestream;
} }
/*
* getEnd
*
* @return end
*/
public Date getEnd() { public Date getEnd() {
return end; return end;
} }
/*
* getStart
*
* @return start
*/
public Date getStart() { public Date getStart() {
return start; return start;
} }
} }

View File

@ -9,30 +9,57 @@ public class FileData {
private HashMap<String, Integer> keys; private HashMap<String, Integer> keys;
private Iterator<Row> rows; private Iterator<Row> rows;
/*
* FileData
*
* @param keys this is a hashmap of String and Integer
* @param rows this is a iterator of rows.
*/
public FileData(HashMap<String, Integer> keys, Iterator<Row> rows) { public FileData(HashMap<String, Integer> keys, Iterator<Row> rows) {
this.keys = keys; this.keys = keys;
this.rows = rows; this.rows = rows;
} }
/*
* getRows
*
* @return rows
*/
public Iterator<Row> getRows() { public Iterator<Row> getRows() {
return rows; return rows;
} }
/*
* setRows
* @param rows set the rows to given function
*/
public void setRows(Iterator<Row> rows) { public void setRows(Iterator<Row> rows) {
this.rows = rows; this.rows = rows;
} }
/*
* getKeys
* @return keys
*/
public HashMap<String, Integer> getKeys() { public HashMap<String, Integer> getKeys() {
return keys; return keys;
} }
/*
* setKeys
* @param keys set the key is being a struck of hashmap (String, Integer)
*/
public void setKeys(HashMap<String, Integer> keys) { public void setKeys(HashMap<String, Integer> keys) {
this.keys = keys; this.keys = keys;
} }
/*
* getIndexOf
* @return index
*/
public int getIndexOf(String key) { public int getIndexOf(String key) {
int index = this.keys.get(key); int index = this.keys.get(key);
return index; return index;
} }
} }

View File

@ -9,6 +9,13 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* AssignmentRepository.getByCommision:
* Return list of:
* SELECT * FROM Assignment WHERE commision_id = i .
*
* Where i, ?1 are equale to variables.
*/
@Repository @Repository
public interface AssignmentRepository extends JpaRepository<Assignment, Long> { public interface AssignmentRepository extends JpaRepository<Assignment, Long> {

View File

@ -9,6 +9,19 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* CommisionRepository.getUsers:
* Return list of:
* SELECT * FROM Commision WHERE owner_id = i .
*
* Where i, ?1 are equale to variables.
*
* CommisionRepository.getNewestCommision
* Return list of:
* SELECT * FROM Commision WHERE owner_id = i Order by commisionDate desc.
*
* Where i, ?1 are equale to variables.
*/
@Repository @Repository
public interface CommisionRepository extends JpaRepository<Commision, Long> { public interface CommisionRepository extends JpaRepository<Commision, Long> {
@Query("FROM Commision WHERE owner_id = ?1") @Query("FROM Commision WHERE owner_id = ?1")

View File

@ -9,6 +9,13 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* CourseRepository.findByName:
* Return list of:
* SELECT * FROM Course WHERE name = i .
*
* Where i, ?1 are equale to variables.
*/
@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")

View File

@ -10,6 +10,19 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* GroupRepository.find:
* Return list of:
* SELECT * FROM Groups WHERE time = i AND room = j AND capacity = k .
*
* Where i, j, k, ?1, ?2, ?3 are equale to variables.
*
* GroupRepository.getByCourse:
* Return list of:
* SELECT * FROM Groups WHERE course_id = i .
*
* Where i, ?1 are equale to variables.
*/
@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")

View File

@ -9,6 +9,13 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* LecturerRepository.find:
* Return list of:
* SELECT * FROM Lecturer WHERE title = i AND name = j AND surname = k.
*
* Where i, j, k, ?1, ?2, ?3 are equale to variables.
*/
@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")

View File

@ -11,6 +11,32 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/**
* UserRepository.getByAuthority:
* Return list of:
* SELECT * FROM User WHERE email = i.
*
* Where i, ?1 are equale to variables.
*
* UserRepository.getByToken:
* Return list of:
* SELECT * FROM User WHERE token = i.
*
* Where i, ?1 are equale to variables.
*
* UserRepository.searchForUsers:
* Return list of:
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%).
*
* Where i, ?1 are equale to variables.
*
* UserRepository.searchForUsers with role:
* Return list of:
* SELECT * FROM User WHERE (name LIKE %?1% OR surname LIKE %?1%) AND role=?2").
*
* Where i, ?1 are equale to variables.
*/
@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")

View File

@ -10,6 +10,10 @@ 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 of Assignment which can save assignments, diplay assignments, get ammount of assigments.
*/
@Service @Service
public class AssignmentService { public class AssignmentService {
@Autowired @Autowired
@ -18,19 +22,37 @@ public class AssignmentService {
public AssignmentService() { public AssignmentService() {
} }
/**
* Save given assignment
* @param assignment assignment to save
* @return assignment saved assignment with database id
*/
public Assignment save(Assignment assignment) { public Assignment save(Assignment assignment) {
return this.repo.save(assignment); return this.repo.save(assignment);
} }
/*
* getCommisionAssignments
* Return id of the commision
*/
public List<Assignment> getCommisionAssignments(Commision com) { public List<Assignment> getCommisionAssignments(Commision com) {
return this.repo.getByCommision(com.getId()); return this.repo.getByCommision(com.getId());
} }
/*
* getAssignmentsAmmount
* Return count assignments ammount
*/
public long getAssignmentsAmmount() { public long getAssignmentsAmmount() {
return this.repo.count(); return this.repo.count();
} }
/**
* Get assigmnent by id
* @param id id of assigmnent
* @return Optional of assignment
*/
public Optional<Assignment> getById(Long id) { public Optional<Assignment> getById(Long id) {
return this.repo.findById(id); return this.repo.findById(id);
} }
} }

View File

@ -11,6 +11,10 @@ import com.plannaplan.repositories.CommisionRepository;
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 of CommisionService which can save commision, get user's commisions, get newest user's commision, get ammount of commisions.
*/
@Service @Service
public class CommisionService { public class CommisionService {
@Autowired @Autowired
@ -21,6 +25,12 @@ public class CommisionService {
public CommisionService() { public CommisionService() {
} }
/*
* save
*
* @param commision which assignment should be save in service
* @return commision
*/
public Commision save(Commision commision) { public Commision save(Commision commision) {
Optional<Commision> lastCommision = this.getNewestCommision(commision.getCommisionOwner()); Optional<Commision> lastCommision = this.getNewestCommision(commision.getCommisionOwner());
if (lastCommision.isPresent()) { if (lastCommision.isPresent()) {
@ -35,14 +45,26 @@ public class CommisionService {
} }
/*
* getUsersCommisions
* Return given users id
*/
public List<Commision> getUsersCommisions(User user) { public List<Commision> getUsersCommisions(User user) {
return this.repo.getUsers(user.getId()); return this.repo.getUsers(user.getId());
} }
/*
* getNewestCommision
* Return the newest commision of the user
*/
public Optional<Commision> getNewestCommision(User user) { public Optional<Commision> getNewestCommision(User user) {
return this.repo.getNewestCommision(user.getId()).stream().findFirst(); return this.repo.getNewestCommision(user.getId()).stream().findFirst();
} }
/*
* getCommisionsAmmount
* Return ammount of commisions
*/
public long getCommisionsAmmount() { public long getCommisionsAmmount() {
return this.repo.count(); return this.repo.count();
} }

View File

@ -8,6 +8,9 @@ import org.springframework.stereotype.Component;
import com.plannaplan.configutils.*; import com.plannaplan.configutils.*;
/**
* FileReader is used for reading xls file from input stream.
*/
@Component @Component
public class ConfiguratorService { public class ConfiguratorService {

View File

@ -9,29 +9,53 @@ import com.plannaplan.repositories.CourseRepository;
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 of CourseService which can get(Course By Name, All Courses, Courses Ammount ), save, delete course.
*/
@Service @Service
public class CourseService { public class CourseService {
@Autowired @Autowired
private CourseRepository repo; private CourseRepository repo;
/*
* getCourseByName
* Return Course By Name
*/
public Optional<Course> getCourseByName(String name) { public Optional<Course> getCourseByName(String name) {
return this.repo.findByName(name); return this.repo.findByName(name);
} }
/*
* getAllCourses
* Return List of get courses
*/
public List<Course> getAllCourses() { public List<Course> getAllCourses() {
return this.repo.findAll(); return this.repo.findAll();
} }
/*
* save
* @param course which course you would like to save
*/
public Course save(Course course) { public Course save(Course course) {
this.repo.save(course); this.repo.save(course);
return course; return course;
} }
/*
* delete
* @param course which course you would like to delete
*/
public void delete(Course course) { public void delete(Course course) {
this.repo.delete(course); this.repo.delete(course);
} }
/*
* getCoursesAmmount
* Return a ammount of courses
*/
public int getCoursesAmmount() { public int getCoursesAmmount() {
return (int) this.repo.count(); return (int) this.repo.count();
} }
} }

View File

@ -13,6 +13,10 @@ import com.plannaplan.repositories.GroupRepository;
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 of GroupService which can find(optional), get(By Course, Groups Ammount, Group By Id, find Not Existing Group), save, delete group.
*/
@Service @Service
public class GroupService { public class GroupService {
@Autowired @Autowired

View File

@ -8,6 +8,9 @@ import com.plannaplan.repositories.LecturerRepository;
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 of LecturerService which can get(Lecturer, Lecturers Ammount), save, delete lecturers.
*/
@Service @Service
public class LecturerService { public class LecturerService {
@Autowired @Autowired

View File

@ -12,6 +12,9 @@ import com.plannaplan.types.UserRoles;
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 of UserService which can get(By Email), login, save user.
*/
@Service @Service
public class UserService { public class UserService {
@Autowired @Autowired

View File

@ -1,5 +1,9 @@
package com.plannaplan.types; package com.plannaplan.types;
/**
* GroupType contains types: LECTURE, CLASS
*/
public enum GroupType { public enum GroupType {
LECTURE, CLASS LECTURE, CLASS
} }

View File

@ -1,5 +1,9 @@
package com.plannaplan.types; package com.plannaplan.types;
/**
* UserRoles contains types: STUDENT, DEANERY, ADMIN, TEST_USER
*/
public enum UserRoles { public enum UserRoles {
STUDENT, DEANERY, ADMIN, TEST_USER STUDENT, DEANERY, ADMIN, TEST_USER
} }

View File

@ -1,5 +1,9 @@
package com.plannaplan.types; package com.plannaplan.types;
/**
* WeekDay contains types: MONDAY(0), TUESDAY(1), WEDNESDAY(2), THURSDAY(3), FRIDAY(4), SATURDAY(5), SUNDAY(6).
*/
public enum WeekDay { public enum WeekDay {
MONDAY(0), TUESDAY(1), WEDNESDAY(2), THURSDAY(3), FRIDAY(4), SATURDAY(5), SUNDAY(6); MONDAY(0), TUESDAY(1), WEDNESDAY(2), THURSDAY(3), FRIDAY(4), SATURDAY(5), SUNDAY(6);