|
|
|
@ -5,16 +5,20 @@ import org.openqa.selenium.WebElement;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeDriver;
|
|
|
|
|
import org.openqa.selenium.chrome.ChromeOptions;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import ru.ulstu.configuration.ApplicationProperties;
|
|
|
|
|
import ru.ulstu.grant.model.GrantDto;
|
|
|
|
|
import ru.ulstu.grant.page.KiasPage;
|
|
|
|
|
import ru.ulstu.user.service.UserService;
|
|
|
|
|
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static org.apache.commons.lang3.StringUtils.isEmpty;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class KiasService {
|
|
|
|
|
private final static String BASE_URL = "https://www.rfbr.ru/rffi/ru/contest_search?CONTEST_STATUS_ID=%s&CONTEST_TYPE=%s&CONTEST_YEAR=%s";
|
|
|
|
@ -27,9 +31,12 @@ public class KiasService {
|
|
|
|
|
private final static String DRIVER_TYPE = "webdriver.chrome.driver";
|
|
|
|
|
|
|
|
|
|
private final UserService userService;
|
|
|
|
|
private final ApplicationProperties applicationProperties;
|
|
|
|
|
|
|
|
|
|
public KiasService(UserService userService) {
|
|
|
|
|
public KiasService(UserService userService,
|
|
|
|
|
ApplicationProperties applicationProperties) {
|
|
|
|
|
this.userService = userService;
|
|
|
|
|
this.applicationProperties = applicationProperties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<GrantDto> getNewGrantsDto() throws ParseException {
|
|
|
|
@ -78,8 +85,10 @@ public class KiasService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getDriverExecutablePath() {
|
|
|
|
|
return KiasService.class.getClassLoader().getResource(
|
|
|
|
|
String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile();
|
|
|
|
|
return isEmpty(applicationProperties.getDriverPath())
|
|
|
|
|
? KiasService.class.getClassLoader()
|
|
|
|
|
.getResource(String.format(DRIVER_LOCATION, getDriverExecutable(isWindows()))).getFile()
|
|
|
|
|
: Paths.get(applicationProperties.getDriverPath(), getDriverExecutable(isWindows())).toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getDriverExecutable(boolean isWindows) {
|
|
|
|
|