show active grants
This commit is contained in:
parent
9ba4476f80
commit
2012a58fc2
@ -1,12 +1,8 @@
|
||||
package ru.ulstu.grant.page;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.html.DomElement;
|
||||
import com.gargoylesoftware.htmlunit.html.DomNode;
|
||||
import com.gargoylesoftware.htmlunit.html.DomNodeList;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlTableDataCell;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlTableRow;
|
||||
|
||||
import java.text.ParseException;
|
||||
@ -39,7 +35,8 @@ public class KiasPage {
|
||||
}
|
||||
|
||||
public String getGrantTitle(DomNode grant) {
|
||||
return ((DomNode)grant.getFirstByXPath("td[@class='tertiary']/a")).getTextContent();
|
||||
return ((DomNode) grant.getFirstByXPath("td[2]")).getTextContent() + " "
|
||||
+ ((DomNode) grant.getFirstByXPath("td[@class='tertiary']/a")).getTextContent();
|
||||
}
|
||||
|
||||
public Date parseDeadLineDate(DomNode grantElement) throws ParseException {
|
||||
@ -52,7 +49,7 @@ public class KiasPage {
|
||||
return ((DomNode) grantElement.getFirstByXPath("td[5]")).getTextContent();
|
||||
}
|
||||
|
||||
public boolean isTrGrantLine(DomNode grantElement) {
|
||||
public boolean isTableRowGrantLine(DomNode grantElement) {
|
||||
return !((HtmlTableRow) grantElement).getAttribute("class").contains("pagerSavedHeightSpacer");
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class GrantScheduler {
|
||||
@Scheduled(cron = "0 0 8 * * MON", zone = "Europe/Samara")
|
||||
public void checkDeadlineBeforeWeek() {
|
||||
log.debug("GrantScheduler.checkDeadlineBeforeWeek started");
|
||||
grantNotificationService.sendDeadlineNotifications(grantService.findAll(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
grantNotificationService.sendDeadlineNotifications(grantService.findAllActive(), IS_DEADLINE_NOTIFICATION_BEFORE_WEEK);
|
||||
log.debug("GrantScheduler.checkDeadlineBeforeWeek finished");
|
||||
}
|
||||
|
||||
|
@ -326,7 +326,7 @@ public class GrantService extends BaseService {
|
||||
return convert(findAllActive(), GrantDto::new);
|
||||
}
|
||||
|
||||
private List<Grant> findAllActive() {
|
||||
public List<Grant> findAllActive() {
|
||||
return grantRepository.findAllActive();
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,7 @@
|
||||
package ru.ulstu.grant.service;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.WebClient;
|
||||
import com.gargoylesoftware.htmlunit.html.DomElement;
|
||||
import com.gargoylesoftware.htmlunit.html.DomNode;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlPage;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.configuration.ApplicationProperties;
|
||||
@ -58,7 +56,7 @@ public class KiasService {
|
||||
private List<GrantDto> getGrantsFromPage(KiasPage kiasPage) throws ParseException {
|
||||
List<GrantDto> grants = new ArrayList<>();
|
||||
for (DomNode grantElement : kiasPage.getPageOfGrants()) {
|
||||
if (kiasPage.isTrGrantLine(grantElement)) {
|
||||
if (kiasPage.isTableRowGrantLine(grantElement)) {
|
||||
GrantDto grantDto = new GrantDto(
|
||||
kiasPage.getGrantTitle(grantElement),
|
||||
kiasPage.parseDeadLineDate(grantElement));
|
||||
|
Loading…
Reference in New Issue
Block a user