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