@ -0,0 +1,165 @@
|
||||
{
|
||||
// JSHint Default Configuration File (as on JSHint website)
|
||||
// See http://jshint.com/docs/ for more details
|
||||
|
||||
"maxerr": 50,
|
||||
// {int} Maximum error before stopping
|
||||
|
||||
// Enforcing
|
||||
"bitwise": true,
|
||||
// true: Prohibit bitwise operators (&, |, ^, etc.)
|
||||
"camelcase": false,
|
||||
// true: Identifiers must be in camelCase
|
||||
"curly": true,
|
||||
// true: Require {} for every new block or scope
|
||||
"eqeqeq": true,
|
||||
// true: Require triple equals (===) for comparison
|
||||
"forin": true,
|
||||
// true: Require filtering for..in loops with obj.hasOwnProperty()
|
||||
"freeze": true,
|
||||
// true: prohibits overwriting prototypes of native objects such as Array, Date etc.
|
||||
"immed": false,
|
||||
// true: Require immediate invocations to be wrapped in parens e.g. `(function () { } ());`
|
||||
"latedef": false,
|
||||
// true: Require variables/functions to be defined before being used
|
||||
"newcap": false,
|
||||
// true: Require capitalization of all constructor functions e.g. `new F()`
|
||||
"noarg": true,
|
||||
// true: Prohibit use of `arguments.caller` and `arguments.callee`
|
||||
"noempty": true,
|
||||
// true: Prohibit use of empty blocks
|
||||
"nonbsp": true,
|
||||
// true: Prohibit "non-breaking whitespace" characters.
|
||||
"nonew": false,
|
||||
// true: Prohibit use of constructors for side-effects (without assignment)
|
||||
"plusplus": false,
|
||||
// true: Prohibit use of `++` and `--`
|
||||
"quotmark": false,
|
||||
// Quotation mark consistency:
|
||||
// false : do nothing (default)
|
||||
// true : ensure whatever is used is consistent
|
||||
// "single" : require single quotes
|
||||
// "double" : require double quotes
|
||||
"undef": true,
|
||||
// true: Require all non-global variables to be declared (prevents global leaks)
|
||||
"unused": true,
|
||||
// Unused variables:
|
||||
// true : all variables, last function parameter
|
||||
// "vars" : all variables only
|
||||
// "strict" : all variables, all function parameters
|
||||
"strict": false,
|
||||
// true: Requires all functions run in ES5 Strict Mode
|
||||
"maxparams": false,
|
||||
// {int} Max number of formal params allowed per function
|
||||
"maxdepth": false,
|
||||
// {int} Max depth of nested blocks (within functions)
|
||||
"maxstatements": false,
|
||||
// {int} Max number statements per function
|
||||
"maxcomplexity": false,
|
||||
// {int} Max cyclomatic complexity per function
|
||||
"maxlen": false,
|
||||
// {int} Max number of characters per line
|
||||
"varstmt": false,
|
||||
// true: Disallow any var statements. Only `let` and `const` are allowed.
|
||||
|
||||
// Relaxing
|
||||
"asi": false,
|
||||
// true: Tolerate Automatic Semicolon Insertion (no semicolons)
|
||||
"boss": false,
|
||||
// true: Tolerate assignments where comparisons would be expected
|
||||
"debug": false,
|
||||
// true: Allow debugger statements e.g. browser breakpoints.
|
||||
"eqnull": true,
|
||||
// true: Tolerate use of `== null`
|
||||
"esversion": 5,
|
||||
// {int} Specify the ECMAScript version to which the code must adhere.
|
||||
"moz": false,
|
||||
// true: Allow Mozilla specific syntax (extends and overrides esnext features)
|
||||
// (ex: `for each`, multiple try/catch, function expression…)
|
||||
"evil": false,
|
||||
// true: Tolerate use of `eval` and `new Function()`
|
||||
"expr": false,
|
||||
// true: Tolerate `ExpressionStatement` as Programs
|
||||
"funcscope": false,
|
||||
// true: Tolerate defining variables inside control statements
|
||||
"globalstrict": false,
|
||||
// true: Allow global "use strict" (also enables 'strict')
|
||||
"iterator": false,
|
||||
// true: Tolerate using the `__iterator__` property
|
||||
"lastsemic": false,
|
||||
// true: Tolerate omitting a semicolon for the last statement of a 1-line block
|
||||
"laxbreak": false,
|
||||
// true: Tolerate possibly unsafe line breakings
|
||||
"laxcomma": false,
|
||||
// true: Tolerate comma-first style coding
|
||||
"loopfunc": false,
|
||||
// true: Tolerate functions being defined in loops
|
||||
"multistr": false,
|
||||
// true: Tolerate multi-line strings
|
||||
"noyield": false,
|
||||
// true: Tolerate generator functions with no yield statement in them.
|
||||
"notypeof": false,
|
||||
// true: Tolerate invalid typeof operator values
|
||||
"proto": false,
|
||||
// true: Tolerate using the `__proto__` property
|
||||
"scripturl": false,
|
||||
// true: Tolerate script-targeted URLs
|
||||
"shadow": false,
|
||||
// true: Allows re-define variables later in code e.g. `var x=1; x=2;`
|
||||
"sub": false,
|
||||
// true: Tolerate using `[]` notation when it can still be expressed in dot notation
|
||||
"supernew": false,
|
||||
// true: Tolerate `new function () { ... };` and `new Object;`
|
||||
"validthis": false,
|
||||
// true: Tolerate using this in a non-constructor function
|
||||
|
||||
// Environments
|
||||
"browser": true,
|
||||
// Web Browser (window, document, etc)
|
||||
"browserify": false,
|
||||
// Browserify (node.js code in the browser)
|
||||
"couch": false,
|
||||
// CouchDB
|
||||
"devel": true,
|
||||
// Development/debugging (alert, confirm, etc)
|
||||
"dojo": false,
|
||||
// Dojo Toolkit
|
||||
"jasmine": false,
|
||||
// Jasmine
|
||||
"jquery": true,
|
||||
// jQuery
|
||||
"mocha": false,
|
||||
// Mocha
|
||||
"mootools": false,
|
||||
// MooTools
|
||||
"node": false,
|
||||
// Node.js
|
||||
"nonstandard": false,
|
||||
// Widely adopted globals (escape, unescape, etc)
|
||||
"phantom": false,
|
||||
// PhantomJS
|
||||
"prototypejs": false,
|
||||
// Prototype and Scriptaculous
|
||||
"qunit": false,
|
||||
// QUnit
|
||||
"rhino": false,
|
||||
// Rhino
|
||||
"shelljs": false,
|
||||
// ShellJS
|
||||
"typed": false,
|
||||
// Globals for typed array constructions
|
||||
"worker": false,
|
||||
// Web Workers
|
||||
"wsh": false,
|
||||
// Windows Scripting Host
|
||||
"yui": false,
|
||||
// Yahoo User Interface
|
||||
|
||||
// Custom Globals
|
||||
"globals": {
|
||||
"spc": false,
|
||||
"spsn": false,
|
||||
"spconf": false
|
||||
}
|
||||
// additional predefined global variables
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# to run this execute
|
||||
# export PSQL_HOME_DIR=/home/user/pgsql-10.5.1; bash ./deploy/run_psql.sh
|
||||
PSQL_DATA_DIR=./ng-tracker
|
||||
PSQL_USER_NAME=postgres
|
||||
PSQL_DB_NAME=ng-tracker
|
||||
if [ ! -d "$PSQL_HOME_DIR" ]; then
|
||||
echo "Directory $PSQL_HOME_DIR is not exists"
|
||||
exit 0
|
||||
fi
|
||||
cd "$PSQL_HOME_DIR"
|
||||
if [ ! -d "$PSQL_DATA_DIR" ]; then
|
||||
./bin/initdb "$PSQL_DATA_DIR"
|
||||
./bin/pg_ctl -D "$PSQL_DATA_DIR" start
|
||||
./bin/createuser -s "$PSQL_USER_NAME"
|
||||
./bin/createdb -O "$PSQL_USER_NAME" "$PSQL_DB_NAME"
|
||||
else
|
||||
PSQL_STATUS=$(./bin/pg_ctl -D "$PSQL_DATA_DIR" status | wc -l)
|
||||
if [ $PSQL_STATUS -eq 1 ]; then
|
||||
./bin/pg_ctl -D "$PSQL_DATA_DIR" start
|
||||
else
|
||||
./bin/pg_ctl -D "$PSQL_DATA_DIR" stop
|
||||
fi
|
||||
fi
|
@ -0,0 +1,23 @@
|
||||
package ru.ulstu.activity.api;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface ActivityRepository<T> {
|
||||
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||
|
||||
T save(T t);
|
||||
|
||||
T getById(Integer id);
|
||||
|
||||
Page<T> findAll(Pageable pageable);
|
||||
|
||||
void deleteById(Integer id);
|
||||
|
||||
Optional<T> findById(Integer id);
|
||||
|
||||
void detach(T t);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ru.ulstu.activity.api.model;
|
||||
|
||||
public abstract class ActivityDashboardDto {
|
||||
private final Integer id;
|
||||
private final String title;
|
||||
|
||||
protected ActivityDashboardDto(Integer id, String title) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package ru.ulstu.activity.api.model;
|
||||
|
||||
public abstract class ActivityDto {
|
||||
private final Integer id;
|
||||
|
||||
public ActivityDto(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ru.ulstu.activity.api.model;
|
||||
|
||||
public abstract class ActivityListDto {
|
||||
private final Integer id;
|
||||
private final String title;
|
||||
|
||||
protected ActivityListDto(Integer id, String title) {
|
||||
this.id = id;
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
package ru.ulstu.utils.timetable;
|
||||
package ru.ulstu.activity.boundary.timetable;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
import ru.ulstu.activity.boundary.timetable.errors.TimetableClientException;
|
||||
import ru.ulstu.activity.boundary.timetable.model.Lesson;
|
||||
import ru.ulstu.activity.boundary.timetable.model.TimetableResponse;
|
||||
import ru.ulstu.core.util.DateUtils;
|
||||
import ru.ulstu.utils.timetable.errors.TimetableClientException;
|
||||
import ru.ulstu.utils.timetable.model.Lesson;
|
||||
import ru.ulstu.utils.timetable.model.TimetableResponse;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.errors;
|
||||
package ru.ulstu.activity.boundary.timetable.errors;
|
||||
|
||||
public class TimetableClientException extends RuntimeException {
|
||||
public TimetableClientException(String message) {
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.model;
|
||||
package ru.ulstu.activity.boundary.timetable.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.model;
|
||||
package ru.ulstu.activity.boundary.timetable.model;
|
||||
|
||||
public class Lesson {
|
||||
private String group;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.model;
|
||||
package ru.ulstu.activity.boundary.timetable.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.model;
|
||||
package ru.ulstu.activity.boundary.timetable.model;
|
||||
|
||||
public class TimetableResponse {
|
||||
private Response response;
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.utils.timetable.model;
|
||||
package ru.ulstu.activity.boundary.timetable.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
@ -0,0 +1,24 @@
|
||||
package ru.ulstu.activity.common.model;
|
||||
|
||||
import ru.ulstu.activity.timeline.model.Event;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class AbstractActivity extends BaseEntity {
|
||||
private String title;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public abstract Set<User> getActivityMembers();
|
||||
|
||||
public abstract List<Event> getEvents();
|
||||
}
|
@ -0,0 +1,77 @@
|
||||
package ru.ulstu.activity.common.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Size;
|
||||
|
||||
public class ScienceGroupMemberDto {
|
||||
|
||||
private Integer id;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 50)
|
||||
private String firstName;
|
||||
|
||||
@NotBlank
|
||||
@Size(min = 2, max = 50)
|
||||
private String lastName;
|
||||
|
||||
@JsonCreator
|
||||
public ScienceGroupMemberDto(@JsonProperty("id") Integer id,
|
||||
@JsonProperty("firstName") String firstName,
|
||||
@JsonProperty("lastName") String lastName) {
|
||||
this.id = id;
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public ScienceGroupMemberDto(User user) {
|
||||
this.id = user.getId();
|
||||
this.firstName = user.getFirstName();
|
||||
this.lastName = user.getLastName();
|
||||
}
|
||||
|
||||
public ScienceGroupMemberDto(ConferenceUser conferenceUser) {
|
||||
User user = conferenceUser.getUser();
|
||||
this.id = user.getId();
|
||||
this.firstName = user.getFirstName();
|
||||
this.lastName = user.getLastName();
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ScienceGroupMember{" +
|
||||
"id=" + id +
|
||||
", firstName='" + firstName + '\'' +
|
||||
", lastName='" + lastName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package ru.ulstu.activity.common.service;
|
||||
|
||||
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.MailService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class ActivityNotificationService<T extends AbstractActivity> {
|
||||
private final MailService mailService;
|
||||
|
||||
protected ActivityNotificationService(MailService mailService) {
|
||||
this.mailService = mailService;
|
||||
}
|
||||
|
||||
public abstract void sendCreateNotification(T entity);
|
||||
|
||||
protected void sendForAuthor(Map<String, Object> variables, User author, String template, String title) {
|
||||
mailService.sendEmailFromTemplate(variables, author, template, title);
|
||||
}
|
||||
|
||||
protected void sendForAllAuthors(Map<String, Object> variables, T entity, String template, String title) {
|
||||
entity.getActivityMembers().forEach(author -> sendForAuthor(variables, author, template, title));
|
||||
}
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package ru.ulstu.activity.common.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.activity.api.ActivityRepository;
|
||||
import ru.ulstu.activity.api.model.ActivityDto;
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||
import ru.ulstu.activity.common.model.EventSource;
|
||||
import ru.ulstu.activity.ping.service.PingService;
|
||||
import ru.ulstu.activity.timeline.model.Event;
|
||||
import ru.ulstu.activity.timeline.service.EventService;
|
||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
|
||||
import javax.persistence.EntityNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||
|
||||
public abstract class ActivityService<L extends ActivityListDto, T extends AbstractActivity, D extends ActivityDto> {
|
||||
|
||||
protected final ActivityRepository<T> activityRepository;
|
||||
protected final ActivityNotificationService<T> activityNotificationService;
|
||||
protected final PingService pingService;
|
||||
protected final EventService eventService;
|
||||
|
||||
protected ActivityService(ActivityRepository activityRepository,
|
||||
ActivityNotificationService<T> activityNotificationService,
|
||||
PingService pingService,
|
||||
EventService eventService) {
|
||||
this.activityRepository = activityRepository;
|
||||
this.activityNotificationService = activityNotificationService;
|
||||
this.pingService = pingService;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public D create(D entityDto) {
|
||||
T newEntity;
|
||||
try {
|
||||
newEntity = copyFromDto(getNewActivity(), entityDto);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return getNewActivityDto(create(newEntity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public T update(T oldEntity, T entity) {
|
||||
entity.getEvents().clear();
|
||||
eventService.deleteAll(getEvents(entity));
|
||||
eventService.createFromObject((EventSource) entity);
|
||||
doActionsOnDiffObjects(oldEntity, entity);
|
||||
return activityRepository.save(entity);
|
||||
}
|
||||
|
||||
protected abstract void doActionsOnDiffObjects(T oldEntity, T entity);
|
||||
|
||||
protected abstract List<Event> getEvents(T entity);
|
||||
|
||||
@Transactional
|
||||
public D update(D entityDto) {
|
||||
T oldEntity = activityRepository.getById(entityDto.getId());
|
||||
//to init lazy collection
|
||||
oldEntity.getActivityMembers().size();
|
||||
activityRepository.detach(oldEntity);
|
||||
T newEntity;
|
||||
try {
|
||||
newEntity = copyFromDto(activityRepository.getById(entityDto.getId()), entityDto);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return getNewActivityDto(update(oldEntity, newEntity));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public T create(T entity) {
|
||||
eventService.createFromObject((EventSource) entity);
|
||||
T newEntity = activityRepository.save(entity);
|
||||
activityNotificationService.sendCreateNotification(newEntity);
|
||||
return newEntity;
|
||||
}
|
||||
|
||||
public boolean delete(Integer id) {
|
||||
activityRepository.deleteById(id);
|
||||
return true;
|
||||
}
|
||||
|
||||
public D findDtoById(Integer id) {
|
||||
return getNewActivityDto(findById(id));
|
||||
}
|
||||
|
||||
public T findById(Integer id) {
|
||||
return activityRepository.findById(id)
|
||||
.orElseThrow(() -> new EntityNotFoundException("Entity with id=" + id + " not found"));
|
||||
}
|
||||
|
||||
public PageableItems<T> findAll(int offset, int count) {
|
||||
final Page<T> page = activityRepository.findAll(new OffsetablePageRequest(offset, count));
|
||||
return new PageableItems<>(page.getTotalElements(), page.getContent());
|
||||
}
|
||||
|
||||
public PageableItems<L> findAllDto(int offset, int count) {
|
||||
return convertPageable(findAll(offset, count), entity -> getActivityListDto(entity));
|
||||
}
|
||||
|
||||
public abstract PageableItems findAllActiveDto(int offset, int count);
|
||||
|
||||
public abstract PageableItems<T> findAllActive(int offset, int count);
|
||||
|
||||
protected abstract T copyFromDto(T t, D d) throws IOException;
|
||||
|
||||
protected abstract L getActivityListDto(T entity);
|
||||
|
||||
protected abstract T getNewActivity();
|
||||
|
||||
protected abstract D getNewActivityDto(T entity);
|
||||
|
||||
protected boolean checkUniqueName(String title, Integer id) {
|
||||
return title.equals(activityRepository.findByNameAndNotId(title, id));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void ping(int entityId) {
|
||||
pingService.addPing(findById(entityId));
|
||||
}
|
||||
}
|
@ -1,21 +1,21 @@
|
||||
package ru.ulstu.strategy.api;
|
||||
package ru.ulstu.activity.common.strategy.api;
|
||||
|
||||
import ru.ulstu.core.model.UserActivity;
|
||||
import ru.ulstu.activity.common.model.AbstractActivity;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class EntityCreateStrategy<T extends UserActivity> {
|
||||
public abstract class EntityCreateStrategy<T extends AbstractActivity> {
|
||||
protected abstract List<T> getActiveEntities();
|
||||
|
||||
protected abstract void createEntity(User user);
|
||||
|
||||
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends UserActivity> entities) {
|
||||
private void createDefaultEntityIfNeed(List<User> allUsers, List<? extends AbstractActivity> entities) {
|
||||
allUsers.forEach(user -> {
|
||||
if (entities
|
||||
.stream()
|
||||
.filter(entity -> entity.getActivityUsers().contains(user))
|
||||
.filter(entity -> entity.getActivityMembers().contains(user))
|
||||
.collect(Collectors.toSet()).isEmpty()) {
|
||||
createEntity(user);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.strategy.api;
|
||||
package ru.ulstu.activity.common.strategy.api;
|
||||
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
@ -0,0 +1,70 @@
|
||||
package ru.ulstu.activity.conference.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import ru.ulstu.activity.api.ActivityController;
|
||||
import ru.ulstu.activity.conference.model.ConferenceDashboardDto;
|
||||
import ru.ulstu.activity.conference.model.ConferenceDto;
|
||||
import ru.ulstu.activity.conference.model.ConferenceListDto;
|
||||
import ru.ulstu.activity.conference.service.ConferenceService;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
public class ConferenceController implements ActivityController<ConferenceListDto, ConferenceDashboardDto, ConferenceDto> {
|
||||
|
||||
private final ConferenceService conferenceService;
|
||||
|
||||
public ConferenceController(ConferenceService conferenceService) {
|
||||
this.conferenceService = conferenceService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("list")
|
||||
public Response<PageableItems<ConferenceListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "0") int count) {
|
||||
return new Response<>(conferenceService.findAllDto(offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("dashboard")
|
||||
public Response<PageableItems<ConferenceDashboardDto>> getDashboard(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "0") int count) {
|
||||
return new Response<>(conferenceService.findAllActiveDto(offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("{conference-id}")
|
||||
public Response<ConferenceDto> get(@PathVariable("conference-id") Integer entityId) {
|
||||
return new Response<>(conferenceService.findConferenceById(entityId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping
|
||||
public Response<ConferenceDto> create(@RequestBody @Valid ConferenceDto entity) {
|
||||
return new Response<>(conferenceService.create(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PutMapping
|
||||
public Response<ConferenceDto> update(@RequestBody @Valid ConferenceDto entity) {
|
||||
return new Response<>(conferenceService.update(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeleteMapping("{conference-id}")
|
||||
public Response<Boolean> delete(@PathVariable("conference-id") Integer entityId) {
|
||||
return new Response<>(conferenceService.delete(entityId));
|
||||
}
|
||||
|
||||
@PostMapping("ping/{conference-id}")
|
||||
public void ping(@PathVariable("conference-id") int conferenceId) {
|
||||
conferenceService.ping(conferenceId);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package ru.ulstu.activity.conference.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class ConferenceDashboardDto extends ActivityDashboardDto {
|
||||
private final Set<ScienceGroupMemberDto> members;
|
||||
|
||||
public ConferenceDashboardDto(Conference conference) {
|
||||
super(conference.getId(), conference.getTitle());
|
||||
this.members = convert(conference.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return members;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.conference.model;
|
||||
package ru.ulstu.activity.conference.model;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,21 @@
|
||||
package ru.ulstu.activity.conference.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class ConferenceListDto extends ActivityListDto {
|
||||
private final Set<ScienceGroupMemberDto> members;
|
||||
|
||||
public ConferenceListDto(Conference conference) {
|
||||
super(conference.getId(), conference.getTitle());
|
||||
this.members = convert(conference.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return members;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.conference.model;
|
||||
package ru.ulstu.activity.conference.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,7 +1,7 @@
|
||||
package ru.ulstu.conference.repository;
|
||||
package ru.ulstu.activity.conference.repository;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||
|
||||
public interface ConferenceUserRepository extends JpaRepository<ConferenceUser, Integer> {
|
||||
}
|
@ -1,23 +1,25 @@
|
||||
package ru.ulstu.conference.repository;
|
||||
package ru.ulstu.activity.conference.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Modifying;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.name.BaseRepository;
|
||||
import ru.ulstu.activity.api.ActivityRepository;
|
||||
import ru.ulstu.activity.conference.model.Conference;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface ConferenceRepository extends JpaRepository<Conference, Integer>, BaseRepository {
|
||||
interface ConferenceRepository extends JpaRepository<Conference, Integer>, ActivityRepository<Conference> {
|
||||
@Query("SELECT c FROM Conference c LEFT JOIN c.users u WHERE (:user IS NULL OR u.user = :user) " +
|
||||
"AND (YEAR(c.beginDate) = :year OR :year IS NULL) ORDER BY begin_date DESC")
|
||||
List<Conference> findByUserAndYear(@Param("user") User user, @Param("year") Integer year);
|
||||
|
||||
@Query("SELECT c FROM Conference c WHERE c.beginDate > :date")
|
||||
List<Conference> findAllActive(@Param("date") Date date);
|
||||
Page<Conference> findAllActive(Pageable pageable, @Param("date") Date date);
|
||||
|
||||
@Query("SELECT case when count(c) > 0 then true else false end FROM Conference c JOIN c.papers p WHERE p.id = :paperId")
|
||||
boolean isPaperAttached(@Param("paperId") Integer paperId);
|
@ -0,0 +1,154 @@
|
||||
package ru.ulstu.activity.conference.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.activity.common.service.ActivityService;
|
||||
import ru.ulstu.activity.conference.model.Conference;
|
||||
import ru.ulstu.activity.conference.model.ConferenceDashboardDto;
|
||||
import ru.ulstu.activity.conference.model.ConferenceDto;
|
||||
import ru.ulstu.activity.conference.model.ConferenceFilterDto;
|
||||
import ru.ulstu.activity.conference.model.ConferenceListDto;
|
||||
import ru.ulstu.activity.deadline.model.Deadline;
|
||||
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||
import ru.ulstu.activity.paper.service.PaperService;
|
||||
import ru.ulstu.activity.ping.service.PingService;
|
||||
import ru.ulstu.activity.timeline.model.Event;
|
||||
import ru.ulstu.activity.timeline.service.EventService;
|
||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||
|
||||
@Service
|
||||
public class ConferenceService extends ActivityService<ConferenceListDto, Conference, ConferenceDto> {
|
||||
|
||||
private final ConferenceRepository conferenceRepository;
|
||||
private final ConferenceUserService conferenceUserService;
|
||||
private final DeadlineService deadlineService;
|
||||
private final PaperService paperService;
|
||||
private final UserService userService;
|
||||
private final PingService pingService;
|
||||
private final ConferenceNotificationService conferenceNotificationService;
|
||||
private final EventService eventService;
|
||||
|
||||
public ConferenceService(ConferenceRepository conferenceRepository,
|
||||
ConferenceUserService conferenceUserService,
|
||||
DeadlineService deadlineService,
|
||||
PaperService paperService,
|
||||
UserService userService,
|
||||
PingService pingService,
|
||||
ConferenceNotificationService conferenceNotificationService,
|
||||
EventService eventService) {
|
||||
super(conferenceRepository, conferenceNotificationService, pingService, eventService);
|
||||
this.conferenceRepository = conferenceRepository;
|
||||
this.conferenceUserService = conferenceUserService;
|
||||
this.deadlineService = deadlineService;
|
||||
this.paperService = paperService;
|
||||
this.userService = userService;
|
||||
this.pingService = pingService;
|
||||
this.conferenceNotificationService = conferenceNotificationService;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConferenceListDto getActivityListDto(Conference entity) {
|
||||
return new ConferenceListDto(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Conference getNewActivity() {
|
||||
return new Conference();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConferenceDto getNewActivityDto(Conference entity) {
|
||||
return new ConferenceDto(entity);
|
||||
}
|
||||
|
||||
protected Conference copyFromDto(Conference conference, ConferenceDto conferenceDto) throws IOException {
|
||||
conference.setTitle(conferenceDto.getTitle());
|
||||
conference.setDescription(conferenceDto.getDescription());
|
||||
conference.setUrl(conferenceDto.getUrl());
|
||||
conference.setBeginDate(conferenceDto.getBeginDate());
|
||||
conference.setEndDate(conferenceDto.getEndDate());
|
||||
conference.getPapers().clear();
|
||||
conferenceDto.getPaperIds().forEach(paperId -> conference.getPapers().add(paperService.findById(paperId)));
|
||||
conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines()));
|
||||
conference.setUsers(conferenceUserService.saveOrCreate(conferenceDto.getUsers()));
|
||||
if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) {
|
||||
conferenceDto.getPaperIds().forEach(paperId ->
|
||||
conference.getPapers().add(paperService.findById(paperId)));
|
||||
}
|
||||
return conference;
|
||||
}
|
||||
|
||||
public List<ConferenceDto> filter(ConferenceFilterDto conferenceFilterDto) {
|
||||
return convert(conferenceRepository.findByUserAndYear(
|
||||
conferenceFilterDto.getFilterUserId() == null ? null : userService.findById(conferenceFilterDto.getFilterUserId()),
|
||||
conferenceFilterDto.getYear()), ConferenceDto::new);
|
||||
|
||||
}
|
||||
|
||||
public PageableItems<ConferenceDashboardDto> findAllActiveDto(int offset, int count) {
|
||||
return convertPageable(findAllActive(offset, count), ConferenceDashboardDto::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableItems<Conference> findAllActive(int offset, int count) {
|
||||
Page<Conference> activeConferencePage = conferenceRepository
|
||||
.findAllActive(new OffsetablePageRequest(offset, count), new Date());
|
||||
return new PageableItems<>(activeConferencePage.getTotalElements(), activeConferencePage.getContent());
|
||||
}
|
||||
|
||||
public ConferenceDto findConferenceById(Integer id) {
|
||||
return new ConferenceDto(findById(id));
|
||||
}
|
||||
|
||||
public Conference findById(Integer id) {
|
||||
return conferenceRepository.getOne(id);
|
||||
}
|
||||
|
||||
public Conference getActiveConferenceByUser(User user) {
|
||||
return conferenceRepository.findActiveByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionsOnDiffObjects(Conference oldEntity, Conference entity) {
|
||||
if (!entity.getBeginDate().equals(oldEntity.getBeginDate())
|
||||
|| !entity.getEndDate().equals(oldEntity.getEndDate())) {
|
||||
conferenceNotificationService.updateConferencesDatesNotification(entity, oldEntity.getBeginDate(), oldEntity.getEndDate());
|
||||
}
|
||||
entity.getActivityMembers().forEach(author -> {
|
||||
if (!oldEntity.getActivityMembers().contains(author)) {
|
||||
conferenceNotificationService.sendCreateNotification(entity);
|
||||
}
|
||||
});
|
||||
sendNotificationAfterUpdateDeadlines(entity, oldEntity.getDeadlines());
|
||||
}
|
||||
|
||||
private void sendNotificationAfterUpdateDeadlines(Conference conference, List<Deadline> oldDeadlines) {
|
||||
if (oldDeadlines.size() != conference.getDeadlines().size()) {
|
||||
conferenceNotificationService.updateDeadlineNotification(conference);
|
||||
return;
|
||||
}
|
||||
|
||||
if (conference.getDeadlines()
|
||||
.stream()
|
||||
.filter(deadline -> !oldDeadlines.contains(deadline))
|
||||
.count() > 0) {
|
||||
conferenceNotificationService.updateDeadlineNotification(conference);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Event> getEvents(Conference entity) {
|
||||
return eventService.findByConference(entity);
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package ru.ulstu.conference.service;
|
||||
package ru.ulstu.activity.conference.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.conference.model.ConferenceUser;
|
||||
import ru.ulstu.conference.repository.ConferenceUserRepository;
|
||||
import ru.ulstu.activity.conference.model.ConferenceUser;
|
||||
import ru.ulstu.activity.conference.repository.ConferenceUserRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
@ -0,0 +1,61 @@
|
||||
package ru.ulstu.activity.deadline.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class DeadlineDto {
|
||||
private final Integer id;
|
||||
private final Date date;
|
||||
private final String description;
|
||||
private final List<Integer> executorsIds;
|
||||
private final Boolean done;
|
||||
|
||||
public DeadlineDto() {
|
||||
this.id = null;
|
||||
this.date = null;
|
||||
this.description = null;
|
||||
this.executorsIds = new ArrayList<>();
|
||||
this.done = false;
|
||||
}
|
||||
|
||||
public DeadlineDto(Deadline deadline) {
|
||||
this.id = deadline.getId();
|
||||
this.date = deadline.getDate();
|
||||
this.description = deadline.getDescription();
|
||||
this.executorsIds = deadline.getExecutors()
|
||||
.stream()
|
||||
.map(executor -> executor.getId())
|
||||
.collect(Collectors.toList());
|
||||
this.done = deadline.isDone();
|
||||
}
|
||||
|
||||
public DeadlineDto(Date date, String description) {
|
||||
this.id = null;
|
||||
this.date = date;
|
||||
this.description = description;
|
||||
this.executorsIds = new ArrayList<>();
|
||||
this.done = false;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public List<Integer> getExecutorsIds() {
|
||||
return executorsIds;
|
||||
}
|
||||
|
||||
public Boolean isDone() {
|
||||
return done;
|
||||
}
|
||||
}
|
@ -1,14 +1,14 @@
|
||||
package ru.ulstu.deadline.repository;
|
||||
package ru.ulstu.activity.deadline.service;
|
||||
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.deadline.model.Deadline;
|
||||
import ru.ulstu.activity.deadline.model.Deadline;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public interface DeadlineRepository extends JpaRepository<Deadline, Integer> {
|
||||
interface DeadlineRepository extends JpaRepository<Deadline, Integer> {
|
||||
|
||||
@Query("SELECT d.date FROM Grant g JOIN g.deadlines d WHERE (g.id = :id) AND (d.date = :date)")
|
||||
Date findByGrantIdAndDate(@Param("id") Integer grantId, @Param("date") Date date);
|
@ -0,0 +1,65 @@
|
||||
package ru.ulstu.activity.deadline.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.activity.deadline.model.Deadline;
|
||||
import ru.ulstu.activity.deadline.model.DeadlineDto;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DeadlineService {
|
||||
private final DeadlineRepository deadlineRepository;
|
||||
private final UserService userService;
|
||||
|
||||
public DeadlineService(DeadlineRepository deadlineRepository,
|
||||
UserService userService) {
|
||||
this.deadlineRepository = deadlineRepository;
|
||||
this.userService = userService;
|
||||
}
|
||||
|
||||
public List<Deadline> saveOrCreate(List<DeadlineDto> deadlines) {
|
||||
return deadlines
|
||||
.stream()
|
||||
.map(deadline -> {
|
||||
return deadline.getId() != null ? update(deadline) : create(deadline);
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Deadline update(DeadlineDto deadlineDto) {
|
||||
Deadline updateDeadline = deadlineRepository.getOne(deadlineDto.getId());
|
||||
deadlineRepository.save(copyFromDto(updateDeadline, deadlineDto));
|
||||
return updateDeadline;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Deadline create(DeadlineDto deadlineDto) {
|
||||
return deadlineRepository.save(copyFromDto(new Deadline(), deadlineDto));
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Deadline create(Deadline deadline) {
|
||||
return deadlineRepository.save(deadline);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void remove(Integer deadlineId) {
|
||||
deadlineRepository.deleteById(deadlineId);
|
||||
}
|
||||
|
||||
private Deadline copyFromDto(Deadline deadline, DeadlineDto deadlineDto) {
|
||||
deadline.setDate(deadlineDto.getDate());
|
||||
deadline.setDescription(deadlineDto.getDescription());
|
||||
deadline.setExecutors(userService.findByIds(deadlineDto.getExecutorsIds()));
|
||||
deadline.setDone(deadlineDto.isDone());
|
||||
return deadline;
|
||||
}
|
||||
|
||||
public Date findByGrantIdAndDate(Integer id, Date date) {
|
||||
return deadlineRepository.findByGrantIdAndDate(id, date);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.file.model;
|
||||
package ru.ulstu.activity.file.model;
|
||||
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.file.model;
|
||||
package ru.ulstu.activity.file.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -0,0 +1,7 @@
|
||||
package ru.ulstu.activity.file.service;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.activity.file.model.FileData;
|
||||
|
||||
interface FileRepository extends JpaRepository<FileData, Integer> {
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
package ru.ulstu.activity.grant.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.activity.api.ActivityController;
|
||||
import ru.ulstu.activity.grant.model.GrantDashboardDto;
|
||||
import ru.ulstu.activity.grant.model.GrantDto;
|
||||
import ru.ulstu.activity.grant.model.GrantListDto;
|
||||
import ru.ulstu.activity.grant.service.GrantService;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Constants.API_1_0 + "grants")
|
||||
public class GrantController implements ActivityController<GrantListDto, GrantDashboardDto, GrantDto> {
|
||||
private final GrantService grantService;
|
||||
|
||||
public GrantController(GrantService grantService) {
|
||||
this.grantService = grantService;
|
||||
}
|
||||
|
||||
@GetMapping("grab")
|
||||
public void grab() throws IOException, ParseException {
|
||||
grantService.createFromKias();
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("list")
|
||||
public Response<PageableItems<GrantListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "0") int count) {
|
||||
return new Response<>(grantService.findAllDto(offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("dashboard")
|
||||
public Response<PageableItems<GrantDashboardDto>> getDashboard(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "0") int count) {
|
||||
return new Response<>(grantService.findAllActiveDto(offset, count));
|
||||
}
|
||||
|
||||
@Override
|
||||
@GetMapping("{grant-id}")
|
||||
public Response<GrantDto> get(@PathVariable("grant-id") Integer entityId) {
|
||||
return new Response<>(grantService.findDtoById(entityId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping
|
||||
public Response<GrantDto> create(@RequestBody @Valid GrantDto entity) {
|
||||
return new Response<>(grantService.create(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PutMapping
|
||||
public Response<GrantDto> update(@RequestBody @Valid GrantDto entity) {
|
||||
return new Response<>(grantService.update(entity));
|
||||
}
|
||||
|
||||
@Override
|
||||
@DeleteMapping("{grant-id}")
|
||||
public Response<Boolean> delete(@PathVariable("grant-id") Integer entityId) {
|
||||
return new Response<>(grantService.delete(entityId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@PostMapping("ping/{grant-id}")
|
||||
public void ping(@PathVariable("grant-id") int entityId) {
|
||||
grantService.ping(entityId);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.activity.grant.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class GrantDashboardDto extends ActivityDashboardDto {
|
||||
private final Grant.GrantStatus status;
|
||||
private final Set<ScienceGroupMemberDto> members;
|
||||
|
||||
public GrantDashboardDto(Grant grant) {
|
||||
super(grant.getId(), grant.getTitle());
|
||||
this.status = grant.getStatus();
|
||||
this.members = convert(grant.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Grant.GrantStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return members;
|
||||
}
|
||||
}
|
@ -0,0 +1,145 @@
|
||||
package ru.ulstu.activity.grant.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import ru.ulstu.activity.api.model.ActivityDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
import ru.ulstu.activity.deadline.model.DeadlineDto;
|
||||
import ru.ulstu.activity.file.model.FileDataDto;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class GrantDto extends ActivityDto {
|
||||
@NotEmpty
|
||||
private String title;
|
||||
private Grant.GrantStatus status;
|
||||
private List<DeadlineDto> deadlines = new ArrayList<>();
|
||||
private String comment;
|
||||
private List<FileDataDto> files = new ArrayList<>();
|
||||
private List<Integer> projectIds;
|
||||
private Set<ScienceGroupMemberDto> members;
|
||||
private Integer leaderId;
|
||||
private List<Integer> paperIds = new ArrayList<>();
|
||||
|
||||
@JsonCreator
|
||||
public GrantDto(@JsonProperty("id") Integer id,
|
||||
@JsonProperty("title") String title,
|
||||
@JsonProperty("status") Grant.GrantStatus status,
|
||||
@JsonProperty("deadlines") List<DeadlineDto> deadlines,
|
||||
@JsonProperty("comment") String comment,
|
||||
@JsonProperty("files") List<FileDataDto> files,
|
||||
@JsonProperty("members") Set<ScienceGroupMemberDto> members,
|
||||
@JsonProperty("leaderId") Integer leaderId,
|
||||
@JsonProperty("paperIds") List<Integer> paperIds) {
|
||||
super(id);
|
||||
this.title = title;
|
||||
this.status = status;
|
||||
this.deadlines = deadlines;
|
||||
this.comment = comment;
|
||||
this.files = files;
|
||||
this.members = members;
|
||||
this.leaderId = leaderId;
|
||||
this.paperIds = paperIds;
|
||||
}
|
||||
|
||||
public GrantDto(Integer id) {
|
||||
super(id);
|
||||
}
|
||||
|
||||
public GrantDto(Grant grant) {
|
||||
super(grant.getId());
|
||||
this.title = grant.getTitle();
|
||||
this.status = grant.getStatus();
|
||||
this.deadlines = convert(grant.getDeadlines(), DeadlineDto::new);
|
||||
this.comment = grant.getComment();
|
||||
this.files = convert(grant.getFiles(), FileDataDto::new);
|
||||
this.members = convert(grant.getAuthors(), ScienceGroupMemberDto::new);
|
||||
this.leaderId = grant.getLeader().getId();
|
||||
this.paperIds = convert(grant.getPapers(), paper -> paper.getId());
|
||||
}
|
||||
|
||||
public GrantDto(String grantTitle, Date deadlineDate) {
|
||||
super(null);
|
||||
this.title = grantTitle;
|
||||
this.deadlines.add(new DeadlineDto(deadlineDate, "Окончание приёма заявок"));
|
||||
this.status = Grant.GrantStatus.LOADED_FROM_KIAS;
|
||||
}
|
||||
|
||||
public GrantDto() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public Grant.GrantStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Grant.GrantStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public List<DeadlineDto> getDeadlines() {
|
||||
return deadlines;
|
||||
}
|
||||
|
||||
public void setDeadlines(List<DeadlineDto> deadlines) {
|
||||
this.deadlines = deadlines;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return comment;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public List<FileDataDto> getFiles() {
|
||||
return files;
|
||||
}
|
||||
|
||||
public void setFiles(List<FileDataDto> files) {
|
||||
this.files = files;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getMembers() {
|
||||
return members;
|
||||
}
|
||||
|
||||
public void setMembers(Set<ScienceGroupMemberDto> members) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
public Integer getLeaderId() {
|
||||
return leaderId;
|
||||
}
|
||||
|
||||
public void setLeaderId(Integer leaderId) {
|
||||
this.leaderId = leaderId;
|
||||
}
|
||||
|
||||
public List<Integer> getPaperIds() {
|
||||
return paperIds;
|
||||
}
|
||||
|
||||
public void setPaperIds(List<Integer> paperIds) {
|
||||
this.paperIds = paperIds;
|
||||
}
|
||||
|
||||
public List<Integer> getProjectIds() {
|
||||
return projectIds;
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package ru.ulstu.activity.grant.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class GrantListDto extends ActivityListDto {
|
||||
|
||||
private final Grant.GrantStatus status;
|
||||
private final Set<ScienceGroupMemberDto> members;
|
||||
|
||||
public GrantListDto(Grant grant) {
|
||||
super(grant.getId(), grant.getTitle());
|
||||
this.status = grant.getStatus();
|
||||
this.members = convert(grant.getActivityMembers(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Grant.GrantStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return members;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.grant.page;
|
||||
package ru.ulstu.activity.grant.page;
|
||||
|
||||
import com.gargoylesoftware.htmlunit.html.DomNode;
|
||||
import com.gargoylesoftware.htmlunit.html.HtmlElement;
|
@ -0,0 +1,87 @@
|
||||
package ru.ulstu.activity.paper.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.activity.api.ActivityController;
|
||||
import ru.ulstu.activity.paper.model.PaperDashboardDto;
|
||||
import ru.ulstu.activity.paper.model.PaperDto;
|
||||
import ru.ulstu.activity.paper.model.PaperListDto;
|
||||
import ru.ulstu.activity.paper.model.PaperStatusDto;
|
||||
import ru.ulstu.activity.paper.model.PaperTypeDto;
|
||||
import ru.ulstu.activity.paper.service.PaperService;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
import ru.ulstu.user.model.User;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Constants.API_1_0 + "papers")
|
||||
public class PaperController implements ActivityController<PaperListDto, PaperDashboardDto, PaperDto> {
|
||||
private final PaperService paperService;
|
||||
|
||||
public PaperController(PaperService paperService) {
|
||||
this.paperService = paperService;
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public Response<PageableItems<PaperListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(paperService.findAllDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("dashboard")
|
||||
public Response<PageableItems<PaperDashboardDto>> getDashboard(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(paperService.findAllActiveDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("{paper-id}")
|
||||
public Response<PaperDto> get(@PathVariable("paper-id") Integer paperId) {
|
||||
return new Response<>(paperService.findDtoById(paperId));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Response<PaperDto> create(@RequestBody @Valid PaperDto paperDto) {
|
||||
return new Response<>(paperService.create(paperDto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Response<PaperDto> update(@RequestBody @Valid PaperDto paperDto) {
|
||||
return new Response<>(paperService.update(paperDto));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{paper-id}")
|
||||
public Response<Boolean> delete(@PathVariable("paper-id") Integer paperId) {
|
||||
return new Response<>(paperService.delete(paperId));
|
||||
}
|
||||
|
||||
@PostMapping("ping/{paper-id}")
|
||||
public void ping(@PathVariable("paper-id") int paperId) {
|
||||
paperService.ping(paperId);
|
||||
}
|
||||
|
||||
@GetMapping("allAuthors")
|
||||
public Response<List<User>> getAllAuthors() {
|
||||
return new Response<>(paperService.getPaperAuthors());
|
||||
}
|
||||
|
||||
@GetMapping("allTypes")
|
||||
public Response<List<PaperTypeDto>> getPaperTypes() {
|
||||
return new Response<>(paperService.getPaperTypes());
|
||||
}
|
||||
|
||||
@GetMapping("allStatuses")
|
||||
public Response<List<PaperStatusDto>> getPaperStatuses() {
|
||||
return new Response<>(paperService.getPaperStatuses());
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.paper.model;
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
@ -0,0 +1,45 @@
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class PaperDashboardDto extends ActivityDashboardDto {
|
||||
private Paper.PaperStatus status;
|
||||
private Set<ScienceGroupMemberDto> authors;
|
||||
private String url;
|
||||
|
||||
public PaperDashboardDto(Paper paper) {
|
||||
super(paper.getId(), paper.getTitle());
|
||||
this.status = paper.getStatus();
|
||||
this.authors = convert(paper.getAuthors(), ScienceGroupMemberDto::new);
|
||||
this.url = paper.getUrl();
|
||||
}
|
||||
|
||||
public Paper.PaperStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Paper.PaperStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
|
||||
public void setAuthors(Set<ScienceGroupMemberDto> authors) {
|
||||
this.authors = authors;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -1,27 +1,27 @@
|
||||
package ru.ulstu.paper.model;
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PaperListDto {
|
||||
private List<PaperDto> papers;
|
||||
public class PaperFilterListDto {
|
||||
private List<PaperListDto> papers;
|
||||
private Integer filterAuthorId;
|
||||
private Integer paperDeleteId;
|
||||
private Integer year;
|
||||
|
||||
public PaperListDto() {
|
||||
public PaperFilterListDto() {
|
||||
}
|
||||
|
||||
public PaperListDto(List<PaperDto> paperDtos, Integer filterAuthorId, Integer year) {
|
||||
public PaperFilterListDto(List<PaperListDto> paperDtos, Integer filterAuthorId, Integer year) {
|
||||
this.papers = paperDtos;
|
||||
this.filterAuthorId = filterAuthorId;
|
||||
this.year = year;
|
||||
}
|
||||
|
||||
public List<PaperDto> getPapers() {
|
||||
public List<PaperListDto> getPapers() {
|
||||
return papers;
|
||||
}
|
||||
|
||||
public void setPapers(List<PaperDto> papers) {
|
||||
public void setPapers(List<PaperListDto> papers) {
|
||||
this.papers = papers;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class PaperListDto extends ActivityListDto {
|
||||
private final Paper.PaperStatus status;
|
||||
private final Set<ScienceGroupMemberDto> authors;
|
||||
|
||||
public PaperListDto(Paper paper) {
|
||||
super(paper.getId(), paper.getTitle());
|
||||
this.status = paper.getStatus();
|
||||
this.authors = convert(paper.getAuthors(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Paper.PaperStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Set<ScienceGroupMemberDto> getAuthors() {
|
||||
return authors;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
public class PaperStatusDto {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public PaperStatusDto(Paper.PaperStatus status) {
|
||||
this.id = status.name();
|
||||
this.name = status.getStatusName();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
public class PaperTypeDto {
|
||||
private final String id;
|
||||
private final String name;
|
||||
|
||||
public PaperTypeDto(Paper.PaperType type) {
|
||||
this.id = type.name();
|
||||
this.name = type.getTypeName();
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.paper.model;
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import ru.ulstu.core.model.BaseEntity;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.paper.model;
|
||||
package ru.ulstu.activity.paper.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,8 +1,8 @@
|
||||
package ru.ulstu.paper.service;
|
||||
package ru.ulstu.activity.paper.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.file.service.FileService;
|
||||
import ru.ulstu.paper.model.PaperDto;
|
||||
import ru.ulstu.activity.file.service.FileService;
|
||||
import ru.ulstu.activity.paper.model.PaperDto;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
@ -0,0 +1,201 @@
|
||||
package ru.ulstu.activity.paper.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import ru.ulstu.activity.common.service.ActivityService;
|
||||
import ru.ulstu.activity.deadline.model.Deadline;
|
||||
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||
import ru.ulstu.activity.file.service.FileService;
|
||||
import ru.ulstu.activity.paper.model.Paper;
|
||||
import ru.ulstu.activity.paper.model.PaperDashboardDto;
|
||||
import ru.ulstu.activity.paper.model.PaperDto;
|
||||
import ru.ulstu.activity.paper.model.PaperListDto;
|
||||
import ru.ulstu.activity.paper.model.PaperStatusDto;
|
||||
import ru.ulstu.activity.paper.model.PaperTypeDto;
|
||||
import ru.ulstu.activity.ping.service.PingService;
|
||||
import ru.ulstu.activity.timeline.model.Event;
|
||||
import ru.ulstu.activity.timeline.service.EventService;
|
||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.user.model.User;
|
||||
import ru.ulstu.user.service.UserService;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
|
||||
import static org.springframework.util.ObjectUtils.isEmpty;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.ATTENTION;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.COMPLETED;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.DRAFT;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.FAILED;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
||||
import static ru.ulstu.activity.paper.model.Paper.PaperType.OTHER;
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||
|
||||
@Service
|
||||
public class PaperService extends ActivityService<PaperListDto, Paper, PaperDto> {
|
||||
private final PaperNotificationService paperNotificationService;
|
||||
private final PaperRepository paperRepository;
|
||||
private final UserService userService;
|
||||
private final DeadlineService deadlineService;
|
||||
private final FileService fileService;
|
||||
private final EventService eventService;
|
||||
private final PingService pingService;
|
||||
|
||||
public PaperService(PaperRepository paperRepository,
|
||||
FileService fileService,
|
||||
PaperNotificationService paperNotificationService,
|
||||
UserService userService,
|
||||
DeadlineService deadlineService,
|
||||
EventService eventService,
|
||||
PingService pingService) {
|
||||
super(paperRepository, paperNotificationService, pingService, eventService);
|
||||
this.paperRepository = paperRepository;
|
||||
this.fileService = fileService;
|
||||
this.paperNotificationService = paperNotificationService;
|
||||
this.userService = userService;
|
||||
this.deadlineService = deadlineService;
|
||||
this.eventService = eventService;
|
||||
this.pingService = pingService;
|
||||
}
|
||||
|
||||
public PageableItems<PaperDashboardDto> findAllActiveDto(int offset, int count) {
|
||||
return convertPageable(findAllActive(offset, count), PaperDashboardDto::new);
|
||||
}
|
||||
|
||||
public PageableItems<Paper> findAll(int offset, int count) {
|
||||
final Page<Paper> page = paperRepository.findAll(new OffsetablePageRequest(offset, count));
|
||||
return new PageableItems<>(page.getTotalElements(), sortPapers(page.getContent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaperListDto getActivityListDto(Paper entity) {
|
||||
return new PaperListDto(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Paper getNewActivity() {
|
||||
return new Paper();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected PaperDto getNewActivityDto(Paper entity) {
|
||||
return new PaperDto(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableItems<Paper> findAllActive(int offset, int count) {
|
||||
Page<Paper> activePapersPage = paperRepository.findAllWithoutStatuses(new OffsetablePageRequest(offset, count), COMPLETED, FAILED);
|
||||
return new PageableItems<>(activePapersPage.getTotalElements(), sortPapers(activePapersPage.getContent()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Event> getEvents(Paper entity) {
|
||||
return eventService.findByPaper(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionsOnDiffObjects(Paper oldEntity, Paper entity) {
|
||||
if (oldEntity.getStatus() != entity.getStatus()) {
|
||||
paperNotificationService.statusChangeNotification(entity, oldEntity.getStatus());
|
||||
}
|
||||
if (!oldEntity.getAuthors().equals(entity.getAuthors())) {
|
||||
paperNotificationService.sendCreateNotification(entity, oldEntity.getAuthors());
|
||||
}
|
||||
}
|
||||
|
||||
protected Paper copyFromDto(Paper paper, PaperDto paperDto) {
|
||||
paper.setComment(paperDto.getComment());
|
||||
paper.setUrl(paperDto.getUrl());
|
||||
paper.setCreateDate(paper.getCreateDate() == null ? new Date() : paper.getCreateDate());
|
||||
paper.setLocked(paperDto.getLocked());
|
||||
paper.setStatus(paperDto.getStatus() == null ? DRAFT : paperDto.getStatus());
|
||||
paper.setType(paperDto.getType() == null ? OTHER : paperDto.getType());
|
||||
paper.setTitle(paperDto.getTitle());
|
||||
paper.setUpdateDate(new Date());
|
||||
paper.setDeadlines(deadlineService.saveOrCreate(paperDto.getDeadlines()));
|
||||
//TODO: move to service
|
||||
try {
|
||||
if (paperDto.getFiles() != null) {
|
||||
paper.setFiles(fileService.saveOrCreate(paperDto.getFiles().stream()
|
||||
.filter(f -> !f.isDeleted())
|
||||
.collect(toList())));
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
paper.getAuthors().clear();
|
||||
if (isNotEmpty(paperDto.getAuthors())) {
|
||||
paperDto.getAuthors().forEach(authors -> paper.getAuthors().add(userService.findById(authors.getId())));
|
||||
}
|
||||
return paper;
|
||||
}
|
||||
|
||||
public List<PaperStatusDto> getPaperStatuses() {
|
||||
return convert(Arrays.asList(Paper.PaperStatus.values()), PaperStatusDto::new);
|
||||
}
|
||||
|
||||
public List<PaperTypeDto> getPaperTypes() {
|
||||
return convert(Arrays.asList(Paper.PaperType.values()), PaperTypeDto::new);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Paper create(String title, User user, Date deadlineDate) {
|
||||
Paper paper = new Paper();
|
||||
paper.setTitle(title);
|
||||
paper.getAuthors().add(user);
|
||||
paper.getDeadlines().add(new Deadline(deadlineDate, "первый дедлайн"));
|
||||
paper.setCreateDate(new Date());
|
||||
paper.setUpdateDate(new Date());
|
||||
paper.setStatus(DRAFT);
|
||||
paper.setType(OTHER);
|
||||
|
||||
return create(paper);
|
||||
}
|
||||
|
||||
private List<Paper> sortPapers(List<Paper> papers) {
|
||||
return papers.stream().sorted((paper1, paper2) -> {
|
||||
int statusCompareResult =
|
||||
Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus()))
|
||||
.compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus()));
|
||||
if (statusCompareResult != 0) {
|
||||
return statusCompareResult;
|
||||
}
|
||||
return paper1.getTitle().compareTo(paper2.getTitle());
|
||||
}).collect(toList());
|
||||
}
|
||||
|
||||
public void closeFailedPapers() {
|
||||
List<Paper> papers = paperRepository.findAll()
|
||||
.stream()
|
||||
.filter(paper -> paper.lastDeadlineFailed()
|
||||
&& (paper.getStatus() == ON_PREPARATION
|
||||
|| paper.getStatus() == DRAFT
|
||||
|| paper.getStatus() == ATTENTION))
|
||||
.collect(toList());
|
||||
papers.forEach(paper -> {
|
||||
Paper.PaperStatus oldStatus = paper.getStatus();
|
||||
paper.setStatus(Paper.PaperStatus.FAILED);
|
||||
paperRepository.save(paper);
|
||||
paperNotificationService.sendFailedNotification(paper, oldStatus);
|
||||
});
|
||||
}
|
||||
|
||||
public void save(PaperDto paperDto) {
|
||||
if (isEmpty(paperDto.getId())) {
|
||||
create(paperDto);
|
||||
} else {
|
||||
update(paperDto);
|
||||
}
|
||||
}
|
||||
|
||||
public List<User> getPaperAuthors() {
|
||||
return userService.findAll();
|
||||
}
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package ru.ulstu.paper.repository;
|
||||
package ru.ulstu.activity.paper.service;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import ru.ulstu.paper.model.Reference;
|
||||
import ru.ulstu.activity.paper.model.Reference;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.ping.model;
|
||||
package ru.ulstu.activity.ping.model;
|
||||
|
||||
import ru.ulstu.user.model.User;
|
||||
|
@ -1,15 +1,15 @@
|
||||
package ru.ulstu.ping.repository;
|
||||
package ru.ulstu.activity.ping.service;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.conference.model.Conference;
|
||||
import ru.ulstu.ping.model.Ping;
|
||||
import ru.ulstu.activity.conference.model.Conference;
|
||||
import ru.ulstu.activity.ping.model.Ping;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public interface PingRepository extends JpaRepository<Ping, Integer> {
|
||||
interface PingRepository extends JpaRepository<Ping, Integer> {
|
||||
|
||||
@Query("SELECT count(*) FROM Ping p WHERE (DAY(p.date) = :day) AND (MONTH(p.date) = :month) AND (YEAR(p.date) = :year) AND (p.activityType = 'conference') AND (p.activity = :conference)")
|
||||
long countByConferenceAndDate(@Param("conference") Conference conference, @Param("day") Integer day, @Param("month") Integer month, @Param("year") Integer year);
|
@ -0,0 +1,68 @@
|
||||
package ru.ulstu.activity.project.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.activity.api.ActivityController;
|
||||
import ru.ulstu.activity.project.model.ProjectDashboardDto;
|
||||
import ru.ulstu.activity.project.model.ProjectDto;
|
||||
import ru.ulstu.activity.project.model.ProjectListDto;
|
||||
import ru.ulstu.activity.project.service.ProjectService;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Constants.API_1_0 + "projects")
|
||||
public class ProjectController implements ActivityController<ProjectListDto, ProjectDashboardDto, ProjectDto> {
|
||||
private final ProjectService projectService;
|
||||
|
||||
public ProjectController(ProjectService projectService) {
|
||||
this.projectService = projectService;
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public Response<PageableItems<ProjectListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(projectService.findAllDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("dashboard")
|
||||
public Response<PageableItems<ProjectDashboardDto>> getDashboard(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(projectService.findAllActiveDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("{project-id}")
|
||||
public Response<ProjectDto> get(@PathVariable("project-id") Integer projectId) {
|
||||
return new Response<>(projectService.findDtoById(projectId));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Response<ProjectDto> create(@RequestBody @Valid ProjectDto projectDto) {
|
||||
return new Response<>(projectService.create(projectDto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Response<ProjectDto> update(@RequestBody @Valid ProjectDto projectDto) {
|
||||
return new Response<>(projectService.update(projectDto));
|
||||
}
|
||||
|
||||
@DeleteMapping("/{project-id}")
|
||||
public Response<Boolean> delete(@PathVariable("project-id") Integer projectId) {
|
||||
return new Response<>(projectService.delete(projectId));
|
||||
}
|
||||
|
||||
@PostMapping("ping/{project-id}")
|
||||
public void ping(@PathVariable("project-id") int projectId) {
|
||||
projectService.ping(projectId);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.activity.project.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class ProjectDashboardDto extends ActivityDashboardDto {
|
||||
private final Project.ProjectStatus status;
|
||||
private final List<ScienceGroupMemberDto> executors;
|
||||
|
||||
public ProjectDashboardDto(Project project) {
|
||||
super(project.getId(), project.getTitle());
|
||||
this.status = project.getStatus();
|
||||
this.executors = convert(project.getExecutors(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Project.ProjectStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<ScienceGroupMemberDto> getExecutors() {
|
||||
return executors;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package ru.ulstu.activity.project.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
import ru.ulstu.activity.common.model.ScienceGroupMemberDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convert;
|
||||
|
||||
public class ProjectListDto extends ActivityListDto {
|
||||
private final Project.ProjectStatus status;
|
||||
private final List<ScienceGroupMemberDto> executors;
|
||||
|
||||
public ProjectListDto(Project project) {
|
||||
super(project.getId(), project.getTitle());
|
||||
this.status = project.getStatus();
|
||||
this.executors = convert(project.getExecutors(), ScienceGroupMemberDto::new);
|
||||
}
|
||||
|
||||
public Project.ProjectStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<ScienceGroupMemberDto> getExecutors() {
|
||||
return executors;
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package ru.ulstu.activity.project.service;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.activity.common.service.ActivityNotificationService;
|
||||
import ru.ulstu.activity.project.model.Project;
|
||||
import ru.ulstu.user.service.MailService;
|
||||
|
||||
@Service
|
||||
public class ProjectNotificationService extends ActivityNotificationService<Project> {
|
||||
|
||||
public ProjectNotificationService(MailService mailService) {
|
||||
super(mailService);
|
||||
}
|
||||
|
||||
public void sendCreateNotification(Project project) {
|
||||
throw new RuntimeException("not implemented yet");
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package ru.ulstu.activity.project.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import ru.ulstu.activity.api.ActivityRepository;
|
||||
import ru.ulstu.activity.project.model.Project;
|
||||
|
||||
interface ProjectRepository extends JpaRepository<Project, Integer>, ActivityRepository<Project> {
|
||||
@Query("SELECT p FROM Project p WHERE p.status NOT IN (:statuses)")
|
||||
Page<Project> findAllWithoutStatuses(Pageable pageable, @Param("statuses") Project.ProjectStatus... statuses);
|
||||
|
||||
@Query("SELECT p.title FROM Project p WHERE (p.title = :name) AND (:id IS NULL OR p.id != :id) ")
|
||||
String findByNameAndNotId(@Param("name") String name, @Param("id") Integer id);
|
||||
}
|
@ -0,0 +1,96 @@
|
||||
package ru.ulstu.activity.project.service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.activity.common.service.ActivityService;
|
||||
import ru.ulstu.activity.deadline.service.DeadlineService;
|
||||
import ru.ulstu.activity.file.service.FileService;
|
||||
import ru.ulstu.activity.ping.service.PingService;
|
||||
import ru.ulstu.activity.project.model.Project;
|
||||
import ru.ulstu.activity.project.model.ProjectDashboardDto;
|
||||
import ru.ulstu.activity.project.model.ProjectDto;
|
||||
import ru.ulstu.activity.project.model.ProjectListDto;
|
||||
import ru.ulstu.activity.timeline.model.Event;
|
||||
import ru.ulstu.activity.timeline.service.EventService;
|
||||
import ru.ulstu.core.jpa.OffsetablePageRequest;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static ru.ulstu.activity.project.model.Project.ProjectStatus.CLOSED;
|
||||
import static ru.ulstu.activity.project.model.Project.ProjectStatus.FAILED;
|
||||
import static ru.ulstu.activity.project.model.Project.ProjectStatus.TECHNICAL_TASK;
|
||||
import static ru.ulstu.core.util.StreamApiUtils.convertPageable;
|
||||
|
||||
@Service
|
||||
public class ProjectService extends ActivityService<ProjectListDto, Project, ProjectDto> {
|
||||
private final ProjectRepository projectRepository;
|
||||
private final DeadlineService deadlineService;
|
||||
private final FileService fileService;
|
||||
private final PingService pingService;
|
||||
private final EventService eventService;
|
||||
|
||||
public ProjectService(ProjectRepository projectRepository,
|
||||
ProjectNotificationService projectNotificationService,
|
||||
DeadlineService deadlineService,
|
||||
FileService fileService,
|
||||
PingService pingService, EventService eventService) {
|
||||
super(projectRepository, projectNotificationService, pingService, eventService);
|
||||
this.projectRepository = projectRepository;
|
||||
this.deadlineService = deadlineService;
|
||||
this.fileService = fileService;
|
||||
this.pingService = pingService;
|
||||
this.eventService = eventService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableItems<ProjectDashboardDto> findAllActiveDto(int offset, int count) {
|
||||
return convertPageable(findAllActive(offset, count), ProjectDashboardDto::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageableItems<Project> findAllActive(int offset, int count) {
|
||||
Page<Project> activeProjectPage = projectRepository.findAllWithoutStatuses(new OffsetablePageRequest(offset, count), CLOSED, FAILED);
|
||||
return new PageableItems<>(activeProjectPage.getTotalElements(), activeProjectPage.getContent());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doActionsOnDiffObjects(Project oldEntity, Project entity) {
|
||||
//TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<Event> getEvents(Project entity) {
|
||||
return eventService.findByProject(entity);
|
||||
}
|
||||
|
||||
protected Project copyFromDto(Project project, ProjectDto projectDto) throws IOException {
|
||||
project.setDescription(projectDto.getDescription());
|
||||
project.setStatus(projectDto.getStatus() == null ? TECHNICAL_TASK : projectDto.getStatus());
|
||||
project.setTitle(projectDto.getTitle());
|
||||
project.setRepository(projectDto.getRepository());
|
||||
project.setDeadlines(deadlineService.saveOrCreate(projectDto.getDeadlines()));
|
||||
project.setFiles(fileService.saveOrCreate(projectDto.getFiles().stream()
|
||||
.filter(f -> !f.isDeleted())
|
||||
.collect(toList())));
|
||||
project.getGrants().clear();
|
||||
return project;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectListDto getActivityListDto(Project entity) {
|
||||
return new ProjectListDto(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Project getNewActivity() {
|
||||
return new Project();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProjectDto getNewActivityDto(Project entity) {
|
||||
return new ProjectDto(entity);
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
package ru.ulstu.activity.students.controller;
|
||||
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import ru.ulstu.activity.api.ActivityController;
|
||||
import ru.ulstu.activity.students.model.TaskDashboardDto;
|
||||
import ru.ulstu.activity.students.model.TaskDto;
|
||||
import ru.ulstu.activity.students.model.TaskListDto;
|
||||
import ru.ulstu.activity.students.service.TaskService;
|
||||
import ru.ulstu.configuration.Constants;
|
||||
import ru.ulstu.core.model.response.PageableItems;
|
||||
import ru.ulstu.core.model.response.Response;
|
||||
|
||||
import javax.validation.Valid;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Constants.API_1_0 + "students")
|
||||
public class TaskController implements ActivityController<TaskListDto, TaskDashboardDto, TaskDto> {
|
||||
|
||||
private final TaskService taskService;
|
||||
|
||||
public TaskController(TaskService taskService) {
|
||||
this.taskService = taskService;
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
public Response<PageableItems<TaskListDto>> getList(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(taskService.findAllDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("dashboard")
|
||||
public Response<PageableItems<TaskDashboardDto>> getDashboard(@RequestParam(value = "offset", defaultValue = "0") int offset,
|
||||
@RequestParam(value = "count", defaultValue = "10") int count) {
|
||||
return new Response<>(taskService.findAllActiveDto(offset, count));
|
||||
}
|
||||
|
||||
@GetMapping("{task-id}")
|
||||
public Response<TaskDto> get(@PathVariable("task-id") Integer taskId) {
|
||||
return new Response<>(taskService.findDtoById(taskId));
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Response<TaskDto> create(@RequestBody @Valid TaskDto taskDto) {
|
||||
return new Response<>(taskService.create(taskDto));
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public Response<TaskDto> update(@RequestBody @Valid TaskDto paperDto) {
|
||||
return new Response<>(taskService.update(paperDto));
|
||||
}
|
||||
|
||||
@DeleteMapping("{task-id}")
|
||||
public Response<Boolean> delete(@PathVariable("task-id") Integer taskId) {
|
||||
return new Response<>(taskService.delete(taskId));
|
||||
}
|
||||
|
||||
@PostMapping("ping/{task-id}")
|
||||
public void ping(@PathVariable("task-id") int taskId) {
|
||||
taskService.ping(taskId);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.students.model;
|
||||
package ru.ulstu.activity.students.model;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import ru.ulstu.core.model.BaseEntity;
|
@ -0,0 +1,16 @@
|
||||
package ru.ulstu.activity.students.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityDashboardDto;
|
||||
|
||||
public class TaskDashboardDto extends ActivityDashboardDto {
|
||||
private final Task.TaskStatus status;
|
||||
|
||||
public TaskDashboardDto(Task task) {
|
||||
super(task.getId(), task.getTitle());
|
||||
this.status = task.getStatus();
|
||||
}
|
||||
|
||||
public Task.TaskStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.students.model;
|
||||
package ru.ulstu.activity.students.model;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -0,0 +1,16 @@
|
||||
package ru.ulstu.activity.students.model;
|
||||
|
||||
import ru.ulstu.activity.api.model.ActivityListDto;
|
||||
|
||||
public class TaskListDto extends ActivityListDto {
|
||||
private final Task.TaskStatus status;
|
||||
|
||||
public TaskListDto(Task task) {
|
||||
super(task.getId(), task.getTitle());
|
||||
this.status = task.getStatus();
|
||||
}
|
||||
|
||||
public Task.TaskStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package ru.ulstu.activity.students.service;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import ru.ulstu.activity.students.model.Scheduler;
|
||||
import ru.ulstu.activity.students.model.Task;
|
||||
|
||||
interface SchedulerRepository extends JpaRepository<Scheduler, Integer> {
|
||||
|
||||
Scheduler findOneByTask(Task task);
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.students.service;
|
||||
package ru.ulstu.activity.students.service;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
@ -0,0 +1,24 @@
|
||||
package ru.ulstu.activity.students.service;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.activity.common.service.ActivityNotificationService;
|
||||
import ru.ulstu.activity.students.model.Task;
|
||||
import ru.ulstu.user.service.MailService;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class TaskNotificationService extends ActivityNotificationService<Task> {
|
||||
private final static String TEMPLATE_CREATE = "taskCreateNotification";
|
||||
private final static String TITLE_CREATE = "Создана задача";
|
||||
|
||||
public TaskNotificationService(MailService mailService) {
|
||||
super(mailService);
|
||||
}
|
||||
|
||||
public void sendCreateNotification(Task task) {
|
||||
Map<String, Object> variables = ImmutableMap.of("task", task);
|
||||
sendForAllAuthors(variables, task, TEMPLATE_CREATE, TITLE_CREATE);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package ru.ulstu.tags.model;
|
||||
package ru.ulstu.activity.tags.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue