fix type cast
This commit is contained in:
parent
f1229b6019
commit
93cf1fa2a8
@ -64,7 +64,7 @@ public abstract class ActivityService<L extends ActivityListDto, T extends Abstr
|
||||
|
||||
@Transactional
|
||||
public T create(T entity) {
|
||||
eventService.createFromObject((EventSource) eventService);
|
||||
eventService.createFromObject((EventSource) entity);
|
||||
T newEntity = activityRepository.save(entity);
|
||||
activityNotificationService.sendCreateNotification(newEntity);
|
||||
return newEntity;
|
||||
|
@ -6,8 +6,6 @@ import ru.ulstu.activity.api.model.ActivityDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
import ru.ulstu.activity.deadline.model.DeadlineDto;
|
||||
import ru.ulstu.activity.file.model.FileDataDto;
|
||||
import ru.ulstu.activity.paper.model.PaperDto;
|
||||
import ru.ulstu.activity.project.model.ProjectDto;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.ArrayList;
|
||||
@ -25,7 +23,6 @@ public class GrantDto extends ActivityDto {
|
||||
private String comment;
|
||||
private List<FileDataDto> files = new ArrayList<>();
|
||||
private List<Integer> projectIds;
|
||||
private Set<Integer> authorIds;
|
||||
private Set<ScienceGroupMemberDto> members;
|
||||
private Integer leaderId;
|
||||
private List<Integer> paperIds = new ArrayList<>();
|
||||
@ -37,22 +34,15 @@ public class GrantDto extends ActivityDto {
|
||||
@JsonProperty("deadlines") List<DeadlineDto> deadlines,
|
||||
@JsonProperty("comment") String comment,
|
||||
@JsonProperty("files") List<FileDataDto> files,
|
||||
@JsonProperty("project") ProjectDto project,
|
||||
@JsonProperty("authorIds") Set<Integer> authorIds,
|
||||
@JsonProperty("members") Set<ScienceGroupMemberDto> members,
|
||||
@JsonProperty("leaderId") Integer leaderId,
|
||||
@JsonProperty("wasLeader") boolean wasLeader,
|
||||
@JsonProperty("hasAge") boolean hasAge,
|
||||
@JsonProperty("hasDegree") boolean hasDegree,
|
||||
@JsonProperty("paperIds") List<Integer> paperIds,
|
||||
@JsonProperty("papers") List<PaperDto> papers) {
|
||||
@JsonProperty("paperIds") List<Integer> paperIds) {
|
||||
super(id);
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
this.deadlines = deadlines;
|
||||
this.comment = comment;
|
||||
this.files = files;
|
||||
this.authorIds = authorIds;
|
||||
this.members = members;
|
||||
this.leaderId = leaderId;
|
||||
this.paperIds = paperIds;
|
||||
@ -69,7 +59,6 @@ public class GrantDto extends ActivityDto {
|
||||
this.deadlines = convert(grant.getDeadlines(), DeadlineDto::new);
|
||||
this.comment = grant.getComment();
|
||||
this.files = convert(grant.getFiles(), FileDataDto::new);
|
||||
this.authorIds = convert(grant.getAuthors(), user -> user.getId());
|
||||
this.members = convert(grant.getAuthors(), ScienceGroupMemberDto::new);
|
||||
this.leaderId = grant.getLeader().getId();
|
||||
this.paperIds = convert(grant.getPapers(), paper -> paper.getId());
|
||||
@ -126,14 +115,6 @@ public class GrantDto extends ActivityDto {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public Set<Integer> getAuthorIds() {
|
||||
return authorIds;
|
||||
}
|
||||
|
||||
public void setAuthorIds(Set<Integer> authorIds) {
|
||||
this.authorIds = authorIds;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
@ -116,8 +116,8 @@ public class GrantService extends ActivityService<GrantListDto, Grant, GrantDto>
|
||||
.collect(toList())));
|
||||
}
|
||||
grant.getAuthors().clear();
|
||||
if (grantDto.getAuthorIds() != null && !grantDto.getAuthorIds().isEmpty()) {
|
||||
grantDto.getAuthorIds().forEach(authorIds -> grant.getAuthors().add(userService.findById(authorIds)));
|
||||
if (grantDto.getMembers() != null && !grantDto.getMembers().isEmpty()) {
|
||||
grantDto.getMembers().forEach(memberDto -> grant.getAuthors().add(userService.findById(memberDto.getId())));
|
||||
}
|
||||
if (grantDto.getLeaderId() != null) {
|
||||
grant.setLeader(userService.findById(grantDto.getLeaderId()));
|
||||
|
Loading…
Reference in New Issue
Block a user