some refactor
This commit is contained in:
parent
2b911017b1
commit
336a16ff73
@ -43,7 +43,7 @@ public class GrantController {
|
||||
|
||||
@GetMapping("/dashboard")
|
||||
public void getDashboard(ModelMap modelMap) {
|
||||
modelMap.put("grants", grantService.findAllDto());
|
||||
modelMap.put("grants", grantService.findAllActiveDto());
|
||||
}
|
||||
|
||||
@GetMapping("/grant")
|
||||
|
@ -43,7 +43,8 @@ public class Grant extends BaseEntity implements UserContainer {
|
||||
IN_WORK("В работе"),
|
||||
COMPLETED("Завершен"),
|
||||
FAILED("Провалены сроки"),
|
||||
LOADED_FROM_KIAS("Загружен автоматически");
|
||||
LOADED_FROM_KIAS("Загружен автоматически"),
|
||||
SKIPPED("Не интересует");
|
||||
|
||||
private String statusName;
|
||||
|
||||
@ -62,14 +63,14 @@ public class Grant extends BaseEntity implements UserContainer {
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private GrantStatus status = GrantStatus.APPLICATION;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL)
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@JoinColumn(name = "grant_id")
|
||||
@OrderBy("date")
|
||||
private List<Deadline> deadlines = new ArrayList<>();
|
||||
|
||||
private String comment;
|
||||
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
|
||||
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
|
||||
@JoinColumn(name = "grant_id", unique = true)
|
||||
@Fetch(FetchMode.SUBSELECT)
|
||||
private List<FileData> files = new ArrayList<>();
|
||||
|
@ -17,4 +17,7 @@ public interface GrantRepository extends JpaRepository<Grant, Integer>, BaseRepo
|
||||
@Override
|
||||
@Query("SELECT title FROM Grant g WHERE (g.title = :name) AND (:id IS NULL OR g.id != :id) ")
|
||||
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||
|
||||
@Query("SELECT g FROM Grant g WHERE (g.status <> 'SKIPPED') AND (g.status <> 'COMPLETED')")
|
||||
List<Grant> findAllActive();
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class GrantScheduler {
|
||||
log.debug("GrantScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
@Scheduled(cron = "0 0 8 1 * ?", zone = "Europe/Samara")
|
||||
@Scheduled(cron = "0 0 8 * * ?", zone = "Europe/Samara")
|
||||
public void loadGrantsFromKias() {
|
||||
log.debug("GrantScheduler.loadGrantsFromKias started");
|
||||
try {
|
||||
|
@ -41,7 +41,6 @@ import static ru.ulstu.grant.model.Grant.GrantStatus.APPLICATION;
|
||||
|
||||
@Service
|
||||
public class GrantService extends BaseService {
|
||||
private final static int MAX_DISPLAY_SIZE = 50;
|
||||
private final Logger log = LoggerFactory.getLogger(GrantService.class);
|
||||
|
||||
private final GrantRepository grantRepository;
|
||||
@ -80,9 +79,7 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
|
||||
public List<GrantDto> findAllDto() {
|
||||
List<GrantDto> grants = convert(findAll(), GrantDto::new);
|
||||
grants.forEach(grantDto -> grantDto.setTitle(StringUtils.abbreviate(grantDto.getTitle(), MAX_DISPLAY_SIZE)));
|
||||
return grants;
|
||||
return convert(findAll(), GrantDto::new);
|
||||
}
|
||||
|
||||
public GrantDto findOneDto(Integer id) {
|
||||
@ -273,11 +270,7 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
|
||||
public List<PaperDto> getAllUncompletedPapers() {
|
||||
List<PaperDto> papers = paperService.findAllNotCompleted();
|
||||
papers.stream()
|
||||
.forEach(paper ->
|
||||
paper.setTitle(StringUtils.abbreviate(paper.getTitle(), MAX_DISPLAY_SIZE)));
|
||||
return papers;
|
||||
return paperService.findAllNotCompleted();
|
||||
}
|
||||
|
||||
public void attachPaper(GrantDto grantDto) {
|
||||
@ -335,4 +328,12 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<GrantDto> findAllActiveDto() {
|
||||
return convert(findAllActive(), GrantDto::new);
|
||||
}
|
||||
|
||||
private List<Grant> findAllActive() {
|
||||
return grantRepository.findAllActive();
|
||||
}
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ public class Event extends BaseEntity {
|
||||
|
||||
private String description;
|
||||
|
||||
@ManyToMany(fetch = FetchType.EAGER)
|
||||
private List<User> recipients = new ArrayList<User>();
|
||||
@ManyToMany(fetch = FetchType.LAZY)
|
||||
private List<User> recipients = new ArrayList<>();
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "child_id")
|
||||
|
@ -35,6 +35,6 @@ liquibase.change-log=classpath:db/changelog-master.xml
|
||||
ng-tracker.base-url=http://127.0.0.1:8080
|
||||
ng-tracker.undead-user-login=admin
|
||||
ng-tracker.dev-mode=true
|
||||
ng-tracker.debug_email=romanov73@gmail.com
|
||||
ng-tracker.debug_email=
|
||||
ng-tracker.use-https=false
|
||||
ng-tracker.check-run=false
|
@ -8,7 +8,8 @@
|
||||
<div class="col">
|
||||
<span th:replace="grants/fragments/grantStatusFragment :: grantStatus(grantStatus=${grant.status})"/>
|
||||
<a th:href="@{'grant?id='+${grant.id}}">
|
||||
<span class="h6" th:text="${grant.title}"/>
|
||||
<span class="h6" th:if="${#strings.length(grant.title) > 50}" th:text="${#strings.substring(grant.title, 0, 50)} + '...'" th:title="${grant.title}"/>
|
||||
<span class="h6" th:if="${#strings.length(grant.title) le 50}" th:text="${grant.title}" th:title="${grant.title}"/>
|
||||
<span class="text-muted" th:text="${grant.authorsString}"/>
|
||||
</a>
|
||||
<input class="id-class" type="hidden" th:value="${grant.id}"/>
|
||||
|
@ -186,47 +186,7 @@
|
||||
<div class="row">
|
||||
<div class="form-control list-group div-selected-papers" id="selected-papers">
|
||||
<div th:each="paper, rowStat : *{papers}">
|
||||
<input type="hidden" th:field="*{papers[__${rowStat.index}__].id}"/>
|
||||
<div class="col">
|
||||
<a th:href="@{'/papers/paper?id=' + *{papers[__${rowStat.index}__].id} + ''}">
|
||||
<img class="icon-paper" src="/img/conference/paper.png"/>
|
||||
<span th:text="*{papers[__${rowStat.index}__].title}">
|
||||
Название статьи
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="col">
|
||||
<label>Статус: </label>
|
||||
<span th:text="*{papers[__${rowStat.index}__].status.statusName}">
|
||||
Статус статьи
|
||||
</span>
|
||||
</div>
|
||||
<!--
|
||||
<div class="col" th:unless="${#lists.isEmpty(paper.grants)}">
|
||||
<label>Гранты: </label>
|
||||
<div th:each="grant, grantRowStat : *{papers[__${rowStat.index}__].grants}"
|
||||
th:remove="tag">
|
||||
<div th:unless="${grant.id}==*{id}" th:remove="tag">
|
||||
<li>
|
||||
<a th:href="@{'/grants/grant?id=' + ${grant.id} + ''}">
|
||||
<span th:text="${grant.title} "></span>
|
||||
</a>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col" th:unless="${#lists.isEmpty(paper.conferences)}">
|
||||
<label>Конференции: </label>
|
||||
<div th:each="conference, conferenceRowStat : *{papers[__${rowStat.index}__].conferences}"
|
||||
th:remove="tag">
|
||||
<li>
|
||||
<a th:href="@{'/conferences/conference?id=' + ${conference.id} + ''}">
|
||||
<span th:text="${conference.title}"></span>
|
||||
</a>
|
||||
</li>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
||||
<div th:replace="papers/fragments/paperLineFragment :: paperLine(paper=${paper})"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -8,7 +8,8 @@
|
||||
<div class="col">
|
||||
<span th:replace="papers/fragments/paperStatusFragment :: paperStatus(paperStatus=${paper.status})"/>
|
||||
<a th:href="@{'paper?id='+${paper.id}}">
|
||||
<span class="h6" th:text="${paper.title}"/>
|
||||
<span class="h6" th:if="${#strings.length(paper.title)} > 50" th:text="${#strings.substring(paper.title, 0, 50) + '...'}" th:title="${paper.title}"/>
|
||||
<span class="h6" th:if="${#strings.length(paper.title) le 50}" th:text="${paper.title}" th:title="${paper.title}"/>
|
||||
<span class="text-muted" th:text="${paper.authorsString}"/>
|
||||
</a>
|
||||
<input class="id-class" type="hidden" th:value="${paper.id}"/>
|
||||
|
Loading…
Reference in New Issue
Block a user