fix warnings
This commit is contained in:
parent
24f447aed7
commit
df1bf873ff
@ -4,20 +4,17 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.commit.model.CommitListDto;
|
||||
import ru.ulstu.commit.service.CommitService;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.odin.controller.OdinController;
|
||||
import ru.ulstu.odin.model.OdinVoid;
|
||||
|
||||
import static ru.ulstu.commit.controller.CommitController.URL;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(URL)
|
||||
@RequestMapping(Constants.API_1_0 + "commits")
|
||||
public class CommitController extends OdinController<CommitListDto, OdinVoid> {
|
||||
public static final String URL = Constants.API_1_0 + "commits";
|
||||
private final CommitService commitService;
|
||||
|
||||
public CommitController(CommitService commitService) {
|
||||
|
@ -22,7 +22,7 @@ public class ConferenceUser extends BaseEntity {
|
||||
INTRAMURAL("Очная"),
|
||||
EXTRAMURAL("Заочная");
|
||||
|
||||
private String participationName;
|
||||
private final String participationName;
|
||||
|
||||
Participation(String name) {
|
||||
this.participationName = name;
|
||||
@ -38,7 +38,7 @@ public class ConferenceUser extends BaseEntity {
|
||||
REPORT("Доклад"),
|
||||
PRESENTATION("Презентация");
|
||||
|
||||
private String depositName;
|
||||
private final String depositName;
|
||||
|
||||
Deposit(String name) {
|
||||
this.depositName = name;
|
||||
|
@ -63,7 +63,7 @@ public class ConferenceNotificationService {
|
||||
|
||||
public void sendCreateNotification(Conference conference) {
|
||||
Map<String, Object> variables = ImmutableMap.of("conference", conference);
|
||||
sendForAllUsers(variables, TEMPLATE_CREATE, String.format(TITLE_CREATE, conference.getTitle()));
|
||||
sendForAllUsers(variables, String.format(TITLE_CREATE, conference.getTitle()));
|
||||
}
|
||||
|
||||
public void updateDeadlineNotification(Conference conference) {
|
||||
@ -76,8 +76,8 @@ public class ConferenceNotificationService {
|
||||
sendForAllParticipants(variables, conference, TEMPLATE_UPDATE_DATES, String.format(TITLE_UPDATE_DATES, conference.getTitle()));
|
||||
}
|
||||
|
||||
private void sendForAllUsers(Map<String, Object> variables, String template, String title) {
|
||||
userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, template, title));
|
||||
private void sendForAllUsers(Map<String, Object> variables, String title) {
|
||||
userService.findAll().forEach(user -> mailService.sendEmailFromTemplate(variables, user, ConferenceNotificationService.TEMPLATE_CREATE, title));
|
||||
}
|
||||
|
||||
private void sendForAllParticipants(Map<String, Object> variables, Conference conference, String template, String title) {
|
||||
|
@ -96,7 +96,6 @@ public class ConferenceService extends BaseService {
|
||||
checkUniqueName(conferenceDto,
|
||||
errors,
|
||||
conferenceDto.getId(),
|
||||
"title",
|
||||
"Конференция с таким именем уже существует");
|
||||
if (errors.hasErrors()) {
|
||||
return false;
|
||||
@ -121,7 +120,7 @@ public class ConferenceService extends BaseService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Conference update(ConferenceDto conferenceDto) throws IOException {
|
||||
private Conference update(ConferenceDto conferenceDto) throws IOException {
|
||||
Conference conference = conferenceRepository.getOne(conferenceDto.getId());
|
||||
List<Deadline> oldDeadlines = conference.getDeadlines().stream()
|
||||
.map(this::copyDeadline)
|
||||
@ -293,7 +292,7 @@ public class ConferenceService extends BaseService {
|
||||
return newDeadline;
|
||||
}
|
||||
|
||||
public void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) {
|
||||
private void checkEmptyFieldsOfDeadline(ConferenceDto conferenceDto, Errors errors) {
|
||||
for (Deadline deadline : conferenceDto.getDeadlines()) {
|
||||
if (deadline.getDate() == null || deadline.getDescription().isEmpty()) {
|
||||
errors.rejectValue("deadlines", "errorCode", "Все поля дедлайна должны быть заполнены");
|
||||
|
@ -26,7 +26,7 @@ public class ConferenceUserService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ConferenceUser update(ConferenceUser user) {
|
||||
private ConferenceUser update(ConferenceUser user) {
|
||||
ConferenceUser updateUser = conferenceUserRepository.getOne(user.getId());
|
||||
updateUser.setDeposit(user.getDeposit());
|
||||
updateUser.setParticipation(user.getParticipation());
|
||||
@ -35,7 +35,7 @@ public class ConferenceUserService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public ConferenceUser create(ConferenceUser user) {
|
||||
private ConferenceUser create(ConferenceUser user) {
|
||||
ConferenceUser newUser = new ConferenceUser();
|
||||
newUser.setDeposit(user.getDeposit());
|
||||
newUser.setParticipation(user.getParticipation());
|
||||
|
@ -22,7 +22,7 @@ public class MailTemplateConfiguration {
|
||||
return templateEngine;
|
||||
}
|
||||
|
||||
public ClassLoaderTemplateResolver emailTemplateResolver() {
|
||||
private ClassLoaderTemplateResolver emailTemplateResolver() {
|
||||
ClassLoaderTemplateResolver emailTemplateResolver = new ClassLoaderTemplateResolver();
|
||||
emailTemplateResolver.setPrefix("/mail_templates/");
|
||||
emailTemplateResolver.setTemplateMode("HTML");
|
||||
|
@ -35,6 +35,11 @@ public class AdviceController {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@ModelAttribute("currentUser")
|
||||
public String getCurrentUser() {
|
||||
return userService.getCurrentUser().getUserAbbreviate();
|
||||
}
|
||||
|
||||
@ModelAttribute("flashMessage")
|
||||
public String getFlashMessage() {
|
||||
return null;
|
||||
|
@ -65,7 +65,7 @@ public class OffsetablePageRequest implements Pageable, Serializable {
|
||||
return hasPrevious() ? previous() : first();
|
||||
}
|
||||
|
||||
public Pageable previous() {
|
||||
private Pageable previous() {
|
||||
return getOffset() == 0 ? this : new OffsetablePageRequest(getOffset() - getPageSize(), getPageSize(), getSort());
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ public abstract class BaseEntity implements Serializable, Comparable {
|
||||
@Version
|
||||
private Integer version;
|
||||
|
||||
public BaseEntity() {
|
||||
protected BaseEntity() {
|
||||
}
|
||||
|
||||
public BaseEntity(Integer id, Integer version) {
|
||||
@ -49,13 +49,8 @@ public abstract class BaseEntity implements Serializable, Comparable {
|
||||
}
|
||||
BaseEntity other = (BaseEntity) obj;
|
||||
if (id == null) {
|
||||
if (other.id != null) {
|
||||
return false;
|
||||
}
|
||||
} else if (!id.equals(other.id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return other.id == null;
|
||||
} else return id.equals(other.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,8 +16,8 @@ public enum ErrorConstants {
|
||||
FILE_UPLOAD_ERROR(110, "File upload error"),
|
||||
USER_SENDING_MAIL_EXCEPTION(111, "Во время отправки приглашения пользователю произошла ошибка");
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
||||
ErrorConstants(int code, String message) {
|
||||
this.code = code;
|
||||
|
@ -1,34 +0,0 @@
|
||||
package ru.ulstu.core.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TreeDto {
|
||||
private Integer id;
|
||||
private String text;
|
||||
private List<TreeDto> children = new ArrayList<>();
|
||||
|
||||
public TreeDto() {
|
||||
}
|
||||
|
||||
public <T extends TreeEntity> TreeDto(TreeEntity item) {
|
||||
this.text = item.toString();
|
||||
this.id = item.getId();
|
||||
}
|
||||
|
||||
public TreeDto(String rootName) {
|
||||
this.text = rootName;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public List<TreeDto> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
package ru.ulstu.core.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface TreeEntity<T> {
|
||||
|
||||
Integer getId();
|
||||
|
||||
List<T> getChildren();
|
||||
|
||||
void setChildren(List<T> children);
|
||||
|
||||
T getParent();
|
||||
|
||||
void setParent(T parent);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package ru.ulstu.core.model.response;
|
||||
|
||||
class ControllerResponse<D, E> {
|
||||
private D data;
|
||||
private ControllerResponseError<E> error;
|
||||
private final D data;
|
||||
private final ControllerResponseError<E> error;
|
||||
|
||||
ControllerResponse(D data) {
|
||||
this.data = data;
|
||||
|
@ -3,8 +3,8 @@ package ru.ulstu.core.model.response;
|
||||
import ru.ulstu.core.model.ErrorConstants;
|
||||
|
||||
class ControllerResponseError<D> {
|
||||
private ErrorConstants description;
|
||||
private D data;
|
||||
private final ErrorConstants description;
|
||||
private final D data;
|
||||
|
||||
ControllerResponseError(ErrorConstants description, D data) {
|
||||
this.description = description;
|
||||
|
@ -8,7 +8,7 @@ import java.io.Serializable;
|
||||
|
||||
public class JpaDetachableRepositoryImpl<T, ID extends Serializable> extends SimpleJpaRepository<T, ID>
|
||||
implements JpaDetachableRepository<T, ID> {
|
||||
private EntityManager entityManager;
|
||||
private final EntityManager entityManager;
|
||||
|
||||
public JpaDetachableRepositoryImpl(JpaEntityInformation<T, ?> entityInformation, EntityManager entityManager) {
|
||||
super(entityInformation, entityManager);
|
||||
|
@ -1,17 +0,0 @@
|
||||
package ru.ulstu.core.util;
|
||||
|
||||
public class NumberUtils {
|
||||
public static Double ceil(Double number) {
|
||||
if (number == null) {
|
||||
return 0.0;
|
||||
}
|
||||
return Double.valueOf(Math.ceil(number));
|
||||
}
|
||||
|
||||
public static Double round(Double number) {
|
||||
if (number == null) {
|
||||
return 0.0;
|
||||
}
|
||||
return Double.valueOf(Math.ceil(number * 100)) / 100;
|
||||
}
|
||||
}
|
@ -11,12 +11,12 @@ public class StreamApiUtils {
|
||||
public static <T, R> List<T> convert(List<R> entities, Function<R, T> converter) {
|
||||
return entities == null
|
||||
? Collections.emptyList()
|
||||
: entities.stream().map(e -> converter.apply(e)).collect(Collectors.toList());
|
||||
: entities.stream().map(converter).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static <T, R> Set<T> convert(Set<R> entities, Function<R, T> converter) {
|
||||
return entities == null
|
||||
? Collections.emptySet()
|
||||
: entities.stream().map(e -> converter.apply(e)).collect(Collectors.toSet());
|
||||
: entities.stream().map(converter).collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class DeadlineService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Deadline update(Deadline deadline) {
|
||||
private Deadline update(Deadline deadline) {
|
||||
Deadline updateDeadline = deadlineRepository.getOne(deadline.getId());
|
||||
updateDeadline.setDate(deadline.getDate());
|
||||
updateDeadline.setDescription(deadline.getDescription());
|
||||
|
@ -21,13 +21,10 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static ru.ulstu.file.FileController.URL;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(URL)
|
||||
@RequestMapping(Constants.API_1_0 + "files")
|
||||
public class FileController {
|
||||
public static final String URL = Constants.API_1_0 + "files";
|
||||
|
||||
private final FileService fileService;
|
||||
|
||||
public FileController(FileService fileService) {
|
||||
@ -53,6 +50,6 @@ public class FileController {
|
||||
|
||||
@PostMapping("/uploadTmpFile")
|
||||
public Response<FileDataDto> upload(@RequestParam("file") MultipartFile multipartFile) throws IOException {
|
||||
return new Response(fileService.createFromMultipartFile(multipartFile));
|
||||
return new Response<>(fileService.createFromMultipartFile(multipartFile));
|
||||
}
|
||||
}
|
||||
|
@ -27,15 +27,15 @@ public class FileService {
|
||||
private final static int META_FILE_NAME_INDEX = 0;
|
||||
private final static int META_FILE_SIZE_INDEX = 1;
|
||||
|
||||
private String tmpDir;
|
||||
private FileRepository fileRepository;
|
||||
private final String tmpDir;
|
||||
private final FileRepository fileRepository;
|
||||
|
||||
public FileService(FileRepository fileRepository) {
|
||||
tmpDir = System.getProperty("java.io.tmpdir");
|
||||
this.fileRepository = fileRepository;
|
||||
}
|
||||
|
||||
public FileData createFileFromTmp(String tmpFileName) throws IOException {
|
||||
private FileData createFileFromTmp(String tmpFileName) throws IOException {
|
||||
FileData fileData = new FileData();
|
||||
fileData.setData(getTmpFile(tmpFileName));
|
||||
fileData.setSize(getTmpFileSize(tmpFileName));
|
||||
@ -43,7 +43,7 @@ public class FileService {
|
||||
return fileRepository.save(fileData);
|
||||
}
|
||||
|
||||
public String uploadToTmpDir(MultipartFile multipartFile) throws IOException {
|
||||
private String uploadToTmpDir(MultipartFile multipartFile) throws IOException {
|
||||
String tmpFileName = String.valueOf(System.currentTimeMillis()) + UUID.randomUUID();
|
||||
Files.write(getTmpFilePath(tmpFileName), multipartFile.getBytes());
|
||||
String meta = multipartFile.getOriginalFilename() + "\n" + multipartFile.getSize();
|
||||
@ -56,7 +56,7 @@ public class FileService {
|
||||
.split("\n");
|
||||
}
|
||||
|
||||
public long getTmpFileSize(String tmpFileName) throws IOException {
|
||||
private long getTmpFileSize(String tmpFileName) throws IOException {
|
||||
return Long.valueOf(getMeta(tmpFileName)[META_FILE_SIZE_INDEX]).longValue();
|
||||
}
|
||||
|
||||
@ -97,13 +97,13 @@ public class FileService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FileData update(FileDataDto fileDataDto) {
|
||||
private FileData update(FileDataDto fileDataDto) {
|
||||
FileData file = fileRepository.getOne(fileDataDto.getId());
|
||||
return fileRepository.save(copyFromDto(file, fileDataDto));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public FileData create(FileDataDto fileDataDto) throws IOException {
|
||||
private FileData create(FileDataDto fileDataDto) throws IOException {
|
||||
FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName());
|
||||
copyFromDto(newFile, fileDataDto);
|
||||
return fileRepository.save(newFile);
|
||||
|
@ -50,7 +50,7 @@ public class Grant extends BaseEntity implements UserActivity, EventSource {
|
||||
LOADED_FROM_KIAS("Загружен автоматически"),
|
||||
SKIPPED("Не интересует");
|
||||
|
||||
private String statusName;
|
||||
private final String statusName;
|
||||
|
||||
GrantStatus(String statusName) {
|
||||
this.statusName = statusName;
|
||||
|
@ -79,8 +79,7 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
|
||||
public GrantDto getExistGrantById(Integer id) {
|
||||
GrantDto grantDto = new GrantDto(findById(id));
|
||||
return grantDto;
|
||||
return new GrantDto(findById(id));
|
||||
}
|
||||
|
||||
public List<Grant> findAll() {
|
||||
@ -134,7 +133,7 @@ public class GrantService extends BaseService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer update(GrantDto grantDto) throws IOException {
|
||||
private Integer update(GrantDto grantDto) throws IOException {
|
||||
Grant grant = findById(grantDto.getId());
|
||||
Set<User> oldAuthors = new HashSet<>(grant.getAuthors());
|
||||
User oldLeader = grant.getLeader();
|
||||
@ -182,7 +181,7 @@ public class GrantService extends BaseService {
|
||||
filterEmptyDeadlines(grantDto);
|
||||
checkEmptyDeadlines(grantDto, errors);
|
||||
checkEmptyLeader(grantDto, errors);
|
||||
checkUniqueName(grantDto, errors, grantDto.getId(), "title", "Грант с таким именем уже существует");
|
||||
checkUniqueName(grantDto, errors, grantDto.getId(), "Грант с таким именем уже существует");
|
||||
if (errors.hasErrors()) {
|
||||
return false;
|
||||
}
|
||||
@ -194,7 +193,7 @@ public class GrantService extends BaseService {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean saveFromKias(GrantDto grantDto) throws IOException {
|
||||
private boolean saveFromKias(GrantDto grantDto) throws IOException {
|
||||
grantDto.setName(grantDto.getTitle());
|
||||
String title = checkUniqueName(grantDto, grantDto.getId()); //проверка уникальности имени
|
||||
if (title != null) {
|
||||
|
@ -23,12 +23,10 @@ public class KiasService {
|
||||
private final static String CONTEST_TYPE = "-1";
|
||||
|
||||
private final UserService userService;
|
||||
private final ApplicationProperties applicationProperties;
|
||||
|
||||
public KiasService(UserService userService,
|
||||
ApplicationProperties applicationProperties) {
|
||||
this.userService = userService;
|
||||
this.applicationProperties = applicationProperties;
|
||||
}
|
||||
|
||||
public List<GrantDto> getNewGrantsDto() throws ParseException, IOException {
|
||||
@ -44,7 +42,7 @@ public class KiasService {
|
||||
return grants;
|
||||
}
|
||||
|
||||
public List<GrantDto> getKiasGrants(HtmlPage page) throws ParseException {
|
||||
private List<GrantDto> getKiasGrants(HtmlPage page) throws ParseException {
|
||||
List<GrantDto> newGrants = new ArrayList<>();
|
||||
KiasPage kiasPage = new KiasPage(page);
|
||||
do {
|
||||
|
@ -8,13 +8,13 @@ public abstract class BaseService {
|
||||
|
||||
public BaseRepository baseRepository;
|
||||
|
||||
public void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String checkField, String errorMessage) {
|
||||
protected void checkUniqueName(NameContainer nameContainer, Errors errors, Integer id, String errorMessage) {
|
||||
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||
errors.rejectValue(checkField, "errorCode", errorMessage);
|
||||
errors.rejectValue("title", "errorCode", errorMessage);
|
||||
}
|
||||
}
|
||||
|
||||
public String checkUniqueName(NameContainer nameContainer, Integer id) {
|
||||
protected String checkUniqueName(NameContainer nameContainer, Integer id) {
|
||||
if (nameContainer.getName().equals(baseRepository.findByNameAndNotId(nameContainer.getName(), id))) {
|
||||
return baseRepository.findByNameAndNotId(nameContainer.getName(), id);
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import ru.ulstu.odin.service.OdinService;
|
||||
|
||||
public abstract class OdinController<L, E extends OdinDto> {
|
||||
public static final String META_LIST_URL = "/meta/list";
|
||||
public static final String META_ELEMENT_URL = "/meta/element";
|
||||
private static final String META_ELEMENT_URL = "/meta/element";
|
||||
|
||||
private Class<L> listDtoClass;
|
||||
private Class<E> elementDtoClass;
|
||||
private final Class<L> listDtoClass;
|
||||
private final Class<E> elementDtoClass;
|
||||
@Autowired
|
||||
private OdinService<L, E> odinService;
|
||||
|
||||
|
@ -3,6 +3,7 @@ package ru.ulstu.odin.model;
|
||||
import ru.ulstu.core.error.OdinException;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@ -14,9 +15,9 @@ public class OdinCollectionField extends OdinField {
|
||||
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
||||
Type fieldElementClass = genericType.getActualTypeArguments()[0];
|
||||
try {
|
||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance();
|
||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance();
|
||||
this.path = someInstance.getControllerPath();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
||||
fieldElementClass.getTypeName()));
|
||||
}
|
||||
|
@ -31,15 +31,16 @@ public abstract class OdinField implements Comparable {
|
||||
return this.name().toLowerCase();
|
||||
}
|
||||
}
|
||||
protected final OdinFieldType fieldType;
|
||||
protected final String fieldName;
|
||||
protected final String caption;
|
||||
protected final OdinVisible.OdinVisibleType visible;
|
||||
protected final boolean readOnly;
|
||||
protected final boolean notEmpty;
|
||||
private Field field;
|
||||
|
||||
public OdinField(Field field, OdinFieldType fieldType) {
|
||||
private final OdinFieldType fieldType;
|
||||
private final String fieldName;
|
||||
private final String caption;
|
||||
private final OdinVisible.OdinVisibleType visible;
|
||||
private final boolean readOnly;
|
||||
private final boolean notEmpty;
|
||||
private final Field field;
|
||||
|
||||
OdinField(Field field, OdinFieldType fieldType) {
|
||||
this.field = field;
|
||||
this.fieldName = getFieldName(field);
|
||||
this.caption = Optional.ofNullable(getValueFromAnnotation(OdinCaption.class, "value"))
|
||||
@ -92,7 +93,7 @@ public abstract class OdinField implements Comparable {
|
||||
}
|
||||
}
|
||||
|
||||
protected <T> T getValue(Class<? extends Annotation> annotationClass, String valueName, Class<T> clazz) {
|
||||
<T> T getValue(Class<? extends Annotation> annotationClass, String valueName, Class<T> clazz) {
|
||||
if (field.isAnnotationPresent(annotationClass)) {
|
||||
return cast(getValueFromAnnotation(annotationClass, valueName), clazz);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package ru.ulstu.odin.model;
|
||||
import ru.ulstu.core.error.OdinException;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public class OdinObjectField extends OdinField {
|
||||
@ -12,9 +13,9 @@ public class OdinObjectField extends OdinField {
|
||||
super(field, OdinFieldType.OBJECT);
|
||||
Type fieldElementClass = field.getType();
|
||||
try {
|
||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).newInstance();
|
||||
OdinDto someInstance = (OdinDto) ((Class) (fieldElementClass)).getDeclaredConstructor().newInstance();
|
||||
this.path = someInstance.getControllerPath();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||
throw new OdinException(String.format("Can't create new instance, check default constructor of %s",
|
||||
fieldElementClass.getTypeName()));
|
||||
}
|
||||
|
@ -1,4 +0,0 @@
|
||||
package ru.ulstu.odinexample.controller;
|
||||
|
||||
public class OdinExampleController {
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package ru.ulstu.odinexample.model;
|
||||
|
||||
public class OdinExampleDto {
|
||||
}
|
@ -1,103 +0,0 @@
|
||||
package ru.ulstu.odinexample.model;
|
||||
|
||||
import ru.ulstu.core.util.DateUtils;
|
||||
import ru.ulstu.odin.model.annotation.OdinCaption;
|
||||
import ru.ulstu.odin.model.annotation.OdinDate;
|
||||
import ru.ulstu.odin.model.annotation.OdinNumeric;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Date;
|
||||
|
||||
public class OdinExampleListDto {
|
||||
@OdinCaption("instant")
|
||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||
private Instant instant;
|
||||
@OdinCaption("date")
|
||||
private Date date;
|
||||
@OdinCaption("localdate")
|
||||
private LocalDate localDate;
|
||||
@OdinCaption("localtime")
|
||||
@OdinDate(type = OdinDate.OdinDateType.TIME)
|
||||
private LocalTime localTime;
|
||||
@OdinCaption("localdatetime")
|
||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||
private LocalDateTime localDateTime;
|
||||
@OdinCaption("int")
|
||||
private int intval;
|
||||
@OdinCaption("int+settings")
|
||||
@OdinNumeric(precision = 5, scale = 2)
|
||||
private int intvalset;
|
||||
@OdinCaption("float")
|
||||
private float floatval;
|
||||
@OdinCaption("double")
|
||||
private double aDouble;
|
||||
@OdinCaption("double+set")
|
||||
@OdinNumeric(precision = 5, scale = 3)
|
||||
private double aDoubles;
|
||||
@OdinCaption("int+positive")
|
||||
@OdinNumeric(positiveOnly = true, scale = 2)
|
||||
private int invalpos;
|
||||
|
||||
public OdinExampleListDto() {
|
||||
this.instant = Instant.now();
|
||||
this.date = new Date();
|
||||
this.localDate = LocalDate.now();
|
||||
this.localTime = LocalTime.now();
|
||||
this.localDateTime = LocalDateTime.now();
|
||||
intval = -134;
|
||||
intvalset = 1343423232;
|
||||
floatval = 2323.44F;
|
||||
aDouble = -232323.43434;
|
||||
aDoubles = 0.456456456;
|
||||
invalpos = -23232323;
|
||||
}
|
||||
|
||||
|
||||
public Date getInstant() {
|
||||
return DateUtils.instantToDate(instant);
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public Date getLocalDate() {
|
||||
return DateUtils.localDateToDate(localDate);
|
||||
}
|
||||
|
||||
public Date getLocalTime() {
|
||||
return DateUtils.localTimeToDate(localTime);
|
||||
}
|
||||
|
||||
public Date getLocalDateTime() {
|
||||
return DateUtils.localDateTimeToDate(localDateTime);
|
||||
}
|
||||
|
||||
public int getIntval() {
|
||||
return intval;
|
||||
}
|
||||
|
||||
public int getIntvalset() {
|
||||
return intvalset;
|
||||
}
|
||||
|
||||
public float getFloatval() {
|
||||
return floatval;
|
||||
}
|
||||
|
||||
public double getaDouble() {
|
||||
return aDouble;
|
||||
}
|
||||
|
||||
public double getaDoubles() {
|
||||
return aDoubles;
|
||||
}
|
||||
|
||||
public int getInvalpos() {
|
||||
return invalpos;
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
package ru.ulstu.odinexample.service;
|
||||
|
||||
public class OdinExampleService {
|
||||
}
|
@ -40,7 +40,7 @@ public class PaperRestController {
|
||||
|
||||
@GetMapping("/{paper-id}")
|
||||
public Response<PaperDto> getPaper(@PathVariable("paper-id") Integer paperId) {
|
||||
return new Response(paperService.findById(paperId));
|
||||
return new Response<>(paperService.findById(paperId));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@ -56,7 +56,7 @@ public class PaperRestController {
|
||||
@DeleteMapping("/{paper-id}")
|
||||
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
||||
paperService.delete(paperId);
|
||||
return new Response<>(true);
|
||||
return new Response<>(Boolean.TRUE);
|
||||
}
|
||||
|
||||
@PostMapping("/filter")
|
||||
|
@ -1,7 +0,0 @@
|
||||
package ru.ulstu.paper.error;
|
||||
|
||||
public class PaperConferenceRelationExistException extends RuntimeException {
|
||||
public PaperConferenceRelationExistException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -48,7 +48,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
||||
DRAFT("Черновик"),
|
||||
FAILED("Провалены сроки");
|
||||
|
||||
private String statusName;
|
||||
private final String statusName;
|
||||
|
||||
PaperStatus(String name) {
|
||||
this.statusName = name;
|
||||
@ -65,7 +65,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
||||
SCOPUS("Scopus"),
|
||||
WEB_OF_SCIENCE("Web Of Science");
|
||||
|
||||
private String typeName;
|
||||
private final String typeName;
|
||||
|
||||
PaperType(String name) {
|
||||
this.typeName = name;
|
||||
@ -201,7 +201,7 @@ public class Paper extends BaseEntity implements UserActivity, EventSource {
|
||||
|
||||
@Override
|
||||
public List<User> getRecipients() {
|
||||
return new ArrayList(authors);
|
||||
return new ArrayList<>(authors);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -8,7 +8,7 @@ public class ReferenceDto {
|
||||
ARTICLE("Статья"),
|
||||
BOOK("Книга");
|
||||
|
||||
private String typeName;
|
||||
private final String typeName;
|
||||
|
||||
ReferenceType(String name) {
|
||||
this.typeName = name;
|
||||
@ -23,7 +23,7 @@ public class ReferenceDto {
|
||||
GOST("ГОСТ"),
|
||||
SPRINGER("Springer");
|
||||
|
||||
private String standardName;
|
||||
private final String standardName;
|
||||
|
||||
FormatStandard(String name) {
|
||||
this.standardName = name;
|
||||
|
@ -12,11 +12,11 @@ import java.nio.file.Files;
|
||||
|
||||
@Service
|
||||
public class LatexService {
|
||||
private final String pdfLatexError = "Errors occurred while executing pdfLaTeX.";
|
||||
private final String bibtexError = "Errors occurred while executing bibtex.";
|
||||
private static final String PDF_LATEX_ERROR = "Errors occurred while executing pdfLaTeX.";
|
||||
private static final String BIBTEX_ERROR = "Errors occurred while executing bibtex.";
|
||||
private String errorMessage;
|
||||
private File pdfFile;
|
||||
private FileService fileService;
|
||||
private final FileService fileService;
|
||||
|
||||
public LatexService(FileService fileService) {
|
||||
this.fileService = fileService;
|
||||
@ -56,9 +56,9 @@ public class LatexService {
|
||||
}
|
||||
|
||||
private boolean generate(String filename, File dir) throws IOException, InterruptedException {
|
||||
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError);
|
||||
startProcess(new String[]{"bibtex", filename}, dir, bibtexError);
|
||||
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, pdfLatexError) != 0) {
|
||||
startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR);
|
||||
startProcess(new String[]{"bibtex", filename}, dir, BIBTEX_ERROR);
|
||||
if (startProcess(new String[]{"pdflatex", filename, "--interaction=nonstopmode"}, dir, PDF_LATEX_ERROR) != 0) {
|
||||
return false;
|
||||
}
|
||||
return checkPdf(filename, dir);
|
||||
|
@ -85,7 +85,7 @@ public class PaperService {
|
||||
return papers;
|
||||
}
|
||||
|
||||
public List<Paper> findAllActive() {
|
||||
private List<Paper> findAllActive() {
|
||||
return findAll()
|
||||
.stream()
|
||||
.filter(paper -> paper.getStatus() != COMPLETED && paper.getStatus() != FAILED)
|
||||
@ -139,7 +139,7 @@ public class PaperService {
|
||||
return paper;
|
||||
}
|
||||
|
||||
public List<Reference> saveOrCreateReferences(List<ReferenceDto> references) {
|
||||
private List<Reference> saveOrCreateReferences(List<ReferenceDto> references) {
|
||||
return references
|
||||
.stream()
|
||||
.filter(reference -> !reference.getDeleted())
|
||||
@ -148,7 +148,7 @@ public class PaperService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Reference updateReference(ReferenceDto referenceDto) {
|
||||
private Reference updateReference(ReferenceDto referenceDto) {
|
||||
Reference updateReference = referenceRepository.getOne(referenceDto.getId());
|
||||
copyFromDto(updateReference, referenceDto);
|
||||
referenceRepository.save(updateReference);
|
||||
@ -156,7 +156,7 @@ public class PaperService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Reference createReference(ReferenceDto referenceDto) {
|
||||
private Reference createReference(ReferenceDto referenceDto) {
|
||||
Reference newReference = new Reference();
|
||||
copyFromDto(newReference, referenceDto);
|
||||
newReference = referenceRepository.save(newReference);
|
||||
@ -358,7 +358,7 @@ public class PaperService {
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public String getGostReference(ReferenceDto referenceDto) {
|
||||
private String getGostReference(ReferenceDto referenceDto) {
|
||||
return MessageFormat.format(referenceDto.getReferenceType() == BOOK ? "{0} {1} - {2}{3}. - {4}с." : "{0} {1}{5} {2}{3}. С. {4}.",
|
||||
referenceDto.getAuthors(),
|
||||
referenceDto.getPublicationTitle(),
|
||||
@ -368,7 +368,7 @@ public class PaperService {
|
||||
StringUtils.isEmpty(referenceDto.getJournalOrCollectionTitle()) ? "." : " // " + referenceDto.getJournalOrCollectionTitle() + ".");
|
||||
}
|
||||
|
||||
public String getSpringerReference(ReferenceDto referenceDto) {
|
||||
private String getSpringerReference(ReferenceDto referenceDto) {
|
||||
return MessageFormat.format("{0} ({1}) {2}.{3} {4}pp {5}",
|
||||
referenceDto.getAuthors(),
|
||||
referenceDto.getPublicationYear() != null ? referenceDto.getPublicationYear().toString() : "",
|
||||
|
@ -17,14 +17,12 @@ import java.util.List;
|
||||
public class PingService {
|
||||
private final PingRepository pingRepository;
|
||||
private final UserService userService;
|
||||
private final PingScheduler pingScheduler;
|
||||
|
||||
public PingService(PingRepository pingRepository,
|
||||
UserService userService,
|
||||
PingScheduler pingScheduler) {
|
||||
this.pingRepository = pingRepository;
|
||||
this.userService = userService;
|
||||
this.pingScheduler = pingScheduler;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
@ -42,7 +42,7 @@ public class Project extends BaseEntity implements UserActivity, EventSource {
|
||||
CLOSED("Закрыт"),
|
||||
FAILED("Провалены сроки");
|
||||
|
||||
private String statusName;
|
||||
private final String statusName;
|
||||
|
||||
ProjectStatus(String statusName) {
|
||||
this.statusName = statusName;
|
||||
|
@ -81,7 +81,7 @@ public class ProjectService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Project update(ProjectDto projectDto) throws IOException {
|
||||
private Project update(ProjectDto projectDto) throws IOException {
|
||||
Project project = projectRepository.getOne(projectDto.getId());
|
||||
projectRepository.save(copyFromDto(project, projectDto));
|
||||
eventService.updateProjectDeadlines(project);
|
||||
@ -143,8 +143,7 @@ public class ProjectService {
|
||||
}
|
||||
|
||||
public List<User> getProjectExecutors(ProjectDto projectDto) {
|
||||
List<User> users = userService.findAll();
|
||||
return users;
|
||||
return userService.findAll();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@ -153,11 +152,10 @@ public class ProjectService {
|
||||
}
|
||||
|
||||
public List<GrantDto> getAllGrants() {
|
||||
List<GrantDto> grants = convert(grantRepository.findAll(), GrantDto::new);
|
||||
return grants;
|
||||
return convert(grantRepository.findAll(), GrantDto::new);
|
||||
}
|
||||
|
||||
public List<GrantDto> getProjectGrants(List<Integer> grantIds) {
|
||||
private List<GrantDto> getProjectGrants(List<Integer> grantIds) {
|
||||
return convert(grantRepository.findAllById(grantIds), GrantDto::new);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ public abstract class EntityCreateStrategy<T extends UserActivity> {
|
||||
|
||||
protected abstract void createEntity(User user);
|
||||
|
||||
protected void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
||||
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
||||
allUsers.forEach(user -> {
|
||||
if (entities
|
||||
.stream()
|
||||
|
@ -2,7 +2,7 @@ package ru.ulstu.students.controller;
|
||||
|
||||
import org.springframework.validation.Errors;
|
||||
|
||||
public class Navigation {
|
||||
class Navigation {
|
||||
public static final String REDIRECT_TO = "redirect:%s";
|
||||
public static final String TASKS_PAGE = "/students/tasks";
|
||||
public static final String TASK_PAGE = "/students/task";
|
||||
|
@ -8,7 +8,6 @@ import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.tags.model.Tag;
|
||||
import ru.ulstu.timeline.model.Event;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import javax.persistence.CascadeType;
|
||||
import javax.persistence.Column;
|
||||
@ -23,7 +22,6 @@ import javax.persistence.OneToMany;
|
||||
import javax.persistence.OrderBy;
|
||||
import javax.persistence.Temporal;
|
||||
import javax.persistence.TemporalType;
|
||||
import javax.persistence.Transient;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
@ -39,7 +37,7 @@ public class Task extends BaseEntity implements EventSource {
|
||||
FAILED("Провалены сроки"),
|
||||
LOADED_FROM_KIAS("Загружен автоматически");
|
||||
|
||||
private String statusName;
|
||||
private final String statusName;
|
||||
|
||||
TaskStatus(String name) {
|
||||
this.statusName = name;
|
||||
@ -55,17 +53,10 @@ public class Task extends BaseEntity implements EventSource {
|
||||
|
||||
private String description;
|
||||
|
||||
@Transient
|
||||
private UserService userService;
|
||||
|
||||
public Task() {
|
||||
|
||||
}
|
||||
|
||||
public Task(UserService userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
@Enumerated(value = EnumType.STRING)
|
||||
private TaskStatus status = TaskStatus.IN_WORK;
|
||||
|
||||
|
@ -101,7 +101,7 @@ public class TaskService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer update(TaskDto taskDto) throws IOException {
|
||||
private Integer update(TaskDto taskDto) throws IOException {
|
||||
Task task = taskRepository.getOne(taskDto.getId());
|
||||
taskRepository.save(copyFromDto(task, taskDto));
|
||||
eventService.updateTaskDeadlines(task);
|
||||
|
@ -33,17 +33,17 @@ public class TagService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tag getExistById(Tag tag) {
|
||||
private Tag getExistById(Tag tag) {
|
||||
return tagRepository.getOne(tag.getId());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tag isExistByName(String tagName) {
|
||||
private Tag isExistByName(String tagName) {
|
||||
return tagRepository.findByName(tagName);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Tag create(Tag tag) {
|
||||
private Tag create(Tag tag) {
|
||||
Tag newTag = new Tag();
|
||||
newTag.setTagName(tag.getTagName());
|
||||
newTag = tagRepository.save(newTag);
|
||||
|
@ -16,12 +16,9 @@ import ru.ulstu.timeline.service.EventService;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.timeline.controller.EventController.URL;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(URL)
|
||||
@RequestMapping(Constants.API_1_0 + "events")
|
||||
public class EventController {
|
||||
public static final String URL = Constants.API_1_0 + "events";
|
||||
|
||||
private final EventService eventService;
|
||||
|
||||
@ -40,18 +37,18 @@ public class EventController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Response createEvent(@RequestBody @Valid EventDto timelineDto) {
|
||||
return new Response(eventService.create(timelineDto));
|
||||
public Response<Integer> createEvent(@RequestBody @Valid EventDto timelineDto) {
|
||||
return new Response<>(eventService.create(timelineDto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Response updateEvent(@RequestBody @Valid EventDto eventDto) {
|
||||
return new Response(eventService.update(eventDto));
|
||||
public Response<Integer> updateEvent(@RequestBody @Valid EventDto eventDto) {
|
||||
return new Response<>(eventService.update(eventDto));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{event-id}")
|
||||
public Response delete(@PathVariable("event-id") Integer eventId) {
|
||||
public Response<Boolean> delete(@PathVariable("event-id") Integer eventId) {
|
||||
eventService.delete(eventId);
|
||||
return new Response(true);
|
||||
return new Response<>(Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class Event extends BaseEntity {
|
||||
public enum EventStatus {
|
||||
POSSIBLE("Возможное"), NEW("Новое"), IN_PROGRESS("В процессе"), COMPLETED("Завершено");
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
EventStatus(String name) {
|
||||
this.name = name;
|
||||
|
@ -1,19 +0,0 @@
|
||||
package ru.ulstu.timeline.model;
|
||||
|
||||
public class EventStatusDto {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public EventStatusDto(Event.EventStatus status) {
|
||||
this.id = status.name();
|
||||
this.name = status.getName();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -8,8 +8,8 @@ public enum PeriodEvent {
|
||||
EVERY_WEEK(Period.ofWeeks(1), "Каждую неделю"),
|
||||
EVERY_DAY(Period.ofDays(1), "Каждый день");
|
||||
|
||||
private Period period;
|
||||
private String message;
|
||||
private final Period period;
|
||||
private final String message;
|
||||
|
||||
PeriodEvent(Period period, String message) {
|
||||
this.period = period;
|
||||
|
@ -49,7 +49,7 @@ public class EventService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int create(EventDto eventDto) {
|
||||
public Integer create(EventDto eventDto) {
|
||||
return eventRepository.save(copyFromDto(new Event(), eventDto)).getId();
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public class EventService {
|
||||
return eventRepository.findByCurrentDate();
|
||||
}
|
||||
|
||||
public List<Event> findAllFuture() {
|
||||
private List<Event> findAllFuture() {
|
||||
return eventRepository.findAllFuture();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
public final class IpAddressResolver {
|
||||
final class IpAddressResolver {
|
||||
private static final String CLIENT_IP_HEADER = "Client-IP";
|
||||
private static final String FORWARDED_FOR_HEADER = "X-Forwarded-For";
|
||||
|
||||
|
@ -41,9 +41,9 @@ import static ru.ulstu.user.controller.UserController.URL;
|
||||
public class UserController extends OdinController<UserListDto, UserDto> {
|
||||
public static final String URL = Constants.API_1_0 + "users";
|
||||
public static final String ROLES_URL = "/roles";
|
||||
public static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL;
|
||||
public static final String SESSIONS_URL = "/sessions";
|
||||
public static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL;
|
||||
private static final String ROLES_META_URL = ROLES_URL + OdinController.META_LIST_URL;
|
||||
private static final String SESSIONS_URL = "/sessions";
|
||||
private static final String SESSIONS_META_URL = SESSIONS_URL + OdinController.META_LIST_URL;
|
||||
public static final String REGISTER_URL = "/register";
|
||||
public static final String ACTIVATE_URL = "/activate";
|
||||
public static final String PASSWORD_RESET_REQUEST_URL = "/password-reset-request";
|
||||
|
@ -71,11 +71,4 @@ public class UserMvcController extends OdinController<UserListDto, UserDto> {
|
||||
"CONFERENCE", "Конференции");
|
||||
}
|
||||
|
||||
@GetMapping("/pings")
|
||||
public void getPings() {
|
||||
}
|
||||
|
||||
@GetMapping("/block")
|
||||
public void getBlock() {
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class User extends BaseEntity {
|
||||
CANDIDATE("Кандидат технических наук"),
|
||||
DOCTOR("Доктор технических наук");
|
||||
|
||||
private String degreeName;
|
||||
private final String degreeName;
|
||||
|
||||
UserDegree(String degreeName) {
|
||||
this.degreeName = degreeName;
|
||||
|
@ -53,7 +53,7 @@ public class UserDto implements OdinDto {
|
||||
private boolean activated;
|
||||
|
||||
@OdinCaption("Роли")
|
||||
private LinkedHashSet<UserRoleDto> roles;
|
||||
private final LinkedHashSet<UserRoleDto> roles;
|
||||
|
||||
@OdinString(type = PASSWORD)
|
||||
@OdinVisible(type = OdinVisible.OdinVisibleType.ON_UPDATE)
|
||||
@ -189,9 +189,9 @@ public class UserDto implements OdinDto {
|
||||
@JsonIgnore
|
||||
public boolean isPasswordsValid() {
|
||||
if (StringUtils.isEmpty(password) || StringUtils.isEmpty(passwordConfirm)) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
return Objects.equals(password, passwordConfirm);
|
||||
return !Objects.equals(password, passwordConfirm);
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
|
@ -11,19 +11,19 @@ import java.util.Optional;
|
||||
|
||||
public class UserListDto implements OdinDto {
|
||||
@OdinVisible(type = OdinVisible.OdinVisibleType.NONE)
|
||||
private int id;
|
||||
private final int id;
|
||||
@OdinCaption("Логин")
|
||||
private String login;
|
||||
private final String login;
|
||||
@OdinCaption("Имя")
|
||||
private String firstName;
|
||||
private final String firstName;
|
||||
@OdinCaption("Фамилия")
|
||||
private String lastName;
|
||||
private final String lastName;
|
||||
@OdinCaption("E-Mail")
|
||||
private String email;
|
||||
private final String email;
|
||||
@OdinCaption("Аккаунт активен")
|
||||
private boolean activated;
|
||||
private final boolean activated;
|
||||
@OdinCaption("Права администратора")
|
||||
private boolean admin;
|
||||
private final boolean admin;
|
||||
|
||||
public UserListDto(User user) {
|
||||
this.id = user.getId();
|
||||
|
@ -7,19 +7,19 @@ import java.util.Date;
|
||||
|
||||
public class UserSessionListDto {
|
||||
@OdinCaption("Сессия")
|
||||
private String sessionId;
|
||||
private final String sessionId;
|
||||
@OdinCaption("Пользователь")
|
||||
private String login;
|
||||
private final String login;
|
||||
@OdinCaption("IP адрес")
|
||||
private String ipAddress;
|
||||
private final String ipAddress;
|
||||
@OdinCaption("Хост")
|
||||
private String host;
|
||||
private final String host;
|
||||
@OdinCaption("Вход")
|
||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||
private Date loginTime;
|
||||
private final Date loginTime;
|
||||
@OdinCaption("Выход")
|
||||
@OdinDate(type = OdinDate.OdinDateType.DATETIME)
|
||||
private Date logoutTime;
|
||||
private final Date logoutTime;
|
||||
|
||||
public UserSessionListDto(UserSession userSession) {
|
||||
this.sessionId = userSession.getSessionId();
|
||||
|
@ -39,7 +39,7 @@ public class MailService {
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendEmail(String to, String subject, String content) throws MessagingException, MailException {
|
||||
private void sendEmail(String to, String subject, String content) throws MessagingException, MailException {
|
||||
log.debug("Send email to '{}' with subject '{}'", to, subject);
|
||||
MimeMessage mimeMessage = javaMailSender.createMimeMessage();
|
||||
MimeMessageHelper message = new MimeMessageHelper(mimeMessage, false, StandardCharsets.UTF_8.name());
|
||||
@ -60,7 +60,7 @@ public class MailService {
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendEmailFromTemplate(User user, String templateName, String subject) {
|
||||
private void sendEmailFromTemplate(User user, String templateName, String subject) {
|
||||
Context context = new Context();
|
||||
context.setVariable(USER, user);
|
||||
context.setVariable(BASE_URL, applicationProperties.getBaseUrl());
|
||||
@ -99,7 +99,7 @@ public class MailService {
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendEmailFromTemplate(Map<String, Object> variables, String templateName, String subject, String email)
|
||||
private void sendEmailFromTemplate(Map<String, Object> variables, String templateName, String subject, String email)
|
||||
throws MessagingException {
|
||||
Context context = new Context();
|
||||
variables.entrySet().forEach(entry -> context.setVariable(entry.getKey(), entry.getValue()));
|
||||
|
@ -38,7 +38,7 @@ public class UserMapper {
|
||||
return new UserDto(userEntity);
|
||||
}
|
||||
|
||||
public UserListDto userEntityToUserListDto(User userEntity) {
|
||||
private UserListDto userEntityToUserListDto(User userEntity) {
|
||||
if (userEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ public class UserService implements UserDetailsService {
|
||||
if (getUserByEmail(userDto.getEmail()) != null) {
|
||||
throw new UserEmailExistsException(userDto.getEmail());
|
||||
}
|
||||
if (!userDto.isPasswordsValid()) {
|
||||
if (userDto.isPasswordsValid()) {
|
||||
throw new UserPasswordsNotValidOrNotMatchException("");
|
||||
}
|
||||
User user = userMapper.userDtoToUserEntity(userDto);
|
||||
@ -223,7 +223,7 @@ public class UserService implements UserDetailsService {
|
||||
? Collections.singleton(new UserRole(UserRoleConstants.USER))
|
||||
: roles);
|
||||
if (!StringUtils.isEmpty(userDto.getOldPassword())) {
|
||||
if (!userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) {
|
||||
if (userDto.isPasswordsValid() || !userDto.isOldPasswordValid()) {
|
||||
throw new UserPasswordsNotValidOrNotMatchException("");
|
||||
}
|
||||
if (!passwordEncoder.matches(userDto.getOldPassword(), user.getPassword())) {
|
||||
|
@ -16,9 +16,9 @@ import java.util.List;
|
||||
|
||||
public class TimetableService {
|
||||
private static final String TIMETABLE_URL = "http://timetable.athene.tech/api/1.0/timetable?filter=%s";
|
||||
private SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm");
|
||||
private final SimpleDateFormat lessonTimeFormat = new SimpleDateFormat("hh:mm");
|
||||
|
||||
private long[] lessonsStarts = new long[]{
|
||||
private final long[] lessonsStarts = new long[]{
|
||||
lessonTimeFormat.parse("8:00:00").getTime(),
|
||||
lessonTimeFormat.parse("9:40:00").getTime(),
|
||||
lessonTimeFormat.parse("11:30:00").getTime(),
|
||||
|
@ -365,7 +365,7 @@ header.masthead .intro-text .intro-heading {
|
||||
}
|
||||
|
||||
.portfolio-modal {
|
||||
padding-right: 0px !important;
|
||||
padding-right: 0 !important;
|
||||
}
|
||||
|
||||
.portfolio-modal .modal-dialog {
|
||||
|
@ -57,7 +57,7 @@ body {
|
||||
|
||||
.deadline-list {
|
||||
height: 200px;
|
||||
padding: 0px;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ body {
|
||||
|
||||
.member-list {
|
||||
height: 200px;
|
||||
padding: 0px;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
@ -135,7 +135,7 @@ body {
|
||||
|
||||
.paper-list {
|
||||
height: 200px;
|
||||
padding: 0px;
|
||||
padding: 0;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ body {
|
||||
}
|
||||
|
||||
.paper-name span:nth-child(1) {
|
||||
margin: 3px 0px 3px 10px;
|
||||
margin: 3px 0 3px 10px;
|
||||
float: left;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
.div-deadline-date {
|
||||
padding-right: 0px;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
.form-deadline-date {
|
||||
@ -16,7 +16,7 @@
|
||||
}
|
||||
|
||||
.div-selected-papers {
|
||||
border: 0px;
|
||||
border: 0;
|
||||
padding-left: 12px;
|
||||
}
|
||||
|
||||
|
@ -52,8 +52,7 @@
|
||||
Odin Paginator
|
||||
*/
|
||||
.odin-paginator {
|
||||
margin: 0;
|
||||
margin-top: 5px;
|
||||
margin: 5px 0 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@
|
||||
|
||||
.tag-name span[data-role="remove"]:after {
|
||||
content: "x";
|
||||
padding: 0px 2px;
|
||||
padding: 0 2px;
|
||||
}
|
||||
|
||||
.tag-name input[type="text"] {
|
||||
|
@ -89,11 +89,6 @@ function getFromRest(url, callBack, errorCallBack) {
|
||||
});
|
||||
}
|
||||
|
||||
/* exported getFromRestWithVersion */
|
||||
function getFromRest(url, callBack, errorCallBack) {
|
||||
getFromRestWithParams(url, "", callBack, errorCallBack);
|
||||
}
|
||||
|
||||
/* exported getFromRestWithVersionAndParams */
|
||||
function getFromRestWithParams(url, params, callBack, errorCallBack) {
|
||||
$.ajax({
|
||||
|
@ -126,7 +126,7 @@
|
||||
</div>
|
||||
</script>
|
||||
<script type="text/template" id="choseTable">
|
||||
<div id="table-block" class=\"panel-body odin-kill-padding\"></div>
|
||||
<div id="table-block" class="panel-body odin-kill-padding"></div>
|
||||
</script>
|
||||
<script type="text/template" id="formTabs">
|
||||
<ul class="nav nav-tabs">
|
||||
|
@ -68,7 +68,7 @@ public class PaperTest extends TestTemplate {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
String testTitle = "test " + (String.valueOf(System.currentTimeMillis()));
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
fillRequiredFields(paperPage, testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
@ -85,7 +85,7 @@ public class PaperTest extends TestTemplate {
|
||||
papersPage.clickFirstPaper();
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
String testTitle = "test " + (String.valueOf(System.currentTimeMillis()));
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
paperPage.setTitle(testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
@ -95,7 +95,7 @@ public class PaperTest extends TestTemplate {
|
||||
private void createNewPaper() {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
String testTitle = "test " + (String.valueOf(System.currentTimeMillis()));
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
fillRequiredFields(paperPage, testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
}
|
||||
@ -128,7 +128,7 @@ public class PaperTest extends TestTemplate {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
String testTitle = "test " + (String.valueOf(System.currentTimeMillis()));
|
||||
String testTitle = "test " + System.currentTimeMillis();
|
||||
paperPage.setTitle(testTitle);
|
||||
paperPage.clickSaveBtn();
|
||||
|
||||
@ -152,7 +152,7 @@ public class PaperTest extends TestTemplate {
|
||||
papersPage.clickFirstPaper();
|
||||
|
||||
PaperPage paperPage = getPaperPage();
|
||||
fillRequiredFields(paperPage, "test " + (String.valueOf(System.currentTimeMillis())));
|
||||
fillRequiredFields(paperPage, "test " + System.currentTimeMillis());
|
||||
paperPage.clickReferenceTab();
|
||||
paperPage.clickAddReferenceButton();
|
||||
|
||||
@ -197,7 +197,7 @@ public class PaperTest extends TestTemplate {
|
||||
getContext().goTo(applicationProperties.getBaseUrl() + getPaperPageUrl());
|
||||
PaperPage paperPage = getPaperPage();
|
||||
|
||||
fillRequiredFields(paperPage, "test " + (String.valueOf(System.currentTimeMillis())));
|
||||
fillRequiredFields(paperPage, "test " + System.currentTimeMillis());
|
||||
String testLink = "http://test.com/";
|
||||
paperPage.setUrl(testLink);
|
||||
paperPage.clickSaveBtn();
|
||||
|
@ -36,7 +36,7 @@ public class ConferencePage extends PageObject {
|
||||
driver.findElement(By.id("addDeadline")).click();
|
||||
}
|
||||
|
||||
public List<WebElement> getDeadlineList() {
|
||||
private List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.className("deadline"));
|
||||
}
|
||||
|
||||
|
@ -9,9 +9,9 @@ import java.util.concurrent.TimeUnit;
|
||||
public abstract class Context {
|
||||
private final static String DRIVER_LOCATION = "drivers/%s";
|
||||
|
||||
protected WebDriver driver;
|
||||
WebDriver driver;
|
||||
|
||||
protected WebDriver getDriver() {
|
||||
private WebDriver getDriver() {
|
||||
if (driver != null) {
|
||||
return driver;
|
||||
}
|
||||
@ -40,8 +40,8 @@ public abstract class Context {
|
||||
return getDriver().getTitle();
|
||||
}
|
||||
|
||||
public <T extends PageObject> T initPage(T pageObject) {
|
||||
return (T) pageObject.setDriver(getDriver());
|
||||
public <T extends PageObject> PageObject initPage(T pageObject) {
|
||||
return pageObject.setDriver(getDriver());
|
||||
}
|
||||
|
||||
protected abstract void createDriver();
|
||||
|
@ -9,7 +9,7 @@ import org.openqa.selenium.Dimension;
|
||||
public abstract class TestTemplate {
|
||||
private static Context context;
|
||||
|
||||
public static Context getContext() {
|
||||
protected static Context getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class GrantPage extends PageObject {
|
||||
return select.getAllSelectedOptions();
|
||||
}
|
||||
|
||||
public List<WebElement> getDeadlineList() {
|
||||
private List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.id("deadlines"));
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ public class ProjectPage extends PageObject {
|
||||
getFirstStatus();
|
||||
}
|
||||
|
||||
public void getFirstStatus() {
|
||||
private void getFirstStatus() {
|
||||
driver.findElement(By.xpath("//*[@id=\"status\"]/option[1]")).click();
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ public class ProjectPage extends PageObject {
|
||||
driver.findElement(By.id("repository")).sendKeys(link);
|
||||
}
|
||||
|
||||
public List<WebElement> getDeadlineList() {
|
||||
private List<WebElement> getDeadlineList() {
|
||||
return driver.findElements(By.className("deadline"));
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ public class ProjectPage extends PageObject {
|
||||
getFirstExecutor();
|
||||
}
|
||||
|
||||
public void getFirstExecutor() {
|
||||
private void getFirstExecutor() {
|
||||
driver.findElement(By.xpath("//*[@id=\"status\"]/option[1]")).click();
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class ProjectsPage extends PageObject {
|
||||
return driver.findElement(By.tagName("h2")).getText();
|
||||
}
|
||||
|
||||
public List<WebElement> getProjectsList() {
|
||||
private List<WebElement> getProjectsList() {
|
||||
return driver.findElements(By.cssSelector("span.h6"));
|
||||
}
|
||||
|
||||
|
@ -67,25 +67,18 @@ public class GrantServiceTest {
|
||||
private final static Integer MAX_DISPLAY_SIZE = 50;
|
||||
|
||||
private List<Grant> grants;
|
||||
private List<GrantDto> grantDtos;
|
||||
private List<Deadline> deadlines;
|
||||
private List<Paper> papers;
|
||||
private PaperDto paperDto;
|
||||
private List<PaperDto> paperDtos;
|
||||
private Set<User> authors;
|
||||
private GrantDto grantDto;
|
||||
private Deadline deadline;
|
||||
private User leader;
|
||||
private User author;
|
||||
|
||||
private Grant grantWithId;
|
||||
private Paper paperWithId;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
grants = new ArrayList<>();
|
||||
grantDtos = new ArrayList<>();
|
||||
paperDtos = new ArrayList<>();
|
||||
grantWithId = new Grant();
|
||||
|
||||
@ -96,16 +89,16 @@ public class GrantServiceTest {
|
||||
|
||||
leader = Mockito.mock(User.class);
|
||||
|
||||
papers = new ArrayList<>();
|
||||
paperWithId = new Paper();
|
||||
List<Paper> papers = new ArrayList<>();
|
||||
Paper paperWithId = new Paper();
|
||||
paperWithId.setId(ID);
|
||||
paperWithId.setTitle(TITLE);
|
||||
papers.add(paperWithId);
|
||||
paperDto = new PaperDto(paperWithId);
|
||||
PaperDto paperDto = new PaperDto(paperWithId);
|
||||
paperDtos.add(paperDto);
|
||||
|
||||
authors = new HashSet<>();
|
||||
author = leader;
|
||||
Set<User> authors = new HashSet<>();
|
||||
User author = leader;
|
||||
authors.add(author);
|
||||
|
||||
grantWithId.setId(ID);
|
||||
@ -118,7 +111,6 @@ public class GrantServiceTest {
|
||||
|
||||
grants.add(grantWithId);
|
||||
grantDto = new GrantDto(grantWithId);
|
||||
grantDtos.add(grantDto);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -67,8 +67,6 @@ public class ProjectServiceTest {
|
||||
private FileData file;
|
||||
private List<FileData> files;
|
||||
private User user;
|
||||
private GrantDto grant;
|
||||
private List<GrantDto> grants;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
@ -86,8 +84,8 @@ public class ProjectServiceTest {
|
||||
user = new User();
|
||||
user.setFirstName(NAME);
|
||||
|
||||
grants = new ArrayList<>();
|
||||
grant = new GrantDto();
|
||||
List<GrantDto> grants = new ArrayList<>();
|
||||
GrantDto grant = new GrantDto();
|
||||
grant.setId(ID);
|
||||
grants.add(grant);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class TaskPage extends PageObject {
|
||||
driver.findElement(By.cssSelector("#addDeadline")).click();
|
||||
}
|
||||
|
||||
public List<WebElement> getDeadlines() {
|
||||
private List<WebElement> getDeadlines() {
|
||||
return driver.findElements(By.cssSelector(".form-group:nth-of-type(5) .row"));
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class TasksPage extends PageObject {
|
||||
return driver.findElements(By.cssSelector("span.h6"));
|
||||
}
|
||||
|
||||
public List<WebElement> getTaskRows() {
|
||||
private List<WebElement> getTaskRows() {
|
||||
return driver.findElements(By.className("task-row"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user