ng-tracker/src/main/java/ru/ulstu/paper/service/PaperCreateStrategy.java
Anton Romanov 9380b74f67 move class
2018-11-11 12:43:27 +04:00

32 lines
1010 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package ru.ulstu.paper.service;
import org.springframework.stereotype.Service;
import ru.ulstu.core.util.DateUtils;
import ru.ulstu.paper.model.Paper;
import ru.ulstu.strategy.api.EntityCreateStrategy;
import ru.ulstu.user.model.User;
import java.util.Date;
import java.util.List;
@Service
public class PaperCreateStrategy extends EntityCreateStrategy<Paper> {
private static final String DEFAULT_NAME = "Статья создана автоматически, т.к. у вас не найдено статей";
private static final int DEFAULT_DEADLINE_DAYS = 14;
private final PaperService paperService;
public PaperCreateStrategy(PaperService paperService) {
this.paperService = paperService;
}
@Override
protected List<Paper> getActiveEntities() {
return paperService.findAll();
}
@Override
protected void createEntity(User user) {
paperService.create(DEFAULT_NAME, user, DateUtils.addDays(new Date(), DEFAULT_DEADLINE_DAYS));
}
}