responses done

This commit is contained in:
Filip Izydorczyk 2021-01-15 17:53:13 +01:00
parent f77213a01e
commit e600e84ae2
6 changed files with 90 additions and 2 deletions

View File

@ -11,12 +11,25 @@ import com.plannaplan.entities.Groups;
import com.plannaplan.responses.models.AssignmentResponse;
import com.plannaplan.types.GroupType;
/**
* Mappers for Assingnmetns to api responses
*/
public class AssignmentResponseMappers {
/**
* @param assignments lsit of assignments to be maped
* @return list of api responses
*/
public static final List<AssignmentResponse> mapToResponse(List<Assignment> assignments) {
return mapToResponse(assignments, null);
}
/**
*
* @param assignments lsit of assignments to be maped
* @param ammounts ammounts to be take into account
* @return list of api responses
*/
public static final List<AssignmentResponse> mapToResponse(List<Assignment> assignments,
HashMap<Long, Integer> ammounts) {
List<AssignmentResponse> response = new ArrayList<>();

View File

@ -8,11 +8,22 @@ import com.plannaplan.entities.Commision;
import com.plannaplan.responses.models.CommisionResponse;
import com.plannaplan.responses.models.CommisionWithGroupsResponse;
/**
* Mappers for Commisions to api responses
*/
public class CommisionResponseMappers {
/**
* @param commisions list of commisions to be mapped
* @return list of api responses
*/
public static final List<CommisionResponse> mapToResponse(List<Commision> commisions) {
return commisions.stream().filter(Objects::nonNull).map(CommisionResponse::new).collect(Collectors.toList());
}
/**
* @param commisions list of commisions to be mapped
* @return list of api responses
*/
public static final List<CommisionWithGroupsResponse> mapToResponseWithGroups(List<Commision> commisions) {
return commisions.stream().filter(Objects::nonNull).map(CommisionWithGroupsResponse::new)
.collect(Collectors.toList());

View File

@ -8,11 +8,22 @@ import com.plannaplan.entities.Course;
import com.plannaplan.responses.models.CoursesDefaultResponse;
import com.plannaplan.responses.models.CoursesWithGroupsResponse;
/**
* Mappers for Courses to api responses
*/
public class CoursesResponseMappers {
/**
* @param courses list of courses to be mapped
* @return list of api responses
*/
public static final List<CoursesDefaultResponse> mapToGetCoursesResponse(List<Course> courses) {
return courses.stream().filter(Objects::nonNull).map(CoursesDefaultResponse::new).collect(Collectors.toList());
}
/**
* @param courses list of courses to be mapped
* @return list of api responses
*/
public static final List<CoursesWithGroupsResponse> mapToGetCoursesWithGroupsResponse(List<Course> courses) {
return courses.stream().filter(Objects::nonNull).map(CoursesWithGroupsResponse::new)
.collect(Collectors.toList());

View File

@ -7,7 +7,14 @@ import java.util.stream.Collectors;
import com.plannaplan.entities.Exchange;
import com.plannaplan.responses.models.ExchangeResponse;
/**
* Mappers for Exchange to api responses
*/
public class ExchangeResponseMappers {
/**
* @param exchanges lsit of exchanges to be mapped
* @return list of api responses
*/
public static final List<ExchangeResponse> mapToDefaultResponse(List<Exchange> exchanges) {
return exchanges.stream().filter(Objects::nonNull).map(ExchangeResponse::new).collect(Collectors.toList());
}

View File

@ -13,7 +13,15 @@ import com.plannaplan.responses.models.CourseWithGroupsResponse;
import com.plannaplan.responses.models.GroupWithCapacityResponse;
import com.plannaplan.types.GroupType;
/**
* Mappers for Groups to api responses
*/
public class GroupsMappers {
/**
* @param groups list of groups to be mapped
* @param taken ammoints to be take into account
* @return list of api responses
*/
public static List<GroupDefaultResponse> mapToDefaultResponse(List<Groups> groups, HashMap<Long, Integer> taken) {
return groups.stream().filter(Objects::nonNull).map(new Function<Groups, GroupDefaultResponse>() {
@Override
@ -27,10 +35,20 @@ public class GroupsMappers {
}).collect(Collectors.toList());
}
/**
*
* @param groups list of groups to be mapped
* @return ammoints to be take into account
*/
public static List<GroupDefaultResponse> mapToDefaultResponse(List<Groups> groups) {
return GroupsMappers.mapToDefaultResponse(groups, null);
}
/**
* @param groups list of groups to be mapped
* @param taken ammoints to be take into account
* @return list of api responses
*/
public static List<GroupWithCapacityResponse> mapToCapacityResponse(List<Groups> groups,
HashMap<Long, Integer> taken) {
return groups.stream().filter(Objects::nonNull).map(new Function<Groups, GroupWithCapacityResponse>() {
@ -45,10 +63,19 @@ public class GroupsMappers {
}).collect(Collectors.toList());
}
/**
* @param groups list of groups to be mapped
* @return ammoints to be take into account
*/
public static List<GroupWithCapacityResponse> mapToCapacityResponse(List<Groups> groups) {
return GroupsMappers.mapToCapacityResponse(groups, null);
}
/**
* @param groups list of groups to be mapped
* @param taken ammoints to be take into account
* @return list of api responses
*/
public static CourseWithGroupsResponse<GroupDefaultResponse> mapToGetCourseGroupsDefaultResponse(
List<Groups> groups, HashMap<Long, Integer> taken) {
@ -74,11 +101,20 @@ public class GroupsMappers {
return new CourseWithGroupsResponse<>(classes, lectures);
}
/**
* @param groups list of groups to be mapped
* @return ammoints to be take into account
*/
public static CourseWithGroupsResponse<GroupDefaultResponse> mapToGetCourseGroupsDefaultResponse(
List<Groups> groups) {
return GroupsMappers.mapToGetCourseGroupsDefaultResponse(groups, null);
}
/**
* @param groups list of groups to be mapped
* @param taken ammoints to be take into account
* @return list of api responses
*/
public static CourseWithGroupsResponse<GroupWithCapacityResponse> mapToGetCourseGroupsWithCapacityResponse(
List<Groups> groups, HashMap<Long, Integer> taken) {
@ -105,6 +141,10 @@ public class GroupsMappers {
return new CourseWithGroupsResponse<>(classes, lectures);
}
/**
* @param groups list of groups to be mapped
* @return ammoints to be take into account
*/
public static CourseWithGroupsResponse<GroupWithCapacityResponse> mapToGetCourseGroupsWithCapacityResponse(
List<Groups> groups) {
return GroupsMappers.mapToGetCourseGroupsWithCapacityResponse(groups, null);

View File

@ -7,9 +7,15 @@ import java.util.stream.Collectors;
import com.plannaplan.entities.User;
import com.plannaplan.responses.models.UserResponse;
/**
* Mappers for Users to api responses
*/
public class UserResponseMappers {
/**
* @param groups list of groups to be mapped
* @return list of api responses
*/
public static List<UserResponse> mapToDefaultResponse(List<User> groups) {
return groups.stream().filter(Objects::nonNull).map(UserResponse::new)
.collect(Collectors.toList());
return groups.stream().filter(Objects::nonNull).map(UserResponse::new).collect(Collectors.toList());
}
}