Resrservice docs 1st part
This commit is contained in:
@ -8,6 +8,9 @@ import com.plannaplan.types.GroupType;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Assignment entity api response
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about given assigment to course.", value = "AssignmentResponse")
|
||||
public class AssignmentResponse {
|
||||
private Long id;
|
||||
@ -15,6 +18,11 @@ public class AssignmentResponse {
|
||||
private GroupWithCapacityResponse classes;
|
||||
private GroupWithCapacityResponse lecture;
|
||||
|
||||
/**
|
||||
* @param course course entity
|
||||
* @param lecture lecture Groups entity
|
||||
* @param classes class Groups entity
|
||||
*/
|
||||
public AssignmentResponse(Course course, Groups lecture, Groups classes) {
|
||||
this.id = course.getId();
|
||||
this.name = course.getName();
|
||||
@ -22,6 +30,13 @@ public class AssignmentResponse {
|
||||
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param course course entity
|
||||
* @param lecture lecture Groups entity
|
||||
* @param classes class Groups entity
|
||||
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
||||
* places
|
||||
*/
|
||||
public AssignmentResponse(Course course, Groups lecture, Groups classes, HashMap<Long, Integer> ammounts) {
|
||||
this.id = course.getId();
|
||||
this.name = course.getName();
|
||||
@ -29,28 +44,51 @@ public class AssignmentResponse {
|
||||
this.classes = classes == null ? null : new GroupWithCapacityResponse(classes, ammounts.get(classes.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param course course entity
|
||||
* @param group class/lecture entity
|
||||
*/
|
||||
public AssignmentResponse(Course course, Groups group) {
|
||||
this(course, group.getType() == GroupType.LECTURE ? group : null,
|
||||
group.getType() == GroupType.CLASS ? group : null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param course course entity
|
||||
* @param group class/lecture entity
|
||||
* @param ammounts map with ammounts key - group id, value - ammounts of taken
|
||||
* places
|
||||
*/
|
||||
public AssignmentResponse(Course course, Groups group, HashMap<Long, Integer> ammounts) {
|
||||
this(course, group.getType() == GroupType.LECTURE ? group : null,
|
||||
group.getType() == GroupType.CLASS ? group : null, ammounts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Lecture in api response forms
|
||||
*/
|
||||
public GroupWithCapacityResponse getLecture() {
|
||||
return this.lecture;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Class in api response forms
|
||||
*/
|
||||
public GroupWithCapacityResponse getClasses() {
|
||||
return this.classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return String course name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db assignment id
|
||||
*/
|
||||
public Long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import com.plannaplan.entities.Commision;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Commision api response
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about commision.", value = "CommisionResponse")
|
||||
public class CommisionResponse {
|
||||
@ApiModelProperty(value = "ID created by database")
|
||||
@ -19,6 +22,9 @@ public class CommisionResponse {
|
||||
@ApiModelProperty(value = "Timestamp where the user commit the commision")
|
||||
private String commisionDate;
|
||||
|
||||
/**
|
||||
* @param commision commision to map to api response
|
||||
*/
|
||||
public CommisionResponse(Commision commision) {
|
||||
this.id = commision.getId();
|
||||
this.commisionDate = commision.getCommisionDate().toString();
|
||||
@ -27,18 +33,30 @@ public class CommisionResponse {
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get Commiter user as api response
|
||||
*/
|
||||
public UserResponse getCommiter() {
|
||||
return commiter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get Owner user as api response
|
||||
*/
|
||||
public UserResponse getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return when commision was created string formated
|
||||
*/
|
||||
public String getCommisionDate() {
|
||||
return commisionDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -11,12 +11,18 @@ import com.plannaplan.entities.Commision;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Commision With Groups api Response. It extends CommisionResponse repsone
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about commision and its groups.", value = "CommisionWithGroupsResponse")
|
||||
public class CommisionWithGroupsResponse extends CommisionResponse {
|
||||
|
||||
@ApiModelProperty(value = "List of groups ids in databse that belongs to commision")
|
||||
private List<Long> groups;
|
||||
|
||||
/**
|
||||
* @param commision commision to map to api response
|
||||
*/
|
||||
public CommisionWithGroupsResponse(Commision commision) {
|
||||
super(commision);
|
||||
this.groups = commision.getAssignments().stream().filter(Objects::nonNull)
|
||||
@ -29,6 +35,9 @@ public class CommisionWithGroupsResponse extends CommisionResponse {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return lsit of fetured groups ids
|
||||
*/
|
||||
public List<Long> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
|
@ -5,21 +5,36 @@ import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Course respose with all realted groups as api response. Alse needs to specify
|
||||
* what type of Groups api response will be kept here. For excmaple it can be
|
||||
* <b> GroupDefaultRespnse </b>
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about groups to given course.", value = "CourseWithGroupsResponse")
|
||||
public class CourseWithGroupsResponse <T> {
|
||||
public class CourseWithGroupsResponse<T> {
|
||||
|
||||
private List<T> lectures = new ArrayList<>();
|
||||
private List<T> classes = new ArrayList<>();
|
||||
|
||||
public CourseWithGroupsResponse(List<T> classes, List<T> lectures ){
|
||||
/**
|
||||
* @param classes realted classes Groups instance
|
||||
* @param lectures realted lectures Groups instance
|
||||
*/
|
||||
public CourseWithGroupsResponse(List<T> classes, List<T> lectures) {
|
||||
this.lectures = lectures;
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return realted classes Groups instance
|
||||
*/
|
||||
public List<T> getClasses() {
|
||||
return this.classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return realted lectures Groups instance
|
||||
*/
|
||||
public List<T> getLectures() {
|
||||
return this.lectures;
|
||||
}
|
||||
|
@ -5,9 +5,21 @@ import com.plannaplan.responses.models.abstracts.CoursesResponse;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Courses Default Api Response. It extends abstract response - CoursesResponse.
|
||||
* It was one of first repsones created in system. Later we resigned from
|
||||
* asbstract and used settig
|
||||
* <code>spring.jackson.default-property-inclusion = NON_NULL</code> in
|
||||
* properties instead.
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about course.", value = "CoursesDefaultResponse")
|
||||
public class CoursesDefaultResponse extends CoursesResponse {
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param course course to map to api response
|
||||
*/
|
||||
public CoursesDefaultResponse(Course course) {
|
||||
super(course);
|
||||
}
|
||||
|
@ -9,12 +9,24 @@ import com.plannaplan.types.GroupType;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Courses With Groups Api Response . It extends abstract response -
|
||||
* CoursesResponse. It was one of first repsones created in system. Later we
|
||||
* resigned from asbstract and used settig
|
||||
* <code>spring.jackson.default-property-inclusion = NON_NULL</code> in
|
||||
* properties instead.
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about groups to given course.", value = "CoursesWithGroupsResponse")
|
||||
public class CoursesWithGroupsResponse extends CoursesResponse {
|
||||
|
||||
private List<GroupWithCapacityResponse> lectures = new ArrayList<>();
|
||||
private List<GroupWithCapacityResponse> classes = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param course course to map to api response
|
||||
*/
|
||||
public CoursesWithGroupsResponse(Course course) {
|
||||
super(course);
|
||||
course.getGroups().stream().forEach(group -> {
|
||||
@ -26,6 +38,12 @@ public class CoursesWithGroupsResponse extends CoursesResponse {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param course course to map to api response
|
||||
* @param lectures list of api resposnes of lectures
|
||||
* @param classes list of api resposnes of classes
|
||||
*/
|
||||
public CoursesWithGroupsResponse(Course course, List<GroupWithCapacityResponse> lectures,
|
||||
List<GroupWithCapacityResponse> classes) {
|
||||
super(course);
|
||||
@ -33,10 +51,16 @@ public class CoursesWithGroupsResponse extends CoursesResponse {
|
||||
this.classes = classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of api resposnes of classes
|
||||
*/
|
||||
public List<GroupWithCapacityResponse> getClasses() {
|
||||
return this.classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list of api resposnes of lectures
|
||||
*/
|
||||
public List<GroupWithCapacityResponse> getLectures() {
|
||||
return this.lectures;
|
||||
}
|
||||
|
@ -2,35 +2,72 @@ package com.plannaplan.responses.models;
|
||||
|
||||
import com.plannaplan.entities.Exchange;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Exchange proposal api repsonse
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about user exchanges", value = "CourseWithGroupsResponse")
|
||||
public class ExchangeResponse {
|
||||
private Long id;
|
||||
private GroupDefaultResponse ownedAssignment;
|
||||
private GroupDefaultResponse desiredGroup;
|
||||
@ApiModelProperty(value = "Database id")
|
||||
private Long id;
|
||||
@ApiModelProperty(value = "Assignmetn that user want to trade")
|
||||
private GroupDefaultResponse ownedAssignment;
|
||||
@ApiModelProperty(value = "Group that user want to get")
|
||||
private GroupDefaultResponse desiredGroup;
|
||||
|
||||
public ExchangeResponse(Exchange exchange){
|
||||
this.id = exchange.getId();
|
||||
this.ownedAssignment = new GroupDefaultResponse(exchange.getOwnedAssignment().getGroup());
|
||||
this.desiredGroup = new GroupDefaultResponse(exchange.getDesiredAssignment());
|
||||
}
|
||||
/**
|
||||
* creat new instance
|
||||
*
|
||||
* @param exchange entity to map to api repsone
|
||||
*/
|
||||
public ExchangeResponse(Exchange exchange) {
|
||||
this.id = exchange.getId();
|
||||
this.ownedAssignment = new GroupDefaultResponse(exchange.getOwnedAssignment().getGroup());
|
||||
this.desiredGroup = new GroupDefaultResponse(exchange.getDesiredAssignment());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get api respondse of wanted byt user group
|
||||
*/
|
||||
public GroupDefaultResponse getDesiredGroup() {
|
||||
return desiredGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param desiredGroup set api respondse of wanted byt user group
|
||||
*/
|
||||
public void setDesiredGroup(GroupDefaultResponse desiredGroup) {
|
||||
this.desiredGroup = desiredGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return get api respondse of owned user group
|
||||
*/
|
||||
public GroupDefaultResponse getOwnedAssignment() {
|
||||
return ownedAssignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ownedAssignment set api respondse of owned user group
|
||||
*/
|
||||
public void setOwnedAssignment(GroupDefaultResponse ownedAssignment) {
|
||||
this.ownedAssignment = ownedAssignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return database id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id set database id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -8,6 +8,9 @@ import com.plannaplan.types.GroupType;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Default api response for Groups entity
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@ApiModel(description = "Response shows information about given group.", value = "GroupDefaultResponse")
|
||||
public class GroupDefaultResponse {
|
||||
@ -36,6 +39,11 @@ public class GroupDefaultResponse {
|
||||
@ApiModelProperty(value = "Value shows how many places is already taken by other students.")
|
||||
private Integer takenPlaces;
|
||||
|
||||
/**
|
||||
* creat new entity
|
||||
*
|
||||
* @param group entity to map to api response
|
||||
*/
|
||||
public GroupDefaultResponse(Groups group) {
|
||||
this.id = group.getId() != null ? group.getId() : null;
|
||||
this.day = group.getDay() != null ? group.getDay().label : -1;
|
||||
@ -46,43 +54,77 @@ public class GroupDefaultResponse {
|
||||
this.type = group.getType() != null ? group.getType() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param group entity to map to api response
|
||||
* @param takenPlaces ammount of taken places for group by other users
|
||||
*/
|
||||
public GroupDefaultResponse(Groups group, int takenPlaces) {
|
||||
this(group);
|
||||
this.takenPlaces = takenPlaces;
|
||||
}
|
||||
|
||||
/**
|
||||
* creat new entity
|
||||
*
|
||||
* @param assignment entity to map to api response
|
||||
*/
|
||||
public GroupDefaultResponse(Assignment assignment) {
|
||||
this(assignment.getGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return what typew of group is this (lecture or class)
|
||||
*/
|
||||
public GroupType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return room where classes will take place
|
||||
*/
|
||||
public String getRoom() {
|
||||
return room;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return name of group lecturer
|
||||
*/
|
||||
public String getLecturer() {
|
||||
return lecturer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time when group is scheduled on
|
||||
*/
|
||||
public String getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time when class ends
|
||||
*/
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int what day is it. 0-6 (Monday - Sunday)
|
||||
*/
|
||||
public int getDay() {
|
||||
return day;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ammount of taken places for group by other users
|
||||
*/
|
||||
public Integer getTakenPlaces() {
|
||||
return this.takenPlaces;
|
||||
}
|
||||
|
@ -4,29 +4,57 @@ import com.plannaplan.entities.Assignment;
|
||||
import com.plannaplan.entities.Groups;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Group api response featuring group capacity
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about group with included capacity.", value = "GroupWithCapacityResponse")
|
||||
public class GroupWithCapacityResponse extends GroupDefaultResponse {
|
||||
|
||||
private int capacity;
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param group entity to map to api response
|
||||
*/
|
||||
public GroupWithCapacityResponse(Groups group) {
|
||||
super(group);
|
||||
this.capacity = group.getCapacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param group entity to map to api response
|
||||
* @param takenPlaces group taken places
|
||||
*/
|
||||
public GroupWithCapacityResponse(Groups group, int takenPlaces) {
|
||||
super(group, takenPlaces);
|
||||
this.capacity = group.getCapacity();
|
||||
}
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param assignment entity to map to api response
|
||||
*/
|
||||
public GroupWithCapacityResponse(Assignment assignment) {
|
||||
this(assignment.getGroup());
|
||||
}
|
||||
|
||||
/**
|
||||
* create new instance
|
||||
*
|
||||
* @param assignment entity to map to api response
|
||||
* @param takenPlaces group taken places
|
||||
*/
|
||||
public GroupWithCapacityResponse(Assignment assignment, int takenPlaces) {
|
||||
this(assignment.getGroup(), takenPlaces);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return group taken places
|
||||
*/
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import com.plannaplan.entities.User;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* Response to show after successfully login cation
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about logged user.", value = "TokenResponse")
|
||||
public class TokenResponse {
|
||||
@ApiModelProperty(value = "user token used to verify requests")
|
||||
@ -18,6 +21,9 @@ public class TokenResponse {
|
||||
@ApiModelProperty(value = "user unviersity email")
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* @param user user to be mapped to api response
|
||||
*/
|
||||
public TokenResponse(User user) {
|
||||
this.id = user.getId();
|
||||
this.authorityRole = user.getRole().toString();
|
||||
@ -26,22 +32,37 @@ public class TokenResponse {
|
||||
this.refreshToken = user.getRefreshToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user role in system
|
||||
*/
|
||||
public String getAuthorityRole() {
|
||||
return authorityRole;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user token to authorize other requests
|
||||
*/
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user refresh token
|
||||
*/
|
||||
public String getRefreshToken() {
|
||||
return this.refreshToken;
|
||||
}
|
||||
|
@ -4,6 +4,9 @@ import com.plannaplan.entities.User;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
/**
|
||||
* Model for api response for user serach results.
|
||||
*/
|
||||
@ApiModel(description = "Response shows information about user.", value = "UserResponse")
|
||||
public class UserResponse {
|
||||
|
||||
@ -12,6 +15,9 @@ public class UserResponse {
|
||||
private String surname;
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* @param user entity to be mapped to api response
|
||||
*/
|
||||
public UserResponse(User user) {
|
||||
this.id = user.getId();
|
||||
this.name = user.getName() != null ? user.getName() : "";
|
||||
@ -19,18 +25,30 @@ public class UserResponse {
|
||||
this.email = user.getEmail();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user email
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user surname
|
||||
*/
|
||||
public String getSurname() {
|
||||
return surname;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return user name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
@ -2,20 +2,34 @@ package com.plannaplan.responses.models.abstracts;
|
||||
|
||||
import com.plannaplan.entities.Course;
|
||||
|
||||
/**
|
||||
* Course entity api response
|
||||
*/
|
||||
public abstract class CoursesResponse {
|
||||
|
||||
private Long id;
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* create instance
|
||||
*
|
||||
* @param course entity to map to api response
|
||||
*/
|
||||
public CoursesResponse(Course course) {
|
||||
this.id = course.getId() != null ? course.getId() : null;
|
||||
this.name = course.getName() != null ? course.getName() : "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return course name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return db id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
Reference in New Issue
Block a user